// set page scope variable timestamp to be used by ad tags.
var d = new Date();
var gTimestmp = d.getTime();

function openNewWindow (url) {
	//simple function, mimmicks opening window using target = _blank, but places a sized window in upper left corner
	window.open (url, '', 'left=50,top=50,location=yes,scrollbars=yes,width=600,height=500,menubar=yes,status=yes,resizable=yes,toolbar=yes');
}

//open travel photo galleries
function openTPG (url, type) {
		var windowName = "";
		switch (type) {
			case "screensaver":
				windowName = "screensaver_preview";
				break;
			case "gallery":
				windowName = "photo_gallery";
				break;
			case "slideshow":
				windowName = "slideshow";
				break;
			default:
				break;
		}
		window.open (url, windowName, 'width=792,height=700,scrollbars=yes,resizable=yes,left=50,top=50');
	}
	
//open media player
function openMEDIA (url, type) {
		var windowName = "";
		switch (type) {
			case "mediaplayer":
				windowName = "mediaplayer_window";
				break;
			default:
				break;
		}
		window.open (url, windowName, 'width=765,height=665,scrollbars=yes,resizable=yes,left=50,top=50');
	}
	
	
	//worldwide travel deals layer
	function changeLayer (tab) {
	
	layerArray = new Array ("vacations", "flights", "internat", "lastmin");
	
	for (i = 0; i < layerArray.length; i++) {
		if (layerArray[i] == tab) {
			document.getElementById("ww_" + tab).style.display = "block";
			document.getElementById(tab + "Img").src = "/images/dip/right_nav/" + tab + "_tab_on.gif";
		} else { 
			document.getElementById("ww_" + layerArray[i]).style.display = "none";
			document.getElementById(layerArray[i] + "Img").src = "/images/dip/right_nav/" + layerArray[i] + "_tab_off.gif";
		}
	
	}
}

//function to validate search box
function validateSiteSearch()  {
	query = document.keyword_search_form.q.value;
	if (isBlank(query) || (query.indexOf('Your Destination') != -1) ) {	
		var n = prompt("Please enter your destination or travel interest:", "");
		if (n == null) {
		  document.keyword_search_form.q.value = "[ Your Destination ]";
		  return;
		} else {
		  document.keyword_search_form.q.value = n;
		} 
		validateSiteSearch(); 
	} else if (query =="null" ) {
	  	 document.keyword_search_form.q.value=" ";
	} else {
	   	document.keyword_search_form.submit();
	}
}

function clearSearchBox(box) {
	query = document.keyword_search_form.q.value;
	if (query.indexOf('Destination') != -1) {
		box.value = "";
	}
}

function isBlank(string) {
  	for(var i = 0; i < string.length; i++) {
  		var c = string.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '')) return false;	
	}	
	return true;
 }//end isBlank
 


 //overture - legacy
 function ShowListings () {
 	//do nothing for now
 }
 
 function ShowListings_LEGACY () {
	var i=6;
	while (i < zSr.length) {
		var descr = zSr[i++]; // listing description
		var unused1 = zSr[i++]; // (ignore)
		var clickURL = zSr[i++]; // listing link
		var title = zSr[i++]; // listing title
		var sitehost = zSr[i++]; // advertiser’s domain name
		var unused2 = zSr[i++]; // (ignore)
		document.write('<li>');
		document.write('<a target="_blank" href="' + clickURL + '">');
		document.write(title + '</a>');
		document.write('<p class="descr"><a target="_blank" href="' + clickURL + '">' + descr + '</a><br />');
		document.write('<a target="_blank" href="' + clickURL + '" class="sitehost">' + sitehost + '</a></p></li>');
	}
}


//legacy
function KeywordSearch(){
		   	term=document.keyword_search_form.keyword.value;
		   	if (term=="" || term=="search" || term==" ") {	
		   	var n = prompt("Please enter a keyword or phrase to search:", "");
		  	 document.keyword_search_form.keyword.value=n
		   	KeywordSearch(); 
		   } else if (term =="null" ) {
		  	 document.keyword_search_form.keyword.value=" "
		   } else {
		   	document.keyword_search_form.submit();
		   }
		   }

