function doClick(obj)
{
	if (obj.id == "hotel") {
		//if (obj.options[obj.selectedIndex].value != "") 
			//document.getElementById("star").selectedIndex = 0; 
	} else if (obj.id == "star") {
		if (obj.options[obj.selectedIndex].value != "") 
			document.getElementById("hotel").selectedIndex = 0; 	
	} else if(obj.id == "ProdTypeAirfare" || obj.id == "ProdTypePackage")
		location.replace('default.asp?product=' + obj.value);
	else
		if(obj.selectedIndex >=0 && obj.options[obj.selectedIndex].value != '' && typeof(obj.options[obj.selectedIndex].value) != 'null' && typeof(obj.options[obj.selectedIndex].value) != 'undefined')
			location.replace('default.asp?' + obj.name + '='+obj.options[obj.selectedIndex].value);
}

function openWindow(hotelurl){
	var w = window.open(hotelurl, "hotel", "height=400,width=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	w.focus();
}

function openInsInfo(infourl) {                 
	var w = window.open(infourl, "", "width=360,height=400,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes");
	w.focus();
}

function paxAdjustment(obj){
  //location.replace('default.asp?' + obj.name + '='+obj.options[obj.selectedIndex].value);
  document.bookform.submit();
}

function copyAddress()
{
	document.getElementById("a1").value = document.getElementById("addr").value;
	document.getElementById("a2").value = document.getElementById("city").value;
	//document.getElementById("a3").value = document.getElementById("prov").value;
	document.getElementById("a4").value = document.getElementById("postal").value;
	document.getElementById("ph1").value = document.getElementById("hphone").value;
	document.getElementById("ph2").value = document.getElementById("bphone").value;
	document.getElementById("ea").value = document.getElementById("email").value;												
}

function displayTerms()
{
	for(var i=1; i<=4; i++)
	{
		var p = document.getElementById('p' + i.toString());
		//p.style.display = (i!=k)? "none": "";
		p.className = "displayEndbled";
	}
}

function LTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);

    if (whitespace.indexOf(s.charAt(0)) != -1)
    {
        var j=0, i = s.length;

        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
        {
            j++;
        }
        s = s.substring(j, i);
    }
    return s;
}

function RTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);

    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
        var i = s.length - 1;

        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
            i--;
        }
        s = s.substring(0, i+1);
    }

    return s;
}

function Trim(str)
{
    return RTrim(LTrim(str));
}

function isEmpty(obj)
{
    //obj=document.getElementsByName(obj).item(0);

    if(Trim(obj.value)=="")
    {
        if(obj.disabled==false && obj.readOnly==false)
        {
            obj.focus();
        }
		return true;
    }
	return false;
}

function isEmail(a)
{ 
	var len = a.length;
 	var at = a.indexOf('@');
 	var dot = a.indexOf('.');
 	
	return (at>1 && dot>1 && len>at+3) ? true : false;
}

function checkInput(objForm)
{
	var i, o;

	for (i=0; i<objForm.length; i++) {
		o = objForm.elements[i];

		if (o.getAttribute("request")=="true" && isEmpty(o)) {
				alert(o.getAttribute("requesterror"));
				o.focus(); 
				return false;
		}

		if (o.getAttribute("datatype")=="email" && !isEmpty(o) && !isEmail(o.value)) {
				alert(o.getAttribute("datatypeerror"));
				o.focus();
				return false;
		}
	}
	return true;
}

function openWindowEx(url, name, width, height){
	var w = window.open(url, name, "height=" + height.toString() + ",width=" + width.toString() + ",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");
	w.focus();
}

function openWindowEx2(url, name, width, height){
	var w = window.open(url, name, "height=" + height.toString() + ",width=" + width.toString() + ",status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes");
	w.focus();
}