$(document).ready(function(){
	$("#passwordField").click(function(){
		var localPasswordField = '<input type="password" name="pw" class="passwordField" id="passwordField" value="" />';
		$(this).replaceWith(localPasswordField);
		$("#passwordField").trigger('focus');  //since we recreate the input element we need to trigger the focus on it because the event click was removed
	});
	$(".userNameField").click(function(){
		var fieldValue = $(this).val();
		if(fieldValue == 'User Name'){
			$(this).val('');
		}
	});
	$(".userNameField").blur(function(){
		var fieldValue = $(this).val();
		if(fieldValue == ''){
			$(this).val('User Name');
		}
	});
	$("#lfnMedicalNutrition").hover(
		function(){
			$(".secondaryNav.medicalNutrition").addClass('show');
			$(this).css({backgroundColor:'#e5edf2'});
		}, 
		function (){
			$(".secondaryNav.medicalNutrition").removeClass('show');
			$(this).css({backgroundColor:'transparent'});
		}
	);
	$("#lfnPrePostNatal").hover(
		function(){
			$(".secondaryNav.PrePostNatal").addClass('show');
			$(this).css({backgroundColor:'#e5edf2'});
		}, 
		function (){
			$(".secondaryNav.PrePostNatal").removeClass('show');
			$(this).css({backgroundColor:'transparent'});
		}
	);
	$("#lfnHealthWell").hover(
		function(){
			$(".secondaryNav.healthWell").addClass('show');
			$(this).css({backgroundColor:'#e5edf2'});
		}, 
		function (){
			$(".secondaryNav.healthWell").removeClass('show');
			$(this).css({backgroundColor:'transparent'});
		}
	);
	$("#topNavOurTeamIMG").hover(
		function (){	$(this).attr({src: "images/topNavOurTeamActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavOurTeam.jpg"});}
	);
	$("#topNavOurPhilosophyIMG").hover(
		function (){$(this).attr({src: 'images/topNavOurPhilosophyActive.jpg'});},
		function (){$(this).attr({src: 'images/topNavOurPhilosophy.jpg'});}
	);
	$("#topNavServiceIMG").hover(
		function(){	$(this).attr({src: "images/topNavServicesActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavService.jpg"});}
	);
	$("#topNavPressIMG").hover(
		function(){	$(this).attr({src: "images/topNavPressActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavPress.jpg"});}
	);
	$("#topNavDietTipsIMG").hover(
		function (){$(this).attr({src: "images/topNavDietTipsActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavDietTips.jpg"});}
	);
	$("#topNavShopIMG").hover(
		function(){	$(this).attr({src: "images/topNavShopActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavShop.jpg"});}
	);
	$("#topNavPartnersIMG").hover(
		function(){	$(this).attr({src: "images/topNavPartnersActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavPartners.jpg"});}
	);
	$("#topNavContactUsIMG").hover(
		function(){	$(this).attr({src: "images/topNavContactUsActive.jpg"});}, 
		function (){$(this).attr({src: "images/topNavContactUs.jpg"});}
	);

// Alternate hover states to handle relative URLs

	$("#topNavOurTeamIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavOurTeamActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavOurTeam.jpg"});}
	);
	$("#topNavOurPhilosophyIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavOurPhilosophyActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavOurPhilosophy.jpg"});}
	);
	$("#topNavServiceIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavServicesActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavService.jpg"});}
	);
	$("#topNavPressIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavPressActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavPress.jpg"});}
	);
	$("#topNavDietTipsIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavDietTipsActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavDietTips.jpg"});}
	);
	$("#topNavShopIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavShopActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavShop.jpg"});}
	);
	$("#topNavPartnersIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavPartnersActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavPartners.jpg"});}
	);
	$("#topNavContactUsIMGContent").hover(
		function(){	$(this).attr({src: "../images/topNavContactUsActive.jpg"});}, 
		function (){$(this).attr({src: "../images/topNavContactUs.jpg"});}
	);
	

	var preload1 = new Image();
	preload1.src = 'images/topNavOurTeamActive.jpg';
	var preload2 = new Image();
	preload2.src = 'images/topNavOurPhilosophyActive.jpg';
	var preload3 = new Image();
	preload3.src = 'images/topNavServicesActive.jpg';
	var preload4 = new Image();
	preload4.src = 'images/topNavPressActive.jpg';
	var preload5 = new Image();
	preload5.src = 'images/topNavCaseStudiesActive.jpg';
	var preload6 = new Image();
	preload6.src = 'images/topNavShopActive.jpg';
	var preload7 = new Image();
	preload7.src = 'images/topNavPartnersActive.jpg';
	var preload8 = new Image();
	preload8.src = 'images/topNavContactUsActive.jpg';
	
});

