/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


// animated scroller
$(document).ready(function() {
$('.scrollPage').click(function() {
   var elementClicked = $(this).attr("href");
   var destination = $(elementClicked).offset().top;
   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-150}, 500 );
   return false;
});
});

/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
//@edited by: Branko Djurkovic www.plagosus.net
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup1(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$(".backgroundPopup").css({
			"opacity": "0.8"
		});
		$(".backgroundPopup").fadeIn("slow");
		$("#popup1").fadeIn("slow");
		popupStatus = 1;
	}
}

function loadPopup2(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$(".backgroundPopup").css({
			"opacity": "0.8"
		});
		$(".backgroundPopup").fadeIn("slow");
		$("#popup2").fadeIn("slow");
		popupStatus = 1;
	}
}

function loadPopup3(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$(".backgroundPopup").css({
			"opacity": "0.8"
		});
		$(".backgroundPopup").fadeIn("slow");
		$("#popup3").fadeIn("slow");
		popupStatus = 1;
	}
}

function loadPopup4(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$(".backgroundPopup").css({
			"opacity": "0.8"
		});
		$(".backgroundPopup").fadeIn("slow");
		$("#popup4").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$(".backgroundPopup").fadeOut("slow");
		$("#popup1").fadeOut("slow");
                $("#popup2").fadeOut("slow");
                $("#popup3").fadeOut("slow");
                $("#popup4").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup1").height();
	var popupWidth = $("#popup1").width();
	//centering
	$("#popup1").css({
		//"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
                //"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
        $("#popup2").css({
		//"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
        $("#popup3").css({
		//"position": "absolute",
		"top": windowHeight/2-240,
		"left": windowWidth/2-popupWidth/2
	});
        $("#popup4").css({
		//"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$("#backgroundPopup").css({
		"height": windowHeight
	});

}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

	//LOADING POPUP
	//Click the button event!
	$("#nf-kon").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup1();
                return false;
	});
	$("#nf-zap").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup2();
                return false;
	});
        $("#nf-zpp").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup3();
                return false;
	});
        $("#nf-pos").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup4();
                return false;
	});

	//CLOSING POPUP
	//Click the x event!
	$(".popupClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$(".backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});

