﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

function popup(picnum) {
    //SETTING UP OUR POPUP
    //0 means disabled; 1 means enabled;
    this.popupStatus = 0;

    this.picnum = picnum;

    if (this.picnum==0) {
        this.popupContact = "#popupContact"
    }
    else{
        this.popupContact = "#popupContact" + picnum;
    }


    //centering popup
    this.centrePopup = function(){
        //request data for centering
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = 0;
        var popupWidth = 0;

        //centering
        popupHeight = $(this.popupContact).height();
        popupWidth = $(this.popupContact).width();

        //centering
        $(this.popupContact).css({
            "position": "fixed",
            "top": windowHeight/2-popupHeight/2,
            "left": windowWidth/2-popupWidth/2
        });

        //only need force for IE6

        $("#backgroundPopup").css({
            "height": windowHeight
        });
    }

    //loading popup with jQuery magic!
    this.loadPopup = function(){
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
    
        //loads popup only if it is disabled
        if(this.popupStatus==0){
            $("#backgroundPopup").fadeIn("fast");
            $(this.popupContact).fadeIn("fast");
            this.popupStatus = 1;
        }
    }
    
    //disabling popup with jQuery magic!
    this.disablePopup = function(){

        //disables popup only if it is enabled
        if(this.popupStatus==1){
            $("#backgroundPopup").fadeOut("slow");
            $(this.popupContact).fadeOut("slow");
            this.popupStatus = 0;
        }
    }

}

