function slideSwitch(span) {
	
	var $active = jQuery('#'+span+' DIV.active');

	if ( $active.length == 0 ) $active = jQuery('#'+span+' DIV:last');
	
	//alert(index);
	
	// use this to pull the divs in the order they appear in the markup
	var $next =  $active.next().length ? $active.next()
	: $('#'+span+' DIV:first');

	if(jQuery("#"+span+"-rotator")){
		var index = (jQuery("#"+span+ " div.slide").index(jQuery($active)))+1;
		jQuery("#"+span+"-rotator .activeSlide").removeClass('activeSlide');
		//alert(index);
		if(jQuery("#"+span+"-rotator").children().size()==index) {
			index = 0;
		}
		jQuery("#"+span+"-rotator li:eq("+(index)+")").find("a").addClass("activeSlide");
	}	
	
	// uncomment below to pull the divs randomly
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );


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

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

function pauseSlideSwitch(span, id) {
	var index = id-1;
	jQuery("#"+span+"-rotator .activeSlide").removeClass('activeSlide');
	jQuery("#"+span+"-rotator li:eq("+(index)+")").find("a").addClass("activeSlide");
	jQuery("#"+span+" .active").removeClass('active');
	jQuery("#"+span+" div.slide:nth-child("+(index+1)+")").addClass("active");
	
}

	jQuery(document).ready(function() {
		
		////// Top search box //////
		var topSearch = jQuery('#header #searchform #s');
		if(topSearch.val()=='')
			topSearch.val('search');
		topSearch.blur(function() { 
			if (jQuery(this).val()=='') jQuery(this).val('search');
		});
		topSearch.focus(function() { 
			if (jQuery(this).val()=='search') jQuery(this).val('');
		});
		
					
		jQuery("#primary .linkcat a").click(function() { 
			var linkIndex = (jQuery("#primary .linkcat a").index(this));
		
			var currentSpan, classToAdd, classToRemove;
			jQuery("#primary .linkcat a").each(function (i) {
				currentSpan = "#primary .last span:nth-child("+(i+1)+")";
				if(i==linkIndex) {
					if(currentSpan)
						jQuery(currentSpan).show();
					classToAdd = 'linkcat-active';
					classToRemove = 'linkcat-inactive';
				} else {
					if(currentSpan)
						jQuery(currentSpan).hide();
					classToAdd = 'linkcat-inactive';
					classToRemove = 'linkcat-active';
				}	
				if (jQuery(this).parent().hasClass(classToRemove))
					jQuery(this).parent().removeClass(classToRemove);
				jQuery(this).parent().addClass(classToAdd);
			});
			
			return false; 
		});
		
		jQuery(".group-logo li a").click(function() { 
			var linkIndex = (jQuery(".group-logo li a").index(this));
			
			var currentSpan;//group-summary
			jQuery(".group-summary .group-roundcont .summary-data").each(function (i) {
				
				currentSpan = ".group-summary .group-roundcont .summary-data:nth-child("+(i+2)+")";
				if(i==linkIndex) {
					if(currentSpan) jQuery(currentSpan).show();
				} else {
					if(currentSpan) jQuery(currentSpan).hide();
				}	
			});
			
			return false; 
		});
				
		jQuery(function() {
		    setInterval( "slideSwitch('slideshow')", 7000 );
		    setInterval( "slideSwitch('brand')", 3000 );
		})
		jQuery('#slide-rotator a').click(function() {
    		alert('a');
  		});
  	});	//Document.ready
