

// BMW remove var today="2005/10/19"  //replace this with todays date from the server
var today = new Date();

// DPW 6/6/06
if (document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

/* DPW 6/6/06 - see above 
// SLJ
function ttc_find_element ( arg_item ) {

  if ( document.all ) return ( document.all[arg_item] );

  if ( document.getElementById ) return ( document.getElementById ( arg_item ));

  return ( false );
}

*/

function setCurrentDate(arg_form)
{
	lclDate = today.getDate();
	lclMonth = Calendar._SMN[today.getMonth()];
	lclYear = today.getYear() +  1900;
	lclYearString = lclYear.toString();
	lclYearString = lclYearString.substr(2,3);
	lclDateString = lclDate + lclMonth + lclYearString;

	arg_form.dep_date.value=lclDateString;
}

function verify(arg_form)
{
            lclMsg = "";
            if ( arg_form.dep_city.value == "" || arg_form.dep_city.value == "Select Region" )
            {
                        lclMsg += "> Selected Region\n";            
            }
        // This if statement redundant if setCurrentDate has worked correctly
            if(arg_form.dep_date.value=="choose>")
            {
            lclMsg += "> Selected Tour Date\n";
            }                     
            if ( (parseInt (arg_form.child_1.value) +  parseInt (arg_form.adult_1.value)) > 9 )
			{
            lclMsg += "> Selected no more than 9 passengers (incl. children)\n";         
            }
            if(lclMsg!="")
    {
	lclMsg = "Please ensure you have...\n" + lclMsg;
	alert(lclMsg);
	return false;
    }
    else
    {
		//Detect IE5.5 ~ Popup blocker in 5.5 doesn't allow url re-direction in popup window
		version=0
		if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
		}
		//if browser not ie5.5
		if (version != 5.5) {
			wbSupub = window.open('','wbSupub','resizable=1,width=720,height=580');
			document.params.submit();	
		}
		
		return true;
    } 
}
// controls the display/hide of the child ages according to the   
function displayChildAgeBoxes(numChild)
{
	document.getElementById("ChildAgeRow").style.display = numChild > 0 ? "" : "none";
    for (i=1; i<=numChild; i++)
	  document.getElementById("rm1ChildAge" + i).style.display = "";
	for (; i<=4; i++)
	  document.getElementById("rm1ChildAge" + i).style.display = "none";
}

// Copies child ages over from the drop downs to the webbook child age params.  Clears out any unspecified child ages
function setParams(numChild)
{
	
	// For quickbook, construct the model itin from the departure city

	 if (document.getElementById("itin_code").value == "" || document.getElementById("itin_code").value == "DAYW")
    {
        if (document.getElementById("dep_city") != false)
        {
            
document.getElementById("itin_code").value=document.getElementById("dep_city").value 
+ "DAYW";
        }
    }

									
    for (i=1; i<=numChild; i++)
	  document.getElementById("par_child_1_" + i).value = document.getElementById("rm1ChildAge" + i).value;
	for (; i<=4; i++)
	  document.getElementById("par_child_1_" + i).value = "";
}

function setParamsCB(numChild)
{
									
    for (i=1; i<=numChild; i++)
	  document.getElementById("par_child_1_" + i).value = document.getElementById("rm1ChildAge" + i).value;
	for (; i<=4; i++)
	  document.getElementById("par_child_1_" + i).value = "";
}
