﻿/***************************/
//@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 popupStatus18 = 0;


function loadPopup19(){
    //loads popup only if it is disabled
    if(popupStatus==0){
        jQuery("#backgroundPopup19").css({
            "opacity": "0.85"
        });
        jQuery("#backgroundPopup19").fadeIn("slow");
        jQuery("#popupContact19").fadeIn("slow");
        popupStatus = 1;
    }
}

//disabling popup with jQuery magic!
function disablePopup19(){
    //disables popup only if it is enabled
    if(popupStatus==1){
        jQuery("#backgroundPopup19").fadeOut("slow");
        jQuery("#popupContact19").fadeOut("slow");
        popupStatus = 0;
    }
}

//centering popup
function centerPopup19(){
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = jQuery("#popupContact19").height();
    var popupWidth = jQuery("#popupContact19").width();
    //centering
    jQuery("#popupContact19").css({
        "position": "absolute",
        "top": 30,
        "left": windowWidth/2-popupWidth/2
    });
    //only need force for IE6
    
    jQuery("#backgroundPopup19").css({
        "height": windowHeight
    });
    
}
//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){
    
    //LOADING POPUP
    //Click the button event!
    jQuery("#popup19").click(function(){
      jQuery('html, body').animate({scrollTop: '0px'}, 500);
        //centering with css
        centerPopup19();
        //load popup
        loadPopup19();
        
    });
                
    //CLOSING POPUP
    //Click the x event!
    jQuery("#popupContactClose19").click(function(){
        disablePopup19();
    });


});

jQuery(function() {
            var offset = jQuery("#b_box").offset();
            var topPadding = 150;
            jQuery(window).scroll(function() {
                if ($(window).scrollTop() > offset.top) {
                    jQuery("#b_box").stop().animate({
                        marginTop: jQuery(window).scrollTop() - offset.top + topPadding
                    });
                } else {
                    jQuery("#b_box").stop().animate({
                        marginTop: 0
                    });
                };
            });
        });
