var $j=jQuery.noConflict();

$j(document).ready(function(){  

	// homepage rollover
	$j("#homeShop").hover(function() {
	  $j("li#nutrition").toggleClass("active");
	}, function() {
	  $j("li#nutrition").toggleClass("active");
	});
	
	$j("#homeSupplement").hover(function() {
	  $j("li#supplement").toggleClass("active");
	}, function() {
	  $j("li#supplement").toggleClass("active");
	});

	$j("#homeProgram").hover(function() {
	  $j("li#personalized").toggleClass("active");
	}, function() {
	  $j("li#personalized").toggleClass("active");
	});
	
	$j("#homeScience").hover(function() {
	  $j("li#approach").toggleClass("active");
	}, function() {
	  $j("li#approach").toggleClass("active");
	});
	
	// remove broken links
	$j('img').error(function() {
		$j(this).remove();
	});
    
    // external sites in a new window
    $j("a[rel=external]").attr('target', '_blank');		
	
	// search boxes
	$j("#searchInput").focus(function() {
        if ($j(this).val() == "Enter Keyword") {
            $j(this).val("");
        }
    });
    $j("#searchInput").blur(function() {
        if ($j(this).val() == "") {
            $j(this).val("Enter Keyword");
        }
    });	
	$j(".signupInput").focus(function() {
        if ($j(this).val() == "Enter Email Address") {
            $j(this).val("");
        }
    });
    $j(".signupInput").blur(function() {
        if ($j(this).val() == "") {
            $j(this).val("Enter Email Address");
        }
    });
	$j("#enterPromo").focus(function() {
        if ($j(this).val() == "Enter promo") {
            $j(this).val("");
        }
    });
    $j("#enterPromo").blur(function() {
        if ($j(this).val() == "") {
            $j(this).val("Enter promo");
        }
    });
	
	// entire home category section clickable
	$j("#homeProducts li").click(function(){
	  window.location=$j(this).find("a").attr("href"); return false;
	});
	
	// entire key objectives row clickable
	$j(".keyWrapper").click(function(){
	  window.location=$j(this).find("a").attr("href"); return false;
	});
	
	// entire search row clickable
	$j(".searchResults li").click(function(){
	  window.location=$j(this).find("a").attr("href"); return false;
	});
	
	// Tabs
	$j(".tab-content").hide(); //Hide all content
	$j("ul.tabs li:first").addClass("selected").show(); //Activate first tab
	$j(".tab-content:first").show(); //Show first tab content

	//On Click Event
	$j("ul.tabs li").click(function() {

		$j("ul.tabs li").removeClass("selected"); //Remove any "active" class
		$j(this).addClass("selected"); //Add "active" class to selected tab
		$j(".tab-content").hide(); //Hide all tab content

		var activeTab = $j(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		if(!$j.browser.msie) { 
			$j(activeTab).fadeIn(); //Fade in the active ID content; IE doesn't render text fades well
		}
		if($j.browser.msie) {
			$j(activeTab).show();
		}
		return false;
	});
	
	// process select box without submit button
	$j(".selectAnother select").submit();
	
	//Examples of how to assign the ColorBox event to elements
	$j("a[rel='colorbox']").colorbox();	
	$j("a.bioBarry").colorbox({width:"50%", inline:true, href:"#bioBarry"});
	$j("a.replenish").colorbox({width:"30%", inline:true, href:"#replenish"});
	$j("a.cvv").colorbox({width:"20%", inline:true, href:"#cvv"});
	$j("a.videoBarry").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	$j("a.videoLB").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	$j("a.imageLB").colorbox();
	$j("a.reviewLB").colorbox({iframe:true, innerWidth:500, innerHeight:400});
	$j("a.pressLB").colorbox({iframe:true, innerWidth:750, innerHeight:500});
	
	
	 $j('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	
});