﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var globaldivid;
//loading popup with jQuery magic!
function loadPopup(divid) {
    //loads popup only if it is disabled
    if (popupStatus == 0) {
        popupStatus = 1;
        $k("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $k("#backgroundPopup").fadeIn("slow");
        $k("#" + divid).fadeIn("slow");

       
    }
}

//disabling popup with jQuery magic!
function disablePopup(divid) {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
        $k("#backgroundPopup").fadeOut("slow");
        $k("#" + divid).fadeOut("slow");
        popupStatus = 0;
        if (globaldivid == 'popupshopingdiv') {
            window.parent.location.href = globalPath + "Deals1.aspx";
        }
    }
  
}



function disablePopup() {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
        $k("#backgroundPopup").fadeOut("slow");
        $k("#" + globaldivid).fadeOut("slow");
        popupStatus = 0;
        if (globaldivid == 'popupshopingdiv') {
            window.parent.location.href = globalPath+"Deals1.aspx";
        }
    }
   
}

// Generalised method for any divid by kamlesh

function callJQureyMagicPopUp(divid, divClose) {
   globaldivid = divid;

    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $k("#" + divid).height();
    var popupWidth = $k("#" + divid).width();
    var top = ($k("#" + divid).offset().top - popupHeight) + 250;
    
    //only need force for IE6
    if ($k.browser.msie && $k.browser.version.substr(0, 1) < 7) {
        var leftvar=(980 - $k(document).width()) / 2;
        $k("#" + divid).css({
            "top": windowHeight / 2 - popupHeight / 2,
            "left": (windowWidth / 2 - popupWidth / 2) + leftvar
        });
        $k("#backgroundPopup").css({
            "height": $k(document).height(),
            "width": $k(document).width() - 20,
            "left": leftvar
        });
    } else {
        $k("#" + divid).css({
            "top": windowHeight / 2 - popupHeight / 2,
            "left": windowWidth / 2 - popupWidth / 2
        });
         $k("#backgroundPopup").css({
            "height": $k(document).height(),
            "width": $k(document).width()
        });
    }

    loadPopup(divid);
    $k(window).scroll(function () {
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $k("#" + divid).height();
        $k("#" + divid).css({
            "top": windowHeight / 2 - popupHeight / 2
        });
    });

    //CLOSING POPUP
    //Click the x event!
    $k("#" + divClose).click(function () {
        disablePopup(divid);
    });
    //Click out event!
   // $k("#backgroundPopup").click(function () {
     //   disablePopup(divid);
    //});
}


//Press Escape event!
$k(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
	disablePopup(globaldivid);
}
});

function callGetAjax(divid, url, paramdata) {

    document.getElementById(divid).innerHTML = "<div style='padding-top:25%;text-align:center'><img src='" + globalPath + "Images/Drip_Circle.gif' alt='Loading Data'></div>";
    $k.get(url, paramdata, function (data) {

        try {
            $k('#' + divid).html(data);
        } catch (e) {
            
        }
    });
}



