var currentTabURL = location.pathname;

var lastX = 0;
var lastY = 0;

var xTotal = 0;
var yTotal = 0;

var cookiesActive = false;

function validateMLSignup(){
	yourname  = document.getElementById("name");
	email = document.getElementById("email");
	
	if(!yourname.value || !email.value){
		alert('please fill out both your name and email address');
		return false;
	}else{
		return true;	
	}
}


function loadTabContents(linkObject){
	var url = linkObject.pathname;
	new Ajax.Updater('tabContents','/load_content.php',{
					 	 method: 'get',
						 onComplete: function(){loadTabContentsComplete()},
						 parameters:{p:url}
						 });
	
	currentTabURL = url;
}

function loadTabContentsComplete(){
	myLightbox.updateImageList();
	setTabState();
}


//Bot blocking code
Event.observe(document, 'mousemove', function (event) {
	posX = Event.pointerX(event);
	posY = Event.pointerY(event);
	
	if(!lastX) {
		lastX = posX;
	}
	
	if(!lastY) {
		lastY = posY;
	}
	
	xTotal = xTotal + Math.abs(posX - lastX);
	yTotal = yTotal + Math.abs(posY - lastY);
	
	lastX = posX;
	lastY = posY
});

setInterval ( "ohTheHumanity()", 5000 );

function clearTotal() {
	xTotal = 0;
	yTotal = 0;
}

function ohTheHumanity( )
{
	pars = 'totalX=' +xTotal + '&totalY=' + yTotal;
	clearTotal();
	new Ajax.Request('/index.php', {
	  	parameters: pars,
		method: 'post'
	});
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//END Bot blocking code


//Cookie Checker
/*
	Insert the following, or something similar, into your template file
	for notification of when cookies are disabled.
	
	<div id="cookieNotice">
    <script type="text/javascript">
		if(!cookiesActive) {
			document.write("Cookies are disabled. Cookies must be enabled for full functionality.");
		}
	</script>
    </div>
*/
/*if (navigator.cookieEnabled) {
cookiesActive = true;
}*/

// remember, these are the possible parameters for Set_Cookie:
// name, value, expires, path, domain, secure
document.cookie="YayCookies"
if (document.cookie.search(/YayCookies/) != -1) {
	cookiesActive = true;
}else{
	cookiesActive = false;
}


/*Event.observe(window, 'load', function (event) {
	reservationArray = $$('a[href="/en/accommodations/make-reservations.html"]', 'a[href="/en/accommodations/make-reservations.html#contentTop"]');
	reservationArray.each(function(s) {
  		Event.observe(s, 'click', function (event) {
			Event.stop(event);
			window.open('http://ib-webserver.infinitybay.com/irm?CFID=923143&CFTOKEN=86d6ae033408c77d-480071E6-FCB9-5BA7-1B0C2F75785FF7E8', '', 'resizable=1, scrollbars=1, width=800, height=550');
		});
	});
	
	ownerArray = $$('a[href="/en/condo-owners.html"]', 'a[href="/en/condo-owners.html#contentTop"]');
	ownerArray.each(function(s) {
  		Event.observe(s, 'click', function (event) {
			Event.stop(event);
			window.open('http://190.4.60.139/IRMNet/Owner/OwnerHome.aspx', '', 'resizable=1, scrollbars=1, width=800, height=550');
		});
	});
});
*/