function popWindow(sURL, sName, nWidth, nHeight) {
	if (sName == "") sName = "popWindow";
	if (nWidth == "") nWidth = "300";
	if (nHeight == "") nHeight = "300";
	var n = window.open(sURL,sName,'status=0,toolbar=0,location=0,menubar=0,directories=0,scrollbars=1,resizable=1,width='+nWidth+',height='+nHeight);
	n.focus();
	void(0);
}

function MM_findObj(n,d) { //v4.01
	var p,i,x;
	if (!d) d=document;
	if ((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); }
	if (!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for (i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function ShowIt(itemName) {
	MM_findObj(itemName).style.display = '';
}

function HideIt(itemName) {
	MM_findObj(itemName).style.display = 'none';
}

function ToggleIt(itemName, plusImg, minusImg) 
{
	if (MM_findObj(itemName).style.display == 'none') 
	{
		MM_findObj(itemName).style.display = '';
		MM_findObj(plusImg).style.display = 'none';
		MM_findObj(minusImg).style.display = '';		
	}
	else 
	{
		MM_findObj(itemName).style.display = 'none';
		MM_findObj(plusImg).style.display = '';
		MM_findObj(minusImg).style.display = 'none';
	}
}

function activateSearchTab(selectedTab) {
	HideIt('panel_search');
	HideIt('panel_search_flights');
	HideIt('panel_search_hotels');
	HideIt('panel_search_cars');
	panelID = "panel_search_" + selectedTab;
	ShowIt(panelID);
}

function ShowSubMenu(submenuId, parentItemId)
{
	subMenu = document.getElementById(submenuId, parentItemId);
	
	subMenu.style.visibility = "visible";
	subMenu.style.display = "block";
	subMenu.style.zIndex = "100";
	subMenu.style.position = "absolute";
	subMenu.style.top = getElementPosition(parentItemId).top + 21;
	subMenu.style.left = getElementPosition(parentItemId).left + 5;
}

function KeepVisible(submenuId)
{
	subMenu = document.getElementById(submenuId);
	
	subMenu.style.visibility = "visible";
	subMenu.style.display = "block";
	subMenu.style.zIndex = "100";
}

function HideSubMenu(submenuId)
{
	subMenu = document.getElementById(submenuId);
	subMenu.style.visibility = "hidden";
	subMenu.style.display = "none";
}

//Courtesy of Danny Goodman
//http://groups.google.com.au/group/comp.lang.javascript/browse_thread/thread/34d0b0cfb3425863/ee8c5620586c6400?lnk=st&q=get+absolute+position+javascript+menu&rnum=2&hl=en#ee8c5620586c6400
function getElementPosition(elemID){
 var offsetTrail = document.getElementById(elemID);
 var offsetLeft = 0;
 var offsetTop = 0;
 while (offsetTrail){
  offsetLeft += offsetTrail.offsetLeft;
  offsetTop += offsetTrail.offsetTop;
  offsetTrail = offsetTrail.offsetParent;
 }
 if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
  offsetLeft += document.body.leftMargin;
  offsetTop += document.body.topMargin;
 }
 return {left:offsetLeft,top:offsetTop};

} 

//http://www.somacon.com/p355.php
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, ""); }
	
function ValidateForm(name, comments)
{
	var isValid = true;
	
	
	if (MM_findObj(name).value.trim().length == 0)
		isValid = false;
		
	if (MM_findObj(comments).value.trim().length == 0) 
		isValid = false;
		
	if (!isValid)
		alert("Please complete all mandatory fields before continuing.");
	else
		alert("Thank you for submitting your feedback.\nWe appreciate any comments made.");
		
	return isValid;
}

// Start Clevermail
// Created By Udana Abeypala UAb 28/03/2008
//get page scrolled value
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
//get page size
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
// display  div layer
function cleverdisplay(e){
	var arrayPageScroll = getPageScroll();
	var arrayPageSize = getPageSize();
	var C_DIV_WIDTH = 235;
	var C_DIV_HEIGHT = 300;
	
e.style.display = 'inline';
e.style.left=(((arrayPageSize[0] - 20 - C_DIV_WIDTH) / 2) + 'px');
e.style.top=(arrayPageScroll[1] + ((arrayPageSize[3] - 35 - C_DIV_HEIGHT) / 2) + 'px');
}
// hide  div layer
function cleverhide(e)
{
e.style.display = 'none';
}
// Clevermail// Fast mail Travel Club Holiday club

// DSkinner ~ PS 10806 ~ 31/3/08
// The following function calls cleverdisplay(e) to show the terms and conditions DIV for marketing promotions.
function termsAndConditions()
{
	var arrayPageScroll = getPageScroll();
	var arrayPageSize = getPageSize();
	var C_DIV_WIDTH = 235;
	var C_DIV_HEIGHT = 300;
	
	e.style.display = 'block';
	e.style.left = (((arrayPageSize[0] - 20 - C_DIV_WIDTH) / 2) + 'px');
	e.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - C_DIV_HEIGHT) / 2) + 'px');
}
