//***************************************************************
function ValidateMakePaymentForm(toForm) {
if (!VarCheck(toForm.txtNameOnCard, 'Please enter the Name on the Credit Card.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcAddress, 'Please enter the Credit Card Billing Address.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcCity, 'Please enter the Credit Card Billing City.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcState, 'Please enter the Credit Card Billing State.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcZipcode, 'Please enter the Credit Card Billing Zipcode.', false)) {
  return false; }
if (!VarCheck(toForm.CcNumber, 'Please enter a Credit Card Number.', true)) {
  return false; }
if (!VarCheck(toForm.ccMonth, 'Please enter the Credit Card Expiration Month.', false)) {
  return false; }
if (!VarCheck(toForm.ccYear, 'Please enter the Credit Card Expiration Year.', false)) {
  return false; }
return true;
}
//***************************************************************
function ValidateChangeProfileForm(toForm) {
var lcVar = toForm.email;
if (!(lcVar==null)) {
	if (!check_email(toForm.email.value)){
		alert("Invalid email address.");
		toForm.email.focus(); 
		return false;
	}
}
}
//***************************************************************
function SetFormOrderLogonFocus(toDoc) {
var lcVal = toDoc.frmOrderLogon.Email.value;
if (lcVal=="")
	toDoc.frmOrderLogon.Email.focus();
else
	toDoc.frmOrderLogon.Password.focus();
}
//***************************************************************
function setReturnValuesFromCalendarPopup(y,m,d) {
	document.frmTourAvail.DepartDateMonthYear.value=y+'-'+m;
	for (var i=0; i<document.frmTourAvail.DepartDateDay.options.length; i++) {
		if (document.frmTourAvail.DepartDateDay.options[i].value==d) {
			document.frmTourAvail.DepartDateDay.selectedIndex=i;
			}
		}
	}
//***************************************************************
function getDateString(ym_obj,d_obj) {
	if (ym_obj.selectedIndex < 0) {return null;}
	var ym = ym_obj.options[ym_obj.selectedIndex].value;
	var d = d_obj.options[d_obj.selectedIndex].value;
	if (ym=="") { return null; }
	if (d=="") { d="1"; }
	return str= ym+'-'+d;
	}
//***************************************************************
function createOnTopTourAvailTarget(toForm){
if (ValidateTourAvailForm(toForm)) {
	launch("", toForm.target, "", "myWindow");
  return true; }
return false;
}
//***************************************************************
function RunLifestyleParmTarget(toForm){
if (ValidateLifestyleForm(toForm)) {
	var lcParms = BuildParmList(toForm);
	launch('/webbook/Lifestyle.wbk' + lcParms,'window2',"height=" + screen.height - 1 + ",width=600,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",'myWindow');
}}
//***************************************************************
function RunLifestyleParmTargetNoValidate(toForm){
if  (VarCheck(toForm.cboLifeStyle, '', false)) {
	var lcParms = BuildParmList(toForm);
	launch('/webbook/Lifestyle.wbk' + lcParms,'window2',"height=" + screen.height - 1 + ",width=600,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",'myWindow');
}}
//***************************************************************
function SetOriginalDate() {
var ldDate = new Date() ;
ldDate.setDate(ldDate.getDate() + 1) ;
if (ldDate.getDay() != 5 && ldDate.getDay() != 6 && ldDate.getDay() != 0) {
	for (i=1;i<7;i++) {
		if (ldDate.getDay() == 5 || ldDate.getDay() == 6 || ldDate.getDay() == 0) break
		else ldDate.setDate(ldDate.getDate() + 1) 
  }
}
var lnMth   = ldDate.getMonth() + 1;
var lcMthYr = ldDate.getFullYear() + '-' + lnMth;
document.frmTourAvail.DepartDateMonthYear.value = lcMthYr ;
document.frmTourAvail.DepartDateDay.value = ldDate.getDate() ;
}
//***************************************************************
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//***************************************************************
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//***************************************************************
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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//***************************************************************
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//***************************************************************
// from travelvision
function WTV_onimageload(id, url, caption) {
	document.getElementById(id).innerHTML =
	 "<a href = \"#\" onclick=\"window.open(\'" + url + "\',\'\', \'width= 700,height= 450\')\">" + caption + "</a>";
}
//***************************************************************
function SelectListItem(loList,lcValue) {
loList.selectedIndex = 0;
for (x=0;x<loList.length-1;x++) {
	if (loList.options[x].value == lcValue) {
		loList.selectedIndex = x;
		break;
	}
}
}
//***************************************************************
function launch(newURL, newName, newFeatures, orgName) {
var remote = open(newURL, newName, newFeatures);
if (remote.opener == null) remote.opener = window;
remote.opener.name = orgName; remote.focus(); return remote;
}
//***************************************************************
function BuildParmList(toForm){
var lcParms = '?'
for(i=0; i<toForm.elements.length; i++){
	var field = toForm.elements[i]; //alert(field.name+' / '+field.type+' / '+field.value);
	if(field.type=="text" || field.type=="textarea"){
		lcParms = lcParms + field.value + '~' };
	if(field.type=="select-one"){	
		lcParms = lcParms + field.value + '~' };
}
return lcParms;
}
//***************************************************************
function BuildNamedParmList(toForm, tlExclCcNum){
var lcParms = '?'
for(i=0; i<toForm.elements.length; i++){
	var field = toForm.elements[i]; //alert(field.name+' / '+field.type+' / '+field.value);
	if(field.type=="text" || field.type=="textarea" || field.type=="select-one") {
		if (field.name != 'CcNumber' || tlExclCcNum != true) {
			lcParms = lcParms + field.name + '=' + field.value + '&'};
	}
}
return lcParms;
}
//***************************************************************
function LoadMain(file,target) {
    if (target != '')
        target.window.location.href = file;
    else
        window.location.href = file;
}
//***************************************************************
function VarCheck(toVar, tcMsg, tlNum){
var lcVal = toVar.value;
if((lcVal==null)||(lcVal=="")||((tlNum && isNaN(lcVal)))) {
	if (tcMsg != "") {alert(tcMsg)};
	toVar.focus();
  lcType = toVar.type ;
  if (lcType == 'text' || lcType == 'textarea') {
	  toVar.select();
	}
  return false;
}
return true;
}
//***************************************************************
function CreateSlideShowLinkTarget(tcTarget){
launch("", 'Slideshow',	"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=550,height=330", "myWindow");
return true;
}
//***************************************************************
function launchPdf(tcUrl) {
	winPdf = launch(tcUrl,
                  "winPdf",
                  "height=" + screen.height - 1 + ",width=" + screen.width - 1 + ",screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",
                  "myWindow");
}
//***************************************************************
function launchStarRatings() {
	winStars = launch("/webbook/static/StarRatings.htm",
                    "winStars",
                    "height=500,width=594,screenX=50,left=50,screenY=50,top=50,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0",
                    "myWindow");
}

//***************************************************************
function launchFlightInfo(tcUrl) {
	winFlightInfo = launch(tcUrl,
                    "winFlightInfo",
                    "height=600,width=540,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0",
                    "myWindow");
}
//***************************************************************
function launchProofOfCitizenship() {
	winCitizen = launch("/webbook/static/ProofOfCitizenship.htm",
                    "winCitizen",
                    "height=" + screen.height - 1 + ",width=594,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0",
                    "myWindow");
}
//***************************************************************
function launchPrivacyPolicy() {
	winPrivacy = launch("/privpol.html",
                    "winPrivacy",
                    "height=" + screen.height - 1 + ",width=584,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",
                    "myWindow");
}
//***************************************************************
function launchWeather(tcLoc) {
	if (tcLoc == null || tcLoc == 'XXX') {
		alert('Weather temporarily unavailable for this destination.');
	} 
	else {
		winWeather = launch("http://www.intellicast.com/Local/ccclip.asp?loc=" + tcLoc + "&company=1017947967",
											"winWeather",
											"height=206,width=264,screenX=200,left=200,screenY=200,top=200,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0",
											"myWindow");
	} 
}
//***************************************************************
function launchDepart(tcDest) {
	if (tcDest == null)
  	var tcDest = document.frmTourAvail.Dest.value;
	if(tcDest == "") {
		alert('Please select a Destination.');
	} 
	else {
		winDepart = launch("/webbook/DepartQry.wbk?" + tcDest,
                    "winDepart",
                    "height=" + screen.height - 1 + ",width=435,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",
                    "myWindow");
	} 
}
//***************************************************************
function SelectListItem(loList,lcValue) {
   loList.selectedIndex = 0;
	for (x=0;x<loList.length;x++) {
     if (loList.options[x].value == lcValue) {
	       loList.selectedIndex = x;
	       break;
	    }
	}
}
//***************************************************************
function CopyPaxContactInfo(tcNum) {
var oTmp = eval("document.frmSecInfo.cEmConName" + tcNum)
if (typeof(oTmp) == 'object' && typeof(document.frmSecInfo.cEmConName1) == 'object') oTmp.value = document.frmSecInfo.cEmConName1.value
  oTmp = eval("document.frmSecInfo.cEmConRel" + tcNum)
if (typeof(oTmp) == 'object' && typeof(document.frmSecInfo.cEmConRel1) == 'object') oTmp.value = document.frmSecInfo.cEmConRel1.value
  oTmp = eval("document.frmSecInfo.cEmConPhon" + tcNum)
if (typeof(oTmp) == 'object' && typeof(document.frmSecInfo.cEmConPhon1) == 'object') oTmp.value = document.frmSecInfo.cEmConPhon1.value
}
//***************************************************************
function focusFirst(tcFormName) {
	if (tcFormName == null)
  	var tcFormName = 'forms[0]';
	var loForm = eval('document.' + tcFormName);
  if (loForm)
  {
    if ( loForm.elements.length ) {
       // JS 1.1 needed for form.elements.length property
       var lnElems = loForm.elements.length ;
     }
     else {
       var lnElems = 2 ;
     }
     var lnElem = 0 ;
     var lcType = '' ;
     while ( lnElem < lnElems ) {
       lcType = loForm.elements[lnElem].type ;
       if ( lcType == 'text' || lcType == 'textarea' || lcType == 'select-one' || lcType == 'password' ) {
           loForm.elements[lnElem].focus() ;
           break ;
       }
       if ( lcType == 'radio' || lcType == 'checkbox' || lcType == 'select-multiple' ) {
           // break, so we don't give focus to a later textbox
           break ;
       }
       lnElem++ ;
     }
  }
}
//***************************************************************
function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
for(i=0; i < e.length ;i++){
	if(ok.indexOf(e.charAt(i))<0){ 
		return (false);
	}	
} 
if (document.images) {
	re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if (!e.match(re) && e.match(re_two)) {
		return (-1);		
	} 
}
}
//***************************************************************
function ValidateCustAccountForm(toForm){
if (!VarCheck(toForm.FirstName, 'Please enter your First Name.', false)) {
  return false; }
if (!VarCheck(toForm.LastName, 'Please enter your Last Name.', false)) {
  return false; }
if (!VarCheck(toForm.Address, 'Please enter your Address.', false)) {
  return false; }
if (!VarCheck(toForm.City, 'Please enter your City.', false)) {
  return false; }
if (!VarCheck(toForm.State, 'Please enter your State.', false)) {
  return false; }
if (!VarCheck(toForm.Zip, 'Please enter your Zipcode.', false)) {
  return false; }
if(!check_email(toForm.EMail.value)){
	alert("Invalid email address.");
	toForm.EMail.focus(); 
  return false; }
if (!VarCheck(toForm.Phone, 'Please enter your Phone Number.', false)) {
  return false; }
if (!VarCheck(toForm.Password, 'Please enter your Password.', false)) {
  return false; }
if (!VarCheck(toForm.confirmpassword, 'Please enter your Confirm Password.', false)) {
  return false; }
return true;
}
//***************************************************************
function ValidateTourAvailForm(toForm){
if (VarCheck(toForm.Dest, 'Please select a Destination.', false)) {
  return true; }
return false;
}
//***************************************************************
function RunClearPubAgencySaveParm(){
var toForm = document.forms(0);
var lcParms = BuildNamedParmList(toForm, true);
window.location.href = '/webbook/ClearPubAgency.gwv' + lcParms
}
//***************************************************************
function CreateOnTopFindAnAgentTarget(toForm){
if (ValidateSelectAgencyForm(toForm)) {
	launch("", toForm.target,
					  "height=" + screen.height - 1 + ",width=700,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",
					  "myWindow");
  return true; }
return false;
}
//***************************************************************
//function ValidateFindAnAgentForm(toForm){
//if (VarCheck(toForm.txtZipcode, 'Please enter your zipcode to find nearby agencies.', true)) {
//  return true; }
//return false;
//}
//***************************************************************
/*function RunRulesAndRestrictionsTarget(){
var toForm = document.forms(0);
var lcParms = BuildNamedParmList(toForm);
launch('/webbook/RulesAndRestrictions.gwv' + lcParms,'window2',"height=410,width=600,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0",'myWindow');
}*/
//***************************************************************
//THIS FUNC GENERATED IN CODE
/*function ValidateGetPaxForm(toForm){
if (!VarCheck(toForm.Street1, 'Please enter your Address.', false)) {
  return false; }
if (!VarCheck(toForm.City, 'Please enter your City.', false)) {
  return false; }
if (!VarCheck(toForm.State, 'Please enter your State.', false)) {
  return false; }
if (!VarCheck(toForm.Zipcode, 'Please enter your Zipcode.', true)) {
  return false; }
if (!VarCheck(toForm.Phone, 'Please enter your Phone Number.', false)) {
  return false; }
return true;
}*/
//***************************************************************
//NOT USED NOW - use when calling from button
//[<form name="frmSlideShow" method="post" action="SlideShow.wbk?] + lcTVid + [" onsubmit="CreateSlideShowTarget(this)" target="Slideshow">] +;
//[<input type="submit" name="SlideShow" value="View Hotel Slide Show"></form><br>]
//function CreateSlideShowTarget(toForm){
//launch("", toForm.target,
//					"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=550,height=330",
//					"myWindow");
//return true;
//}
//***************************************************************
/*function BuildNamedFindAgencyParmList(toForm){
var lcParms = '?'
var field = toForm.txtAgencyName;
lcParms = lcParms + field.name + '=' + field.value + '&';
field = toForm.txtAgencyCity;
lcParms = lcParms + field.name + '=' + field.value + '&';
field = toForm.txtAgencyZipcode;
lcParms = lcParms + field.name + '=' + field.value + '&';
return lcParms;
}*/
//***************************************************************
//function SetOrderLogonFormFocus(toDoc){
//var loPw = toDoc.frmOrderLogon.Password;
//var loEmail = toDoc.frmOrderLogon.Email;
//if (typeof(loEmail) == 'object' && typeof(loPw) == 'object')
//	if (loEmail.value == '')
//		toDoc.frmOrderLogon.Email.focus();
//	else
//		toDoc.frmOrderLogon.Password.focus();
//}
//***************************************************************
