//start new script code

YAHOO.namespace("example.calendar");
var htlDoaCal;
var htlDodCal;
var calArray = new Array(); // store calendar objects for use to show calendar.
		
function initCal()
{
		 htlDoaCal = new WCT.calendar("htlDoaCal","cal1Container","calendarBoxArrive","chk_in","DOA");		 
		 htlDodCal = new WCT.calendar("htlDodCal","cal2Container","calendarBoxDepart","chk_out","DOD");
 		 htlDoaCal.addLinkedCal(htlDodCal);
		 htlDodCal.addLinkedCal(htlDoaCal);	
		 htlDoaCal.position("relative");
		 htlDodCal.position("relative");
		
 		 calArray.push(htlDoaCal);
		 calArray.push(htlDodCal);
}




// Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
function isBrowserSupp() {
    // Get the version of the browser
    version =  parseFloat( navigator.appVersion );

    if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
        return false;
    }
    else {
    return true;
    }

return true;
}

function isLeapYear(yrStr)
{
var leapYear=false;
var year = parseInt(yrStr, 10);
// every fourth year is a leap year
if (year%4 == 0)
    {
    leapYear=true;
    // unless it's a multiple of 100
    if (year%100 == 0)
        {
        leapYear=false;
        // unless it's a multiple of 400
        if (year%400 == 0)
            {
            leapYear=true;
            }
        }
    }
return leapYear;
}


function getDaysInMonth(mthIdx, YrStr)
{
// all the rest have 31
var maxDays=31
// expect Feb. (of course)
if (mthIdx==1)
    {
    if (isLeapYear(YrStr))
        {
        maxDays=29;
        }
    else
        {
        maxDays=28;
        }
    }
// thirty days hath...
if (mthIdx==3 || mthIdx==5 || mthIdx==8 || mthIdx==10)
    {
    maxDays=30;
    }
return maxDays;
}


function getYear(mthIdx){
	var today = new Date()
	var theYear = parseInt(today.getYear(),10)
	
	if (mthIdx < today.getMonth()) {
		theYear = (parseInt(today.getYear(), 10) + 1)
	}
	if(theYear<100){
		theYear = "19" + theYear
	}
	else{
		if((theYear-100) < 10){
			theYear = "0" + (theYear-100)
		}
		else{
			theYear = (theYear-100)+""
		}
		theYear = "20" + theYear
	}
	return theYear;
}

//the function which does some magic to the date fields
// return non-zero if it is the last day of the month
function adjustDate(mthIdx, Dt)
{
var value=0;

var today = new Date()
var theYear = parseInt(today.getYear(),10)

if (mthIdx < today.getMonth()) {
    theYear = (parseInt(today.getYear(), 10) + 1)
}
if(theYear<100){
    theYear = "19" + theYear
}
else{
    if((theYear-100) < 10){
        theYear = "0" + (theYear-100)
    }
    else{
        theYear = (theYear-100)+""
    }
    theYear = "20" + theYear
}


var numDays=getDaysInMonth(mthIdx, theYear);

if (mthIdx==1)
    {
    if (Dt.options.selectedIndex + 1 < numDays)
        {
        return 0;
        }
    else
        {
        Dt.options.selectedIndex=numDays - 1;
        //check for leap year
        if (numDays==29)
            {
            return 99;
            }
        else
            {
            return 1;
            }
        }
    }
if (Dt.options.selectedIndex + 1 < numDays)
    {
    value=0;
    }
else
    {
    if (Dt.options.selectedIndex + 1 > numDays)
        {
        Dt.options.selectedIndex--;
        value=3;
        }
    else
        {
        //index is 31 or 30
        value=2;
        }
    }
return value;
}

function changeOptionDate(inM,inD)
{
	// Dynamically add/remove dates according to the selected month
	var o_days = new Array(31, ((getYear(inM.options.selectedIndex) % 4 == 0 && getYear(inM.options.selectedIndex) % 100 != 0) || getYear(inM.options.selectedIndex) % 400 == 0 ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // Set the days for each month

	if (inD.options.length >o_days[inM.options.selectedIndex])
	{
		for (var i = 31; i >= o_days[inM.options.selectedIndex]; i--)
		{
			inD.options[i] = null;
		}
	}
	if (inD.options.length <o_days[inM.options.selectedIndex])
	{
		for (var i = inD.options.length+1; i <=o_days[inM.options.selectedIndex]; i++)
		{
			inD.options[i-1] = new Option(i,i);
		}
	}
	
}
						  

//changes departure month when arrival month is changed
function amadChange(inM,inD,outM,outD)
{

if (!isBrowserSupp())
    {
    return;
    }

changeOptionDate(inM,inD);
var res = adjustDate(inM.options.selectedIndex, inD);
if (res != 0)
    {
           outD.options.selectedIndex=0;

           if (outM.options.selectedIndex==11){
            outM.options.selectedIndex=0
           }
           else{
            outM.options.selectedIndex=inM.options.selectedIndex + 1;
           }
    }
else
    {
    outM.options.selectedIndex = inM.options.selectedIndex;
    outD.options.selectedIndex = inD.options.selectedIndex+1;
    }
return;
}

function dmddChange(outM,outD)
{
if (!isBrowserSupp())
    {
    return;
    }

adjustDate(outM.options.selectedIndex,outD);
return;
}

function varNewWindow(url, width, height) {
	var w = 800, h = 600; // Assume

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	if (width == null) {
		width = 450;
	}

	if (height == null) {
		height = 350;
	}

	var leftPos = (w-width)/2, topPos = (h-height)/2;

	var win = window.open('', '', "resizable=1,toolbar=0,status=0,scrollbars=1,width=" + width + ",height=" + height + ",top=" + topPos + ",left=" + leftPos);
	win.focus();
	win.document.write('<HTML><BODY bgcolor="#FFFFFF"><TABLE border=0 width="100%" height="100%"><TR><TD width="100%" height="100%" align=center valign=middle><font FACE="Verdana, Arial, MS Sans Serif, Helvetica, Geneva" size="-1"><B>Just a moment...</B><BR>&nbsp;</FONT></TD></TR></TABLE></BODY></HTML>');

	win.location.href = url;

}

function newWindow(url)
{
urlWindow = window.open(url, 'AirportCodes', 'width=450,height=350');
urlWindow.focus;
}

function setRadioBtn (theForm,radioObjName,valOfBtnToSet) {
for (var i = 0; i < theForm[radioObjName].length; i++) {
if (theForm[radioObjName][i].value == valOfBtnToSet)
theForm[radioObjName][i].checked=true;
}
}

function reload_page()
{
	var newWin = window.location;
	var url = newWin.search;
	var queryString = url.substring(url.indexOf('?')+1);
	var params = queryString.split('&');
	var newURL;

	//populate the array with keys & values
	for (var i=0; i<params.length; i++) {
		var key = params[i].substring(0,params[i].indexOf('='));
		var value = params[i].substring(params[i].indexOf('=')+1);
		if ((key == 'clear_cache' && (value == 'Y' || value == 'N' || value == ''))) {
			var myBoolean = 1;
			}
		}
	
	if (myBoolean != 1){ 
		newURL = newWin.href + "&clear_cache=Y";
	} else {
		newURL = newWin.href;
	}
	newWin.replace(newURL);
}

//new power search javascript code

var currentPaneStyle = 0;
var currentTab = 0;

function tabstrip()
{
   this.tabs = new Array();
   this.add = addTab;
   this.write = writeTabstrip;
}

function tab(caption,content,tabNumber)
{
  this.setId = setId;
  this.caption = caption;
  this.content = content;
  this.write = writeTab;
  this.writeContent = writePane;
}

function addTab(tab)
{
  tab.setId("tab" + this.tabs.length);
  this.tabs[this.tabs.length] = tab;
}

function setId(id)
{
  this.id = id;
}


function writePane()
{
  document.write("<div class='pane tableWidth' style='block' id='pn_" + this.id + "'>");
  document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0'>");
  document.write("<tr class='mainTable'>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_leftM.gif' width='8'><img src='http://images.wctravel.com/images-general/null.gif' width='8' height='6' border='0'></td>");
  document.write("<td width='100%'><img src='http://images.wctravel.com/images/space.gif' width='1' height='6' border='0'></td>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_in.gif'  width='5'><img src='http://images.wctravel.com/images-general/null.gif' width='5' height='6' border='0'></td>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_out.gif' class='unselected' width='2'><img src='http://images.wctravel.com/images-general/null.gif' width='2' height='6' border='0'></td>");
  document.write("</tr><tr class='mainTable'>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_leftM.gif' width='8'><img src='http://images.wctravel.com/images-general/null.gif' width='8' height='1' border='0'></td>");
  document.write("<td width='100%' class='innerTableLine'>");
  document.write("<table width='100%' border='0' cellspacing='1' cellpadding='1'>");
  document.write("<tr class='innerTableBg'>");
  document.write("<td class='innerTable'>");
  document.write("<table width='100%' border='0' cellspacing='0' cellpadding='3'>");
  document.write("<tr>");
  // HERE IS WHERE THE BOX WITH ALL THE FORMS ARE GENERATED //
  document.write("<td width='100%'>" + this.content + "</td>");
    // HERE IS WHERE THE BOX WITH ALL THE FORMS ARE GENERATED //
  document.write("<td><img src='http://images.wctravel.com/images/space.gif' width='8' height='1' border='0'></td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("</td>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_in.gif' width='5'><img src='http://images.wctravel.com/images-general/null.gif' width='5' height='1' border='0'></td>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_out.gif' class='unselected' width='2'><img src='http://images.wctravel.com/images-general/null.gif' width='2' height='1' border='0'></td>");
  document.write("</tr>");
  document.write("<tr class='mainTable'>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_bt_left.gif' width='8'><img src='http://images.wctravel.com/images-general/null.gif' width='8' height='1' border='0'></td>");
  document.write("<td width='100%'><img src='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_in.gif' width='1' height='1' border='0'></td>");
  document.write("<td width='5'><img src='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_in.gif' width='5' height='1' border='0'></td>");
  document.write("<td background='http://images.wctravel.com/images-general/powersearch/tbl_main_rightM_out.gif' class='unselected' width='2'><img src='http://images.wctravel.com/images-general/null.gif' width='2' height='1' border='0'></td>");
  document.write("</tr>");
  document.write("<tr class='mainTable'>");
  document.write("<td width='8'><img src='http://images.wctravel.com/images-general/powersearch/tbl_main_bt_left.gif' width='8' height='6' border='0'></td>");
  document.write("<td width='100%' background='http://images.wctravel.com/images-general/powersearch/tbl_main_btM.gif'><img src='http://images.wctravel.com/images-general/null.gif' height='6' border='0'></td>");
  document.write("<td width='5'><img src='http://images.wctravel.com/images-general/powersearch/tbl_main_bt_right_in.gif' width='5' height='6' border='0'></td>");
  document.write("<td width='2'><img src='http://images.wctravel.com/images-general/powersearch/tbl_main_bt_right_out.gif' width='2' height='6' border='0'></td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("</div>");

}

function writeTab()
{
	document.write("<td style='padding: 1px 1px 0px 1px;'>");
	document.write("<div class='unselectedTab tabSize' id='" + this.id + "' onclick='showPane(this)'>");
	document.write("<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr>");
	document.write("<td class='leftTop'><img src='http://images.wctravel.com/images-general/powersearch/null.gif'></td>");
	document.write("<td class='tab'><img src='http://images.wctravel.com/images-general/powersearch/null.gif'></td>");
	document.write("<td class='rightTop'><img src='http://images.wctravel.com/images-general/powersearch/null.gif'></td></tr>");
	document.write("<tr><td rowspan='2' class='leftTabBorder'></td></tr>");
	document.write("<tr>");
	document.write("<td align='center' class='tabs'>" + this.caption + "</td>");
	document.write("<td class='rightTabBorder'><img src='http://images.wctravel.com/images-general/powersearch/null.gif'></td>");
	document.write("</tr></table>");
	document.write("</div>");
	document.write("</td>");
// document.write("<td class='tabs' align='center'><div class='tabs' id='" + this.id + "' onclick='showPane(this)'>" + this.caption + "</div></td>");
}

  // HERE IS WHERE THE TABS GET CALLED //
function writeTabstrip()
{
  document.write("<table border='0' cellspacing='0' cellpadding='0'><tr>");
  for(var i = 0; i < this.tabs.length; i++)
  {
    this.tabs[i].write();
  }
  document.write("</tr></table>");
  
  for(var k = 0; k < this.tabs.length; k++)
  {
    this.tabs[k].writeContent();
  }
  initiate();
}

function ShowHide(obj, visibility) {
	if(document.getElementById){
		divs = document.getElementsByTagName("div");
    		divs[obj].style.visibility = visibility;
	}
}



function currencyWindow(curr)
	{
	currWindow = window.open(curr, 'CurrConverter', 'width=500,height=400');
	currWindow.focus;
	}


function writeSessionCookie (cookieName, cookieValue) {
  if (testSessionCookie()) {
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
    return true;
  }
  else return false;
}

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}

function testSessionCookie () {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
    return true 
  else
    return false;
}

function hotelCheckBox(chkbox)
{
	if (chkbox.checked == true){
		if (!getCookieValue("HID")) {
			// no cookie present.  Set new cookie
			writeSessionCookie("HID",chkbox.value);
		}
		else{
			//append current value to cookie
			var cookieVal = getCookieValue("HID");
			if (window.RegExp) {
				var htlregstr = cookieVal;
				var reg1 = new RegExp(htlregstr);
				if (!reg1.test(chkbox.value)){
					cookieVal = cookieVal + "|"+chkbox.value;
					writeSessionCookie("HID",cookieVal);
				}
			}
		}
	}
	else{
	// remove hotel value from cookie
			var reg1str = getCookieValue("HID");
			if (reg1str){
				var newString = reg1str.replace(chkbox.value,'');
				if (window.RegExp) {
					newString = newString.replace(/(\|$)|(^\|)/g,'');
					newString = newString.replace(/(\|\|)/g,'|');
				}
				writeSessionCookie("HID",newString);			 
			}
	}
}	

function resizeIframe(frameid){
	var currentfr = document.all? document.all[frameid] : document.getElementById(frameid);
	
	if (currentfr){
		currentfr.style.display="block";
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
	}
}





/*    AJAX libraries

HTMLHttpRequest v1.0 beta2
(c) 2001-2005 Angus Turnbull, TwinHelix Designs http://www.twinhelix.com

Licensed under the CC-GNU LGPL, version 2.1 or later:
http://creativecommons.org/licenses/LGPL/2.1/
This is distributed WITHOUT ANY WARRANTY;
 without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

*/

var aeOL=[];
function addEvent(o,n,f,l)
{
	var a='addEventListener',h='on'+n,b='',s='';
	if(o[a]&&!l)return o[a](n,f,false);
		o._c|=0;
	if(o[h])
	{
		b='_f'+o._c++;
		o[b]=o[h]
	}
	s='_f'+o._c++;
	o[s]=f;
	o[h]=function(e){e=e||window.event;
		var r=true;
		if(b)r=o[b](e)!=false&&r;
			r=o[s](e)!=false&&r;
		return r};
		aeOL[aeOL.length]={o:o,h:h}
};

addEvent(window,'unload',function()
{
	for(var i=0;i<aeOL.length;i++)with(aeOL[i])
	{
		o[h]=null;
		for(var c=0;o['_f'+c];c++)o['_f'+c]=null
	}
});

function cancelEvent(e,c)
{
	e.returnValue=false;
	if(e.preventDefault)
		e.preventDefault();
	if(c)
	{
		e.cancelBubble=true;
		if(e.stopPropagation)
			e.stopPropagation()
	}
};

function HTMLHttpRequest(myName,callback){with(this)
{
	this.myName=myName;
	this.callback=callback;
	this.xmlhttp=null;
	this.iframe=null;
	window._ifr_buf_count|=0;
	this.iframeID='iframebuffer'+window._ifr_buf_count++;
	this.loadingURI='';
	if(window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
			if(xmlhttp.overrideMimeType)
				xmlhttp.overrideMimeType('text/xml')
		}
	if(!xmlhttp)
	{
		if(document.createElement&&document.documentElement&&(window.opera||navigator.userAgent.indexOf('MSIE 5.0')==-1))
		{
			var ifr=document.createElement('iframe');
			ifr.setAttribute('id',iframeID);
			ifr.setAttribute('name',iframeID);
			ifr.style.visibility='hidden';
			ifr.style.position='absolute';
			ifr.style.width=ifr.style.height=ifr.borderWidth='0px';
			iframe=document.getElementsByTagName('body')[0].appendChild(ifr);

		}
		else if(document.body&&document.body.insertAdjacentHTML)
		{
			document.body.insertAdjacentHTML('beforeEnd','<iframe name="'+iframeID+'" id="'+iframeID+'" style="display:none"></iframe>')
		}
		if(window.frames&&window.frames[iframeID])
			iframe=window.frames[iframeID];
		iframe.name=iframeID
	}
	return this
}};

HTMLHttpRequest.prototype.parseForm=function(form){with(this)
{
	var str='',gE='getElementsByTagName',inputs=[(form[gE]?form[gE]('input'):form.all?form.all.tags('input'):[]),(form[gE]?form[gE]('select'):form.all?form.all.tags('select'):[]),(form[gE]?form[gE]('textarea'):form.all?form.all.tags('textarea'):[])];
	for(var i=0;i<inputs.length;i++)
		for(j=0;j<inputs[i].length;j++)
			if(inputs[i][j])
			{
				var plus='++'.substring(0,1);
				str+=escape(inputs[i][j].getAttribute('name')).replace(plus,'%2B')+'='+escape(inputs[i][j].value).replace(plus,'%2B')+'&'
			}
	return str.substring(0,str.length-1)
}};

HTMLHttpRequest.prototype.xmlhttpSend=function(uri,formStr){with(this)
{
	xmlhttp.open(formStr?'POST':'GET',uri,true);
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			var doc=xmlhttp.responseText;
			if(callback)callback(doc,loadingURI);
			loadingURI=''
		}
	};
	if(formStr&&xmlhttp.setRequestHeader)
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(formStr);
	loadingURI=uri;
	return true
}};

HTMLHttpRequest.prototype.iframeSend=function(uri,formRef){with(this)
{
	if(!document.readyState)
		return false;
	if(document.getElementById)
		var o=document.getElementById(iframeID).offsetWidth;
	if(formRef)
		formRef.setAttribute('target',iframeID);
	else
	{
		var ifrDoc=iframe.contentDocument||iframe.document;
		if(!window.opera&&ifrDoc.location&&ifrDoc.location.href!=location.href)
			ifrDoc.location.replace(uri);
		else 
			iframe.src=uri
	}
	loadingURI=uri;
	setTimeout(myName+'.iframeCheck()',(window.opera?250:100));
	return true
}};

HTMLHttpRequest.prototype.iframeCheck=function(){with(this)
{
	doc=iframe.contentDocument||iframe.document;
	var il=iframe.location,dr=doc.readyState;
	if(dr=='complete')
	{
		if(callback)
			callback((doc.documentElement||doc),loadingURI);
		loadingURI=''
	}
	else 
		setTimeout(myName+'.iframeCheck()',50)
}};

HTMLHttpRequest.prototype.load=function(uri){with(this)
{
	if(!uri||(!xmlhttp&&!iframe))
		return false;
	if(xmlhttp)
		return xmlhttpSend(uri,'');
	else if(iframe)
		return iframeSend(uri,null);
	else 
		return false
}};

HTMLHttpRequest.prototype.submit=function(formRef,evt){with(this)
{
	evt=evt||window.event;
	if(!formRef||(!xmlhttp&&!iframe))
		return false;
	var method=formRef.getAttribute('method'),uri=formRef.getAttribute('action');
	if(method&&method.toLowerCase()=='post')
	{
		if(xmlhttp)
		{
			cancelEvent(evt);
			return xmlhttpSend(uri,parseForm(formRef))
		}
		else if(iframe)
			return iframeSend(uri,formRef);
		else return false
	}
	else
	{
		return load(uri+(uri.indexOf('?')==-1?'?':'&')+parseForm(formRef));
		cancelEvent(evt)
	}
}};

function RemoteFileLoader(myName)
{
	this.myName=myName;
	this.threads=[];
	this.loadingIDs={};
	this.onload=null
};

RemoteFileLoader.prototype.getThread=function(destId){with(this)
{
	var thr=-1;
	for(var id in loadingIDs)
	{
		if(id==destId)
		{
			thr=loadingIDs[id];
			break
		}
	}
	if(thr==-1)
		for(var t=0;t<threads.length;t++)
		{
			if(!threads[t].loadingURI)
			{
				thr=t;
				break
			}
		}
		if(thr==-1)
		{
			thr=threads.length;
			threads[thr]=new HTMLHttpRequest(myName+'.threads['+thr+']',null);
			loadingIDs[destId]=thr
		}
		threads[thr].callback=new Function('doc','uri','with('+myName+'){copyContent(doc,"'+destId+'");if(onload)onload(doc,uri,"'+destId+'")}');
		return threads[thr]
}};

RemoteFileLoader.prototype.loadInto=function(uri,destId)
{
	return this.getThread(destId).load(uri)
};

RemoteFileLoader.prototype.submitInto=function(formRef,destId,event)
{
	return this.getThread(destId).submit(formRef,event)
};
	
RemoteFileLoader.prototype.copyContent=function(domDoc,destId)
{
	var src=domDoc.getElementsByTagName?domDoc.getElementsByTagName('body')[0]:(domDoc.body?domDoc.body:null);
	var dest=document.getElementById?document.getElementById(destId):(document.all?document.all[destId]:null);
	if (!src && domDoc.length > 0)
	{
		src= domDoc;
	}
	
	if(!src||!dest)
		return;	
	if(src.innerHTML)
		dest.innerHTML=src.innerHTML;
	else if (domDoc.length > 0)
	{
		dest.innerHTML= domDoc;
	}
	else if(document.importNode)
	{
		while(dest.firstChild)dest.removeChild(dest.firstChild);
		for(var i=0;i<src.childNodes.length;i++)
			dest.appendChild(document.importNode(src.childNodes.item(i),true))
	}
};












