﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************
// Jason Note: actually this has been changed heaps.*/

var popupContainerElementIdentifier = ".popupContainer";
var popupButtonOpenIdentifier = ".popupOpenButton";
var popupButtonCloseIdentifier = ".popupCloseButton";

//loading popup with jQuery magic!
function loadPopupForSnippet(popupLink) {

    $(popupLink).parent().find(popupContainerElementIdentifier).css({
        "opacity": "1"
    });
    $(popupLink).parent().find(popupContainerElementIdentifier).fadeIn("slow");
}

//disabling popup with jQuery magic!
function disablePopupForSnippet(closeLink) {
    $(closeLink).parent().fadeOut("slow");    
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function () {
    //LOADING POPUP
    $(popupButtonOpenIdentifier).click(function () {
        //load popup
        loadPopupForSnippet(this);
        return false;
    });

    //CLOSING POPUP
    //Click the x event!
    $(popupButtonCloseIdentifier).click(function () {
        disablePopupForSnippet(this);
        return false;
    });

    //Press Escape event!
    $(document).keypress(function (e) {
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopupForSnippet();
        }
    });

});
