$(function() {
    
/*$(".btnBuy").hover(
 function()
 {
  $(this).css("background-image", "url(/majestic/images/book-now-on.png)");  
 },
 function()
 {
  $(this).css("background-image", "url(/majestic/images/book-now-off.png)");             
 }
);*/    
	
var popup = false;
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');

$("#button").click(function(){
    $body.animate({scrollTop: $('#booking-form').offset().top}, 1000);   
/*	if(popup == false){
		$("#overlayEffect").show();
		$("#popupContainer").fadeIn("slow");
		$("#close").fadeIn("slow");
	    center();
		popup = true;
	}  */
    return false;	
	});
	
	$("#close").click(function(){
		hidePopup();
	});
	
	$("#overlayEffect").click(function(){
		hidePopup();
	});    

function center(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContainer").height();
	var popupWidth = $("#popupContainer").width();
    //var height = windowHeight/2-popupHeight/2;
    //if(height < 0)
    //    height = 30;
    var top = 0;
    var left = 100;
	$("#popupContainer").css({
		"position": "absolute",
		"top": top,
		"left": left //windowWidth/2-popupWidth/2
	});
    $("#flashcontainer").hide();   
    $body.animate({scrollTop: $('#header').offset().top}, 1000);   
	}
function hidePopup(){
	if(popup==true){
		$("#overlayEffect").hide();
		$("#popupContainer").fadeOut("slow");
		$("#close").fadeOut("slow");
		popup = false;
        $("#flashcontainer").show();
	}
}

$("#buttonRecommend").click(function(){
    if(popup == false){
        $("#overlayEffectRecommend").show();
        $("#RecommendDiv").fadeIn("slow");
        $("#closeRecommend").fadeIn("slow");
        centerRecommend();
        popup = true;
    }
    return false;    
    });
    
    $("#closeRecommend").click(function(){
        hidePopupRecommend();
    });
    
    $("#overlayEffectRecommend").click(function(){
        hidePopupRecommend();
    });    

function centerRecommend(){
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#RecommendDiv").height();
    var popupWidth = $("#RecommendDiv").width();
    //var height = windowHeight/2-popupHeight/2;
    //if(height < 0)
    //    height = 30;
    var top = 100;
    var left = 200;
    if($(".modfirst").length > 0)
        left = 350; 
    $("#RecommendDiv").css({
        "position": "absolute",
        "top": top,
        "left": left
    });
    if($(".modfirst").length == 0)
        $("#flashcontainer").hide(); 
    $("#RecommendResult").hide(); 
    $("#RecommendSend").show();     
    $body.animate({scrollTop: $('#header').offset().top}, 1000);  
    }
function hidePopupRecommend(){
    if(popup==true){
        $("#overlayEffectRecommend").hide();
        $("#RecommendDiv").fadeOut("slow");
        $("#closeRecommend").fadeOut("slow");
        popup = false;
        if($(".modfirst").length == 0)
            $("#flashcontainer").show();
    }
}

//choose div
var referChooseUrl = "";
$(".buttonReferChoose").click(function(){
    referChooseUrl = $(this).attr("href");
    if(popup == false){
        $("#overlayEffectReferChoose").show();
        $("#ReferChooseDiv").fadeIn("slow");
        $("#closeReferChoose").fadeIn("slow");
        centerReferChoose();
        popup = true;
    }
    return false;    
    });
    
    $("#closeReferChoose").click(function(){
        hidePopupReferChoose();
    });
    
    $("#overlayEffectReferChoose").click(function(){
        hidePopupReferChoose();
    });   
$("#btnReferChooseContinue").click(function(){
    window.open(referChooseUrl ,'_blank');
}); 

function centerReferChoose(){
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#ReferChooseDiv").height();
    var popupWidth = $("#ReferChooseDiv").width();
    //var height = windowHeight/2-popupHeight/2;
    //if(height < 0)
    //    height = 30;
    var top = 100;
    var left = 200;
    if($(".modfirst").length > 0)
        left = 350; 
    $("#ReferChooseDiv").css({
        "position": "absolute",
        "top": top,
        "left": left
    });
    if($(".modfirst").length == 0)
        $("#flashcontainer").hide();    
    $body.animate({scrollTop: $('#header').offset().top}, 1000);  
    }
function hidePopupReferChoose(){
    if(popup==true){
        $("#overlayEffectReferChoose").hide();
        $("#ReferChooseDiv").fadeOut("slow");
        $("#closeReferChoose").fadeOut("slow");
        popup = false;
        if($(".modfirst").length == 0)
            $("#flashcontainer").show();
    }
}
});



