//added by Miro - i4vegas tracking
function createRequestObject_i4v() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}
function ajaxI4Vegas() {
	var http1 = '';

	this.init = function () {
		http1 = createRequestObject_i4v();
	}

	this.sndReq = function (hotel_id) {
		var uri = '/'+config_cms_folder_name+'/ajax/getsubcat.php?action=i4v_click&hotel_id=' + encodeURI(hotel_id);
		http1.open('get', uri);
		return false;
		http1.onreadystatechange = this.handleResponse;
		http1.send(null);
	}

	this.handleResponse = function () {}
}
var ai4v = new ajaxI4Vegas();
ai4v.init();
//----------------------------------

function checkDates(form) { 
 inday = form.inday[form.inday.selectedIndex].value;
 inmonth = form.inmonth[form.inmonth.selectedIndex].value;
 inyear = form.inyear[form.inyear.selectedIndex].value;
 if (inyear.length == 2)
 	inyear = '20'+inyear;
 outday = form.outday[form.outday.selectedIndex].value;
 outmonth = form.outmonth[form.outmonth.selectedIndex].value;
 outyear = form.outyear[form.outyear.selectedIndex].value;
 if (outyear.length == 2)
 	outyear = '20'+outyear;
 d1 = new Date(inyear,inmonth,inday);
 d2 = new Date(inyear,inmonth,1);
 d3 = new Date(outyear,outmonth,outday);
 d4 = new Date();
 d5 = new Date(d4.getFullYear(),d4.getMonth(),d4.getDate());
 message = "";
 if (d1.getMonth() != d2.getMonth()) { message += "* Your check-in date is not valid.\n"; } 
 if (d1.getTime() >= d3.getTime()) { message += "* Your check-out date must not be the same, or before your check-in date.\n"; } 
 if (d1.getTime() < d5.getTime()) { message += "* Your check-in date may not be before today.\n"; } 
 if (message.length > 0) { alert("Please address the following errors:\n" + message); return false; } 

 alert(form.hotn_id.value);
 ai4v.sndReq(form.hotn_id.value);
alert('ddd'); 
 return false;
}

function doSO(f,tV,tF) {
 for(i=0;i<f[tF].options.length;i++)
  if(f[tF].options[i].value==tV){f[tF].options[i].selected=true;}
} 

function dateChange(f) { 
 thisdate = new Date(f.inyear[f.inyear.selectedIndex].value, f.inmonth[f.inmonth.selectedIndex].value-1, f.inday[f.inday.selectedIndex].value);
 msecs = (thisdate-0);
 twoday = new Date(msecs+(86400000*2));
 im = thisdate.getMonth()+1;
 id = thisdate.getDate();
 iy = thisdate.getFullYear();
 om = twoday.getMonth()+1;
 od = twoday.getDate();
 oy = twoday.getFullYear();
 doSO(f,im,"inmonth");
 doSO(f,id,"inday");
 doSO(f,iy,"inyear");
 doSO(f,om,"outmonth");
 doSO(f,od,"outday");
 doSO(f,oy,"outyear");
}

function initializeDates(f) {
 thisdate = new Date();
 thisdate = new Date(thisdate.getFullYear(),thisdate.getMonth(),thisdate.getDate());
 msecs = (thisdate-0); oneday = new Date(msecs+86400000*2);
 twoday = new Date(msecs+(86400000*4));
 im = oneday.getMonth()+1;
 id = oneday.getDate();
 iy = oneday.getFullYear();
 om = twoday.getMonth()+1;
 od = twoday.getDate();
 oy = twoday.getFullYear();
 doSO(f,im,"inmonth");
 doSO(f,id,"inday");
 doSO(f,iy,"inyear");
 doSO(f,om,"outmonth");
 doSO(f,od,"outday");
 doSO(f,oy,"outyear");
 temponload();
}

function i4init() { 
 if (document.tv) { 
  initializeDates(document.tv);
 }
 if (document.th) {
  initializeDates(document.th);
 }
}
temponload = (window.onload) ? window.onload : new Function; window.onload=i4init;
