//settings
var popupShowTimes1 = undefined; //how many times to show the popup, "undefined" (without quotes) for unlimited
var popupSensibility1 = 20; //how many pixels should the mouse be close to the top of the page before
							//displaying the popup
							
var popupTopSpace1 = 100; //value in pixels or 'middle' (with quotes) to place it on the screen middle



//other variables, you shouldn't change these
var popupOnContent1 = false;
var popupVisible1 = false;
var popupHeight1 = 0;

function popup1() {

	//reset
	popupOnContent1 = false;
	popupVisible1 = true;
	
	//show popup
	$('#curtain4').fadeIn(100);
	if (popupShowTimes1 != undefined) {
		popupShowTimes1--;
	}
	
	//center it vertically
	popupHeight1 = $('#custom_popup4').height();
	
	if (popupTopSpace1 == 'middle' || $(document).height() < (popupHeight1 + popupTopSpace1)) {
		
		if (($(document).height() - popupHeight1) < 0) {
			var newTop = '2px';
		} else {
			var newTop = ($(document).height() - popupHeight1) / 2;
		}
		
	} else {
		var newTop = popupTopSpace1 + 'px';
	}
	
	$('#custom_popup4').css('top', newTop);
	
	return true;

}


function closePopup1() {

	popupVisible1 = false;
	$('#curtain4').hide();

}


$(document).ready(function() {

	$(document).mousemove(function(e) {
		
		//if the mouse already was down then enable popup
		if (e.pageY>popupSensibility1) {popupOnContent1 = true;}
		
		if (e.pageY<=popupSensibility1 && popupOnContent1 == true && popupVisible1 == false &&
		(popupShowTimes1 > 0 || popupShowTimes1 == undefined)) {
			popup1();
		}
		
	
	});
	
	$('#curtain4 #popup-close').click(function() {
		closePopup1();
	});

});

