function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}



jQuery(document).ready(function(){

	var clearMePrevious = '';
	
	//PNG Fix for IE6
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	
	if (jQuery.browser.msie && (ie55 || ie6)) {
			jQuery('#header_logo, #banner img, .cta_readmore').supersleight({shim: 'js/x.gif', apply_positioning: false});
	} else { jQuery( function() { setInterval( "slideSwitch()", 5000 ); } ); }
	//Replace fonts
	Cufon.replace('#footer_partners h3, .font_replace,  h1.entry-title, h1.page-title', { fontFamily: 'JohnSans' }); 
		
	// clear input on focus
	jQuery('.clearMeFocus').focus(function() { if(jQuery(this).val()==jQuery(this).attr('title')) { clearMePrevious = jQuery(this).val(); jQuery(this).val(''); } });
	
	// if field is empty afterward, add text again
	jQuery('.clearMeFocus').blur( function() { if(jQuery(this).val()=='') { jQuery(this).val(clearMePrevious); } } );

	jQuery('#page_navig a').live('click', function(e) {
		e.preventDefault();
		var link = jQuery(this).attr('href');
		var bh = jQuery('#ajaxcontentinner').height();
		var ah = 0;
		jQuery('#page_navig').append('<li class="small-loading"><img src="http://www.adda.sk/wp-content/themes/adda/images/loading_small.gif" alt="" title="" width="13" heigth="13"  /></li>');
		//'<li class="small-loading"><img src="http://www.adda.sk/wp-content/themes/adda/images/loading_small.gif" alt="loading" title="loading" /></li>"
		jQuery('#ajaxcontent').load( link + ' #ajaxcontentinner', function() {
		    ah = jQuery('#ajaxcontentinner').height();
  			jQuery('#ajaxcontentinner').height(bh);	
  			jQuery('#ajaxcontentinner').css({ 'opacity' : 0 });
  			Cufon.replace('#footer_partners h3, .font_replace,  h1.entry-title, h1.page-title', { fontFamily: 'JohnSans' });
  			jQuery('#ajaxcontentinner').animate({ height: ah, opacity:1}, 350, 'linear', function() {} );
		});

	});
	
	//code to hide topic selection, disable for demo
	var course_order_delivery = jQuery("input[name='same_addr[]']");
	// newsletter topics are optional, hide at first
	course_order_delivery.attr('checked', true);
	var inital = course_order_delivery.is(":checked");
	//var addr = $("#course_order_delivery_address")[inital ? "addClass" : "removeClass"]("gray");
	var addr = jQuery("#deliver_addr")[inital ? "slideUp" : "slideDown"]("fast");
	addr = jQuery("#deliver_addr")[inital ? "addClass" : "removeClass"]("gray");
	var addrInputs = addr.find("input").attr("disabled", inital);
	// show when newsletter is checked
	course_order_delivery.click(function() {
		//addr[this.checked ? "addClass" : "removeClass"]("gray");
		//addr.css({ 'opacity' : this.checked ? 0 : 1,'z-index':-1 });
		addr[this.checked ? "slideUp" : "slideDown"]("fast");
		addr[this.checked ? "addClass" : "removeClass"]("gray");
		addrInputs.attr("disabled", this.checked);
	});


});


