//=============================================
//Capturing The Mouse Position in IE4-6 & NS4-6
//(C) 2000 www.CodeLifter.com
//Free for all users, but leave in this  header
//=============================================
			
<!--

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = window.event.screenX //+ document.body.scrollLeft
		tempY = window.event.screenY //+ document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}  
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}  
	
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY
	
	return true
}
		
//RAI Code
function BBBopen() {
	popupWin = window.open
	('http://www.bbbonline.org/cks.asp?id=1071203102429410',
	'Participant',
	'location=yes,scrollbars=yes,width=625,height=350')
	window.name = 'opener';
}

function Rcertify() {
	popupWin = window.open
	('http://www.bbbonline.org/cks.asp?id=1071203102429410',
	'Participant',
	'location=yes,scrollbars=yes,width=450,height=300')
	window.name = 'opener';
}

function openNewPage () {
	window.location.href=(document.TOCNavigator.pageToGoTo.options
	[document.TOCNavigator.pageToGoTo.selectedIndex].value);
	document.TOCNavigator.pageToGoTo.selectedIndex="0";
}

//Functions for the admin section
function OpenAdminImage(hotelID){
	var sURL = "/fla/admin/rai/hotels/image_add.aspx?hotel_ID=" + hotelID;
	OpenWin(sURL, 232, 356);
}		
	
	
//Functions for the image album section
function DeleteAlbum(albumID){
	if(confirm('Are you sure you want to delete this album?')){
		location.href='/fla/admin/rai/imgAlbum/imgAlbum_delete.aspx?ID=' + albumID;
	}
}		

function DeleteImage(imageID,albumID){
	if(confirm('Are you sure you want to delete this image?')){
		location.href = "/fla/admin/rai/imgAlbum/image_delete.aspx?IMAGE_ID=" + imageID + "&ALBUM_ID=" + albumID;
	}
}

function OpenImage(albumID,imageID){
	var sURL = "http://vacationfactory.com/fla/common/image_popup.aspx?album_Id=" + albumID + "&image_id=" + imageID;
	OpenWin(sURL, 405, 505);
}

function OpenAlbum(albumID){
	var sURL = "http://vacationfactory.com/fla/common/image_popup.aspx?album_Id=" + albumID;
	OpenWin(sURL, 345, 420);
}

function OpenCalendar(sDate,sField){
	var iTop= tempY - 100; 
	var iLeft=tempX + 20;
	var sURL = "";
	
	if (sDate.length > 0 ) {
		var oDate = getDateFromString(sDate);
		day = oDate.getDate();
		month=(oDate.getMonth()+1);
		year=oDate.getYear();
		sURL = '/fla/common/popup_calendar.aspx?FIELD='+sField+'&D='+day+'&M='+month+'&Y='+year;
	}
	else
	{
		sURL = '/fla/common/popup_calendar.aspx?FIELD='+sField
	}
	window.open(sURL,"winPopup",'height=169,width=163,top='+iTop+',left='+iLeft+',menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function OpenCalendar1(sDate,sField){
	var iTop= tempY - 100; 
	var iLeft=tempX + 20;
	var sURL = "";
	
	if (sDate.length > 0 ) {
		var oDate = getDateFromString(sDate);
		day = oDate.getDate();
		month=(oDate.getMonth()+1);
		year=oDate.getYear();
		sURL = '/fla/common/popup_calendar1.aspx?FIELD='+sField+'&D='+day+'&M='+month+'&Y='+year;
	}
	else
	{
		sURL = '/fla/common/popup_calendar1.aspx?FIELD='+sField
	}
	window.open(sURL,"winPopup",'height=169,width=163,top='+iTop+',left='+iLeft+',menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no, location=no');
}


function OpenCCID(){
	var sURL = "http://vacationfactory.com/fla/reservation_ccid.aspx";
	OpenWin(sURL,150, 300);
}

function OpenWebPage(sUrl){
	window.open(sUrl,"winPopup",'height='+screen.height-5+',width='+screen.width -5+',location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes');
}

function OpenWin(sUrl, iHeight, iWidth){
	window.open(sUrl,"winPopup",'height='+iHeight+',width='+iWidth+',scrollbars=no');
}

function openRoomInformation(roomID) {
	var iWinHeight = 200;
	var iWinWidth = 450;
	var iTop= tempY - 100; 
	var iLeft=tempX + 20;
	var sUrl = "http://vacationfactory.com/fla/roomInformation.aspx?ROOM_ID="+roomID;
	
	window.open(sUrl,"winPopup",'height='+iWinHeight+',width='+iWinWidth+',top='+iTop+',left='+iLeft+',menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}

function openStarRating() {
	var iWinHeight = 170;
	var iWinWidth = 300;
	var iTop= tempY - 100; 
	var iLeft=tempX + 20;
	var sUrl = "/fla/hotelRating.aspx"
	
	window.open(sUrl,"winPopup",'height='+iWinHeight+',width='+iWinWidth+',top='+iTop+',left='+iLeft+',menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}

function setRateCalender(ofield,sDate) {
	oForm = document.forms[0];
	
	if (ofield == "start") {
		oForm.txtStartDate.value = sDate;
	}
	if (ofield == "end") {
		oForm.txtEndDate.value = sDate;
	}
	if (ofield == "checkIn") {
		oForm.txtCheckInDate.value = sDate;
		oForm.txtCheckOutDate.value=nextDay(sDate);
	}
	if (ofield == "checkOut") {
		oForm.txtCheckOutDate.value = sDate;
	}
	if (ofield == "resStart") {
		oForm.StartDate.value = sDate;
	}
	if (ofield == "resEnd") {
		oForm.EndDate.value = sDate;
	}
	if (ofield == "resCheckIn") {
		oForm.CheckInDate.value = sDate;
	}
	if (ofield == "resCheckOut") {
		oForm.CheckOutDate.value = sDate;
	}
}

function setRateCalender1(ofield,sDate) {
	oForm = document.forms[0];
	
	if (ofield == "start") {
		oForm.txtStartDate.value = sDate;
	}
	if (ofield == "end") {
		oForm.txtEndDate.value = sDate;
	}
	if (ofield == "checkIn") {
		oForm.txtCheckInDate.value = sDate;
		oForm.txtCheckOutDate.value=nextDay1(sDate);
	}
	if (ofield == "checkOut") {
		oForm.txtCheckOutDate.value = sDate;
	}
	if (ofield == "resStart") {
		oForm.StartDate.value = sDate;
	}
	if (ofield == "resEnd") {
		oForm.EndDate.value = sDate;
	}
	if (ofield == "resCheckIn") {
		oForm.CheckInDate.value = sDate;
	}
	if (ofield == "resCheckOut") {
		oForm.CheckOutDate.value = sDate;
	}
}

function setRateDay(dayType) {
	oForm = document.forms[0];
	
	if (dayType == "all") {
		oForm.chkDOW[0].checked = true;
		oForm.chkDOW[1].checked = true;
		oForm.chkDOW[2].checked = true;
		oForm.chkDOW[3].checked = true;
		oForm.chkDOW[4].checked = true;
		oForm.chkDOW[5].checked = true;
		oForm.chkDOW[6].checked = true;	
	}
	if (dayType == "weekdays") {
		oForm.chkDOW[0].checked = true;
		oForm.chkDOW[1].checked = true;
		oForm.chkDOW[2].checked = true;
		oForm.chkDOW[3].checked = true;
		oForm.chkDOW[4].checked = true;
		oForm.chkDOW[5].checked = false;
		oForm.chkDOW[6].checked = false;
	}
	if (dayType == "weekends") {
		oForm.chkDOW[0].checked = false;
		oForm.chkDOW[1].checked = false;
		oForm.chkDOW[2].checked = false;
		oForm.chkDOW[3].checked = false;
		oForm.chkDOW[4].checked = false;
		oForm.chkDOW[5].checked = true;
		oForm.chkDOW[6].checked = true;
	}
}

function ValidateResDates(oCHECK_IN,oCHECK_OUT) {
				
	var bOK = true;
	if(oCHECK_IN.value.length == 0)	{
		bOK = false;
		alert('Please Select a arrival date');
		return false;
	}
	else {
		if (isValidDate(oCHECK_IN)==false) {
			bOK = false;
			alert('Please Enter a valid arrival date');
			return false;
		}
	}
	
	if(oCHECK_OUT.value.length == 0)	{
		bOK = false;
		alert('Please select a check out date');
		return false;
	}
	else {
		if (isValidDate(oCHECK_OUT)==false) {
			return false;
		}
	}
	
	var TODAY = new Date()
	var CHECK_IN = new Date(oCHECK_OUT.value)
	var CHECK_OUT = new Date(oCHECK_IN.value)
		
	if (CHECK_IN <= CHECK_OUT) {
		alert('The check in date must be before the check out date');
		return false;
	}
	
	if (CHECK_IN <= TODAY) {
		alert('The check in date must be after today');
		return false;
	}
	
	
	if (bOK) {
		return true;
	}
}
	
function ValidateDates(oSTART_DATE,oEND_DATE) {
				
		var bOK = true;
		if(oSTART_DATE.value.length == 0)	{
			bOK = false;
			alert('Please Select a start date');
			return false;
		}
		else {
			if (isValidDate(oSTART_DATE)==false) {
				bOK = false;
				alert('Please Enter a valid start date');
				return false;
			}
		}
		
		if(oEND_DATE.value.length == 0)	{
			bOK = false;
			alert('Please select a ending date');
			return false;
		}
		else {
			if (isValidDate(oEND_DATE)==false) {
				return false;
			}
		}
		
		var START_DATE = new Date(oSTART_DATE.value)
		var END_DATE = new Date(oEND_DATE.value)
			
		if (END_DATE <= START_DATE) {
			alert('The start date must be before the end date');
			return false;
		}
				
		if (bOK) {
			return true;
		}
	}
	
function isValidDate(datField) {
	var dateStr;
	dateStr = datField.value
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		//alert("Date is not in a valid format.")
		datField.value = '';
		return false;
	}
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		//alert("Month must be between 1 and 12.");
		datField.value = '';
		return false;
	}
	if (day < 1 || day > 31) {
		//alert("Day must be between 1 and 31.");
		datField.value = '';
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		//alert("Month "+ month +" doesn't have 31 days!")
		datField.value = '';
		return false
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			//alert("February " + year + " doesn't have " + day + " days!");
			datField.value = '';
			return false;
		}
	}
	return true;  // date is valid
}

function nextDay(oDateString) {
	var oDate = addDays(getDateFromString(oDateString),1)
	return (oDate.getMonth()+1)+ "/" + oDate.getDate()+ "/" + oDate.getYear();
}

function nextDay1(oDateString) {
	var oDate = addDays(getDateFromString(oDateString),2)
	return (oDate.getMonth()+1)+ "/" + oDate.getDate()+ "/" + oDate.getYear();
}

function addDays(oDate,iDays){
		day = oDate.getDate();
		month=oDate.getMonth();
		year=oDate.getYear();
		
		for(var i=0;i<iDays;i++){
			day++;
		}

		oDate.setDate(day);
		return oDate;
		//return  (oDate.getMonth()+1) + "/" + oDate.getDate()+ "/" + oDate.getYear();
}

function getDateFromString(dateString) {
	if(dateString.length > 0){
		
		idx=dateString.indexOf("/");
		month=dateString.substring(0,idx);
		dateString=dateString.substring(idx+1,dateString.length);
	
		
		idx=dateString.indexOf("/");
		day=dateString.substring(0,idx);
		dateString=dateString.substring(idx+1,dateString.length);
		
		if (dateString.length == 4){
			year = dateString.substring(2,4);
			
		}
		else {
			year = dateString.substring(0,2);
		}
		
		if (year<80) {
			year = parseInt(year) + 2000;
		}
		else {
			year = parseInt(year) + 1900;
		}	
		
		myDate = new Date(year,month-1,day);
		return myDate;
		
	}
	else {
		return '';
	}
}

function GetDateWithFullYear(dateString) {
	if(isValidDateNoAlert(dateString)){
		var newDate = getDateFromString(dateString);
		return (newDate.getMonth()+1) + "/" + newDate.getDate()	+ "/" + newDate.getYear();
	}
	else {
		return '';
	}
}

function isValidDateNoAlert(dateStr) {

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		return false;
	}
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		return false;
	}
	if (day < 1 || day > 31) {
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		return false
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			return false;
		}
	}
	return true;  // date is valid
}

//-->