
$(document).ready(function() {
	
	// Set opacity on page load
	$(".animatedMenuItem").css("opacity", "0.90");
    $(".testtopper").css("opacity", "0.80");
	
    window.menuHoverStart = function (element, topshift, thumbchange) {
  		
		$(element).animate({
            width: "599px",
            left: "0px",
			top: topshift,
            height: "168px",
            backgroundColor: "#d7df23",
            opacity: 0.95
        }, 100)
		.css({'border-top': 'none'});
			
		$(element).find(".thumb").animate({
       		width: "150px",
        	height: "150px",
        	marginTop: "8px",
       		marginRight: "0px",
        	marginBottom: "0px",
        	marginLeft: "12px"
  		}, 100)
    	.css({'border': '1px solid #FFF'})
		.attr('src','/images/home/animatedMenu/' + thumbchange + '.jpg');
		
		$(element).find("h2").animate({
            left: "600px"
        }, 100).hide();
		
		$(".animatedMenuItem").animate({
            top: topshift
        }, 100);
		
		$(element).find(".moredetail").delay(150).animate({
            left: "174px"
        }, {
            duration: 150,
            easing: 'easeInBounce'
        });
		
	}
	
	
	function menuHoverStop(element, thumbchange) {
  		
		$(element).clearQueue().animate({
            width: "246px",
            left: "9px",
            top: "0px",
            height: "83px",
            backgroundColor: "#222",
            opacity: 0.90
        }, 100)
		.css({'border-top': '1px solid #444'});
		
        $(element).find(".thumb").animate({
            width: "68px",
            height: "68px",
			marginTop: "6px",
			marginRight: "0px",
			marginBottom: "0px",
			marginLeft: "13px"
        }, 100)
		.attr('src','/images/home/animatedMenu/'+thumbchange+'up.jpg')
		.css({'border': '1px solid #000'});
		
        $(element).find("h2").show().animate({
            left: "0px"
        }, {
            duration: 350,
            easing: 'easeOutBounce'
        });
		
        $(element).find(".moredetail").animate({
            left: "600px"
        }, 100);
		
        $(".animatedMenuItem").clearQueue().animate({
            top: "0px"
        }, 100);
		
	}
	
	
	
	function resetBrochure() {
  		
		$("#brochureRequest").animate({
            width: "246px",
            left: "9px",
            height: "83px",
            backgroundColor: "#222",
            opacity: 0.90
        }, 100)
		.css({'border-top': '1px solid #444'});
		
        $("#brochureRequest").find(".thumb").animate({
            width: "68px",
            height: "68px",
			marginTop: "6px",
			marginRight: "0px",
			marginBottom: "0px",
			marginLeft: "13px"
        }, 100)
		.attr('src','/images/home/animatedMenu/'+'brochureRequestIMG'+'up.jpg')
		.css({'border': '1px solid #000'});
		
        $("#brochureRequest").find("h2").show().animate({
            left: "0px"
        }, {
            duration: 350,
            easing: 'easeOutBounce'
        });
		
        $("#brochureRequest").find(".moredetail").animate({
            left: "600px"
        }, 100);
		
	}
	
	
	
	// Animate button 1 on hover
	$("#brochureRequest").hover( function() {
        
		menuHoverStart(this, "0px", 'brochureRequestIMG');
			    
    }, function() {
		
		menuHoverStop(this, 'brochureRequestIMG');
			
	});

	
	// Animate button 2 on hover
    $("#openDays").hover( function() {
        
		menuHoverStart(this, "-21px", "testimonialIMG");
		resetBrochure();
	    
    }, function() {
		
		menuHoverStop(this, "testimonialIMG");
        
    });

	
	
	// Animate button 3 on hover
    $("#callBack").hover( function() {
        
		if (window.location.hostname == 'gi.hpb.co.uk' || window.location.hostname == 'www.hpb.gi' || window.location.hostname == 'hpb.gi') {
			menuHoverStart(this, "-63px", "testimonialIMG");
			resetBrochure();
		} else {
			menuHoverStart(this, "-63px", "openDayIMG");
			resetBrochure();
		}
		
    }, function() {
        if (window.location.hostname == 'gi.hpb.co.uk' || window.location.hostname == 'www.hpb.gi' || window.location.hostname == 'hpb.gi') {
			menuHoverStop(this, "testimonialIMG");
		} else {
			menuHoverStop(this, "openDayIMG");
		}
		
    });
	
	
	$('.requestBrochureButton').click(function() {
		
		menuHoverStop('#brochureRequest', "brochureRequestIMG");
		
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		$("html, body").animate({ scrollTop: 0 }, 500);
		
		$("<div class='forgottenpassword'></div>").hide().appendTo('#loginform');
		$(".forgottenpassword").css({"width":"940px", "margin-left":"-470px"});
		$(".brochureRequestForm").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		
 	});
	
	
	$('.closeBrochureRequest').live('click', function() {
  		var popupToClose = $(this).parent();
		
			$("div.forgottenpassword").delay(500).slideUp( function() {
				$("div.blackout").fadeOut( function() {
					$(popupToClose).appendTo('.forgotContainer');
					$("div.blackout").remove();
					$("div.forgottenpassword").remove();
				});
			});
	});
	
	
	
	$('.privacyLink').click(function() {
		
		$("<div class='blackout'></div>").hide().css("opacity",0.8).appendTo('body').delay(300).fadeIn();
		
		$(".moreDrop").clearQueue().slideUp(150, function () {
			$(".moreDropCont").hide();
		});
		
		$("<div class='forgottenpassword'></div>").css({"width":"900px", "margin-left":"-450px", "height":"500px", "overflow":"auto"}).hide().appendTo('#loginform');
		$(".privacyPolicy").appendTo("div.forgottenpassword");
		$(".forgottenpassword").delay(1000).slideDown();
		
 	});


	// Animate button 3 on hover
    $("#call").hover( function() {
        
		menuHoverStart(this, "-84px", "callbackIMG");
		resetBrochure();
		
       
    }, function() {
		
        menuHoverStop(this, "callbackIMG");
		
    });
	
	//setTimeout(function() { menuHoverStart("#callBack", "-63px", "brochureRequestIMG"); },2000);
	
});


