
$(document).ready(function() {
						   
//preload images for faster loading						   
function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
        // Alternatively you could use:
        // (new Image()).src = this;
    });
}
preload([
    'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/blue_button_left.png',
    'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/blue_button_right.png',
	'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/RotatingImage1.png',
	'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/RotatingImage2.png',
	'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/RotatingImage3.png',
	'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/RotatingImage4.png',
	'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/RotatingImage5.png'
]);


//Front Page Rotating slideshow
$('#slideshowPics ').cycle({
				activePagerClass: 'activeSlide',
				fx:            'fade', 
				pauseOnPagerHover: true,
				speed:  'fast', 
				timeout: 4000, 
				pager:  '#external' 
		    });

//Highlight active subnav for Wellness menu and keep Wellness highlighted
if ($("#subnav").length){
	if ("#subnav li a.active") {
		$("#subnav li a.active").css({"color":"#93c94a"});
		//hack to avoid Welness menu from being highlighted when you are on Patient Guide
		if ($("#navigation-box div.breadcrumb [href='/patient-guide/healthtopic/patient-guide']").length<=0) {
			$(".menu-444").addClass("active");
		}
	}
}

//IF a link under Conditions & Diseases is clicked, keep Conditions & Diseases menu highlighted
if ($("#navigation-box div.breadcrumb [href='/conditions-diseases']").length) {
	//hack to avoid Cond & Dis menu from being highlighted when you are on Patient Guide
	if ($("#navigation-box div.breadcrumb [href='/patient-guide/healthtopic/patient-guide']").length<=0) {
		$(".menu-443").addClass("active");
	}
}
if ($("#navigation-box div.breadcrumb [href='/taxonomy/term/1']").length) {
	//hack to avoid Cond & Dis menu from being highlighted when you are on Patient Guide
	if ($("#navigation-box div.breadcrumb [href='/patient-guide/healthtopic/patient-guide']").length<=0) {
		$(".menu-443").addClass("active");
	}
}

//If there is no active menu item and no subnav, then default to Home as the active menu item
if ($("#nav li a.active").length <=0){
 if ($("#subnav").length<=0){
	 if ($("#navigation-box div.breadcrumb [href='/conditions-diseases']").length<=0) {
		 if ($("#navigation-box div.breadcrumb [href='/taxonomy/term/1']").length<=0) {
			$(".menu-218").addClass("active");
		 }
	 }
 }
}

//Add rounded edges to active nav menu item
if ("#nav li a.active") {
		
	
	
	$("#nav li a.active").wrapInner("<span class='active_button'></span>"); 
  	$("#nav li.active").prepend(													
		$('<img />').attr({   
			'src': 'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/blue_button_left.png',    
			'alt': '',     
			'height': '29' , 
			'width': '6',
			'style': 'float:left'
			
			
			
		})
	)
 
  $("#nav li.active").append(							
		$('<img />').attr({   
			'src': 'http://www.healthandage.com/sites/default/themes/blueprint/images/novoviva/blue_button_right.png',    
			'alt': '',     
			'height': '29' , 
			'width': '6',
			'style': 'float:left'
			
			
			
		})
	)

   $('#nav li.active').css({'float':'left', 'position': 'relative'});

	
} 

//Add Q: in front of questions in home page "Frequently Asked Questions" block
$("<b>Q: </b>").prependTo("#block-boomerang_custom-qna_front div.title a");

//Hide "more" text on home page blocks
$("#block-boomerang_custom-news_front div.more-link-div a").html(""); 
$("#block-boomerang_custom-article_front div.more-link-div a").html(""); 
$("#block-boomerang_custom-qna_front div.more-link-div a").html(""); 

//Create links for Conditions & Diseases selection box
$("#select_condition_diseases").change(function() {         
	var src = $(this).val();          
	window.location.href=src; 
}); 

});
