﻿//SETTING UP OUR POPUP  
//0 means disabled; 1 means enabled;
var stafpopupStatus = 0;

//loading popup with jQuery magic!  
function loadSTAFPopup() {
    //loads popup only if it is disabled
    if (stafpopupStatus == 0) {
        $("#DDSbackgroundPopup").css({
            "opacity": "0.7"
        });
        $("#DDSbackgroundPopup").fadeIn("slow");
        $("#DDSpopupContact").fadeIn("slow");
        stafpopupStatus = 1;
    }
}

//disabling popup with jQuery magic!  
function disableSTAFPopup() {
    //disables popup only if it is enabled
    if (stafpopupStatus == 1) {
        $("#DDSbackgroundPopup").fadeOut("slow");
        $("#DDSpopupContact").fadeOut("slow");
        stafpopupStatus = 0;
    }
}

//centering popup
function centerSTAFPopup() {
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#DDSpopupContact").height();
    var popupWidth = $("#DDSpopupContact").width();
    var popUpYpos = "100px";
    if (windowHeight / 2 - popupHeight / 2 > 0) {
        popUpYpos = windowHeight / 2 - popupHeight / 2;
    }
    
    //centering
    $("#DDSpopupContact").css({
        "position": "absolute",
        "top": popUpYpos,
        "left": windowWidth / 2 - popupWidth / 2
    });

	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) {
		//only need force for IE6
		
		windowHeight = $("body").height();
		
			$("#DDSbackgroundPopup").css({
				"height": windowHeight,
				"position": "absolute"
			});
			$("#DDSpopupContact").css({
				"position": "absolute"
			});
		}
	}
}

$(document).ready(function() {
    //following code will be here
    //LOADING POPUP  
    //Click the button event!
    $("#button").click(function() {
        //centering with css
        centerSTAFPopup();
        //load popup
        loadSTAFPopup();
    });

    //CLOSING POPUP  
    //Click the x event!
    $("#DDSpopupContactClose").click(function() {
        disableSTAFPopup();
    });
});