var $j = jQuery.noConflict(); 

$j(document).ready(function() {

var launched=0;
var max_launch=2;
var updown=false;
var dirIndex=0;
var cYant;

$j(document).mousemove(function(e) {

if (!cYant) cYant=e.pageY;


cY=e.pageY;
if (!cY) cY=e.clientY;
dirIndex = cYant - cY;
updown=(dirIndex<=0)?false:true;
dif=( (dirIndex>=5)|| (dirIndex<=-5) )?false:true;
cYant=cY;

if ( ( (e.pageY <= 20) || (e.clientY <= 20) )&&(launched < max_launch) && (updown) &&(dif) )
{
// Launch MODAL BOX
$j('#exit_content').modal({onOpen: modalOpen, onClose: simplemodal_close});
//alert ('prev: '+cYant+' actual:'+cY+' Index:'+dirIndex);
launched=launched+1;
updown=false;dif=false;
}

});

});
/**
 * When the open event is called, this function will be used to 'open'
 * the overlay, container and data portions of the modal dialog.
 *
 * onOpen callbacks need to handle 'opening' the overlay, container
 * and data.
 */
function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.fadeIn('fast', function () {
			dialog.data.hide().slideDown('fast');
		});
	});
}

   /**
 * When the close event is called, this function will be used to 'close'
 * the overlay, container and data portions of the modal dialog.
 *
 * The SimpleModal close function will still perform some actions that
 * don't need to be handled here.
 *
 * onClose callbacks need to handle 'closing' the overlay, container
 * and data.
 */
function simplemodal_close (dialog) {
	dialog.data.fadeOut('fast', function () {
		dialog.container.hide('fast', function () {
			dialog.overlay.slideUp('fast', function () {
				$j.modal.close();
			});
		});
	});
}




