// build selects for book now form
function buildSelectNum (selectName, startNum, optionNum) {
	document.write('<select name="'+selectName+'">');
	
	for (i=startNum; i<=optionNum; i++) {
		document.write('<option value="'+i+'">'+i+'</option>');
	} // end for
	
	document.write('</select>');
} // end function

function buildSelectMth (selectName, startNum, optionNum) {
	var month=new Array(12);
	month[1]="January";
	month[2]="February";
	month[3]="March";
	month[4]="April";
	month[5]="May";
	month[6]="June";
	month[7]="July";
	month[8]="August";
	month[9]="September";
	month[10]="October";
	month[11]="November";
	month[12]="December";
	
	document.write('<select name="'+selectName+'">');
	
	for (i=startNum; i<=optionNum; i++) {
		document.write('<option value="'+i+'">'+month[i]+'</option>');
	} // end for
	
	document.write('</select>');
} // end function

function buildSelectYear (selectName, startNum, optionNum) {
	var today = new Date();
	
	document.write('<select name="'+selectName+'">');
	
	for (i=startNum; i<=optionNum; i++) {
		document.write('<option value="'+(today.getFullYear()+i)+'">'+(today.getFullYear()+i)+'</option>');
	} // end for
	
	document.write('</select>');
} // end function


// reflow page for correct cross-browser footer positioning

function reflow() {
    var bodydiv = document.getElementById("body");
    if (bodydiv != null) {
        bodydiv.style.minHeight = "100%";
    }
}



// workaround for absence of target attributes in xhtml strict

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}



function validateMailingList() {
	var aMsg = new Array();
	var aMandatory = new Array('Name','Email');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == aMandatory[i]) {
			bMissing = true;
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fEmail = document.getElementById('Email');
	var sEmail = fEmail.value;
	if (sEmail != 'Email' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (regex.test(email))
		return true;
	else
		return false;
}



// eMail Obfuscator Script 1.31 by Tim Williams - freeware

function obfuscate(type) {

var obfuscated = '';

if (type == 'link')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,
99,111,110,116,97,99,116,64,110,97,116,117,114,101,108,97,110,100,115,99,97,112,101,115,46,99,111,109,
34,62,
99,111,110,116,97,99,116,64,110,97,116,117,114,101,108,97,110,100,115,99,97,112,101,115,46,99,111,109,
60,47,97,62);

if (type == 'fm_recipient')

obfuscated = String.fromCharCode(60,105,110,112,117,116,32,116,121,112,101,61,34,104,105,100,100,101,110,34,32,110,97,109,101,61,34,114,101,99,105,112,105,101,110,116,34,32,118,97,108,117,101,61,34,
99,111,110,116,97,99,116,64,112,114,111,116,101,117,115,106,118,46,114,117,
34,32,47,62);

if (type == 'address_m')

obfuscated = String.fromCharCode(109,97,105,108,116,111,58,
99,111,110,116,97,99,116,64,116,117,114,110,115,116,111,110,101,115,105,110,103,97,112,111,114,101,46,99,111,109);

if (type == 'address')

obfuscated = String.fromCharCode(99,111,110,116,97,99,116,64,110,97,116,117,114,101,108,97,110,100,115,99,97,112,101,115,46,99,111,109);

if (type == 'micat')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,98,111,111,107,105,110,103,115,64,109,105,99,97,116,46,99,111,109,46,97,117,34,62,98,111,111,107,105,110,103,115,64,109,105,99,97,116,46,99,111,109,46,97,117,60,47,97,62);

if (type == 'beachhouse')

obfuscated = String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,104,111,108,105,100,97,121,64,98,101,97,99,104,104,111,117,115,101,97,117,115,116,114,97,108,105,97,46,99,111,109,34,62,104,111,108,105,100,97,121,64,98,101,97,99,104,104,111,117,115,101,97,117,115,116,114,97,108,105,97,46,99,111,109,60,47,97,62);

document.write(obfuscated);

}



function display_weather() {

//document.write('<embed pluginspage="http://www.adobe.com/go/getflashplayer" src="http://www.yourminis.com/Dir/GetContainer.api?uri=yourminis/freewebs/mini:weather" wmode="transparent" width="250" height="80" FlashVars="cr=10&view=minimal&title=Weather%20%28ASXX0016%29&mininame=weather&textcolor=0&color=6773760&alpha=100&dayview=regular&loc=Brisbane%2C%20Australia&unit=m&xheight=80&xwidth=250&zipcode=ASXX0016&externalURL=http%3A%2F%2Fct%2Eyourminis%2Ecom%2FDir%2FGetMiniSwfPub%2Eapi%3Furi%3Dyourminis%2Fyourminis%2Fmini%3Aweather%26%5F%5Fversion%3D1180472057&maxheight=370&maxwid=420&uri=yourminis%2Ffreewebs%2Fmini%3Aweather&swfurl=%2Fwidget%5Fweatherchannel%2Eswf&width=240&height=70&" type="application/x-shockwave-flash" allowScriptAccess="always"></embed>')
//document.write('<embed pluginspage="http://www.adobe.com/go/getflashplayer" src="http://www.yourminis.com/Dir/GetContainer.api?uri=yourminis/freewebs/mini:weather" wmode="transparent" width="250" height="80" FlashVars="cr=10&view=minimal&title=Weather%20%28ASXX0016%29&mininame=weather&textcolor=0&color=6773760&alpha=100&dayview=5day&loc=Brisbane%2C%20Australia&unit=m&xheight=80&xwidth=250&zipcode=ASXX0016&externalURL=http%3A%2F%2Fct%2Eyourminis%2Ecom%2FDir%2FGetMiniSwfPub%2Eapi%3Furi%3Dyourminis%2Fyourminis%2Fmini%3Aweather%26%5F%5Fversion%3D1180472057&maxheight=370&maxwid=420&uri=yourminis%2Ffreewebs%2Fmini%3Aweather&swfurl=%2Fwidget%5Fweatherchannel%2Eswf&width=240&height=70&" type="application/x-shockwave-flash" allowScriptAccess="always"></embed>')
//document.write('<div style="line-height: 10px;background:none;"><div style="max-width: 160px; width: 160px; background:none;"><object style="margin:0;padding:0;" type="application/x-shockwave-flash" data="http://static.hotelscombined.com.s3.amazonaws.com/swf/weather_widget.swf" 	id="w4aaa9c4e6c122b4c4af9ecec7aeeb33a" height="272" width="160">	<param value="http://static.hotelscombined.com.s3.amazonaws.com/swf/weather_widget.swf" name="movie"/>	<param value="transparent" name="wmode">	<param value="station_id=002975&city_name=Queensland (Georgia)&language=en&use_celsius=Yes&skinName=LightGreen&PID=62823&ts=201010190344&hideChangeSkin=No" name="flashvars">	<param value="all" name="allowNetworking">	<param value="always" name="allowScriptAccess"></object><a alt="Hotels Combined" title="Hotels Combined" style="margin:0; padding:0; text-decoration: none; background: none;" target="_blank" href="http://widgets.hotelscombined.com/City/Weather/Queensland_Georgia.htm?use_celsius=Yes"><div style="background: none; color: white; text-align: center; width: 160px; height: 17px; margin: 0px 0 0 0; padding: 5px 0 0 0; cursor:pointer; background: transparent url(http://static.hotelscombined.com.s3.amazonaws.com/Pages/WeatherWidget/Images/weather_light_green_bottom.png) no-repeat; font-size: 12px; font-family: Arial,sans-serif; line-height: 12px; font-weight: bold;">See 10-Day Forecast</div></a><div style="text-align: center; width: 160px;"><a alt="Hotels Combined" title="Hotels Combined" style="background:none;font-family:Arial,sans-serif; font-size: 9px; color: #777777;" rel="nofollow" href="http://www.hotelscombined.com"></a></div></div></div>');
document.write('<div style="line-height: 10px;background:none;"><div style="max-width: 160px; width: 160px; background:none;"><object style="margin:0;padding:0;" type="application/x-shockwave-flash" data="http://static.hotelscombined.com.s3.amazonaws.com/swf/weather_widget.swf"             id="w4aaa9c4e6c122b4c4af9ecec7aeeb33a" height="272" width="160">    <param value="http://static.hotelscombined.com.s3.amazonaws.com/swf/weather_widget.swf" name="movie"/>       <param value="transparent" name="wmode">      <param value="station_id=YBAF&city_name=Brisbane&language=en&use_celsius=Yes&skinName=LightBlue&PID=74518&ts=201012010341&hideChangeSkin=No" name="flashvars">    <param value="all" name="allowNetworking">      <param value="always" name="allowScriptAccess"></object><a alt="Hotels Combined" title="Hotels Combined" style="margin:0; padding:0; text-decoration: none; background: none;" target="_blank" href="http://widgets.hotelscombined.com/City/Weather/Brisbane.htm?use_celsius=Yes"><div style="background: none; color: white; text-align: center; width: 160px; height: 17px; margin: 0px 0 0 0; padding: 5px 0 0 0; cursor:pointer; background: transparent url(http://static.hotelscombined.com.s3.amazonaws.com/Pages/WeatherWidget/Images/weather_light_blue_bottom.png) no-repeat; font-size: 12px; font-family: Arial,sans-serif; line-height: 12px; font-weight: bold;">See 10-Day Forecast</div></a><div style="text-align: center; width: 160px;"><a alt="Hotels Combined" title="Hotels Combined" style="background:none;font-family:Arial,sans-serif; font-size: 9px; color: #777777;" rel="nofollow" href="http://www.hotelscombined.com">&copy; HotelsCombined.com</a></div></div></div>');
}



// run all necessary functions on page load

function loadAll() {
   reflow();
   externalLinks();
}
window.onload = loadAll;

