/* accordion.js */

function initMenu() {
	
	$('#accordion ul li ul li ul').hide();
	$('#accordion ul li ul').hide();
	$('#accordion ul').hide();
	
}

//dynamically change the selected state of the nav for each page

var thisURL = window.location.href
			window.location.toString();
			"" + window.location
				
var thisPath = window.location.pathname;

$(document).ready(function(){

/* Initialize Accordion Subnav */
		
	initMenu();
	
	/* Dynamically change the selected state of the nav for each page */
		
	$("a").each(function (i) {
		if (($(this).attr("href") == thisPath) || ($(this).attr("href") == thisPath+"#") || ($(this).attr("href") == thisPath+"/") 
			|| ($(this).attr("class") == "subLinkOn") 
			|| (($(this).attr("href") == "/packages/individual_package/ultimate_health_package") && (thisURL.match("spa_services") == "spa_services")) 
			|| (($(this).attr("href") == "/packages/individual_package/ultimate_health_package") && (thisURL.match("comprehensive_physical_components") == "comprehensive_physical_components"))  
			|| (($(this).attr("href") == "/packages/individual_package/complementary_alternative_medicine/") && (thisURL.match("/packages/individual/category/alternative_medicines/") == "/packages/individual/category/alternative_medicines/")) 
			|| (($(this).attr("href") == "/packages/individual_package/radiology") && (thisURL.match("/packages/individual/category/radiology/") == "/packages/individual/category/radiology/")) 
			|| (($(this).attr("href") == "/packages/individual_package/sleep_medicine/") && (thisURL.match("/packages/individual/category/sleep_medicine/") == "/packages/individual/category/sleep_medicine/")) 
			|| (($(this).attr("href") == "/packages/individual_package/dermatology/") && (thisURL.match("/packages/individual/category/dermatology/") == "/packages/individual/category/dermatology/")) 
			|| (($(this).attr("href") == "/press/releases/") && (thisURL.match("press_release") == "press_release")) 
			|| (($(this).attr("href") == "/press/kits/") && (thisURL.match("press_kit") == "press_kit"))
			|| (($(this).attr("href") == "/calendar/kitchen/") && (thisURL.match("/calendar/kitchen/") == "/calendar/kitchen/"))
			|| (($(this).attr("href") == "/calendar/workshops_calendar/") && (thisURL.match("/calendar/workshops_calendar/") == "/calendar/workshops_calendar/"))
			|| (($(this).attr("href") == "/calendar/fitness_exercise/") && (thisURL.match("/calendar/fitness_exercise/") == "/calendar/fitness_exercise/"))
			|| (($(this).attr("href") == "/thehealthyexecutive/in_the_news/category/press_releases/") && (thisURL.match("/thehealthyexecutive/article/category/press_releases/") == "/thehealthyexecutive/article/category/press_releases/"))
			|| (($(this).attr("href") == "/thehealthyexecutive/experts/") && (thisURL.match("/thehealthyexecutive/experts/") == "/thehealthyexecutive/experts/"))
		) {
			$(this).parents('ul').show();
			$(this).addClass("subLinkOn");
			$(this).siblings('ul').show();
		}
	});
		
	$("a.subLinkOpen").siblings('ul').show();
	$("a[href='/calendar/kitchen/'].subLinkOpen").removeClass("subLinkOn");
					
	$('#homeSide').cycle({
		timeout:	13000  // milliseconds between slide transitions (0 to disable auto advance) 
	});
	
	$('#bannerAnim').cycle({
		timeout:	13000  // milliseconds between slide transitions (0 to disable auto advance) 
	});
			
	$("#accordion a").each(function (i) {
		if ($(this).siblings('ul').size() >= '1') {
			$(this).addClass('subnavParent');
		}
		if ($(this).siblings('ul').is(':visible')) {
			$(this).addClass('subnavParentOpen');
		}
	});
		
	$('ul.mainMenu').superfish({ 
		delay:		850,							// one second delay on mouseout 
		animation:	{								// fade-in and slide-down animation 
						opacity:	'show',
						height:		'show'
					},
		speed:		'normal'						// faster animation speed 
	});
	
	$('ul.pillarsMenu').superfish({ 
		delay:		850,                            // one second delay on mouseout 
		animation:	{								// fade-in and slide-down animation 
						opacity:'show',
						height:'show'},
        speed:		'normal'						// faster animation speed
	}); 

	//$("#sectionTwoBody #logoBar a, #sectionThreeBody #logoBar a, #sectionFourBody #logoBar a, #sectionFiveBody #logoBar a, #sectionSixBody #logoBar a").html("<img src='/img/global/logo_alt.png' alt='California Health &amp; Longevity Institute (CHLI) is a luxurious health spa resort that specializes in individual well-being, corporate wellness and executive health.' id='logoImage' />");

	
	// Match box height on  Home Featured Pods
	/*var specialsPodHeights = [];
	$('#specialsFeature').children('div').each(function (i) {
	
	specialsPodHeights.push($(this).height());
	
	});

    var specialsPodHeightsMax = Math.max.apply( Math, specialsPodHeights );
    specialsPodHeightsMax = specialsPodHeightsMax - '10';
	
	$('#specialsFeature').children('div').css('height', specialsPodHeightsMax);*/
	// ------
	
	$("h1").append("<div></div>");
	
	$('.columnLeftLower .pod').hover(function() {
        $(this).find(".podPanel").stop(true,true).animate({
			left:"152px"
		}, '400');
		
    },
    function() {
       $(this).find(".podPanel").stop(true,true).animate({
			left:"300px"
		}, '400', function(){ 
			$(this).css({
				left:"-70px"
			});
		});
    });
    
	$('.columnRightLower .pod').hover(function() {
        $(this).find(".podPanel").stop(true,true).animate({
			left:"110px"
		}, '400');
		
    },
    function() {
       $(this).find(".podPanel").stop(true,true).animate({
			left:"300px"
		}, '400', function(){ 
			$(this).css({
				left:"-70px"
			});
		});
    });
    
    $("#interested_in_other").hide().css({
    	background: "transparent"
    });
    
    $('#interested_in_6').click(function() {
    	if ($(this).is(":checked")) {
    		$("#interested_in_other").fadeIn('200').removeAttr("disabled").css({
    		}).focus();
    	} else {
    		$("#interested_in_other").fadeOut('200').attr("disabled", "disabled").css({
    			background: "transparent"
    		});
    		}
    
    });

});
