var VT = VT || {};
//Including properties.php
//Including Dom.js

VT.Dom = {};

VT.Dom.isArray = function (o) {
	return Object.prototype.toString.call(o) === '[object Array]';
}

VT.Dom.getZIndex = function(element){
	return VT.Dom.getComputedStyle(element, 'zIndex');
};

VT.Dom.getComputedStyle = function(element, style){ // deprecate when YUI is used
	var value;
	if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
		var computed = document.defaultView.getComputedStyle(element, '');
		if (computed) { // test computed before touching for safari
			value = computed[style];
		}
		return element.style[style] || value;
	} else if (document.documentElement.currentStyle/* && isIE*/) { // IE method
		value = element.currentStyle ? element.currentStyle[style] : null;
		return (element.style[style] || value);
	} else { // default to inline only
		return element.style[style];
	}
};


/**
 * String name - type of HTML tag to hide
 * Element[]/Element dontHideEls - Elements and children of elements contained will NOT be hidden
 */ 
VT.Dom.hideElementsByTag = function(name, dontHideEls){
	function contained (parentEls, checkForChildEl) {
		if( !VT.Dom.isArray(parentEls) ) {
			parentEls = [parentEls];
		}
		
		for(var el=checkForChildEl; el; el=el.parentNode) {
			for(var i=0; i<parentEls.length; i++) {
				if( el==parentEls[i] ) {
					return true;
				}
			}
		}
		return false;
	}
	
	
	var elements = document.getElementsByTagName(name);
	for (var i = 0; i < elements.length; i++) {
		if(
			!contained(dontHideEls, elements[i]) &&
			VT.Dom.getComputedStyle(elements[i], "visibility") != "hidden"
		) {
			elements[i].style.visibility = "hidden";
			elements[i].bleeder = true;
		}
	}
};

VT.Dom.showElementsByTag = function(name) {
	var elements = document.getElementsByTagName(name);
	for (var i = 0; i < elements.length; i++) {
		if (elements[i].bleeder) OT.dom.show(elements[i]);
	}
};



VT.Dom.showBleeders = function(dontHideElArr){
	VT.Dom.showElementsByTag("select");
	VT.Dom.showElementsByTag("embed");
	VT.Dom.showElementsByTag("object");
	VT.Dom.showElementsByTag("iframe");
};

/**
 * Element[]/Element dontHideEls - Elements and children of elements contained will NOT be hidden
 */ 
VT.Dom.hideBleeders = function(dontHideEls){
	VT.Dom.hideElementsByTag("select", dontHideEls);
	VT.Dom.hideElementsByTag("embed", dontHideEls);
	VT.Dom.hideElementsByTag("object", dontHideEls);
	VT.Dom.hideElementsByTag("iframe", dontHideEls);
};




VT.Dom.getDimensions = function(){ // deprecate this once YUI is used
	// returns { page: { width: #, height: #}, viewport: {width: #, height: #}}
	var dx, dy, wW, wH, pgH, pgW, w = window, db = document.body, de = document.documentElement;
	
	if (w.innerHeight && w.scrollMaxY) {
		dx = db.scrollWidth;
		dy = w.innerHeight + w.scrollMaxY;
	} else if (db.scrollHeight > db.offsetHeight) { // all but Explorer Mac
		dx = db.scrollWidth;
		dy = db.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		dx = db.offsetWidth;
		dy = db.offsetHeight;
	}
	
	if (self.innerHeight) { // all except Explorer
		wW = self.innerWidth;
		wH = self.innerHeight;
	} else if (de && de.clientHeight) { // Explorer 6 Strict Mode
		wW = de.clientWidth;
		wH = de.clientHeight;
	} else if (db) { // other Explorers
		wW = de.clientWidth;
		wH = db.clientHeight;
	}
	
	// for small pages with total height / width less then height/width of the viewport
	pgH = dy < wH ? wH : dy;
	pgW = dx < wW ? wW : dx;
	
	return {
		page: {
			width: pgW,
			height: pgH
		},
		viewport: {
			width: wW,
			height: wH
		}
	};
};





//Including Events.js

(function () {
	//create onDomReady Event
	window.onDomReady = DomReady;
	
	//Setup the event
	function DomReady(fn)
	{
		//W3C
		if(document.addEventListener)
		{
			document.addEventListener("DOMContentLoaded", fn, false);
		}
		//IE
		else
		{
			document.onreadystatechange = function(){readyState(fn)}
		}
	}
	
	//IE execute function
	var fired = false;
	function readyState(fn)
	{
		//dom is ready for interaction
		if(!fired && document.readyState == "interactive" || document.readyState == "complete")
		{
			fired = true;
			fn();
		}
	}
})();


//Including BrowserDetection.js
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

window.ie7 = BrowserDetect.browser==="Explorer" && BrowserDetect.version>=7 && BrowserDetect.version<8 ;
window.safari = BrowserDetect.browser==="Safari";

//Including Effects.js



VT.Effects = {};

VT.Effects.GreyOut = function(/*element || zindex*/ z) {
	var o = this;
	var overlay;
	var clickListeners = [];
	var zindex = (typeof z=="number") ? z : VT.Dom.getZIndex(z)-1;
	var aboveGreyOutEl = (typeof z=="object") ? z : null;
	
	function fireClickListeners(){
		for(var i=0; clickListeners.length; i++) {
			clickListeners[i]();
		}
	}
	
	
	this.remove = function() {
		// Remove document listeners
		//window.onresize = ;
		overlay.onclick = null;
		
		// Remove element 
		overlay.parentNode.removeChild(overlay);
		
		// Show bleeders again
		VT.Dom.showBleeders(); 
	}
	
	this.addClickListener = function (callBack) {
		clickListeners[clickListeners.length] = callBack;
	}
	
	this.fitToWindow = function() {
		var dim = VT.Dom.getDimensions();
		overlay.style.width = (dim.viewport.width > dim.page.width ? dim.viewport.width : dim.page.width) + "px";
		overlay.style.height = (dim.viewport.height > dim.page.height ? dim.viewport.height : dim.page.height) + "px";
	}

	
	function performGreyOut() {
		// Hide bleeder elements while greyout
		VT.Dom.hideBleeders(aboveGreyOutEl);
		
		// Build Greyout Layer
		overlay = document.body.appendChild( document.createElement("div") );
		overlay.className = "greyOut";
		overlay.style.zIndex = zindex;
		overlay.onclick = fireClickListeners;
		
		// Fit grey out to window
		o.fitToWindow();
		
		var existingOnResize = window.onresize;
		window.onresize = existingOnResize ? function(){o.fitToWindow(); return existingOnResize();} : o.fitToWindow; 
	}
	performGreyOut();
	
	return this;
};

// Copyright (c)2004 OneTime.com, Inc. All rights reserved.

MONTHS=new Array('January','February','March','April','May','June','July','August','September','October','November','December');

function openPartnerWindow(url,x,y,l){return window.open(url,l,'screenX='+x+',screenY='+y+',left='+x+',top='+y+',width='+(screen.width>1000?800:(screen.width>800?640:520))+',height='+(screen.width>1000?600:(screen.width>800?460:400))+',toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');}
function getObject(n){if(document.all)return document.all[n];else if(document.getElementById)return document.getElementById(n);else return document[n];}
function showObject(o){if(o.style)o.style.visibility='visible';else o.visibility='show';}
function hideObject(o){if(o.style)o.style.visibility='hidden';else o.visibility='hide';}
function getX(o){if(document.layers)return o.left;return o.offsetLeft+(o.offsetParent?getX(o.offsetParent):0);}
function getY(o){if(document.layers)return o.top;return o.offsetTop+(o.offsetParent?getY(o.offsetParent):0);}
function getW(o){if(document.layers)return o.clip.width;return o.offsetWidth;}
function getH(o){if(document.layers)return o.clip.height;return o.offsetHeight;}
function isInside(o,x,y,dx1,dy1,dx2,dy2){var l=getX(o);var t=getY(o);return ((x-(dx1?dx1:0)>=l)&&(y-(dy1?dy1:0)>=t)&&(x-(dx2?dx2:0)<l+getW(o))&&(y-(dy2?dy2:0)<t+getH(o)));}
function moveObject(o,x,y){if(document.layers)o.moveToAbsolute(x,y);else if(o.style.left&&(!o.style.pixelLeft)){o.style.left=x+'px';o.style.top=y+'px';}else{o.style.pixelLeft=x;o.style.pixelTop=y;}}
function writeObject(o,c){if(document.layers){o.document.open('text/html');o.document.write(c);o.document.close();}else o.innerHTML=c;}
function trackMouseClick(f){if(document.layers)document.captureEvents(Event.MOUSEDOWN);document.onmousedown=f; }
function trackMouseClickByObjectName(varName){if(document.layers)document.captureEvents(Event.MOUSEDOWN);document.onmousedown=new Function(varName+'.close();'); }
function untrackMouseClick(){if(document.layers)document.releaseEvents(Event.MOUSEDOWN);document.onmousedown=null;}
function getEventX(e){return (document.all?event.clientX+document.body.scrollLeft:e.pageX);}
function getEventY(e){return (document.all?event.clientY+document.body.scrollTop:e.pageY);}
function updateGuests(o) {
    for (i=0;i<o.form.elements.length;i++) {
        var p=o.form.elements[i];
        if ((p!=o)&&((p.name=='HGuests')||(p.name.substr(0,8)=='HGuests.')))p.selectedIndex=o.selectedIndex;
    }
}

//function moveObject2(o,x,y) { if(document.layers) { o.left = x; o.top=y; } else if(document.getElementById || document.all) { o.style.left=x; o.style.top=y; }}
function placeAd(target,source) {
	var t = getObject(target);
	var s = getObject(source);
	moveObject(s,getX(t),getY(t));
	showObject(s);
 }
 
/* OneTime Flights functions */
function distributeRadioValue(e){var f=e.form;var n=e.name;var v=e.value;for(i=0;i<document.forms.length;i++){var q=document.forms[i];if((q!=f)&&q.elements[n]){var l=q.elements[n].length; if(!l){q.elements[n].value=v;}else{for(var i=0;i<l;i++){if(q.elements[n][i].value==v)q.elements[n][i].checked=true;}}}}}
function disableOptions(){document.f.outDate.disabled=true;document.f.outTime.disabled=true;}
function enableOptions(){document.f.outDate.disabled=false;document.f.outTime.disabled=false;}
function getAirportCode(target,search){var param="?target="+target;if(search != null){param=param.concat("&search=true");	}var url = "http://www.onetime.com/airpcode_usa.html"+param;var optionlist = "scrollbars=yes,width=480,height=400,resizable=yes";window.open(url, "aircodes", optionlist);}
function verify(f) {
 if (f.from.value && f.to.value) return true;
 alert('Please provide city names or airport codes\nfor your flight search.');
 return false;
}
function destroyFormValue(n){var v=''; for(i=0;i<document.forms.length;i++){var q=document.forms[i];if(q.elements[n])q.elements[n].value=v;}}
function destroyTidFid(){destroyFormValue('tid');destroyFormValue('fid');}

function btnChange(type)
{
  if(type==1)
  {
    document.getElementById("OTModF").style.display=""; 
    document.getElementById("OTModH").style.display="none";
    document.getElementById("OTF").className="current";
    document.getElementById("OTH").className="";
    
  }
  else
  {
    document.getElementById("OTModF").style.display="none"; 
    document.getElementById("OTModH").style.display="";
    document.getElementById("OTF").className="";
    document.getElementById("OTH").className="current";
  }
  
}
function otRadioCheck(name) {
    name.checked = false;
}
// Copyright (c)2004 OneTime.com, Inc. All rights reserved.

HCAL_LAYER='HCAL';HCAL_OPEN=null;HCAL_FIELD=null;HCAL_DATE=new Date();HCAL_STARTDATE=new Date();

function h_open(a){h_open_pos(a,getW(a),0);}
function h_open_pos(a,xpos,ypos){var o=getObject(HCAL_LAYER);var n=(HCAL_OPEN==null);if(HCAL_FIELD&&(a==HCAL_FIELD))return false;if(!n)hideObject(HCAL_OPEN);HCAL_OPEN=o;HCAL_FIELD=a;var d;if(a.name=='inDate'){d=new Date();d.setDate(d.getDate()+14);HCAL_STARTDATE=new Date();}else{d=new Date(HCAL_DATE.getFullYear(),HCAL_DATE.getMonth(),HCAL_DATE.getDate());d.setDate(d.getDate()+1);HCAL_STARTDATE=d;}h_renderMonth(d.getMonth()+1,d.getFullYear());moveObject(o,getX(a)+xpos,getY(a)+ypos);showObject(o);if(n)trackMouseClick(h_checkClose);}
function h_checkClose(e){if(HCAL_OPEN==null)return;var x=getEventX(e);var y=getEventY(e);if(!(isInside(HCAL_FIELD,x,y,0,0,4,0)||isInside(HCAL_OPEN,x,y)))h_close();}
function h_setDate(y,m,d){if(HCAL_OPEN==null)return;HCAL_FIELD.value=(m<10?'0':'')+m+'/'+(d<10?'0':'')+d+'/'+y;if(HCAL_FIELD.name=='inDate')HCAL_DATE=new Date(y,m-1,d);h_close();}
function h_close(){hideObject(HCAL_OPEN);if(HCAL_OPEN!=null)untrackMouseClick();HCAL_OPEN=null;HCAL_FIELD=null;}
function h_renderMonth(month,year){if(HCAL_OPEN==null)return;var t_y=HCAL_STARTDATE.getFullYear();var t_m=HCAL_STARTDATE.getMonth()+1;var t_d=HCAL_STARTDATE.getDate();var d=new Date(year,month-1,1);var max=(month==2?28+((year%4==0)&&((year%100!=0)||(year%400==0))?1:0):30+(month<8?1-((month-1)%2):(month-1)%2));var html='<table border=0 cellpadding=1 cellspacing=0 bgcolor="#305799"><tr><td><table border=0 cellpadding=3 cellspacing=1 width=150><tr bgcolor="#305799"><td align=center><a rel="nofollow" href="javascript:void(0)" onclick="h_renderMonth('+(month>1?month-1:12)+',' +(month>1?year:year-1)+');" style="color: white; font-weight: bold; text-decoration: none;">&laquo;</a></td><td colspan=5 align=center><font size=1 face="arial,helvetica" color=white><b>'+MONTHS[month-1].toUpperCase()+' '+year+'</b></font></td><td align=center><a href="javascript:void(0)" onclick="h_renderMonth('+(month<12?month+1:1)+','+(month<12?year:year+1)+');" style="color: white; font-weight: bold; text-decoration: none;">&raquo;</a></td></tr><tr bgcolor="#e1e1e1"><td align=center><font size=1 face="arial,helvetica">S</font></td><td align=center><font size=1 face="arial,helvetica">M</font></td><td align=center><font size=1 face="arial,helvetica">T</font></td><td align=center><font size=1 face="arial,helvetica">W</font></td><td align=center><font size=1 face="arial,helvetica">T</font></td><td align=center><font size=1 face="arial,helvetica">F</font></td><td align=center><font size=1 face="arial,helvetica">S</font></td></tr>';var offset=d.getDay()+1;var count=1, i, a;for (i=1;i<=max;i++){if(count==1)html+='<tr bgcolor=white>';if((i==1)&&(offset>1)){html+='<td colspan='+(offset-1)+' bgcolor="#e1e1e1"><font size=1>&nbsp;</font></td>';count=offset;}a=((year>t_y)||((year==t_y)&&((month>t_m)||((month==t_m)&&(i>=t_d)))));html+='<td align=center><font face="arial,helvetica" size=1'+(a?'><a href="javascript:void(0)" onclick="h_setDate('+year+','+month+','+i+')"><b>':' color=gray>')+i+(a?'</b></a>':'')+'</font></td>';if((i==max)&&(count<7)){html+='<td colspan='+(7-count)+' bgcolor="#e1e1e1"><font size=1>&nbsp;</font></td>';count=7;}count++;if(count>7){count=1;html+='</tr>';}}html+='</table></td></tr></table>';writeObject(HCAL_OPEN,html);}
function OTH_d(d,n){if(!d.value){alert('Please add a valid '+n+'.');return false;}var e1,e2;if((e1=d.value.match(/^(1[0-2]|0?[1-9])\/(3[01]|[12][0-9]|0?[1-9])\/((20)?[0-9]{2})$/))||(e2=d.value.match(/^(3[01]|[12][0-9]|0?[1-9])\.\s*(1[0-2]|0?[1-9])\.\s*((20)?[0-9]{2})$/))){var d,m,y;if(e1){d=Number(e1[2]);m=Number(e1[1]);y=Number(e1[3]);}else{d=Number(e2[1]);m=Number(e2[2]);y=Number(e2[3]);}y=(y<2000?y+2000:y);if(d>(m==2?28+((y%4==0)&&((y%100!=0)||(y%400==0))?1:0):30+(m<8?1-((m-1)%2):(m-1)%2))){alert('The '+n+' does not seem to be a valid date.');return false;}d.value=(m<10?'0':'')+m+'/'+(d<10?'0':'')+d+'/'+y;}else{alert('The '+n+' does not seem to be a valid date.\nPlease provide a date in either the format\n"mm/dd/yyyy" or "dd. mm. yyyy".');return false;}return true;}
function OTH_t(f){if(f.city&&(!f.city.value)){alert('Please provide a city name\nfor your hotel search.');return false;}if(!OTH_d(f.inDate,'Check-In Date'))return false;if(!OTH_d(f.outDate,'Check-Out Date'))return false;var d1=f.inDate.value.match(/^(1[0-2]|0[1-9])\/(3[01]|[12][0-9]|0[1-9])\/(20[0-9]{2})$/);var d2=f.outDate.value.match(/^(1[0-2]|0[1-9])\/(3[01]|[12][0-9]|0[1-9])\/(20[0-9]{2})$/);if((d2[3]<d1[3])||((d2[3]==d1[3])&&((d2[1]<d1[1])||((d2[1]==d1[1])&&(d2[2]<=d1[2]))))){alert('The Check-Out Date must be AFTER the Check-In Date.\nPlease correct and try again.');return false;}return true;}
// Copyright (c)2004 OneTime.com, Inc. All rights reserved.

FCAL_LAYER='FCAL';FCAL_OPEN=null;FCAL_FIELD=null;FCAL_DATE=new Date();FCAL_STARTDATE=new Date();

function f_open(a){f_open_pos(a,getW(a),0);}
function f_open_pos(a,xpos,ypos){
	var o=getObject(FCAL_LAYER);
	var n=(FCAL_OPEN==null);
	if(FCAL_FIELD&&(a==FCAL_FIELD))
		return false;
		
	if(!n)
		hideObject(FCAL_OPEN);
	
	FCAL_OPEN=o;
	FCAL_FIELD=a;
	var d;
	if(a.name=='departureDate'){
		d=new Date();
		d.setDate(d.getDate()+14);
		FCAL_STARTDATE=new Date();
	} else {
		d=new Date(FCAL_DATE.getFullYear(),FCAL_DATE.getMonth(),FCAL_DATE.getDate());
		d.setDate(d.getDate()+1);
		FCAL_STARTDATE=d;
	}
	
	f_renderMonth(d.getMonth()+1,d.getFullYear());
	moveObject(o,getX(a)+xpos,getY(a)+ypos);
	showObject(o);
	
	if(n)
		trackMouseClick(f_checkClose);
}
function f_checkClose(e){if(FCAL_OPEN==null)return;var x=getEventX(e);var y=getEventY(e);if(!(isInside(FCAL_FIELD,x,y,0,0,4,0)||isInside(FCAL_OPEN,x,y)))f_close();}
function f_setDate(y,m,d){if(FCAL_OPEN==null)return;FCAL_FIELD.value=(m<10?'0':'')+m+'/'+(d<10?'0':'')+d+'/'+y;if(FCAL_FIELD.name=='departureDate')FCAL_DATE=new Date(y,m-1,d-1);f_close();}
function f_close(){hideObject(FCAL_OPEN);if(FCAL_OPEN!=null)untrackMouseClick();FCAL_OPEN=null;FCAL_FIELD=null;}
function f_renderMonth(month,year){if(FCAL_OPEN==null)return;var t_y=FCAL_STARTDATE.getFullYear();var t_m=FCAL_STARTDATE.getMonth()+1;var t_d=FCAL_STARTDATE.getDate();var d=new Date(year,month-1,1);var max=(month==2?28+((year%4==0)&&((year%100!=0)||(year%400==0))?1:0):30+(month<8?1-((month-1)%2):(month-1)%2));var html='<table border=0 cellpadding=1 cellspacing=0 bgcolor="#305799"><tr><td><table border=0 cellpadding=3 cellspacing=1 width=150><tr bgcolor="#305799"><td align=center><a rel="nofollow" href="javascript:void(0)" onclick="f_renderMonth('+(month>1?month-1:12)+','+(month>1?year:year-1)+')" style="color: white; font-weight: bold; text-decoration: none;">&laquo;</a></td><td colspan=5 align=center><font size=1 face="arial,helvetica" color=white><b>'+MONTHS[month-1].toUpperCase()+' '+year+'</b></font></td><td align=center><a rel="nofollow" href="javascript:void(0)" onclick="f_renderMonth('+(month<12?month+1:1)+','+(month<12?year:year+1)+')" style="color: white; font-weight: bold; text-decoration: none;">&raquo;</a></td></tr><tr bgcolor="#e1e1e1"><td align=center><font size=1 face="arial,helvetica">S</font></td><td align=center><font size=1 face="arial,helvetica">M</font></td><td align=center><font size=1 face="arial,helvetica">T</font></td><td align=center><font size=1 face="arial,helvetica">W</font></td><td align=center><font size=1 face="arial,helvetica">T</font></td><td align=center><font size=1 face="arial,helvetica">F</font></td><td align=center><font size=1 face="arial,helvetica">S</font></td></tr>';var offset=d.getDay()+1;var count=1, i, a;for (i=1;i<=max;i++){if(count==1)html+='<tr bgcolor=white>';if((i==1)&&(offset>1)){html+='<td colspan='+(offset-1)+' bgcolor="#e1e1e1"><font size=1>&nbsp;</font></td>';count=offset;}a=((year>t_y)||((year==t_y)&&((month>t_m)||((month==t_m)&&(i>=t_d)))));html+='<td align=center><font face="arial,helvetica" size=1'+(a?'><a rel="nofollow" href="javascript:void(0)" onclick="f_setDate('+year+','+month+','+i+')"><b>':' color=gray>')+i+(a?'</b></a>':'')+'</font></td>';if((i==max)&&(count<7)){html+='<td colspan='+(7-count)+' bgcolor="#e1e1e1"><font size=1>&nbsp;</font></td>';count=7;}count++;if(count>7){count=1;html+='</tr>';}}html+='</table></td></tr></table>';writeObject(FCAL_OPEN,html);}
function OTF_d(d,n){if(!d.value){alert('Please add a valid '+n+'.');return false;}var e1,e2;if((e1=d.value.match(/^(1[0-2]|0?[1-9])\/(3[01]|[12][0-9]|0?[1-9])\/((20)?[0-9]{2})$/))||(e2=d.value.match(/^(3[01]|[12][0-9]|0?[1-9])\.\s*(1[0-2]|0?[1-9])\.\s*((20)?[0-9]{2})$/))){var d,m,y;if(e1){d=Number(e1[2]);m=Number(e1[1]);y=Number(e1[3]);}else {d=Number(e2[1]);m=Number(e2[2]);y=Number(e2[3]);}y=(y<2000?y+2000:y);if(d>(m==2?28+((y%4==0)&&((y%100!=0)||(y%400==0))?1:0):30+(m<8?1-((m-1)%2):(m-1)%2))){alert('The '+n+' does not seem to be a valid date.');return false;}d.value=(m<10?'0':'')+m+'/'+(d<10?'0':'')+d+'/'+y;}else{alert('The '+n+' does not seem to be a valid date.\nPlease provide a date in either the format\n"mm/dd/yyyy" or "dd. mm. yyyy".');return false;}return true;}
function OTF_t(f){if((f.from&&(!f.from.value))||(f.to&&(!f.to.value))){alert('Please provide city names or airport codes\nfor your flight search.');return false;}if(!OTF_d(f.departureDate,'Departure Date'))return false;if(!OTF_d(f.returnDate,'Return Date'))return false;var d1=f.departureDate.value.match(/^(1[0-2]|0[1-9])\/(3[01]|[12][0-9]|0[1-9])\/(20[0-9]{2})$/);var d2=f.returnDate.value.match(/^(1[0-2]|0[1-9])\/(3[01]|[12][0-9]|0[1-9])\/(20[0-9]{2})$/);if((d2[3]<d1[3])||((d2[3]==d1[3])&&((d2[1]<d1[1])||((d2[1]==d1[1])&&(d2[2]<d1[2]))))){alert('The Return Date must be ON OR AFTER the Departure Date.\nPlease correct and try again.');return false;}return true;}
// Copyright (c)2002-2003 VirtualTourist.com, Inc. All rights reserved.

var VT_DYNA_PATH = "http://members.virtualtourist.com/";

function _win(l,n,u,w,h,p,c,m) {
  try {
    var w=window.open(u,n,'resizable=1,scrollbars=1'+(w?',width='+w:'')+(h?',height='+h:'')+(p?','+p:''));
    w.focus();
    return w;
  } catch(e) {
    var t='';
    //    for(var n in e)t+=n+' -> '+e[n]+'\n';
    alert((m?m:'The '+(l?l:'popup window')+' has been blocked by a popup blocker.\nTo use all the features of this site, please allow popups.')+'\n\nThanks,\nyour VT Team.'+(c?'\n\n[code:'+c+']':'')+(t!=''?'\n\n'+t:''));
  }
  return null;
}

// start

var cookie_map=null;
function getCookie(name){
  if(!document.cookie)return null;
  if(!cookie_map){
    cookie_map=new Object();
    var cs=document.cookie.split(/; ?/);
    for(var i=0;i<cs.length;i++){
      var c=cs[i].indexOf('=');
      cookie_map[cs[i].substr(0,c)]=unescape(cs[i].substr(c+1));
    }
  }
  return cookie_map[name];
}
function setCookie(name, value, daysTillExpiration, domain){
  var e=(daysTillExpiration?new Date(new Date().getTime()+(3600000*24*daysTillExpiration)):null);
  document.cookie=name+'='+value+((e)?'; expires='+e.toGMTString():'')+'; path=/'+((domain)?'; domain='+domain:'');
  if(cookie_map)cookie_map[name]=value;
}
function checkConsole(){
  
  try{
    var now=new Date();
    var vt=null;
    var id=null;
    try{
      vt=(getCookie('VT')||'').split('|');
      id=vt[0].split('.')[0];
    }catch(e){}
    if(id){
      var val=vt[0];
      for(var i=1;(i<vt.length)||(i<=6);i++)val+='|'+(i==6?now.getTime():vt[i]);
      setCookie('VT',val,(Number(vt[7])?300:0),'.virtualtourist.com');
      if(now-(Number(vt[6])||0)>1800000){
        var c=getCookie('VTC_'+id);
        var p=(c?Number(c.split('|')[0]):1<<7);
        if(((1<<7)&p)>0)showConsole(false);
      }
      window.setTimeout('checkConsole();',600000);
    }
  }catch(e){
    var es='';
    for(var n in e)es+=n+'='+e[n]+'\n';
    alert('CHECK: there was an error,please mail feedback@virtualtourist.com with this message.\n\n'+es);
  }
}

function showConsole(m){
  var w = _win('VT Notice Console','VTConsole',VT_DYNA_PATH+'m/cn/',350,450,null,'console',
    (m?null:'VT Notice Console was blocked by a popup blocker.\n\nIf you want your console to open automatically when you login, please disable your pop up blocker.\n\nIf you want to open the Notice Console manually, click the "notices console" link at the top of this page. You do NOT need to disable pop ups to use the Notices Console.\n\nTo control your Notices Console, simply adjust Preferences found in your console.'));
   if(w==null) { 
    	setTimeout("consoleBlinkOn()",100);
    }
}

function showConsoleClick(m) {
	 var w = _win('VT Notice Console','VTConsole',VT_DYNA_PATH+'m/cn/',350,450,null,'console',
    (m?null:'VT Notice Console was blocked by a popup blocker.\n\nIf you want your console to open automatically when you login, please disable your pop up blocker.\n\nIf you want to open the Notice Console manually, click the "notices console" link at the top of this page. You do NOT need to disable pop ups to use the Notices Console.\n\nTo control your Notices Console, simply adjust Preferences found in your console.'));
   if(w==null) {
		var nc = getObject("nconsole");
		if(nc==null) return;
   	nc.href = VT_DYNA_PATH+"m/cn/";
   	nc.target = "_blank";	
    }
}

function consoleBlinkOn() { 
	if(blinktimes++>10) { blinktimes=0; return; }
	var el = getObject("nconsole");
	if(el==null) return;
	el.className = "blinkOn";
	setTimeout("consoleBlinkOff()",100);
}
function consoleBlinkOff() { 
	var el = getObject("nconsole");
	if(el==null) return;
	el.className = "blinkOff";
	setTimeout("consoleBlinkOn()",200);
}

//end

function pc(pid) {
  _win('Post Card','PCARD_WIN',VT_DYNA_PATH+'vt/ps/'+pid+'/0/',640,600,null,'pc');
}

var picwindow = null;
function wopic(path,w,h) {
	var maxw = (screen.width>=800 ? screen.width : 800)-40;
	var maxh = (screen.height>=600 ? screen.height : 600)-80;
	var xpos = 0;
	var ypos = 0;
	if(w+150>maxw) { w = maxw; xpos=1; }
	else if(w<=350) { w = 500; xpos = Math.round((maxw-w)/2); }
	else { w = w + 150; xpos = Math.round((maxw-w)/2); }
	if (h+250 > maxh) { h = maxh; ypos=1; }
	else { h = h + 250; ypos = Math.round((maxh-h)/2); }
	try { 
		if(picwindow!=null && !picwindow.closed) {
			picwindow.location = VT_DYNA_PATH+path;
			picwindow.resizeTo(w,h);
		} else {
		  picwindow=_win('picture window','PIC_WIN',VT_DYNA_PATH+path,w,h,null,'wopic-'+path);
		}
		picwindow.moveTo(xpos,ypos);
		picwindow.focus();
	} catch(e) { }
}

function pic(pid,w,h) {
	wopic('m/p/m/'+pid+'/',w,h);
}

function cnpic(pid,w,h) {
	wopic('m/p/c/'+pid+'/',w,h);
}

function mpic(mpid,w,h) {
	wopic('m/p/p/'+mpid+'/',w,h);
}

function wo(url) {
  _win('text window','COPY_WIN',url,550,500,null,'wo-'+url);
}

function mapwin(url) {
  _win('map window','EXP_CITY',VT_DYNA_PATH+'l/'+url,800,530,'toolbar=1,status=1','mapwin-'+url);
}

function vtmapwin(url) {
  _win('map window','EXP_CITY',url,800,700,'toolbar=1,status=1','mapwin-'+url);
}

function comment(mid,lid) {
  _win('comments window','COMMENT_WIN',VT_DYNA_PATH+'m/cm/'+mid+'/'+lid+'/',500,400,'dependent=1','cmt-'+mid+'-'+lid);
}

function comment(mid,lid,url) {
  _win('comments window','COMMENT_WIN',VT_DYNA_PATH+'m/cm/'+mid+'/'+lid+'/?'+url,500,400,'dependent=1','cmt-'+mid+'-'+lid);
}

function tellfriend(lid,cid,tgid) {
  _win('message window','TF_WIN',VT_DYNA_PATH+'vt/tf/1/'+lid+'/'+cid+'/'+tgid+'/',530,540,'status=1','tf-'+lid+'-'+cid+'-'+tgid);
}

function addtocustomtravelguide(tid,lid) {
  _win('Custom Travel Guide window','ADD_WIN',VT_DYNA_PATH+'/ptg/pa/0/1/'+tid+'/'+lid+'/?-vt-9',500,400,null,'ctg-'+tid+'-'+lid);
}

function vote(tip,vote,mode,source) {
  _win('vote','VOTE_WIN',VT_DYNA_PATH+'m/tv/'+tip+'/'+mode+'/'+vote+'/'+source+'/',240,200,'dependent=1','vote-'+tip+'-'+mode);
}

function deleteTip(tipid) {
	if(true==confirm("Delete this tip?")) {
		_win('delete tip window','DELETE_WIN',VT_DYNA_PATH+'vt/y/3/'+tipid+'/0/',550,500,null,'delete-'+tipid);
	}
}

function removePicFromRotation(picid) {
	if(true==confirm("Remove this picture from rotation?")) {
			_win('remove  from rotation window','REMOVE_WIN',VT_DYNA_PATH+'vt/y/9/'+picid+'/0/',550,500,null,'remove-'+picid);
	}
}

var _t='tim', _w='www', _h='http://', _o='on', _e='e', _c='com', _dot='.';
function othotellink(sid,hid,lid,kwid) { 
 var url = _h+_w+_dot+_o+_e+_t+_e+_dot+_c+'/hotels?'+ (hid? 'nhid='+hid+'&' : '') + (lid? 'location='+lid+'&' : '') +'sid='+sid+(kwid?'&kwid='+kwid:'');
 window.status = url;
 _win('ot hotel window','OT_HOTEL_WIN',url,800,600,'toolbar=1,status=1,menubar=1,directories=1,location=1',''); }
function otflightlink(sid,to,lid,kwid) {
var url = _h+_w+_dot+_o+_e+_t+_e+_dot+_c+'/flights?'+ (to? 'to='+to+'&' : '') + (lid? 'tid='+lid+'&' : '') +'sid='+sid+(kwid?'&kwid='+kwid:'');
window.status = url;
_win('ot flight window','OT_FLIGHT_WIN',url,800,600,'toolbar=1,status=1,menubar=1,directories=1,location=1','');} 

function checkEmail(e, tracking){ 
	if (e.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){ 
		if (tracking != null && tracking != '')
			urchinTracker(tracking);
		return true;
	} 
	alert('Please provide a valid email address'); return false;
}
var blinktimes = 0;

function opSrvA(){
  num = Math.random()
  try{
  srvA = getCookie('srvA');
  	if(srvA == null || srvA =='' ) {
  		if( num >= .9 ) {
  		
  		  swin = window.open('http://members.virtualtourist.com/vt/sy/9/','SYWIN','width=550,height=525,dependent=yes,scrollbars=yes').focus();
 
  		}
  		
  		setCookie('srvA','op',30,'virtualtourist.com');
 
  	}		
  } catch(e){}
}

//opSrvA();

var cm8pr_plugin = null; // to fix firefox and mozzilla problem with point roll ads

function toggleLayer(event, names, display) {
	var e = event || window.event;
	if (e && e.stopPropagation)
		e.stopPropagation();
	else 
		e.cancelBubble = true;
	var element;
	for (var i=0; i<names.length; i++) {
		element = document.getElementById(names[i]);
		element.style.display = display;
	}
}
var overlay;
var originalX;
var originalY;
function showBuildLayer(event, memberId) {
	var callOutBox = document.getElementById('callOutBox');
	var callOutLayer = document.getElementById('callOutLayer');
	var buildResearchLayer = document.getElementById('buildResearchLayer');
	
	/*if (buildResearchLayer.isOpen == false || buildResearchLayer.isOpen == 'false') {
		overlay = OT.Effect.addScreenOverlay(buildResearchLayer,"buildResearchOverlay");
	}*/
	callOutBox.style.cursor = 'default';

	if (buildResearchLayer.isOpen == true || buildResearchLayer.isOpen == 'true') {
		return;
	}
	if (typeof buildResearchLayer.isOpen == 'undefined'){
		//overlay = OT.Effect.addScreenOverlay(buildResearchLayer,"buildResearchOverlay");
		originalX = OT.Dom.getX(callOutBox);
		originalY = OT.Dom.getY(callOutBox);
		//alert('original X: ' + originalX + ' Y: ' + originalY);
	}
	//alert('callout X: ' + OT.Dom.getX(callOutBox) + ' Y: ' + OT.Dom.getY(callOutBox));
	overlay = OT.Effect.addScreenOverlay(buildResearchLayer,"buildResearchOverlay");
	overlay.id='overlayLayer';
	overlay.style.zIndex=800;
	buildResearchLayer.style.zIndex=1000000;
	callOutBox.style.zIndex = 1000000;
	callOutLayer.style.zIndex = 1000000;
	callOutLayer.style.position = 'absolute';
	callOutLayer.style.top = originalY + OT.Dom.getH(callOutBox) - 1 + 'px';
	/*if (memberId == 0)
		callOutLayer.style.left = originalX - 75 + 'px';
	else 
		callOutLayer.style.left = originalX + 'px';*/
	callOutLayer.style.left = originalX - 75 + 'px';
	callOutBox.style.position = 'absolute';
	callOutBox.style.top = originalY + 'px';
	callOutBox.style.left = originalX + 'px';
	//}
	toggleLayer(event, new Array('overlayLayer', 'closeLayer', 'callOutLayer'), 'block');
	callOutBox.style.borderBottom='none';
	OT.Effect.hideBleeders();
	buildResearchLayer.isOpen = true;
	
}

function hideBuildLayer(event) {
	var buildResearchLayer = document.getElementById('buildResearchLayer');
	var callOutBox = document.getElementById('callOutBox');
	buildResearchLayer.isOpen = false;
	overlay.style.visibility = 'hidden';
	toggleLayer(event, new Array('overlayLayer', 'closeLayer', 'callOutLayer'), 'none');
	callOutBox.style.borderBottom='1px solid #8faf01';
	callOutBox.style.cursor = 'hand';
	callOutBox.style.cursor = 'pointer';
	OT.Effect.showBleeders();
}

/*var friendsTabHtml;
var hometownTabHtml;

function selectTab(selectId, deselectId, divId){
	document.getElementById(selectId).className='select';
	document.getElementById(deselectId).className='deselect';
	//alert('selectId: ' + selectId + ' deselectId: ' + deselectId);
	//alert('innerhtml: ' + document.getElementById(divId).innerHTML);
	if (selectId == 'interestsTab') {
	//if (divId == 'friendsNetwork') {
		friendsTabHtml = document.getElementById(divId).innerHTML;
		someAjaxFunction(divId, selectId);
	}	
	else if (selectId == 'wantToTravelTab') {
	//else if (divId == 'hometownNetwork') {
		hometownTabHtml = document.getElementById(divId).innerHTML;
		someAjaxFunction(divId, selectId);
	}
	else if (deselectId == 'interestsTab') {
		someFunction(divId);
	}
	else if (deselectId == 'wantToTravelTab') {
		someFunction(divId);
	}
}

function someAjaxFunction(divId, tabId) {

	document.getElementById(divId).innerHTML = '';
}

function someFunction(divId) {
	if (divId == 'friendsNetwork') 
	 	document.getElementById(divId).innerHTML = friendsTabHtml;
	else if (divId == 'hometownNetwork') 
		document.getElementById(divId).innerHTML = hometownTabHtml;
}
*/

function selectTab(selectId, deselectId){
	document.getElementById(selectId).className='select';
	document.getElementById(deselectId).className='deselect';
}

function showTab(showDivId, hideDivId) {
	var showDiv = document.getElementById(showDivId);
	var hideDiv = document.getElementById(hideDivId);
	showDiv.style.display = 'block';
	hideDiv.style.display = 'none';
	if (showDiv.innerHTML == '') {
		var mId = document.getElementById('mid').value;
		var mName = document.getElementById('mname').value;
		var lIdElement = document.getElementById('lid');
		var lId = 0;
		if (lIdElement != null)
			lId = lIdElement.value;
		//alert('MID: ' + mId + ', MNAME: ' + mName + ', LID: ' + lId);
		if(showDivId == 'shareInterests') { 
			AjaxServlet.getSharedInterestsTabHtml(mId, mName, sharedInterestsCallback);
			//sharedInterestsCallback("Some text....");
		}
		else if (showDivId == 'wishlistTravel') {
			AjaxServlet.getWishlistTabHtml(mId, lId, mName, wishlistCallback);
			//wishlistCallback("Some text....");
		}
	}
}

function changeWishlistLocation(locId, mId, mName) {
	//alert("changeWishlistLocation()");
	AjaxServlet.getWishlistTabHtml(mId, locId, mName, wishlistCallback);
	//wishlistCallback("Some text....");
}

function sharedInterestsCallback(data) {
	//alert(data);
	if (data) {
		document.getElementById('shareInterests').innerHTML = data;
	}
}

function wishlistCallback(data) {
	//alert(data);
	if (data) {
		document.getElementById('wishlistTravel').innerHTML = data;
	}
}

function showHide(id)
{
	(document.getElementById(id).style.display == 'none') ? document.getElementById(id).style.display = 'block' : document.getElementById(id).style.display = 'none';
}

function showHideInline(id)
{
	(document.getElementById(id).style.display == 'none') ? document.getElementById(id).style.display = 'inline' : document.getElementById(id).style.display = 'none';
}

function toggleShowHideText(x)
{
	(x.innerHTML=="...more") ? x.innerHTML='...less' : x.innerHTML='...more';
}
function getLoggingUrl(loggingUrl) {
	window.location = "http://members.virtualtourist.com" + loggingUrl;
	return false;
}

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function floatDiv(id, sx, sy) {
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	if (el) {
		var px = document.layers ? "" : "px";
		window[id + "_obj"] = el;
		if (d.layers) 
			el.style = el;
		el.cx = el.sx = sx;
		el.cy = el.sy = sy;
		el.sP = function(x, y){
			this.style.left = x + px;
			this.style.top = y + px;
		};
		el.style.display = "block";
		el.floatIt = function(){
			var pX, pY;
			pX = (this.sx >= 0) ? 0 : ns ? innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
			pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
			if (this.sy < 0) 
				pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
			this.cx += (pX + this.sx - this.cx) / 8;
			this.cy += (pY + this.sy - this.cy) / 8;
			this.sP(this.cx, this.cy);
			setTimeout(this.id + "_obj.floatIt()", 40);
		}
	} else {
		el = {floatIt:function(){}};
	}
	return el;
}

function posTop() {
	var yS=0, de = document.documentElement, db = document.body;
	
	if (self.pageYOffset) {
		yS = self.pageYOffset;
	} else if (de && de.scrollTop) { // Explorer 6 Strict
		yS = de.scrollTop;
	} else if (db) {// all other Explorers
		yS = db.scrollTop;
	}
	
	return yS;
}
function moveObjTo(obj,x,y) {var objs = obj.style; objs.left = x; objs.top = y;}

function picPage(idInHex){
	window.location=VT_DYNA_PATH + 'm/p/m/' + idInHex + '/';
	return false;
}


function isString(object) {
	return getClass(object) === "String";
}
function getClass(object) {
	return Object.prototype.toString.call(object)
		.match(/^\[object\s(.*)\]$/)[1];
}
  	
		
function buildLocalIframe(innerHtml, containerEl, resizeToContent, iframeId, className){
	var containerEl = isString(containerEl) ? document.getElementById(containerEl) : containerEl;
	
	// Build iframe
	var fr = document.createElement("iframe");
	fr.setAttribute("scrolling", "no");
	fr.setAttribute("frameBorder","0");
	if(id) fr.id = iframeId;
	fr.className = className;

	// Add iframe to document				
	containerEl.appendChild(fr);
	
	// Write content in iframe
	var doc = fr.contentDocument;
	if (doc == undefined || doc == null)
		doc = fr.contentWindow.document;
	doc.open();
	doc.write(innerHtml);
	doc.close();
	
	// Resize iframe once the page has loaded to allow the iframe enough time to to load before
	// calculating it's content height.
	if (resizeToContent) {
		var existingOnload = window.onload ? window.onload : function(){};
		function setIFrameHeight(){
			height = Math.max(doc.body.scrollHeight, Math.max(doc.body.clientHeight, doc.documentElement.clientHeight));
			fr.height = height;
			fr.style.height = height + 'px';
			
			return existingOnload();
		}
		window.onload = setIFrameHeight;
	}
}
VT.AdDefer = {};

VT.AdDefer.movdeAds = function () {
	var args = arguments;
	
	var move = function () {

		var adEl, placeHolder;
		
		for(var i=0; i < args.length; i++) {
			try { // try protects ad-move errors from affecting other ad moves
				var num = args[i];
				
				adEl = document.getElementById("ad_" + num);
				placeHolder = document.getElementById("adPlaceHolder_" + num);
				if (adEl && placeHolder) { // PlaceHolder may not exist on the page
					placeHolder.appendChild(adEl);
					placeHolder.className = "bannerAds";
				}
			} catch(err){}
		}
	};
	
	move();
}

// 'moveAds' reference is deprecated.  Should be VT.AdDefer.movdeAds. 
// 'moveAds' calls need to be removed from VTStatic
var moveAds = VT.AdDefer.movdeAds;//Including DealsLayer.js
//Including properties.php

VT.DealsLayer = {
	
	open : function () {
		var dealsLayerEl = document.createElement('div'); 
		dealsLayerEl.id="dealsLayer";
		dealsLayerEl.innerHTML = 
'\
	<div class="innerBox">\
		<form name="dealslayerform" action="http://vtmail.virtualtourist.com/WebObjects/VTMail.woa/wa/newsletter" method="get">\
			<div style="margin: 0pt; font-size: 22px; color: rgb(51, 51, 51);">Free Travel Deals Newsletter</div>\
			<a onclick="urchinTracker(\'/nopg/deals/CloseDealsLayer\');document.getElementById(\'dealsLayer\').style.display=\'none\';" href="javascript:void(0);">\
				<img border="0" src="http://cache.virtualtourist.com/i/X-Close.gif" alt="close"/>\
			</a>\
			<table style="margin: 0px 0px 10px; font-size: 14px; color: rgb(51, 51, 51);">\
				<tbody>\
					<tr>\
						<td>\
							<p style="font-size: 13px;">Sure the economy stinks, but wouldn\'t a great deal on a vacation cheer you up?</p>\
							<p style="font-size: 13px;">That\'s why we teamed up with our friends at TripAdvisor to make sure you\'re able to take that next trip (and save money while you\'re at it)!</p>\
						</td>\
						<td style="padding-right: 10px;">\
							<img src="http://cache.virtualtourist.com/i/Newsletter.gif"/>\
						</td>\
					</tr>\
				</tbody>\
			</table>\
			<div style="margin-bottom: 0pt; color: rgb(51, 51, 51); font-size: 13px;">Sign up and you\'ll get great deals every week!</div>\
			<div style="margin-right: 42px; height: 34px;">\
				<input type="text" onfocus="this.value=\'\'" name="EmailField" value="Enter email" size="30" style="border: 1px solid rgb(153, 153, 153); float: left; font-size: 12px; margin-top: 2px;"/>\
				<input type="image" src="http://cache.virtualtourist.com/i/Submit.gif" onclick="return checkEmail(this.form.EmailField.value, \'/nopg/deals/SubmitDealsLayer\');" style="border: 0px none ; padding: 0px; vertical-align: top; float: right;"/>\
			</div>\
			<div style="margin: 15px 0px 10px; font-size: 11px; color: rgb(51, 51, 51); clear: both;">Happy Travels! We never spam.</div>\
			<img style="position: absolute; bottom: 24px; right: 20px;" src="http://cache.virtualtourist.com/d/vtLayerLogo.gif"/>\
		</form>\
	</div>\
';

		
		document.body.appendChild(dealsLayerEl);
		urchinTracker('/nopg/deals/DealsLayer');
	}
};



//Including HotelsLayer.js
//Including properties.php

VT.HotelsLayer = {
	
	open : function (info) {
		var hotelsLayerEl = document.createElement('div'); 
		hotelsLayerEl.id="hotelsLayer";
		
		var n = info.numHotels;
		var linkText = (n ? n+' ' : '') + info.locationName + ' Hotels';
		hotelsLayerEl.innerHTML = 
'\
	<div class="innerBox">\
		<h3>Visiting ' + info.locationName + '?</h3>\
		<p class="slogan">Get real reviews from VirtualTourist locals and travelers!</p>\
		<a class="close" onclick="urchinTracker(\'/nopg/hotels/CloseHotelsLayer\');document.getElementById(\'hotelsLayer\').style.display=\'none\';" href="javascript:void(0);">\
			<img border="0" src="http://cache.virtualtourist.com/i/X-Close.gif" alt="close"/>\
		</a>\
		<div class="body">\
			<img class="hotelEmblem" src="http://cache.virtualtourist.com/i/hotel.gif"/>\
			<div class="callToAction">\
				<p>Read reviews on</p>\
				<a onclick="urchinTracker(\'/nopg/hotels/LinkHotelsLayer\');" href="' + info.path + '">'+ linkText + '</a>\
				<a onclick="urchinTracker(\'/nopg/hotels/ButtonHotelsLayer\');" href="' + info.path + '" class="go">\
					<img border="0" src="http://cache.virtualtourist.com/i/go_button_orange.gif" alt="go"/>\
				</a>\
			</div>\
			<div class=\"spacer\"></div>\
		</div>\
		<div class="vtmark">\
			<img src="http://cache.virtualtourist.com/d/vtLayerLogo.gif"/>\
		</div>\
		<div class="spacer"></div>\
	</div>\
';

		
		document.body.appendChild(hotelsLayerEl);
		urchinTracker('/nopg/hotels/HotelsLayer');
	}
};





VT.PopUnder = {
	/*private*/ infoMap : null,
	/*private*/ fired : false,
	
	/*private*/ getPopUnderDimensions : function () {
		var viewDim = VT.Dom.getDimensions().viewport;

		// Set popUnder final size
		var	finalW = 790;
		var finalH = 650;
		
		// Set popunder size when opening window
		var initW = 1;
		var initH = 1;
		if (window.ie7) {initW = 250; initH = 100;}
		if (window.webkit) { initW = 85; initH = 100;}
		
		// Determine OFF SCREEN coords to open popunder window
		var nX = (window.screenLeft || window.screenX); // Distance left of browswer window from left of screen in pixels
		var nY = (window.screenTop || window.screenY); // Distance top of browswer window from top of screen in pixels
		if (typeof(nX) == "undefined") { // full screen
			nX = 0;
			nY = 0;
			var initX = nX + window.screen.availWidth - initW; // bottom-right corner of window
			var initY = nY + window.screen.availHeight - initH;
		}
		else{
			var initX = nX + viewDim.width - initW; // bottom-right corner of window
			var initY = nY + viewDim.height - initH;
		}
		
		if(window.ie7) {
			initY = initY - 95;
			initX = initX + 13;
		}
		else if(window.safari) {
			initY = initY - 16;
		}
		else{
			initX = 5000;
			initY = 5000;
		}
		
		// Determine final resting place of popunder
		var finalX = nX + (viewDim.width - finalW) / 2;
		var finalY = nY + (viewDim.height - finalH) / 2;

		
		return {
			initX  : initX, 
			initY  : initY, 
			finalX : finalX,
			finalY : finalY,
			
			initW  : initW, 
			initH  : initH, 
			finalW : finalW, 
			finalH : finalH, 
			
			nX      : nX, 
			nY      : nY
		};
	},
	
	open : function() {
		this.setPopUnderPerformedCookie();

		var url = this.getPopUnderUrl();
		try {
			if ( !this.fired && url ) {
				this.fired = true;  // Fire popunder ONLY ONCE
				
				// Initialize popUnder dimensions
				var dims = VT.PopUnder.getPopUnderDimensions();
				var openSmooth = this.checkForSmoothOpen();
				var prefix = openSmooth ? 'init' : 'final';
				var openDims = {x:'x',y:'y',w:'w',h:'h'};

				for (var dim in openDims) {
					openDims[ dim ] = dims[ prefix + dim.toUpperCase() ];
				}

				// Open popUnder. 
				// NOTE: we don't initialize the popunder with the target domain because once we 
				// do, we lose JS control of the window due to XSS security.  Once we've finished 
				// prepping the window we will THEN update the location to the target.
				var cpu_win = window.open(
					'http://'+document.domain+'/assets/blank.html', 
					"CommercePopunder", 
					"toolbar=1,location=1,directories=0,status=1,menubar=1,resizable=1,copyhistory=1,scrollbars=1"+
					",width="+openDims.w+
					",height="+openDims.h+
					",left="+openDims.x+
					",top="+openDims.y
				);

				// If popUnder opened successfully, prep popUnder window
				if (cpu_win) {
					try {
						cpu_win.blur();
						window.focus();
						cpu_win.opener = self;
									
						if(openSmooth) { // Reposition/resize popunder
							cpu_win.moveTo(dims.finalX, dims.finalY);
							cpu_win.resizeTo(dims.finalW, dims.finalH);
						}
					} catch(err) { }
					
					cpu_win.location.href=url;
					// this.setPopUnderPerformedCookie(); Moved to execute BEFORE popunder opens
				}
			} 
			
		}catch(err){}
		
		this.fired = true;
	},
	
	// A smooth open, means we will open popunders OFF SCREEN and THEN move them behind the browser  
	// window.  A non-smooth open simply opens the popunder behind the browser from the get-go. 
	/*private*/ checkForSmoothOpen : function() {
		// Browsers that don't support resize/move operations
		var isMacFF3 = BrowserDetect.OS==='Mac' && BrowserDetect.browser==="Firefox" && BrowserDetect.version >= 3;
		var isCamino = BrowserDetect.browser==="Camino";
		
		var openSmooth = ! (isMacFF3 || isCamino);
				
		return openSmooth;
	},
	
	/**
	 * Add popunder trigger to ALL anchor tags and forms on the page and for page unload.  When any of these 
	 * events are fired, a popunder will be opened behind the browser window.
	 * 
	 * @param {Map} infoMap - data sent by the server to set popunder functionality.  
	 */
	addTriggers : function (infoMap){
		this.infoMap = infoMap;

		// Add popunder open on unload
		var existingUnload = window.onbeforeunload || function(){};
		window.onbeforeunload =  
			function(){
				VT.PopUnder.open();
				return existingUnload(); 
			}; 
	
		
		// Add popunder open on onclick (anchors)	
		var anchors = document.getElementsByTagName('a');
		for (var i = 0; i < anchors.length; i++) {
			(function(){
				var existingOnclick = anchors[i].onclick || function(){};
				anchors[i].onclick = function(){
					VT.PopUnder.open();
					return existingOnclick.apply( anchors[i] );
				};
			})();
		}
		
		
		// Add popunder open on onclick	(form submit)
		var forms = document.getElementsByTagName('form');
		for (var i = 0; i < forms.length; i++) {
			(function(){
				var existingSubmit = forms[i].onsubmit || function(){};
				forms[i].onsubmit = function(){
					VT.PopUnder.open();
					return existingSubmit.apply( forms[i] );
				};
			})();
		}
	},
	
	/**
	 * This method checks if the infoMap exists and contains a popunder URL.  The infoMap is
	 * sent from the server and gives the server precedence in setting the popunderis URL. 
	 * 
	 * If no infoMap url is present, a default popunder URL is prepared.  
	 * 
	 * @return a url that the popunder will open to.  If the returned url is null, then no
	 *   popunder will be opened. 
	 */
	/*private*/ getPopUnderUrl : function() {
		var url;
		
		if(this.infoMap && this.infoMap.url) {
			url = this.infoMap.url;
//		} 
//		else {  // SET DEFAULT URL 
//
//			var locMatches = location.href.match(/(\d+)\/\w+-\w+\.html$/);
//			var cityLocId = locMatches ? locMatches[1] : null;
//
//			if(cityLocId) {
//				url = 'http://www.onetime.com/vtpopunder.php?&sid=922&clid='+cityLocId+'#AfterTopBanner';	
//			} else {
//				url = 'http://www.onetime.com/vtpopunder.php?&sid=921#AfterTopBanner';
//			}
		}
		
		return url;
	},
	
	/**
	 * The popunder checks for this cookie to tell whether a user has already been shown a popunder.  If
	 * the cookie has been set, no popunder will be opened.
	 */
	/*private*/ setPopUnderPerformedCookie : function() {
		var sld_tld = "." + document.domain.match(/\w+\.\w+$/);
		setCookie("CommercePopunder", "performed", 1, sld_tld);
	}
};




// initialize PopUnder 
// (a closure is used here to take the variables contained out of the global scope) 
(function() {
	
	// A 'bouncer' is a web user who fits a profile of an inbound surfer likely to bounce.  This includes first time 
	// users of the site who do not land on Hotel pages.
	var userIsABouncer = function() { 

		var isHotelsPage = location.href.indexOf('/hotels/') !== -1;
		if (isHotelsPage) {
			var isBouncer = false;
		} else {
			// If not a hotels page, check to see if this surfer has received a popunder in the past
			var popUnderCookie = getCookie("CommercePopunder");
			
			var isBouncer = (popUnderCookie !== "performed"); 
		} 
		
		return isBouncer;
	}
	
	var popUnderLayerAdded=false;
	var addPopUnderLayer = function() {
		if( !popUnderLayerAdded ){
			popUnderLayerAdded=true;
			
			var openHotelsLayer = 
				(VT.PopUnderInfo && VT.PopUnderInfo.hotelsLayer) 
				|| 
				VT.HotelsLayerInfo;
			
			if (openHotelsLayer) {
				var info = VT.PopUnderInfo || VT.HotelsLayerInfo;
				VT.HotelsLayer.open( info );
				VT.PopUnder.addTriggers(VT.PopUnderInfo);
			}
			else {
				VT.DealsLayer.open();
				VT.PopUnder.addTriggers(VT.PopUnderInfo);
			}
		}
	}
	
	var browserAllowsPopunder =  function () {
		// Popunders fail for the following browsers: 
		
		// Popunder becomes a popup
		var isLinuxFF = BrowserDetect.OS==='Linux' && BrowserDetect.browser==="Firefox";
		var isWindowsSafari = BrowserDetect.OS==='Windows' && BrowserDetect.browser==="Safari";
		
		// Opens window INSIDE the browser window as a new browser window (really weird looking)
		var isWindowsOpera = BrowserDetect.OS==='Windows' && BrowserDetect.browser==="Opera";
		
		// Opens window in a new tab and focuses on that tab
		var isChrome = BrowserDetect.browser==="Chrome";
		
		
		var browserFailsToPopunder = isLinuxFF || isWindowsSafari || isWindowsOpera || isChrome;
		
		return !browserFailsToPopunder;
	}
	
	
	if( userIsABouncer() && browserAllowsPopunder() ) {
		var existingLoad = window.onload || function(){};
		window.onload = function() { addPopUnderLayer(); return existingLoad();};
		window.onDomReady(addPopUnderLayer);
	}
})();


VT.CheckRatesBox = (function(){
	var lastSerial = 0; 
	
	function CheckRatesBoxConstructor (pUrl) {
		var o = this;
		var serial = lastSerial++;
		var closeElId = 'crbClose_'+ serial;
		var frameElId = 'crbFrame_'+ serial;
		var url = pUrl;
		var box;
		var greyOut;
		
		
		this.setPosition = function(x,y) {
			box.style.left = x+"px";
			box.style.top = y+"px";
		}
		
		this.center = function(){
			var viewDim = VT.Dom.getDimensions().viewport;
			box.style.left = Math.round((viewDim.width - getW(box)) / 2)+"px";
			box.style.top = Math.round((viewDim.height - getH(box)) / 2 + posTop())+"px";
		};
		
		this.remove = function() {
			// Remove greyout
			greyOut.remove();
			
			// Unhook all events connected to the CheckRatesBox HTML Elements
			document.getElementById(closeElId).onclick = "";
			
			// Remove CheckRatesBox from dom
			box.parentNode.removeChild(box);
		};
		

		function buildBox() {
			box = document.createElement("div");
			box.className="checkRatesBox";
						
			box.innerHTML = '\
<a id="'+closeElId+'" class="close" href="javascript:void(0);">close</a>\
<iframe id="'+frameElId+'" scrolling="no" frameborder="0"></iframe>\
			';
			document.body.appendChild(box);
			document.getElementById(frameElId).src = url;
				
			closeEl = document.getElementById(closeElId);
			closeEl.onclick = o.remove;
			
			greyOut = new VT.Effects.GreyOut(box);
		}
		buildBox();
		
		return this;
	}
	
	return CheckRatesBoxConstructor;
})();


