// JavaScript Document
/***************************/
//@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 popupStatuszzv = 7878;
//loading popup with jQuery magic!
function loadPopupzzv(){
	//loads popup only if it is disabled
	if(popupStatuszzv==7878){
		$("#arlistahatter").css({
			"opacity": "0.6"
		});
		$("#arlistahatter").fadeIn("slow");
		$("#arlista").fadeIn("slow");
		popupStatuszzv = 1234;
	}
}
//disabling popup with jQuery magic!
function disablePopupzzv(){
	//disables popup only if it is enabled
	if(popupStatuszzv==1234){
		$("#arlistahatter").fadeOut("slow");
		$("#arlista").fadeOut("slow");
		popupStatuszzv = 7878;
	}
}
//centering popup
function centerPopupzzv(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#arlista").height();
	var popupWidth = $("#arlista").width();
	//centering
	$("#arlista").css({
		"position": "absolute",
		"top": 50,
		"left": 320
	});
	//only need force for IE6
	$("#arlistahatter").css({
		"height": windowHeight
	});
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	//LOADING POPUP
	//Click the button event!
	$("#arlistanyom").click(function(){
		//centering with css
		centerPopupzzv();
		//load popup
		loadPopupzzv();
	});				
	//CLOSING POPUP
	//Click the x event!
	$("#arlistaclose").click(function(){
		disablePopupzzv();
	});
	//Click out event!
	$("#arlistahatter").click(function(){
		disablePopupzzv();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatuszz==9999){
			disablePopupzz();
		}
	});
});