﻿/***************************/
//@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;
//loading popup with jQuery magic!
function loadPopup() {
    //loads popup only if it is disabled
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.4"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#mainContactForm").fadeIn("slow");
        popupStatus = 1;
    }
}
//centering popup
function centerPopup() {
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#mainContactForm").height();
    var popupWidth = $("#mainContactForm").width();
    //centering
    $("#mainContactForm").css({
        "position": "fixed",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    //only need force for IE6

    $("#backgroundPopup").css({
        "height": windowHeight
    });

}
//animate the confirm button
function animateButton() {
    $(document).ready(function () {
        $('.confirmBTN').append('<span class="hover"></span>').each(function () {
            var $span = $('> span.hover', this).css('opacity', 0);
            $(this).hover(function () {
                $span.stop().fadeTo(500, 1);
            },
			function () {
			    $span.stop().fadeTo(500, 0);
			});
        });
    });
}
function showContactForm() {
    centerPopup();
    loadPopup();
   // animateButton();
}


//disabling popup with jQuery magic!
function disablePopup() {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
       // $('.hover').remove();
        $("#mainContactForm").fadeOut("slow");
        popupStatus = 0;
    }
}
function closePopup() {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
       // $('.hover').remove();
        $("#backgroundPopup").fadeOut("slow");
        $("#mainContactForm").fadeOut("slow");
        popupStatus = 0;
    }
}





function goToErrorBox(id) {
    $(document).ready(function () {
        $('html, body').animate({
            scrollTop: $("#" + id).offset().top
        }, 1000);

    });
}

