
//<script language=jscript> test

	 function isEmpty(s_var)	{ return ( typeof(s_var) == "undefined" || String(s_var)=="" || String(s_var)=="null"); }

	 function Set_and_Submit (){
		var h_params=GetParams(arguments);
		debugger;

		for(var s_key in h_params ){
			var s_value=h_params[s_key];
			if (isEmpty(s_key) || isEmpty(s_value)){ continue }
			setFieldValue(s_key,s_value,'',1);
		}
		Do_SubmitForm();
	 }

	 function Do_SubmitForm(ps_FormName){

		//clean some fields
		setFieldValue('special', getFieldValue('special').split(',')[0]);
		setFieldValue('dest', getFieldValue('dest').split(',')[0]);
		setFieldValue('superdest', getFieldValue('superdest').split(',')[0]);
		setFieldValue('vendor', getFieldValue('vendor').split(',')[0]);


		var b_no_redirect=false;

		var o_requireSSL=getDocItem('_requireSSL');
        if (!isEmpty(o_requireSSL) && o_requireSSL.value==1){
			document.frmMain.action=document.frmMain.secure_url.value;
			b_no_redirect=true;

        }else if (document.frmMain.action==document.frmMain.secure_url.value){
			b_no_redirect=true;
		}

		if(String(ps_FormName)=='undefined' || ps_FormName==''){
			ps_FormName='frmMain';
		}
		var o_form=document[ps_FormName];
		
		if (!(typeof o_form._alt_qs_question == "object" && o_form._alt_qs_question.value && o_form.action && !o_form._dont_use_js_change_action.value) ) {
			b_no_redirect=true;
		}

		var a_path = String(location.pathname).split("/")
		if (a_path.length > 2 ){
			b_no_redirect=true;
		}

		if (!b_no_redirect) {
			var s_new_action=String(o_form.action).replace(o_form._file_perlexe.value,'');
			s_new_action+=o_form._alt_qs_question.value+'screen'+o_form._alt_qs_equal.value+o_form.screen.value+o_form._alt_fake_end.value;
			var s_screen=String(o_form.screen.value);
			s_screen=s_screen.replace(/"/g,'%22');
			//s_screen=s_screen.replace(/\(/g,'_');
			//s_screen=s_screen.replace(/\)/g,'_');

			var s_params='screen'+o_form._alt_qs_equal.value+s_screen;
			s_params=s_params+o_form._alt_qs_amp.value+'_ispost'+o_form._alt_qs_equal.value+'1';

			s_new_action=o_form._alt_qs_question.value+s_params+o_form._alt_fake_end.value;
			o_form.action=s_new_action;


		}
		o_form.submit();

	 }

	  function get_css_tags(){
		var o_This=window.event.srcElement;
		var s_String="";
		var i=1; //safety check
		do {
			if (o_This.tagName=="IMG"){

				s_String+="IMGSRC : "+ o_This.src +"\n";
			}
			if (o_This.className != ""){
			  s_String+="Element:"+o_This.tagName+"       Class:"+ o_This.className +"\n";
			}
			o_This=o_This.parentElement;
		} while ( i++<100 && String(o_This)!="null");
		if (s_String==""){s_String="No class names found."}
		alert(s_String);
		window.event.cancelBubble = true;
		return false;

	  }

	function change_double_dest (s_dest_field,s_select_text){
		var o_dropdown1=getDocItem('doubledropdown_superdest');

		var o_dest_field=getDocItem(s_dest_field);
		options_clear(o_dest_field);

		options_add(o_dest_field,s_select_text,'');
		options_add(o_dest_field,'-----------------------------------------','');

		var a_superdests=doubleSplit(';',',',o_dropdown1.value);
		var len_superdests=a_superdests.length;
		for (var count_superdests=0; count_superdests < len_superdests; count_superdests++) {
			var o_superdest=a_superdests[count_superdests];
			options_add(o_dest_field, o_superdest[1], o_superdest[0]);
		}

	}

	function getDocItem(s_name){
		var o_return;
		if (document.getElementById) {
			o_return=document.getElementById(s_name);

			if (String(o_return)=='null') {
				var o_coll=document.getElementsByName(s_name);
				if (o_coll.length >= 1 ) o_return=o_coll.item(0);
			}

		}else if (document.all) {
			o_return= document.all[s_name];
		}else if (document.layers) {
			o_return= document.layers[s_name];
		}
		if (String(o_return)=='null' || String(o_return)=='undefined') o_return='';
		return o_return;
    }

	function dhtmlpicture_click(ps_prefix, ps_name, pn_index){
		var o_bigpic=getDocItem(ps_name+"_bigpic");
		var o_pic_src=getDocItem(ps_name+"_pic"+pn_index);
		o_bigpic.src=ps_prefix+o_pic_src.innerHTML;
		o_bigpic.style.display='block';

	}
	function dhtmlbutton_click(ps_name, pn_index){
    	//alert('hello world '+ps_name);
    	if (String(pn_index)=='undefined'){
    		pn_index=document.frmMain.elements[ps_name].value;
    		//alert(pn_index);
    	}
    	//alert(getDocItem(ps_name+"_class"));

		var s_class=document.frmMain.elements[ps_name+"_class"].value;
    	//alert('hello world1');


		var n_count;
		for (n_count=0;; n_count++){
			if (n_count==pn_index){
				continue;
			}
			var s_name=ps_name+n_count;
			var o_td=getDocItem(s_name+"_td");
			var o_span=getDocItem(s_name+"_span");
			if (String(o_td)=="" || String(o_td)=="undefined"|| String(o_td)=="null"){
				break;
			}
			o_td.className=s_class+"_up_back";
			o_span.className=s_class+"_up_fore";

		}
    	//alert('hello world2');
		//alert("dhtmlbutton_click "+ps_name+" "+pn_index);
		var s_name=ps_name+pn_index;
		var o_td=getDocItem(s_name+"_td");
		var o_span=getDocItem(s_name+"_span");
		o_td.className=s_class+"_down_back";
		o_span.className=s_class+"_down_fore";

		var o_value=getDocItem(s_name+"_value");
		var o_div=getDocItem(ps_name+"_div");
		if (String(o_value.innerText)=="undefined"){
			//for mozilla
			o_div.innerHTML=o_value.innerHTML;
		}else{
			//for ie
			o_div.innerHTML=o_value.innerText;
		}

		var o_hidden=document.frmMain.elements[ps_name];
		o_hidden.value=pn_index;

		//alert(document.frmMain.elements['desttab'].value);

		//alert(o_td);
		//o_td.class=
		//alert(s_name_td + " " + o_td);
	}
	function setdebug(){
		var expdate = new Date();
		expdate.setMonth(expdate.getMonth()+6);

		setCookie("ASPCLIENTDEBUG", 'Set',expdate);

		alert('cookie set');
		alert( getCookie ("ASPCLIENTDEBUG") );
	}

	function getCookie (sCookieName){
		var sName=sCookieName+"=", ichSt, ichEnd;
		var sCookie=document.cookie;

		if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
		{
			if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
				ichEnd = sCookie.length;
			return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
		}

		return null;
	}

	function setCookie (sName, vValue){
		var argv = setCookie.arguments, argc = setCookie.arguments.length;
		var sExpDate = (argc > 2) ? "; expires="+argv[2].toGMTString() : "";
		var sPath = (argc > 3) ? "; path="+argv[3] : "";
		var sDomain = (argc > 4) ? "; domain="+argv[4] : "";
		var sSecure = (argc > 5) && argv[5] ? "; secure" : "";
		document.cookie = sName + "=" + escape(vValue,0) + sExpDate + sPath + sDomain + sSecure + ";";
	}

	function deleteCookie (sName){
		document.cookie = sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
	}

	function test_easeFileOut(po_TextArea, po_DivHTML){
		po_TextArea.value=easeFileOut(po_TextArea.value);
		var s_HTML="<table><tr><td colspan=3>top<br><HR NOSHADE size=1 color=red></td></tr><tr><td>left<VR NOSHADE size=1 color=red></td><td>"+po_TextArea.value+"</td><td>right</td></tr><tr><td colspan=3><HR NOSHADE size=1 color=red>bottom</td></tr></table>";
		po_DivHTML.innerHTML=s_HTML;
	}
	function test_easeFileIn(po_TextArea, po_DivHTML){
		po_TextArea.value=easeFileIn(po_TextArea.value);
		var s_HTML="<table><tr><td colspan=3>top<br><HR NOSHADE size=1 color=red></td></tr><tr><td>left<VR NOSHADE size=1 color=red></td><td>"+po_TextArea.value+"</td><td>right</td></tr><tr><td colspan=3><HR NOSHADE size=1 color=red>bottom</td></tr></table>";
		po_DivHTML.innerHTML=s_HTML;
	}
	function test_ViewAsHTML(po_TextArea, po_DivHTML){
		po_DivHTML.style.display='block';
		po_TextArea.style.display='none';
		var s_HTML="<table><tr><td colspan=3>top<br><HR NOSHADE size=1 color=red></td></tr><tr><td>left<VR NOSHADE size=1 color=red></td><td>"+po_TextArea.value+"</td><td>right</td></tr><tr><td colspan=3><HR NOSHADE size=1 color=red>bottom</td></tr></table>";
		po_DivHTML.innerHTML=s_HTML;

	}
	function test_ViewAsText(po_TextArea, po_DivHTML){
		po_DivHTML.style.display='none';
		po_TextArea.style.display='block';
	}
	function easeFileIn(ps_Str){
		    s_Str=String(ps_Str);
		    s_Str=s_Str.replace(/"/g,"");
	        s_Str=s_Str.replace(/#013#010/g,"\n");
		    s_Str=s_Str.replace(/#010/g," ");
	        s_Str=s_Str.replace(/#034/g,'"');
	        s_Str=s_Str.replace(/#044/g,",");
	        s_Str=s_Str.replace(/#035/g,"#");
	        return s_Str;

	}
	function easeFileOut(ps_Str){
		    s_Str=String(ps_Str);
	        s_Str=s_Str.replace(/#/g,"#035");
	        s_Str=s_Str.replace(/"/g,"#034");
	        s_Str=s_Str.replace(/,/g,"#044");
	        return s_Str;
	}

	function content_set(o_this,s_field,s_value){
		var a_name=String(o_this.name).split(',');
		var o_this2=document.frmMain.elements[a_name[1]];

		if (!String(o_this.value).length){
			return;
		}
		o_this2.value=o_this.value;
		document.frmMain.elements[s_field].value=s_value;

		document.frmMain.sAction.value='';
		Do_SubmitForm;
	}

	function content_refresh(ps_Screen, ps_Template){
		document.frmMain.screen.value=ps_Screen;
		document.frmMain.sAction.value='';
		Do_SubmitForm();
	}

	function content_refresh_vendor(s_field, ps_Screen, ps_Template){
		var o_vendor=document.frmMain.elements[s_field];
		var s_value=o_vendor.options[o_vendor.selectedIndex].value;

		if (o_vendor.selectedIndex && !s_value)
			return;

		document.frmMain.screen.value=ps_Screen;
		document.frmMain.sAction.value='';
		Do_SubmitForm();
	}

	function content_changeTab(ps_Field, pn_Number){
		document.frmMain.elements[ps_Field].value=pn_Number;
		Do_SubmitForm();
	}

	function content_changeVendorPage(pn_Number){
		document.frmMain.vendormenu.value=pn_Number;
		Do_SubmitForm();

	}
	function content_changeDestPage(pn_Number){
		document.frmMain.destmenu.value=pn_Number;
		Do_SubmitForm();

	}

function content_TemplateSave(){
    	var sz_screen=document.frmMain.thisscreen.value;
		switch (sz_screen){
		case "scnCustomer":
			if (ValidateForm()){
				document.frmMain.template.value='scnCustomer';
				document.frmMain.screen.value='scnSaveTemplate';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			}
			break;
		case "scnQuote":
		case "scnQuoteNew":
			if (ValidateForm()){
				document.frmMain.template.value='scnQuoteNew';
				document.frmMain.screen.value='scnSaveTemplate';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			}
			break;
		case "scnGolfRounds":
			//if (ValidateForm()){
				document.frmMain.template.value='scnVendorHome';
				document.frmMain.screen.value='scnSaveTemplate';
				document.frmMain.sAction.value='saveunquote';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			//}
			break;
		case "scnVendorHome":
			if (ValidateForm()){
				document.frmMain.template.value='scnVendorHome';
				document.frmMain.screen.value='scnSaveTemplate';
				document.frmMain.sAction.value='saveunquote';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			}
			break;
		case "scnSell_Special":
			if (ValidateForm()){
				document.frmMain.template.value='scnSell_Special';
				document.frmMain.screen.value='scnSaveTemplate';
				document.frmMain.sAction.value='saveunquote';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			}
			break;
		default:
			alert('can not find screen to save: '+sz_screen);
		}

    }
	function content_TemplateSave_Skip(){
    	var sz_screen=document.frmMain.thisscreen.value;
		switch (sz_screen){
		case "scnVendorHome":
			document.frmMain.screen.value='scnSaveTemplate';
			document.frmMain.sAction.value='skip';
			Do_SubmitForm();
			break;
		}
	}


    function wizardstep_DeleteProduct(pn_step,ps_TsiId,pn_Index){
        if (confirm("Are you sure that you want to delete this item")){
	        document.frmMain.sAction.value='Delete,'+pn_step+','+ps_TsiId;
	        document.frmMain.screen.value='scnWizardSteps('+pn_step+')';
			document.frmMain.action_index.value=1+pn_Index;
	        Do_SubmitForm();
        }

    }
    function quote_DeleteProduct(ps_TsiId){
        if (confirm("Are you sure that you want to delete this item")){
	        //document.frmMain.sAction.value='Delete,'+pn_step+','+ps_TsiId;
	        document.frmMain.screen.value='action_DeleteTSI('+ps_TsiId+')';
			//document.frmMain.action_index.value=1+pn_Index;
	        Do_SubmitForm();
        }
	}

    	//if (String(ps_reqFields)!='undefined'){document.frmMain.reqFields.value=ps_reqFields;}

    function bookingstep_Switch(pn_step){
    	document.frmMain.action=document.frmMain.secure_url.value;

    	var s_action='';
    	var s_action_index='';
    	var sz_screen=document.frmMain.thisscreen.value;
		switch (sz_screen){
//		case "scnQuote":
//		case "scnQuoteNew":
//			if (ValidateForm()){
//				SetupDate('startdate');
//				SetupDate('enddate');
//			}else{
//				return;
//			}
//			break;
		case "scnBookTerms":
			//s_action='saveunquote,'+(1+pn_step);
			break;
		case "scnPayments":
			break;
		case "scnBookGDSAir":
			break;
		case "scnTravelers":
			ValidateForm(1);
			break;
		case "scnTravelers_GDS":
			ValidateForm(1);
			break;
		case "scnCustomer":
			//s_action='saveunquote,'+(1+pn_step);
			break;
//		case "scnVendorHome":
//		case "scnGolfRounds":
//			var a_action_index=String(document.frmMain.action_indexes.value).split(',');
//			var n_counter=0;
//			var n_counter_max=a_action_index.length;
//
//			for (n_counter=0;n_counter<n_counter_max ;n_counter++){
//				var n_index=a_action_index[n_counter];
//				if (Validate_SellProduct(n_index, 1)){
//					if (s_action_index != ''){
//						s_action_index+=',';
//					}
//					s_action_index+=1+n_counter;
//				}
//			}
//			if (s_action_index != '' ) s_action ='saveunquote,'+pn_step;
//			break;
//		case "scnContent_ProductDest":
		case "scnValidation":
			//no validation needed
			break;
		default:
			alert(sz_screen);
		}
//		document.frmMain.vendor_step.value=0;
		document.frmMain.sAction.value=s_action;
//		document.frmMain.action_index.value=s_action_index;
		document.frmMain.screen.value='scnBookSteps('+pn_step+')';
		//alert('test');
		Do_SubmitForm();

    }
    function wizardstep_Switch(pn_GotoStep, pn_SaveStep, pn_silentmode){

    	if (String(pn_silentmode)=='undefined')
    		pn_silentmode=0;
    	else
    		pn_silentmode=1;

    	var s_action='';
    	var s_action_index='';
    	var sz_screen=document.frmMain.thisscreen.value;
    	//alert(sz_screen);
		if (sz_screen=='scnProdGroup'){
			document.frmMain.producttype.value='';
			sz_screen='scnVendorHome';
		}

		//alert(sz_screen);
		switch (sz_screen){
		case "GDSAirSearch":
		case "scnQuote":
		case "scnQuoteNew":
			if (ValidateForm()){
				SetupDate('startdate');
				SetupDate('enddate');
			}else{
				return;
			}
			break;
		case "scnCustomer":
			s_action='saveunquote,'+pn_SaveStep;
			break;
		case "scnGolfRounds":
			document.frmMain.vendor_step.value=0;

			//var a_action_index=String(pn_Index).split(',');
			var a_action_index=String(document.frmMain.action_indexes.value).split(',');
			//alert(document.frmMain.action_indexes.value);

			var n_counter=0;
			var n_counter_max=a_action_index.length;

			var s_good_indexes='';


			for (n_counter=0;n_counter<n_counter_max ;n_counter++){
				var n_index=a_action_index[n_counter];
				//if (Validate_SellProduct(n_index, 1)){
					if (s_good_indexes != ''){
						s_good_indexes+=',';
					}
					s_good_indexes+=1+n_counter;
				//}
			}
			document.frmMain.action_index.value=s_good_indexes;
			//s_action ='saveunquote,'+pn_step;
			//document.frmMain.screen.value='scnWizardSteps';
			document.frmMain.screen.value='scnWizardSteps('+pn_GotoStep+',1)';
			document.frmMain.sAction.value='saveunquote,'+pn_SaveStep;

/*
			if (pn_step==0){ //saving at step 0 here is always alacarte because
							 //the trip quote info is always step 0 during the wizard
				document.frmMain.screen.value='scnAlaCarteSteps';
				document.frmMain.sAction.value='saveunquote';
				Do_SubmitForm();
			}else{
				document.frmMain.screen.value='scnWizardSteps';
				document.frmMain.sAction.value='saveunquote,'+pn_step;
			}
*/
			Do_SubmitForm();
			return;

			break;

		case "scnVendorHome":
		case "scnVendorHome_Quote_Unit":
		case "scnVendorHome_Quote_Person":
		case "scnSell_Special":

			//service_skip
			var s_value_skip=getFieldValue('service_skip');
			if (!s_value_skip){
				var a_action_index=String(document.frmMain.action_indexes.value).split(',');
				//alert(a_action_index);
				var n_counter=0;
				var n_counter_max=a_action_index.length;

				for (n_counter=0;n_counter<n_counter_max ;n_counter++){
					var n_index=a_action_index[n_counter];
					var s_value_skip_item=getFieldValue('skip_'+n_index);
					if (s_value_skip_item){
						continue;
					}

					if (!pn_silentmode && !Validate_SellProduct(n_index,pn_silentmode))
						return;

					if (s_action_index != ''){
						s_action_index+=',';
					}
					s_action_index+=1+n_counter;
					/*
					if (Validate_SellProduct(n_index,pn_silentmode)){
					}else{
						if (!pn_silentmode) {
							return;
						}
					}
					*/
				}
			}
			//s_action_index=a_action_index.join(',');
			////if (s_action_index != '' ) s_action ='saveunquote,'+pn_step;
			s_action ='saveunquote,'+pn_SaveStep;
			break;
		case "scnContent_ProductDest":
		case "scnValidation":
			//no validation needed
			break;
		default:
			//alert(sz_screen);
		}
		document.frmMain.vendor_step.value=0;
		document.frmMain.sAction.value=s_action;
		document.frmMain.action_index.value=s_action_index;
		document.frmMain.screen.value='scnWizardSteps('+pn_GotoStep+',1)';
		Do_SubmitForm();

    }
    function wizardstep_Skip(pn_step){
    	var sz_screen=document.frmMain.thisscreen.value;
			document.frmMain.screen.value='scnWizardSteps';
			document.frmMain.sAction.value='skip,'+pn_step;
			Do_SubmitForm();
    }
    function wizardstep_Step(pn_step, ps_type, ps_value, ps_AltScreen){

		if (String( ps_type )!="undefined" && ps_type != '') {
			var sz_screen=document.frmMain.thisscreen.value;
			document.frmMain.elements[ps_type].value=ps_value;
		}
		if (String( ps_AltScreen )!="undefined" ) {
			document.frmMain.screen.value='scnWizardSteps('+pn_step+',0,0,"'+ps_AltScreen+'")';

		}else{
			document.frmMain.screen.value='scnWizardSteps('+pn_step+')';
		}
		//setFieldValue(ps_type,ps_value);

		document.frmMain.sAction.value='';
		Do_SubmitForm();

    }
    function wizardstep_MultiUpdate(pb_check,ps_name){
		//alert('wizardstep_MultiUpdate: '+ps_name);

		var o_name_flag=document.frmMain.elements[ps_name+'_flag'];
		if (String(o_name_flag)=='undefined'){
			return;
		}
		o_name_flag.value=1;

		var a_name=String(ps_name).split('_');
		var s_name_base=a_name[0]+'_';
		var n_index_base=a_name[1];

		if (s_name_base=='code2_'){
			return;
		}

		var s_value=getFieldValue(ps_name);
		var s_multitype_base=getFieldValue('multitype_'+n_index_base);


		var a_action_index=String(document.frmMain.action_indexes.value).split(',');
		var n_counter=0;
		var n_counter_max=a_action_index.length;

		for (n_counter=0;n_counter<n_counter_max ;n_counter++){
			var n_index=a_action_index[n_counter];
			if (n_index<= n_index_base) continue;
			var s_name=s_name_base+n_index;

			var s_multitype=getFieldValue('multitype_'+n_index);

			var o_name_flag=document.frmMain.elements[s_name+'_flag'];
			//alert(
			if (!o_name_flag.value && (!pb_check || s_multitype==s_multitype_base)){
				setFieldValue(s_name, s_value, '');
			}

		}



    }
	function Validate_SellProduct(pn_Index, pb_NoNoise){
		//alert('cp'+pn_Index);
		var fld_vendor=			document.frmMain.elements['vendor_'+pn_Index];
		var fld_pricecode=		document.frmMain.elements['pricecode_'+pn_Index];
		var fld_code2=			document.frmMain.elements['code2_'+pn_Index];
		var fld_servicestarts=	document.frmMain.elements['servicestarts_'+pn_Index];
		var fld_serviceends=	document.frmMain.elements['serviceends_'+pn_Index];
		//alert(fld_vendor);
		SetupDate('servicestarts_'+pn_Index);
		SetupDate('serviceends_'+pn_Index);

		var s_NoVendor, s_NoPriceCode, s_Code2,s_NoDate;
        if (pb_NoNoise){
			s_NoDate='';
			s_NoVendor='';
			s_NoPriceCode='';
			s_Code2='';
        }else{
			s_NoDate="Please choose a date. This is required information.";
			s_NoVendor="Please choose a list item. This is required information.";
			s_NoPriceCode="Please choose a list item. This is required information.";
			s_Code2="Please choose a valid list item. This is required information.";
        }

        if (isSelected(fld_servicestarts,s_NoDate))return false;
        if (isSelected(fld_serviceends,s_NoDate))return false;
        if (isSelected(fld_vendor,s_NoVendor))return false;
        if (isSelected(fld_pricecode,s_NoPriceCode))return false;
        if (isSelected(fld_code2,s_Code2))return false;

        return true;

	}
	function doubleSplit(s_delim1,s_delim2, s_data){
		//return a 2-dimensional array

		var a_return=[];
		if (!s_data){
			return a_return;
		}

		a_return=String(s_data).split(s_delim1);

		var n_counter=0;
		var n_counter_max=a_return.length;

		for (n_counter=0;n_counter<n_counter_max ;n_counter++){
			a_return[n_counter]=String(a_return[n_counter]).split(s_delim2);

		}
		return a_return;
	}
	function getDblParseValue(s_field,s_delim1,s_delim2,s_search){
		//ex
		// s_field =_Qty_Special-CASD1_Cat-1_Price-119
		// s_delim1=_
		// s_delim2=-
		// s_search=Price

		var a_field=String(s_field).split(s_delim1);
		var n_counter=0;
		var n_counter_max=a_field.length;

		for (n_counter=0;n_counter<n_counter_max ;n_counter++){
			var sa_item=a_field[n_counter];
			if (sa_item == '') {
				continue;

			}
			var a_item=String(sa_item).split(s_delim2);
			if (a_item.length<2) {
				continue;
			}
			if (s_search == a_item[0]) {
				return a_item[1];
			}

		}
		return '';

	}
	function formatCurrency(s_number, s_currency){
		var n_number=Number(s_number)*100;
		n_number=Math.round(n_number)/100;
		//there is now no more than two digits behind the decimal point, we need to make there is two

		var a_number=String(n_number).split('.');
		var s_number_whole=String(a_number[0]);
		var s_number_remainder;
		if (a_number.length==1){
			s_number_remainder="00";
		}else if (a_number[1]<10) {
			s_number_remainder=String(a_number[1])+'0';
		}else{
			s_number_remainder=String(a_number[1]);
		}

		return s_number_whole+"."+s_number_remainder;
	}
	function wizardstep_Next_Group(ps_reqFields){
    	if (String(ps_reqFields)=='undefined'){ps_reqFields="";}

		if (ps_reqFields != "") {
			if (!ValidateForm(0,ps_reqFields)){
				return;
			}
		}
		Do_SubmitForm();
	}
	function wizardstep_Next_Specials_AutoCalc(){

		SetupDate('servicestarts_0');
		SetupDate('serviceends_0');


		var s_field_delim1='``_';//seperates different items
		var s_field_delim2='``-';//item name-value seperator
		var s_field_delim3='``#';//row delimeter

		var s_autocalc_save='';

		var s_fields=getFieldValue("_autocalc_fields");
		var a_fields=String(s_fields).split(',');
		var n_counter=0;
		var n_counter_max=a_fields.length;

		var b_found_req_product=0;

		for (n_counter=0;n_counter<n_counter_max ;n_counter++){
			var s_field=a_fields[n_counter];
			if (s_field == '') {
				continue;

			}
			var n_qty=Number(getFieldValue(s_field));
			if (n_qty>0) {

				s_autocalc_save=s_autocalc_save+s_field+
					s_field_delim1+"Qty"+s_field_delim2+String(n_qty)+
					s_field_delim1+"ServiceStarts"+s_field_delim2+getFieldValue("servicestarts_0")+
					s_field_delim1+"ServiceEnds"+s_field_delim2+getFieldValue("serviceends_0")+
					s_field_delim3;

				//alert(s_autocalc_save);
				var s_cat=getDblParseValue(s_field,s_field_delim1,s_field_delim2,'Cat');
				if (s_cat != '') {
					//Required specials have a Cat
					b_found_req_product=1;
				}
			}

		}
		if (!b_found_req_product) {
			alert('You must select at least one of a special category.');
			return;
		}
		setFieldValue("_autocalc_save",s_autocalc_save);
		setFieldValue("_autocalc_fields",'');
		//alert(s_autocalc_save);
		wizardstep_AddProduct(0,0,"scnSell_Special");
	}

	function wizardstep_AutoCalc(){


		var s_field_delim1='``_';
		var s_field_delim2='``-';
		var s_field_delim3='``#';

		var n_autocalc_value=0;
		var n_autocalc_deposit=0;

		var s_fields=getFieldValue("_autocalc_fields");
		var a_fields=String(s_fields).split(',');
		var n_counter=0;
		var n_counter_max=a_fields.length;

		for (n_counter=0;n_counter<n_counter_max ;n_counter++){
			var s_field=a_fields[n_counter];
			if (s_field == '') {
				continue;

			}
			//alert("**"+s_field);
			var n_qty=Number(getFieldValue(s_field));
			if (n_qty>0) {
				var n_price=  Number(getDblParseValue(s_field,s_field_delim1,s_field_delim2,'Price'));
				var n_deposit=Number(getDblParseValue(s_field,s_field_delim1,s_field_delim2,'Deposit'));
				n_autocalc_value=n_autocalc_value+(n_qty*n_price);
				n_autocalc_deposit=n_autocalc_deposit+(n_qty*n_deposit);
			}

			//alert();
			//alert(s_field);
		}
		setFieldValue("_autocalc_value",formatCurrency(n_autocalc_value));
		setFieldValue("_autocalc_deposit",formatCurrency(n_autocalc_deposit));
		//alert(n_autocalc_value);
		//alert(getFieldValue());

	}
	function wizardstep_AddProduct(pn_step, pn_Index, ps_Screen){
    	if (String(pn_step)=='undefined'){pn_step="";}
    	if (String(ps_Screen)!='undefined'){document.frmMain.thisscreen.value=ps_Screen;}
    	var sz_screen=document.frmMain.thisscreen.value;
    	if (sz_screen=="scnContent_ProductDest"){
    		sz_screen="scnVendorHome";
    	}
		switch (sz_screen){
		case "scnVendorHome":
			if (Validate_SellProduct(pn_Index)){
				if (pn_step==0){ //saving at step 0 here is always alacarte because
								 //the trip quote info is always step 0 during the wizard
					//document.frmMain['startdate'].value=document.frmMain['servicestarts_'+pn_Index].value;
					//document.frmMain['enddate'].value=document.frmMain['serviceends_'+pn_Index].value;

					document.frmMain.screen.value='scnAlaCarteSteps';
					document.frmMain.sAction.value='saveunquote';
					document.frmMain.action_index.value=1+pn_Index;
					Do_SubmitForm();
				}else{
					document.frmMain.screen.value='scnWizardSteps';
					document.frmMain.sAction.value='saveunquote,'+pn_step;
					document.frmMain.action_index.value=1+pn_Index;
					Do_SubmitForm();
				}
			}
			break;
		case "scnSell_Special":
			if (Validate_SellProduct(0)){
				//document.frmMain.template.value='scnSell_Special';
				document.frmMain.action_index.value=1;
				document.frmMain.screen.value='action_SaveSpecial';
				document.frmMain.sAction.value='saveunquote';
				//document.frmMain.quotestep.value=pn_QuoteStep;
				Do_SubmitForm();
			}
			break;

		default:
			alert('can not find screen to save: '+sz_screen);
		}

    }
    function wizardstep_Skip(pn_step, pn_Index){
    	if (String(pn_step)=='undefined'){pn_step="";}
    	if (String(pn_Index)=='undefined'){pn_Index=0;}
    	var sz_screen=document.frmMain.thisscreen.value;

		switch (sz_screen){
		case "scnVendorHome":
			document.frmMain.screen.value='scnWizardSteps';
			document.frmMain.sAction.value='skip,'+pn_step;
			document.frmMain.action_index.value=1+pn_Index;
			Do_SubmitForm();
			break;
		case "scnSell_Special":
			document.frmMain.screen.value='scnWizardSteps';
			document.frmMain.sAction.value='skip,'+pn_step;
			Do_SubmitForm();
			break;
		default:
			alert('can not find screen to save: '+sz_screen);
		}

    }

    function wizardstep_Next(pn_step, pn_Index, ps_SaveScreen, ps_thisscreen, ps_reqFields, ps_field, ps_fieldvalue){
    	if (String(pn_step)=='undefined'){pn_step="";} pn_step=Number(pn_step);
    	if (String(pn_Index)=='undefined'){pn_Index=0;}
    	if (String(ps_thisscreen)!='undefined'){document.frmMain.thisscreen.value=ps_thisscreen;}
    	if (String(ps_reqFields)!='undefined'){document.frmMain.reqFields.value=ps_reqFields;}
    	if (String(ps_field)=='undefined'){ps_field="";}
    	if (String(ps_fieldvalue)=='undefined'){ps_fieldvalue="";}
		if (String(ps_field)!=''){
			document.frmMain[ps_field].value=ps_fieldvalue;
		}
		var n_gotostep=1+Number(pn_step);
    	if (ps_SaveScreen=='scnBookSteps' || ps_SaveScreen=='scnSavePayment'){
    		document.frmMain.action=document.frmMain.secure_url.value;
    	}else if (ps_SaveScreen=='scnWizardSteps'){
			ps_SaveScreen='scnWizardSteps('+n_gotostep+')';
    	}


    	var sz_screen=document.frmMain.thisscreen.value;

		switch (sz_screen){
		case "NewQuote_Min":
		case "scnTrips":
		case "scnLogon":
		case "scnTerms":
		case "scnTravelers":
		case "scnBookGDSAir":
		case "scnTravelers_GDS":
		case "scnPayments":
		case "scnCustomer":
		case "scnQuoteComment":
			if (ValidateForm()){

				document.frmMain.sAction.value='Next,'+pn_step;
				document.frmMain.screen.value=ps_SaveScreen;
				//alert(document.frmMain.action);
				Do_SubmitForm();
			}
			break;
		case "GDSAddAir_quote":
			//adding air tsi here
			if (ValidateForm()){

				if (pn_step==0){ //saving at step 0 here is always alacarte because
								 //the trip quote info is always step 0 during the wizard
					//document.frmMain.sAction.value='Next,'+pn_step;
					document.frmMain.sAction.value='saveunquote';
					ps_SaveScreen='scnAlaCarteSteps';
				}else{
					document.frmMain.sAction.value='saveunquote,'+pn_step;
					ps_SaveScreen='scnWizardSteps('+(1+pn_step)+')';
					//ps_SaveScreen='scnWizardSteps('+(1+pn_step)+')';

				}

				document.frmMain.screen.value=ps_SaveScreen;
				document.frmMain.action_index.value=1+pn_Index;
				Do_SubmitForm();
			}
			break;
		case "GDSAirSearch":
			if (ValidateForm()){
				if (pn_step==0){ //saving at step 0 here is always alacarte because
								 //the trip quote info is always step 0 during the wizard
					//document.frmMain.sAction.value='Next,'+pn_step;
					document.frmMain.sAction.value='';
					ps_SaveScreen='scnAlaCarteSteps';
				}else{
					document.frmMain.sAction.value='Next,'+pn_step;
					ps_SaveScreen='scnWizardSteps('+pn_step+')';
				}
				document.frmMain.screen.value=ps_SaveScreen;
				Do_SubmitForm();
			}
			break;
		case "scnQuote":
		case "scnQuoteNew":
			if (ValidateForm()){
				document.frmMain.sAction.value='Next,'+pn_step;
				document.frmMain.screen.value='scnWizardSteps('+(1+pn_step)+')';
				SetupDate('startdate');
				SetupDate('enddate');
				Do_SubmitForm();
			}
			break;
		case "scnGolfRounds":
			document.frmMain.vendor_step.value=0;

			var a_action_index=String(pn_Index).split(',');
			var n_counter=0;
			var n_counter_max=a_action_index.length;

			var s_good_indexes='';


			for (n_counter=0;n_counter<n_counter_max ;n_counter++){
				var n_index=a_action_index[n_counter];
				//if (Validate_SellProduct(n_index, 1)){
					if (s_good_indexes != ''){
						s_good_indexes+=',';
					}
					s_good_indexes+=1+n_counter;
				//}
			}
			document.frmMain.action_index.value=s_good_indexes;

			if (pn_step==0){ //saving at step 0 here is always alacarte because
							 //the trip quote info is always step 0 during the wizard
				document.frmMain.screen.value='scnAlaCarteSteps';
				document.frmMain.sAction.value='saveunquote';
				Do_SubmitForm();
			}else{
				document.frmMain.screen.value='scnWizardSteps('+(1+pn_step)+')';
				document.frmMain.sAction.value='saveunquote,'+pn_step;
			}
			//alert("screen "+document.frmMain.screen.value);
			//alert("action "+document.frmMain.sAction.value);
			Do_SubmitForm();
			break;
		case "scnVendorHome":
			if (Validate_SellProduct(pn_Index)){
				document.frmMain.screen.value='scnWizardSteps('+(1+pn_step)+')';
				document.frmMain.sAction.value='saveunquote,'+pn_step;
				document.frmMain.action_index.value=1+pn_Index;
				Do_SubmitForm();
			}
			break;
		case "scnSell_Special":
			if (ValidateForm()){
				document.frmMain.screen.value='scnWizardSteps('+(1+pn_step)+')';
				document.frmMain.sAction.value='saveunquote,'+pn_step;
				Do_SubmitForm();
			}
			break;
		default:
			//alert('can not find screen to save: '+sz_screen);
		}

    }
    function content_changeTemplate(ps_template){
		if (String(document.frmMain.template)=="undefined"){
			return;
		}
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }
    function content_changeTemplateDestination(ps_template, ps_dest){
		document.frmMain.dest.value=ps_dest;
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }
	function clearActionFields(){
		if (	String(document.frmMain.reqFields)=='undefined' ||
				String(document.frmMain.sAction)=='undefined' ||
				String(document.frmMain.action_index)=='undefined' ||
				String(document.frmMain.action_indexes)=='undefined' ||
				String(document.frmMain.tamode)=='undefined' ||
				String(document.frmMain.startdate)=='undefined' ||
				String(document.frmMain.enddate)=='undefined'
		){
			return 0;
		}
		document.frmMain.startdate.value='';
		document.frmMain.enddate.value='';

		document.frmMain.reqFields.value='';
		document.frmMain.sAction.value='';
		document.frmMain.action_index.value='';
		document.frmMain.action_indexes.value='';
		document.frmMain.tamode.value='';
	}
	function clearQuoteFields(){
		if (	String(document.frmMain.resno)=='undefined' ||
				String(document.frmMain.unQuoted)=='undefined' ||
				String(document.frmMain.FailQuoted)=='undefined' ||
				String(document.frmMain.Quoted)=='undefined' ||
				String(document.frmMain.popQuoted)=='undefined'
		){
			return 0;
		}

		document.frmMain.resno.value='';
		document.frmMain.popQuoted.value='';
		document.frmMain.unQuoted.value='';
		document.frmMain.FailQuoted.value='';
		document.frmMain.Quoted.value='';
	}
	function isMiddleQuote(){
		if (	String(document.frmMain.resno)=='undefined' ||
				String(document.frmMain.unQuoted)=='undefined' ||
				String(document.frmMain.FailQuoted)=='undefined' ||
				String(document.frmMain.Quoted)=='undefined' ||
				String(document.frmMain.popQuoted)=='undefined'
		){
			return 0;
		}

		return (!(document.frmMain.resno.value=='' && document.frmMain.unQuoted.value=='' && document.frmMain.FailQuoted.value=='' && document.frmMain.Quoted.value=='' && document.frmMain.popQuoted.value==''));
	}

    function changeLink(pl,superdest,dest,producttype,special,vendor,screen){
	//must match perl getlink function
		document.frmMain.pl.value=pl;
		document.frmMain.superdest.value=superdest;
		document.frmMain.dest.value=dest;
		document.frmMain.producttype.value=producttype;
		document.frmMain.special.value=special;
		document.frmMain.vendor.value=vendor;
		document.frmMain.screen.value=screen;
		Do_SubmitForm();
    }
    function changeLink_confirm(pl,superdest,dest,producttype,special,vendor,screen){
	//must match perl getlink function
		if (!isMiddleQuote() || confirm("You are about to leave your current trip. As a reminder, you can click \"Saved Trips\" to return to this and other trips in the future.  \n\nDo you wish to continue?")){
			clearQuoteFields();
			clearActionFields();
			document.frmMain.pl.value=pl;
			document.frmMain.superdest.value=superdest;
			document.frmMain.dest.value=dest;
			document.frmMain.producttype.value=producttype;
			document.frmMain.special.value=special;
			document.frmMain.vendor.value=vendor;
			document.frmMain.screen.value=screen;
			Do_SubmitForm();
		}
    }

    function changePage_confirm(ps_screen){
		if (!isMiddleQuote() || confirm("You are about to leave your current trip. As a reminder, you can click \"Saved Trips\" to return to this and other trips in the future.  \n\nDo you wish to continue?")){
			clearQuoteFields();
			clearActionFields();
			if (ps_screen=='scnWizardSteps'){
			  SetupDate('startdate');
			  SetupDate('enddate');

			}
			document.frmMain.screen.value=ps_screen;
			Do_SubmitForm();
		}
    }
    function contentex_changeDestScreen(ps_dest, ps_screen){
		if (String(ps_dest)=='undefined'){
			ps_dest="";
		}
		if (!isMiddleQuote() || confirm("You are about to leave your current trip. As a reminder, you can click \"Saved Trips\" to return to this and other trips in the future.  \n\nDo you wish to continue?")){
			clearQuoteFields();
			clearActionFields();
			document.frmMain.dest.value=ps_dest;
			document.frmMain.screen.value=ps_screen;
			Do_SubmitForm();
		}
    }
    function content_changeScreenDestination(ps_screen, ps_dest){
		if (String(ps_dest)=='undefined'){
			ps_dest="";
		}
		clearActionFields();
		document.frmMain.dest.value=ps_dest;
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }
    function content_changeTemplateSpecial(ps_template, ps_special){
		document.frmMain.special.value=ps_special;
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }
    function content_changeScreenSpecialDest(ps_screen, ps_special, ps_dest){
		document.frmMain.dest.value=ps_dest;
		document.frmMain.special.value=ps_special;
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }
    function content_changeScreenSpecial(ps_screen, ps_special){
		clearActionFields();
		document.frmMain.special.value=ps_special;
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }
    function content_changeScreen(ps_screen){
		clearActionFields();
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }
    function content_changeTemplateSuperDest(ps_template, ps_superdest){
		document.frmMain.superdest.value=ps_superdest;
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }
    function content_changeScreenSuperDest(ps_screen, ps_superdest){
		clearActionFields();
		document.frmMain.superdest.value=ps_superdest;
		document.frmMain.dest.value='';
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }

	function getFieldValue(s_name){

		var o_name;
		if(String(s_name)==s_name){
			//grab the object from the form
			o_name=document.frmMain.elements[s_name];

			//alert(o_name);

			if(String(o_name)=='undefined'){
				o_name=getDocItem( s_name );
			}
			//alert(o_name);


		}else{
			//assume its an object
			o_name=s_name;
		}
		if(String(o_name)=='undefined' || String(o_name)=='null'){return '';}
		var s_tagname=o_name.tagName;
		if(String(s_tagname)=='undefined' || String(s_tagname)==''){return '';}

		switch (s_tagname){
		case "SELECT":
			return o_name.options[o_name.selectedIndex].value;
		case "DIV":
		case "SPAN":
			if (String(o_name.innerText)=="undefined"){
				//for mozilla
				return o_name.innerHTML;
			}else{
				//for ie
				return o_name.innerText;
			}
		case "TEXTAREA":
			return o_name.innerText;

		case "INPUT":
			var s_type=o_name.type;

			switch (s_type){
			case "radio":
				return o_name.options[o_name.selectedIndex].value;
			case "checkbox":
				return !(!o_name.checked);
			case "text":
			case "hidden":
				return o_name.value;
			default:
				alert("INPUT_"+s_type);
				return;
			}
		default:
			alert("getFieldValue::Error Can not find handler for field: "+s_name+" type: "+s_tagname);
		}
	}

	function setFieldValue(s_name, s_value, s_desc, b_force){
		//provide a default value of s_desc
		if(String(s_desc)=='undefined' || s_desc==''){s_desc=s_value}

		var o_name;
		if(String(s_name)==s_name){
			//grab the object from the form
			o_name=document.frmMain.elements[s_name];

			//alert(o_name);

			if(String(o_name)=='undefined'){
				o_name=getDocItem( s_name );
			}
			//alert(o_name);


		}else{
			//assume its an object
			o_name=s_name;
		}

		if(!isObject(o_name)){

			if (!b_force){ return ''; }
			var s_html=document.frmMain.innerHTML; s_html+='<input type=hidden name="'+s_name+'" value="'+s_value+'">';
			document.frmMain.innerHTML=s_html;
			return '';
		}
		var s_tagname=o_name.tagName;
		if(String(s_tagname)=='undefined' || String(s_tagname)==''){return '';}

		switch (s_tagname){
		case "SELECT":
			if (!options_set(o_name, s_value)){
				options_add(o_name, s_desc, s_value);
			}
			break;
		case "DIV":
		case "SPAN":
			if (String(o_name.innerText)=="undefined"){
				//for mozilla
				o_name.innerHTML=s_value;
			}else{
				//for ie
				o_name.innerText=s_value;
			}
			break;
		case "INPUT":
			var s_type=o_name.type;

			switch (s_type){
			case "radio":
				if (!options_set(o_name, s_value)){
					options_add(o_name, s_desc, s_value);
				}
				break;
			case "checkbox":
				o_name.checked=(s_value);
				break;
			case "text":
			case "hidden":
				o_name.value=s_value;
				break;
			default:
				alert("INPUT_"+s_type);
				//return;
			}
			break;

		default:
			alert("setFieldValue::Error Can not find handler for field: "+s_name+" type: "+s_tagname);
			//o_name.value=s_value;
		}
		return s_value;
	}

    function content_changeScreenVendor(ps_screen, ps_vendor, fld_vendor){
		if(String(fld_vendor)=='undefined' || fld_vendor==''){
			fld_vendor='vendor';
		}
		setFieldValue(fld_vendor,ps_vendor);

		if(String(fld_vendor)!='vendor'){
			setFieldValue('vendor',ps_vendor);
		}

		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
    }

    function content_changeTemplateVendor(ps_template, ps_vendor){
		document.frmMain.vendor.value=ps_vendor;
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }

	function content_changePageProduct (ps_screen, ps_product){
		if (String(document.frmMain.screen)=="undefined"){
			return;
		}
		document.frmMain.vendor.value='';
		document.frmMain.special.value='';
		document.frmMain.producttype.value=ps_product;
		document.frmMain.screen.value=ps_screen;
		Do_SubmitForm();
	}
    function content_changeTemplateProduct(ps_template, ps_product){
		document.frmMain.producttype.value=ps_product;
		document.frmMain.screen.value='scnShowTemplate';
		Do_SubmitForm();
    }



    function ValidateFormStep(){
    	var sz_screen=document.frmMain.thisscreen.value;
    	switch(sz_screen){

		case "scnLessons":
    	case 'scnSkiRental':
    	case 'scnTravelInsurance':
    	case 'scnLiftTicket':
    	case 'scnLodging':
    	case 'scnCar':
	        if (isSelected(document.frmMain.vendor,"Please choose a valid vendor. This is required information."))return false;
        	break;
        }
        return (true);
    }

    function VendorClick(pn_QuoteStep){
		document.frmMain.quotestep.value=pn_QuoteStep;
		document.frmMain.sAction.value='';
		Do_SubmitForm();
    }


    function ValidateForm(pb_Noiseless,ps_reqFields,ps_FormName){
    	var sz_screen=getFieldValue('thisscreen');
		if(String(ps_reqFields)=='undefined' || ps_reqFields==''){
	    	ps_reqFields=getFieldValue('reqFields');
		}
		if(String(ps_FormName)=='undefined' || ps_FormName==''){
	    	ps_FormName='frmMain';
		}
		//alert("ValidateForm--screen:"+ sz_screen);
    	switch(sz_screen){
    	case 'scnQuote':
			var oAdults=document.frmMain.noadults;
			var oChildren=document.frmMain.nochildren;
			var ipeople=Number(document.frmMain.nochildren.options[document.frmMain.nochildren.selectedIndex].value) + Number(document.frmMain.noadults.options[document.frmMain.noadults.selectedIndex].value);
			document.frmMain.people.value=ipeople;
	        if (isSelected(document.frmMain.dest,"Please choose a destination. This is required information."))return false;

    		break;
		case 'scnBookGDSAir':
			break;
    	case 'scnGolfRounds':
    		break;
/*
    	case 'scnSell_Special':

	        if (isSelected(document.frmMain.code2_0,"Please choose a valid category. This is required information."))return false;
			//return false;
			break;
*/

		case "scnTravelers_GDS":
			var n_gdstravs=Number(document.frmMain.nogdstravs.value);
			//alert(n_gdstravs);

			for (var n_counter=0; n_counter<n_gdstravs; n_counter++){
				//alert(n_counter);
		        if (!pb_Noiseless && !ValidateTraveler_GDS(n_counter)){
					return;
		        }
			}
			break;

				/* case "scnTravelers":                                                                                                                         */
				/*     var o_noadults=document.frmMain.noadults;                                                                                                */
				/*     var o_nochildren=document.frmMain.nochildren;                                                                                            */
				/*     var o_nopeople=document.frmMain.people;                                                                                                  */
				/*     var n_travs=Number(o_noadults.value)+Number(o_nochildren.value);                                                                         */
				/*     var n_adults=0;                                                                                                                          */
				/*     var n_children=0;                                                                                                                        */
				/*     var s_children="";                                                                                                                       */
				/*     var n_childage=0;                                                                                                                        */
				/*                                                                                                                                              */
				/*                                                                                                                                              */
				/*     for (var n_counter=0; n_counter<n_travs; n_counter++){                                                                                   */
				/*         if (!pb_Noiseless && !ValidateTraveler(n_counter)){                                                                                  */
				/*             return;                                                                                                                          */
				/*         }                                                                                                                                    */
				/*         if (n_counter>0){                                                                                                                    */
				/*             s_children+=",";                                                                                                                 */
				/*         }                                                                                                                                    */
				/*         if(!document.frmMain['travtype'+n_counter][0].checked){                                                                              */
				/*             n_children++;                                                                                                                    */
				/*             if (!document.frmMain['travage'+n_counter].selectedIndex){                                                                       */
				/*                 n_childage="C";                                                                                                              */
				/*             }else{                                                                                                                           */
				/*                 n_childage=Number(document.frmMain['travage'+n_counter].options[document.frmMain['travage'+n_counter].selectedIndex].value); */
				/*             }                                                                                                                                */
				/*             //document.frmMain['childage'+n_children].value=n_childage;                                                                      */
				/*             s_children+=n_childage;                                                                                                          */
				/*         }else{                                                                                                                               */
				/*             n_adults++;                                                                                                                      */
				/*             s_children+="A";                                                                                                                 */
				/*         }                                                                                                                                    */
				/*         //alert(s_children);                                                                                                                 */
				/*         //alert('res_adult_last'+n_counter);                                                                                                 */
				/*         //alert(document.frmMain['bookingstep'].value);                                                                                      */
				/*                                                                                                                                              */
				/*     }                                                                                                                                        */
				/*     //alert(n_adults + " " + n_children);                                                                                                    */
				/*                                                                                                                                              */
				/*     document.frmMain['book_ageschildren'].value=s_children;                                                                                  */
				/*     o_noadults.value=n_adults;                                                                                                               */
				/*     o_nochildren.value=n_children;                                                                                                           */
				/*     //alert("No. children: "+n_children);                                                                                                    */
				/*     o_nopeople.value=n_adults+n_children;                                                                                                    */
				/*                                                                                                                                              */
				/*     //res_adult_last                                                                                                                         */
				/*     //res_adult_first                                                                                                                        */
				/*     //travcomment                                                                                                                            */
				/*     //travtype: 1=adult; 0=child                                                                                                             */
				/*     //travage: only applicable if child                                                                                                      */
				/*     break;                                                                                                                                   */

				/* case "scnPayments":                                                                                                                                             */
				/* if (isSelected(document.frmMain.newpay_type,"Please choose a Payment Type. This is required information."))return false;                                        */
				/* if (isNumberPos(document.frmMain.newpay_amount,"Please choose a valid amount greater than 0. This is required information."))return false;                      */
				/* if (isCreditCard(document.frmMain.newpay_creditcard,"Please enter a valid credit card number without punctuation. This is required information."))return false; */
				/* if (isSelected(document.frmMain.newpay_creditcard_mo,"Please select an expiration date. This is required information."))return false;                           */
				/* if (isSelected(document.frmMain.newpay_creditcard_yr,"Please select an expiration date. This is required information."))return false;                           */
				/* if (isBlank(document.frmMain.newpay_creditcardname,"Please enter a valid name. This is required information."))return false;                                    */
				/* //          //if (isAlpha(document.frmMain.newpay_creditcardname,"Please enter a valid name. This is required information."))return false;                      */
				/* return true;                                                                                                                                                    */
				/* //                                                                                                                                                              */
				/* break;                                                                                                                                                          */
				/* //                                                                                                                                                              */
				/* //      case "scnBookTerms":                                                                                                                                    */
				/* //          if(!document.frmMain.chkAgree.checked){                                                                                                             */
				/* //              alert("Please accept the terms before continuing.");                                                                                            */
				/* //              return false;                                                                                                                                   */
				/* //          }                                                                                                                                                   */
				/* //          break;                                                                                                                                              */


    	case 'scnVendorHome':
	        if (document.frmMain.producttype.value=='GO'){
	        }else{
		        if (isBlank(document.frmMain.vendor,(pb_Noiseless)?'':"Please choose a valid vendor. This is required information."))return false;

		        var s_Date1='servicestarts';
		        var s_Date2='serviceends';

				if (Number(document.frmMain.product_useAirport_depart.value)){
		        	if (isSelected(document.frmMain.pricecode,(pb_Noiseless)?'':"Please choose a valid airport. This is required information."))return false;
				}

				if (Number(document.frmMain.product_useAirport_return.value)){
		        	if (isSelected(document.frmMain.code2,(pb_Noiseless)?'':"Please choose a valid airport. This is required information."))return false;
				}
			}


    		break;


		case "NewQuote_Min":
		case "scnCustomerFull":
    	case "scnCustomer":
    	case "scnLogon":
    	case "scnTrips":
		case "scnQuoteComment":
		default:
    	//alert("checkpoint1");

	        var a_reqFields=String(ps_reqFields).split(',');
	        var n_count=0;
	        if (a_reqFields.length>1){
		        for (n_count=0; n_count<a_reqFields.length; n_count+=3){
		        	var s_fieldName=a_reqFields[n_count];
		        	var s_fieldType=String(a_reqFields[n_count+1]);
		        	var s_fieldDesc=a_reqFields[n_count+2];

					if (!s_fieldName || !s_fieldType || !s_fieldDesc) {
						continue;
					}

		        	var o_Field=document[ps_FormName][s_fieldName];

		        	//alert("s_fieldName:"+s_fieldName);
		        	//alert("s_fieldType:"+s_fieldType);
		        	switch (s_fieldType){
		        		case "radio":
		        			if (isNotSelected(o_Field,(pb_Noiseless)?'':'Please choose an option for '+s_fieldDesc+'. This is required information.'))return false;
		        			break;
		        		case "checkbox":
		        			if ( !o_Field.checked ) { alert('Please check the '+s_fieldDesc+'. This is required information.'); return false; }
		        			break;
		        		case "zip":
	        				if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
	        				if (isNonSpecial(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
							//if (!isBlank(document.frmMain.phoneday,'Please enter the '+s_fieldName+'. This is required information.'))return (false);
							//if (!isNonSpecial(document.frmMain.phoneday,"Please enter a valid '+s_fieldName+'. This is required information."))return (false);
		        		case "phone":
	        				if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
	        				if (isNonSpecial(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
							//if (!isBlank(document.frmMain.phoneday,'Please enter the '+s_fieldName+'. This is required information.'))return (false);
							//if (!isNonSpecial(document.frmMain.phoneday,"Please enter a valid '+s_fieldName+'. This is required information."))return (false);
							break;

						case "ccard":
	        				if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
	        				if (isCreditCard(o_Field,(pb_Noiseless)?'':'Please enter a valid credit card number without punctuation. This is required information.'))return false;

		        		case "date":
							SetupDate(s_fieldName);
					    	//alert("checkpoint2:"+s_fieldName);
					        //if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the email address. This is required information.'))return (false);
					        //if (!isEmail(o_Field,(pb_Noiseless)?'':'Please enter a valid email address.'))return (false);
							break;

						case "email":
							var isKelloggs=Number(document.frmMain.pl.value)==25 || Number(document.frmMain.pl.value)==102;
							if (isKelloggs){

								if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the email address. This is required information.'))return (false);
								if (!isEmail(o_Field,(pb_Noiseless)?'':'Please enter a valid Kellog email address.'))return (false);

								if (o_Field.value.indexOf('@kellogg.northwestern.edu')==-1){
									alert('Please enter a valid email address.');
									o_Field.focus();

									return false;
								}

							}else{
								if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the email address. This is required information.'))return (false);
								if (!isEmail(o_Field,(pb_Noiseless)?'':'Please enter a valid email address.'))return (false);
							}
							break;
		        		case "select":
	        				if (isSelected(o_Field,(pb_Noiseless)?'':'Please choose a valid '+s_fieldDesc+'. This is required information.'))return false;
							break;

		        		case "text":
							var isKelloggs=Number(document.frmMain.pl.value)==25 || Number(document.frmMain.pl.value)==102;
							if (isKelloggs && s_fieldName=='groupname'){
								if (!/^[a-zA-Z]{3}[0-9]{3}$/i.test(o_Field.value)){
									alert('Please enter a valid NETID.');
									o_Field.focus();
									return false;
								}

							}else{
								if (isBlank(o_Field,(pb_Noiseless)?'':'Please enter the '+s_fieldDesc+'. This is required information.'))return false;
							}
							break;
						case "undefined":
							break;
		        		default:
		        			alert("Field type not found: "+s_fieldName + " " + s_fieldType + " " + o_Field);
		        	}
		        }
	        }
    		break;



			//alert(sz_screen);
    	}

        return (true);

    }
	function submit_validate(ps_reqFields, ps_FormName){
		if(String(ps_FormName)=='undefined' || ps_FormName==''){
	    	ps_FormName='frmMain';
		}
		if (ValidateForm(0,ps_reqFields, ps_FormName)){
			Do_SubmitForm(ps_FormName);
		}
	}
	function calendar_popup(s_orig_screen, s_orig_template, b_enddate, d1_name, d1_value, d1_desc, 	d2_name, d2_value, d2_desc,	d_min, d_max,  	n_defaultdays, n_mindays, n_maxdays,s_startdates,s_enddates, s_dowstart, s_dowend){

        var sz_Url='booking.pl?screen=scnCalendar_print2';//&m='+sz_Month+'&d='+sz_Day+'&y='+sz_Year+'&f='+pForm+'&en='+pElement;

		sz_Url+='&s_orig_screen='+s_orig_screen;
		sz_Url+='&s_orig_template='+s_orig_template;

		sz_Url+='&calmode_'+d1_name+'='+b_enddate;

		sz_Url+='&d1_name='+d1_name;
		sz_Url+='&d1_value='+d1_value;
		sz_Url+='&d1_desc='+d1_desc;

		sz_Url+='&d2_name='+d2_name;
		sz_Url+='&d2_value='+d2_value;
		sz_Url+='&d2_desc='+d2_desc;

		sz_Url+='&d_min='+d_min;
		sz_Url+='&d_max='+d_max;

		sz_Url+='&n_defaultdays='+n_defaultdays;
		sz_Url+='&n_mindays='+n_mindays;
		sz_Url+='&n_maxdays='+n_maxdays;
		sz_Url+='&s_startdates='+s_startdates;
		sz_Url+='&s_enddates='+s_enddates;
		sz_Url+='&s_dowstart='+s_dowstart;
		sz_Url+='&s_dowend='+s_dowend;


        window.open(sz_Url,'','width=550,height=300, resizable=1');
        //window.open(sz_Url,'','width=550,height=300, resizable=1, status=1, location=1');

	}
	function popup (sz_Url,sz_Name,sz_Details){
        if (String(sz_Url)=='undefined')
			return;
        if (String(sz_Details)=='undefined')
			sz_Details='width=550,height=300, resizable=1';

        window.open(sz_Url,sz_Name,sz_Details);
        return;
	}
	function content_refresh_remote(){
		var s_orig_screen=document.frmMain.s_orig_screen.value;
		var s_orig_template=document.frmMain.s_orig_template.value;

		opener.document.frmMain.screen.value=s_orig_screen;
		//opener.document.frmMain.template.value=s_orig_template;
		opener.document.frmMain.sAction.value='';
		opener.Do_SubmitForm();

	}

	function calendar_setDate(pYear, pMonth, pDay){
		var s_d1_name=document.frmMain.d1_name.value;
		var s_d2_name=document.frmMain.d2_name.value;
		var s_calmode_name='calmode_'+s_d1_name;
		var b_EndDate=(Number(document.frmMain.elements[s_calmode_name].value)==1);

		if (!b_EndDate){ 	//start date
			//var o_d1=document.frmMain.d1_value;
			//alert(s_d1_name);
			//alert(o_d1);
			document.frmMain.d1_value.value=pMonth+'/'+pDay+'/'+pYear;

			//alert(opener)

			var o_day=opener.document.frmMain.elements[s_d1_name+'_1'];
			o_day.options[o_day.selectedIndex].value=100+pDay;

			var o_month=opener.document.frmMain.elements[s_d1_name+'_0'];
			o_month.options[o_month.selectedIndex].value=100+pMonth;

			var o_year=opener.document.frmMain.elements[s_d1_name+'_2'];
			o_year.options[o_year.selectedIndex].value=pYear;

			content_refresh_remote();

			var len_startdates=String(document.frmMain.s_startdates.value).length;
			if (len_startdates>0){
				window.close();
			}else{
				var o_calmode=document.frmMain.elements[s_calmode_name];
				o_calmode.value=1;
				Do_SubmitForm();
			}

		}else{				// end date

			var a_d1=String(document.frmMain.d1_value.value).split('/');

			var n_Month1=Number(a_d1[1]);
			var n_Day1=Number(a_d1[0]);
			var n_Year1=Number(a_d1[2]);


			var o_day=opener.document.frmMain.elements[s_d1_name+'_1'];
			o_day.options[o_day.selectedIndex].value=100+n_Month1;

			var o_month=opener.document.frmMain.elements[s_d1_name+'_0'];
			o_month.options[o_month.selectedIndex].value=100+n_Day1;

			var o_year=opener.document.frmMain.elements[s_d1_name+'_2'];
			o_year.options[o_year.selectedIndex].value=n_Year1;


			var o_day2=opener.document.frmMain.elements[s_d2_name+'_1'];
			o_day2.options[o_day2.selectedIndex].value=100+pDay;

			var o_month2=opener.document.frmMain.elements[s_d2_name+'_0'];
			o_month2.options[o_month2.selectedIndex].value=100+pMonth;

			var o_year2=opener.document.frmMain.elements[s_d2_name+'_2'];
			o_year2.options[o_year2.selectedIndex].value=pYear;

			content_refresh_remote();
			window.close();


		}
	}
    function calendar_changeMonth(pn_Mo){
    	//Do_SubmitForm();
    }
    function calendar_changeYear(pn_Yr){
		//document.frmMain.quotestep.value=pn_QuoteStep;
    	//Do_SubmitForm();
    }
    function calendar_changeDay(pn_Dy){
		//document.frmMain.quotestep.value=pn_QuoteStep;
    	//Do_SubmitForm();
    	alert('NYI');
    }

	function isNotSelected(field, errorString){
		var isvalid;
		for (var x = 0;x < field.length; x++){
			isvalid = field[x].checked;
			if (isvalid) { break; }
		}
		if(!isvalid){
			if (errorString!="") {alert(errorString);}
            return (true);
		}
		return (false);

	}

    function isBlank(field, errorString){
        if (String(field)=='undefined'){
        	return false;
        }
        if (field.value == ""){
            if (errorString!="") {alert(errorString);field.focus();}
            return (true);

        }

        return (false);

    }

    function isEmail(field, errorString){
        var n_tmp1=field.value.indexOf("@");
        var n_tmp2=field.value.indexOf(".");
        //var isEmail= (n_tmp1!=-1 && n_tmp2 > n_tmp1)
        var isEmail= (n_tmp1!=-1 && n_tmp2 !=-1);

        //var isEmail = ((field.value.indexOf("@")!= -1)&& (field.value.indexOf(".")!= -1));
        if (!isEmail){
            if (errorString!="") {alert(errorString);field.focus();}
            return (false);

        }

        return (true);

    }

	function sinDateValidate(s_Date1, s_Date2){
        if(Number(document.frmMain.TsisUseCalendar.value)){
	        if (isDateGood('servicestarts',"Please enter a valid date. This is required information."))return false;
			var dtServiceStarts=new Date(parsedate_pd('servicestarts'));
			var dtTripEnds=new Date(parsedate_tb('enddate'));
			var dtTripBegins=new Date(parsedate_tb('startdate'));
			var nDaysAfter=Math.abs((dtTripEnds-dtServiceStarts)/86400000);
			var nDaysBefore=Math.abs((dtTripBegins-dtServiceStarts)/86400000);
			if (dtServiceStarts<dtTripBegins){alert("Please select a valid date. The service start date is "+nDaysBefore+" day(s) before the trip start date.");return false;}
			if (dtServiceStarts>dtTripEnds){alert("Please select a valid date. The service start date is "+nDaysAfter+" day(s) after the trip end date.");return false;}
		}else{
		}
		return true;
	}

	function dblDateValidate(s_Date1, s_Date2){
        if(Number(document.frmMain.TsisUseCalendar.value)){
	        if (isDateGood(s_Date1,"Please enter a valid date. This is required information."))return false;
	        if (isDateGood(s_Date2,"Please enter a valid date. This is required information."))return false;
			var dtServiceStarts=new Date(parsedate_pd(s_Date1));
			var dtServiceEnds=new Date(parsedate_pd(s_Date2));
			var dtTripEnds=new Date(parsedate_tb('enddate'));
			var dtTripBegins=new Date(parsedate_tb('startdate'));
			var nDaysAfter=Math.abs((dtTripEnds-dtServiceEnds)/86400000);
			var nDaysBefore=Math.abs((dtTripBegins-dtServiceStarts)/86400000);
			if (dtServiceStarts>dtServiceEnds){alert("Please select valid dates. The service start date is after the service end date.");return false;}
			if (dtServiceStarts<dtTripBegins){alert("Please select valid dates. The service start date is "+nDaysBefore+" day(s) before the trip start date.");return false;}
			if (dtServiceEnds>dtTripEnds){alert("Please select valid dates. The service end date is "+nDaysAfter+" day(s) after the trip end date.");return false;}
		}else{
			var o_date1=document.frmMain[s_Date1];
			var o_date2=document.frmMain[s_Date2];
			if (!Number(document.frmMain.product_SameDayInOut.value) && o_date1.selectedIndex == o_date2.selectedIndex){
				alert("Please select valid dates. The end date must be after the begin date.");return false;
			}
			if (o_date1.selectedIndex > o_date2.selectedIndex){
				alert("Please select valid dates. The service begin date is after the service end date.");return false;
			}
		}
		return true;
	}
    function isAlpha(field, errorString){
        var checkOK = " '-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        var allValid = true;
        var checkStr = field.value;
        for (i = 0; i < checkStr.length; i++){
            ch = checkStr.charAt(i);
            for (j = 0; j < checkOK.length; j++)if (ch == checkOK.charAt(j))break;
            if (j == checkOK.length){
                allValid = false;
                break;

            }


        }

        if (!allValid){
            if (errorString!="") {alert(errorString);field.focus();}
        }

        return allValid;

    }

    function isZip(field, errorString){
        var isDbl = true;
        var numcount = 0;
        if (isNaN(field.value)){isDbl=false}if (!isPhone){
            if (errorString!="") {alert(errorString);field.focus();}

        }

        return isPhone;

    }
    function isNonSpecial(field, errorString){
        var checkOK = " -ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890&#()//\.,";
        var allValid = true;
        var checkStr = field.value;
        for (i = 0; i < checkStr.length; i++){
            ch = checkStr.charAt(i);
            for (j = 0; j < checkOK.length; j++)if (ch == checkOK.charAt(j))break;
            if (j == checkOK.length){
                allValid = false;
                break;
            }
        }

        if (!allValid){
            if (errorString!="") {alert(errorString);field.focus();}
            return true;
        }

        return false;

    }
    function isSelected(field, errorString){
		if (String(field)=="undefined") { //not a selectbox
			return false;
		}
		if (String(field[0])=="undefined") {//only one item
			return false;
		}
		if (String(field.selectedIndex)=="undefined") {
			var n_max=field.length;
			var n_count=0;
			for (;n_count<n_max;n_count++){
				if (field[n_count].checked){
					return false;
				}
			}
            if (errorString!="") {alert(errorString);}
            return (true);
		}

        if (field.selectedIndex ==0 && field.options[field.selectedIndex].value !=1){
            if (errorString!="") {alert(errorString);field.focus();}
            return (true);
        }
        return (false);
    }
    function parsedate_pd(fieldname){
		var field0=document.frmMain[fieldname+'_0'];
		var field1=document.frmMain[fieldname+'_1'];
		var field2=document.frmMain[fieldname+'_2'];
		if (String(field0)=="undefined") return false;
		return new Date(field2.options[field2.selectedIndex].value, field0.options[field0.selectedIndex].value-101,field1.options[field1.selectedIndex].value-100);
    }
    function parsedate_tb(fieldname){
		var a_date=String(document.frmMain[fieldname].value).split("/");
		return new Date(a_date[2],a_date[0]-1,a_date[1]);
    }
    function isDateGood(fieldname, errorString){
		var field0=document.frmMain[fieldname+'_0'];
		var field1=document.frmMain[fieldname+'_1'];
		var field2=document.frmMain[fieldname+'_2'];
		if (String(field0)=="undefined") return false;
		var varDate = new Date(field2.options[field2.selectedIndex].value, field0.options[field0.selectedIndex].value-101,field1.options[field1.selectedIndex].value-100);
	    if(varDate.getMonth()!=field0.options[field0.selectedIndex].value-101){
            alert(errorString);
            field1.focus();
            return true;
        }
        return false;
    }

    function ChangePage(szScreenname){
        document.frmMain.screen.value=szScreenname;
        document.frmMain.sAction.value='';
        //document.frmMain.quoteaction.value='';
        Do_SubmitForm();
    }
    function ChangePage_popup(szScreenname){
        document.frmMain.screen.value=szScreenname;
        document.frmMain.sAction.value='';
        var s_target_saved=document.frmMain.target.value;
        //debugger;
        document.frmMain.target.value='_blank';
        //document.frmMain.quoteaction.value='';
        Do_SubmitForm();
        //document.frmMain.target.value=s_target_saved;
    }

    function ChangePage_TA(szScreenname){
        document.frmMain.tamode.value=1;
        document.frmMain.screen.value=szScreenname;
        document.frmMain.sAction.value='';
        //document.frmMain.quoteaction.value='';
        Do_SubmitForm();
    }
    function ChangePage_TA_Clear(szScreenname){
        document.frmMain.tamode.value='';
        document.frmMain.screen.value=szScreenname;
        document.frmMain.sAction.value='';
        //document.frmMain.quoteaction.value='';
        Do_SubmitForm();
    }
    function ChangePage_secure(szScreenname){
        document.frmMain.screen.value=szScreenname;
        document.frmMain.action=document.frmMain.secure_url.value;
        //document.frmMain.sAction.value='';
        //document.frmMain.quoteaction.value='';
        Do_SubmitForm();

    }
/*     function DelClick1(){                                               */
/*         if (confirm("Are you sure that you want to delete this item")){ */
/*             document.frmMain.sAction.value='';                          */
/*             document.frmMain.screen.value='scnDelClickQuote';           */
/*             Do_SubmitForm();                                  */
/*         }                                                               */
/*                                                                         */
/*     }                                                                   */
    function ChangePageProduct(){
        if (document.frmMain.sel_producttype.selectedIndex==0){return;}
        var a_product=String(document.frmMain.sel_producttype.options[document.frmMain.sel_producttype.selectedIndex].value).split(",");
        //document.frmMain.screen.value=a_product[2];
        document.frmMain.screen2.value=a_product[2];
        document.frmMain.productno.value=a_product[3];
        document.frmMain.sAction.value='addtsi';
        //document.frmMain.quoteaction.value='addtsi';
        Do_SubmitForm();
    }
    function ValidateTraveler(n_traveler){
		if (isBlank(document.frmMain['res_adult_first'+n_traveler],"Please enter a valid first name. This is required information."))return false;
		if (isBlank(document.frmMain['res_adult_last'+n_traveler],"Please enter a valid last name. This is required information."))return false;
		if(!document.frmMain['travtype'+n_traveler][0].checked){
			if (isSelected(document.frmMain['travage'+n_traveler],"Please select the child's age. This is required information if a child is selected."))return false;
			//alert(document.frmMain['travtype'+n_traveler]);
		}
		return true;
    }
    function ValidateTraveler_GDS(n_traveler){
		//alert(n_traveler);

		if (isBlank(document.frmMain['gds_pax_first'+n_traveler],"Please enter a valid first name. This is required information."))return false;
		if (isBlank(document.frmMain['gds_pax_last'+n_traveler],"Please enter a valid last name. This is required information."))return false;
		return true;
    }
	function EmailRes_QuoteNext1(){
		document.frmMain.screen.value='scnGrabEmailQuote';
		Do_SubmitForm();
	}

	//function EmailRes_QuoteNext1_TA(){
	//	document.frmMain.screen.value='scnGrabEmailQuote_TA';
	//	Do_SubmitForm();
	//}

	function EmailRes_DocLetterNext1(){
		document.frmMain.screen.value='scnGrabEmail_DocLetter';
		Do_SubmitForm();
	}
	function CancelEmail(){
		document.frmMain.screen.value='scnEmailRes';
		Do_SubmitForm();
	}
	function EmailRes_SendDocLetter(){
		document.frmMain.screen.value='scnSendEmailDocLetter';
		Do_SubmitForm();
	}
	function EmailRes_SendQuote(){
		document.frmMain.screen.value='scnSendEmailRes';
		Do_SubmitForm();
	}
	function click_OpenRes(){
		document.frmMain.screen.value='scnGrabQuote';
		Do_SubmitForm();
	}
	function pick_Vendor(s_file, s_orig_screen, s_orig_fieldname, b_norefresh, s_title){
        var sz_Url=s_file+'?screen=scnPicker_Vendor';

		sz_Url+='&s_orig_screen='+s_orig_screen;
		//sz_Url+='&s_orig_template='+s_orig_template;

		sz_Url+='&pl='+document.frmMain.pl.value;

		sz_Url+='&s_title='+s_title;

		if (String(s_orig_fieldname)=='undefined') s_orig_fieldname='vendor';
		sz_Url+='&s_orig_fieldname='+s_orig_fieldname;

		if (b_norefresh==1){
			sz_Url+='&norefresh=1';
		}else{
			sz_Url+='&norefresh=0';
		}

		var a_superdest=String(document.frmMain.superdest.value).split(',');
		sz_Url+='&superdest='+a_superdest[0];

		var a_dest=String(document.frmMain.dest.value).split(',');
		sz_Url+='&dest='+a_dest[0];


		var s_producttype=document.frmMain.producttype.value;
		sz_Url+='&producttype='+s_producttype;

		//sz_Url+='&vendor='+s_vendor;
		//alert(sz_Url);
        //window.open(sz_Url,'','width=480,height=500, scrollbars=1, resizable=1');
        window.open(sz_Url,'','width=620,height=600, scrollbars=1, resizable=1, status=1, location=1');

	}
	function picked_Vendor(ps_value){

		var s_field=document.frmMain.s_orig_fieldname.value;
		var n_counter;

		//var o_select=opener.document.frmMain.elements[s_field]; //ie bug on golf course page
		var o_select=opener.document.all.item(s_field);


		var len_select=o_select.options.length;

		for (n_counter=0; n_counter<len_select; n_counter++){
			//alert(o_select.options[n_counter].value +'\n'+ps_value);

			if (o_select.options[n_counter].value==ps_value){
				o_select.options[n_counter].selected=true;
				break;
			}
		}

		var b_norefresh=(document.frmMain.norefresh.value==1);

		if (!b_norefresh){
			content_refresh_remote();
		}
		window.close();
	}
	function picked_Dest(ps_value){

		var s_field=document.frmMain.s_orig_fieldname.value;
		var n_counter;

		//var o_select=opener.document.frmMain.elements[s_field]; //ie bug on golf course page
		var o_select=opener.document.all.item(s_field);


		var len_select=o_select.options.length;

		for (n_counter=0; n_counter<len_select; n_counter++){
			//alert(o_select.options[n_counter].value +'\n'+ps_value);

			if (o_select.options[n_counter].value==ps_value){
				o_select.options[n_counter].selected=true;
				break;
			}
		}

		var b_norefresh=(document.frmMain.norefresh.value==1);

		if (!b_norefresh){
			content_refresh_remote();
		}
		window.close();
	}

	function picked_Dest2(ps_value){

		var s_field=document.frmMain.s_orig_fieldname.value;
		var n_counter;

		var o_field=opener.document.all.item(s_field);

		if (String(o_field.selectedIndex)=="undefined") {
			var n_max=o_field.length;
			var n_count=0;
			for (;n_count<n_max;n_count++){
				if (o_field[n_count].value==ps_value){
					o_field[n_count].checked=true;
				}
			}
		}else{

			var len_select=o_field.options.length;

			for (n_counter=0; n_counter<len_select; n_counter++){
				//alert(o_select.options[n_counter].value +'\n'+ps_value);

				if (o_field.options[n_counter].value==ps_value){
					o_field.options[n_counter].selected=true;
					break;
				}
			}

		}

		var b_norefresh=(document.frmMain.norefresh.value==1);

		if (!b_norefresh){
			content_refresh_remote();
		}
		window.close();
	}

	function pick_Dest(s_orig_screen, s_orig_template, s_orig_fieldname, b_norefresh){

        var sz_Url='booking.pl?screen=scnPicker_Dest';

		sz_Url+='&s_orig_screen='+s_orig_screen;
		sz_Url+='&s_orig_template='+s_orig_template;

		if (String(s_orig_fieldname)=='undefined') s_orig_fieldname='dest';
		sz_Url+='&s_orig_fieldname='+s_orig_fieldname;

		if (b_norefresh==1){
			sz_Url+='&norefresh=1';
		}else{
			sz_Url+='&norefresh=0';
		}


		var a_superdest=String(document.frmMain.superdest.value).split(',');
		sz_Url+='&superdest='+a_superdest[0];


        window.open(sz_Url,'','width=480,height=500, scrollbars=1, resizable=1');
        //window.open(sz_Url,'','width=550,height=300, resizable=1, status=1, location=1');


	}
	function pick_Dest2(s_SuperDestId, s_orig_screen, s_orig_fieldname, b_norefresh){

        var sz_Url='booking.pl?screen=scnPicker_Dest';
        b_norefresh=1;

		sz_Url+='&s_orig_screen='+s_orig_screen;
		sz_Url+='&s_orig_template=';
		sz_Url+='&superdest='+s_SuperDestId;

		if (String(s_orig_fieldname)=='undefined') s_orig_fieldname='dest';
		sz_Url+='&s_orig_fieldname='+s_orig_fieldname;

		if (b_norefresh==1){
			sz_Url+='&norefresh=1';
		}else{
			sz_Url+='&norefresh=0';
		}
        window.open(sz_Url,'','width=550,height=500, resizable=1, status=1, location=1, scrollbars=1,');
	}
	function click_Row(pn_Index, numElements){
		if (numElements>1){
			document.frmMain.resno[pn_Index].checked=true;
		}else{
			document.frmMain.resno.checked=true;
		}
		document.frmMain.screen.value='scnGrabQuote';
		Do_SubmitForm();
	}
    function isNumberPos(field, errorString){
        if (field.value != Number(field.value) || Number(field.value)<=0){
            alert(errorString);
            field.focus();
            return (true);
        }
        return (false);
    }
    function isCreditCard(field, errorString){
        if (field.value != Number(field.value) || String(field.value).length<12){
            alert(errorString);
            field.focus();
            return (true);
        }
        return (false);
    }
    function isCreditCardExpir(field, errorString){
		var as_tmp=String(field.value).split('/');
		var n_mo=Number(as_tmp[0]);
		var n_yr=Number(as_tmp[1]);
		var n_lenyr=String(as_tmp[1]).length;
        if (!(n_mo>=1 && n_mo<=12) || !(n_yr>=1 && n_yr<=10) || !(n_lenyr==2)){
            alert(errorString);
            field.focus();
            return (true);
        }
        return (false);

    }
    function date_refresh(ps_Screen, ps_DateFld){
		SetupDate(ps_DateFld);
		document.frmMain.screen.value=ps_Screen;
		document.frmMain.sAction.value='';
		Do_SubmitForm();
    }


	function date_getLessDate( s_date1, s_date2 ) {
		var n_daysdiff=date_diffDays(s_date1,s_date2);
		if (n_daysdiff < 0) {
			return s_date2;
		}else{
			return s_date1;
		}
	}
	// will result in negative if d1_value > d2_value
	function date_diffDays( d1_value, d2_value )  {

		var a1_value=String(d1_value).split('/');
		var d1_Date = new Date(a1_value[2], a1_value[0]-1, a1_value[1]);

		var a2_value=String(d2_value).split('/');
		var d2_Date = new Date(a2_value[2], a2_value[0]-1, a2_value[1]);

		var g_msPerDay = 1000*60*60*24;
		var ms1 = d1_Date.getTime();
		var ms2 = d2_Date.getTime();

		ms = (ms2 - ms1);
		var nDays = ms / g_msPerDay;
		var x = parseInt( nDays, 10 );
		if( nDays > x )
			nDays = x+1;

		return nDays-0;
	}

    function date_addDays(d_value, n_days){
		n_days=n_days-0;
		var a_value=d_value.split('/');
		var d_Date = new Date(a_value[2], a_value[0]-1, a_value[1]);

		var g_msPerDay = 1000*60*60*24;
		var ms1 = d_Date.getTime();
		var ms2 = n_days * g_msPerDay;

		// ** fix for date 10/29/2006 **
		// getTime() returns 1 hour short in milliseconds
		// for this date only, so we add 90 minutes to the
		// value for good measure (only really need to add 60 minutes)
		// this fixes the time addition calculation for this date -kg
		// p.s. could not find this bug on google....
		if (d_value == '10/29/2006') {
			//alert('fix applied');
			ms1 += 5400000; // add 90 mins to the milliseconds returned by getTime for this date only
		}
		// ** end fix for date 10/29/2006 **



		d_Date = new Date( ms1 + ms2 );

		var s_mo=d_Date.getMonth()+1;
		var s_dy=d_Date.getDate();
		var s_yr=d_Date.getYear();
		if (s_yr>100 && s_yr<200){
			s_yr=s_yr+1900; //mozilla 1.? bug
		}

		return s_mo+'/'+s_dy+'/'+s_yr;

    }
    function date_getDayStart(d_value){
		var a_value=d_value.split('/');
		var d_Date = new Date(a_value[2], a_value[0]-1, 1);
		var s_dow=d_Date.getDay();
		return s_dow-0;

    }
    function date_getDOW(d_value){
		var a_value=d_value.split('/');
		var d_Date = new Date(a_value[2], a_value[0]-1, a_value[1]);
		var s_dow=d_Date.getDay();
		return s_dow-0;

    }
	function date_click_checkDOW(n_dayofweek, s_daypattern){
		if (s_daypattern == ''){
			return 1
		}
		var s_temp=String(s_daypattern).substr(n_dayofweek,1);
		if (s_temp == 'Y'){
			return 1;
		}else{
			return 0;
		}

	}
    function date_getMaxDays(d_value){

		var a_value=d_value.split('/');

		var d_Date = new Date(a_value[2], a_value[0]-1, 1);
		d_Date.setMonth(d_Date.getMonth() + 1 );
		d_Date.setDate(1);
		d_Date.setDate( d_Date.getDate() - 1);

		var s_dy=d_Date.getDate();
		return s_dy-0;
    }

	function date_click_checkMonth(po_this, dcheck_value, pb_oneDate) {


		//var a_name=String(po_this.name).split('_');
		var s_name_long=String(po_this.name);
		var len_name_long=s_name_long.length;
		var s_name=s_name_long.substr(0,len_name_long-2);


		var o_name_mo=document.frmMain[s_name+'_0'];
		var o_name_dy=document.frmMain[s_name+'_1'];
		var o_name_yr=document.frmMain[s_name+'_2'];
		var s_value;


		var d1_name=document.frmMain[s_name+'_start'].value;
		var d1_value=String(document.frmMain[d1_name].value);

		var d2_name;
		var d2_value;
		if (!pb_oneDate){
			d2_name=document.frmMain[s_name+'_end'].value;
			d2_value=String(document.frmMain[d2_name].value);
		}else{
			d2_name=d1_name;
			d2_value=d1_value;
		}


		var b_enddate=(d1_name!=s_name);

		var d_min=String(document.frmMain[d1_name+'_min'].value);
		var d_max=String(document.frmMain[d1_name+'_max'].value);
		var n_defaultdays=document.frmMain[d1_name+'_defaultdays'].value;
		var n_mindays=document.frmMain[d1_name+'_mindays'].value;
		var n_maxdays=document.frmMain[d1_name+'_maxdays'].value;
		var s_startdates=document.frmMain[d1_name+'_startdates'].value;
		var s_enddates=document.frmMain[d1_name+'_enddates'].value;
		var s_dowstart=document.frmMain[d1_name+'_dowstart'].value;
		var s_dowend=document.frmMain[d1_name+'_dowend'].value;


	    var s_min, s_max, s_dowpattern;
	    if (!b_enddate){
	    	s_min=d_min;
	    	s_max=date_addDays(d_max, -1*n_mindays);
	    	s_dowpattern=s_dowstart;
	    }else{
	    	s_min=date_addDays(d1_value, n_mindays);
			s_max=date_addDays(d1_value, n_maxdays);
			if (date_diffDays(s_max,d_max)<0){
				s_max=d_max;
			}
			s_dowpattern=s_dowend;
	    }
	    s_value=dcheck_value;

		var b_useIndiv_dates=0;
		if (s_startdates != ''){
			b_useIndiv_dates=1;
		}

		var a_value=s_value.split('/');
		var thisMonth=a_value[0],thisDay=a_value[1],thisYear=a_value[2];

		var a_min=s_min.split('/');
		var dmin_mo=a_min[0],dmin_dy=a_min[1],dmin_yr=a_min[2];

		var a_max=s_max.split('/');
		var dmax_mo=a_max[0],dmax_dy=a_max[1],dmax_yr=a_max[2];


		//filtering the days
		var a_days=new Array(), a_days_len=0;
		//get calendar month characteristics
    	var n_daystart=date_getDayStart(s_value);
    	var n_maxdays=date_getMaxDays(s_value);

	   	if (b_useIndiv_dates){ 	    //individual dates
	    	if (!b_enddate){ 	//startdate
			    var d_cal=thisMonth +'/1/'+thisYear;
		    	var a_startdates=String(s_startdates).split(',');

				for (n_count=0; n_count< a_startdates.length; n_count++){
					var cur_date=a_startdates[n_count];
					if (!cur_date){
						break;
					}
					var n_diff_temp= 1+ date_diffDays(d_cal,cur_date);

					if (n_diff_temp >= 1 && n_diff_temp <= n_maxdays){
		        		//inside the month
						return 1;
					}else if (n_diff_temp >= n_maxdays){
						//after the month
						break;
					}

				}

			}else{	//end date
		    	//process matches the startdate against d1
		    	var a_startdates=String(s_startdates).split(',');
		    	var a_enddates=String(s_enddates).split(',');
				var len_startdates=a_startdates.length;
				var n_count;
				for (n_count=0; n_count<len_startdates; n_count++){
					if (d1_value == a_startdates[n_count]){
						var n_day=String(a_startdates[n_count]).split('/')[1];
						return 1;
					}
				}
			}
	    }else{	//min/max dates

			//getting to the maximum day	of the month
			if (dmax_yr==thisYear && dmax_mo==thisMonth){
				n_maxdays=dmax_dy-0;
			}


			//getting to the mininum day of the month
			var n_mindays=1;
			if (dmin_yr==thisYear && dmin_mo==thisMonth){
				n_mindays=dmin_dy-0;
			}


			var n_this_dayofweek;
			for (n_count=n_mindays; n_count<=n_maxdays; n_count++){
				n_this_dayofweek=(n_count+n_daystart-1) % 7;
				if (date_click_checkDOW(n_this_dayofweek, s_dowpattern)){
					return 1;
				}
			}
		}


		return 0;
	}


    function options_clear(o_select){
		var n_count;
		var n_max=o_select.length;
		for (n_count=0; n_count<n_max; n_count++){
			o_select.remove(0);
		}

	}

    function options_add(o_select, s_text, s_value){
		var o_option = new Option(s_text, s_value);
		o_select.options[o_select.options.length] = o_option;

		//var o_option = document.createElement("OPTION");
		//o_option.text=s_text;
		//o_option.value=s_value;
		//o_select.add(o_option);
	}
	function options_set(o_select, s_value) {
		var n_count;
		var b_found=false;
		var n_max=o_select.options.length;
		for (n_count=0; n_count<n_max; n_count++){
			var cur_value=o_select.options[n_count].value;
			if (cur_value==s_value){
				b_found=true;
				break;
			}
		}
		if (b_found){
			o_select.selectedIndex=n_count;
		}
		return b_found;

	}



    function SetupDate(s_name){

		var o_name_moyr=document.frmMain[s_name+'_0'];
		var o_name_dy=document.frmMain[s_name+'_1'];
		//var o_name_yr=document.frmMain[s_name+'_2'];
		var s_value;


		if (String(o_name_moyr)=="undefined" || String(o_name_dy)=="undefined" ||
			String(o_name_moyr.options)=="undefined" || String(o_name_dy.options)=="undefined"
			) return '';


		var a_value_moyr=String(o_name_moyr.options[o_name_moyr.selectedIndex].value).split(',');
		var s_value_mo=Number(a_value_moyr[0]);
		var s_value_dy=Number(o_name_dy.options[o_name_dy.selectedIndex].value);
		var s_value_yr=Number(a_value_moyr[1]);
		s_value=s_value_mo + '/' + s_value_dy + '/' + s_value_yr;

		document.frmMain[s_name].value=s_value;

    }
	function date_startdate_month_change(s_name_start,s_name_end){
		//alert(getFieldValue(s_name_start));

		var s_New_MonthYear;
		//s_NewMonth syntax= 2,2005
		s_New_MonthYear=getFieldValue(s_name_start+'_0');

		var a_New_MonthYear=String(s_New_MonthYear).split(',');
		var n_new_month=0+a_New_MonthYear[0];
		var n_new_year=0+a_New_MonthYear[1];

		var s_existing_date=getFieldValue(s_name_start);
		var a_existing_date=String(s_existing_date).split('/');
		var n_existing_day=0+a_existing_date[1];

		//alert(document.frmMain[s_name_start+'_startdates'].value);
		//the start date valid ranges come in preprocessed
		var a_startdates=String(getFieldValue(s_name_start+'_startdates')).split(',');
		var len_startdates=a_startdates.length-1; //forget about the last element because it always empty
		//alert(a_startdates);


		var o_name_day=getDocItem(s_name_start+'_1');
		//clear the current month year drop down
		options_clear(o_name_day);
		var a_shortdays=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];


		// go through the start dates and look for the dates in the current month
		var n_first_day;
		var b_found_day;
		for (var count_startdates=0; count_startdates < len_startdates; count_startdates++) {

			var s_date_this=a_startdates[count_startdates];
			var atmp_date=String(s_date_this).split('/');
			var n_cur_month=0+atmp_date[0];
			var n_cur_year=0+atmp_date[2];
			if (n_cur_month == n_new_month && n_cur_year == n_new_year) {

				var n_cur_day=0+atmp_date[1];
				if (!n_first_day) {
					//save the first day incase you can't find the existing day
					n_first_day=n_cur_day;
				}
				if (n_cur_day==n_existing_day) {
					b_found_day=1;
				}


				var n_this_dayofweek=date_getDOW(s_date_this);

				var s_dow;
				if (n_this_dayofweek >=0 && n_this_dayofweek <=6)
					s_dow=a_shortdays[n_this_dayofweek];
				if (String(s_dow)=='undefined'){
					s_dow='';
				}
				options_add(o_name_day, (n_cur_day-0)+'  -  '+s_dow, n_cur_day);

			}


		}

		//set the current day
		if (b_found_day) {
			options_set(o_name_day, n_existing_day);
		}else{
			//select the first day when you can't find the existing day
			options_set(o_name_day, n_first_day);
		}
		date_startdate_day_change(s_name_start,s_name_end);
	}

	function date_startdate_day_change(s_name_start,s_name_end){
		SetupDate(s_name_start);

		//must now change the end date month/year drop down
		//the end dates are populated here
		date_set_Valid_EndDates(s_name_start,s_name_end);

		var a_enddates=String(getFieldValue(s_name_end+'_enddates')).split(',');
		var len_enddates=a_enddates.length-1; //forget about the last element because it always empty


		var o_name_month=getDocItem(s_name_end+'_0');
		//clear the current month year drop down
		options_clear(o_name_month);
		var a_months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];


		// go through the start dates and look for different months and years
		var n_last_year;
		var n_last_month;
		var s_first_monthyear;
		for (var count_enddates=0; count_enddates < len_enddates; count_enddates++) {
			var s_date_this=a_enddates[count_enddates];

			var atmp_date=String(s_date_this).split('/');
			var n_cur_month=Number(atmp_date[0]);
			var n_cur_year=Number(atmp_date[2]);

			if (n_cur_month != n_last_month || n_cur_year != n_last_year) {

				if (!s_first_monthyear) {
					s_first_monthyear=n_cur_month+','+n_cur_year;
				}

				n_last_month=n_cur_month;
				n_last_year=n_cur_year;

				var s_optdisplay=a_months[n_cur_month-1]+' '+n_cur_year;
				var s_value=n_cur_month+','+n_cur_year;

				options_add(o_name_month, s_optdisplay, s_value);

			}


		}
		options_set(o_name_month, s_first_monthyear);


		date_enddate_month_change(s_name_start,s_name_end);

	}
	function date_enddate_month_change(s_name_start,s_name_end){
		//you need to change the day drop down now

		var s_New_MonthYear;
		//s_NewMonth syntax= 2,2005
		s_New_MonthYear=getFieldValue(s_name_end+'_0');

		var a_New_MonthYear=String(s_New_MonthYear).split(',');
		var n_new_month=Number(a_New_MonthYear[0]);
		var n_new_year=Number(a_New_MonthYear[1]);

		var s_existing_date=getFieldValue(s_name_end);
		var a_existing_date=String(s_existing_date).split('/');
		var n_existing_day=Number(a_existing_date[1]);
		//alert(n_existing_day);


		var a_enddates=String(getFieldValue(s_name_end+'_enddates')).split(',');
		var len_enddates=a_enddates.length-1; //forget about the last element because it always empty

		var o_name_day=getDocItem(s_name_end+'_1');
		//clear the current month year drop down
		options_clear(o_name_day);
		var a_shortdays=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];


		// go through the end dates and look for the dates in the current month
		var n_first_day;
		var b_found_day;
		for (var count_enddates=0; count_enddates < len_enddates; count_enddates++) {

			var s_date_this=a_enddates[count_enddates];
			var atmp_date=String(s_date_this).split('/');
			var n_cur_month=Number( atmp_date[0] );
			var n_cur_year=Number( atmp_date[2] );
			if (n_cur_month == n_new_month && n_cur_year == n_new_year) {

				var n_cur_day=Number (  atmp_date[1] );
				if (!n_first_day) {
					//save the first day incase you can't find the existing day
					n_first_day=n_cur_day;
				}

				if (n_cur_day==n_existing_day) {
					b_found_day=1;
				}


				var n_this_dayofweek=date_getDOW(s_date_this);

				var s_dow;
				if (n_this_dayofweek >=0 && n_this_dayofweek <=6)
					s_dow=a_shortdays[n_this_dayofweek];
				if (String(s_dow)=='undefined'){
					s_dow='';
				}
				options_add(o_name_day, n_cur_day+'  -  '+s_dow, n_cur_day);

			}


		}

		//set the current day
		if (b_found_day) {
			options_set(o_name_day, n_existing_day);
		}else{
			//select the first day when you can't find the existing day
			options_set(o_name_day, n_first_day);
		}

		date_enddate_day_change(s_name_start,s_name_end);

	}
	function date_enddate_day_change(s_name_start,s_name_end){
		SetupDate(s_name_end);

	}
	function date_parseDate(s_date){
		//this function is to standardize the format of a date so it can be compared
		var a_date=String(s_date).split('/');
		var s_return=Number(a_date[0])+"/"+Number(a_date[1])+"/"+Number(a_date[2]);
		return s_return;
	}
	function date_set_Valid_EndDates(s_name_start,s_name_end){

		var s_enddates='';
		var s_value_StartDate=date_parseDate(getFieldValue(s_name_start));

		var b_FixedDate=getFieldValue(s_name_start+'_fixeddate')==1;
		if (b_FixedDate) {
			//fixed date logic
			//find what date range we are in,
			//only allow the end date from that range
			//alert("fixed date logic ");

			var d_max;
			var sa_dateranges=getFieldValue(s_name_start+'_dateranges');
			var a_dateranges=doubleSplit(';',',',sa_dateranges);

			var b_found_daterange;
			var len_dateranges=a_dateranges.length-1; //forget about the last element because it always empty
			for (var count_dateranges=0; count_dateranges < len_dateranges; count_dateranges++) {
				var d_range_min=date_parseDate(a_dateranges[count_dateranges][0]);
				if (d_range_min != s_value_StartDate) {
					continue;
				}
                d_max=a_dateranges[count_dateranges][1];
                b_found_daterange=1;
			}
			s_enddates=d_max+',';

			setFieldValue(s_name_end+'_enddates',s_enddates);

		}else{
			//dynamic dates

			//alert("dynamic dates");
			var n_Min_Trip_Len=Number( getFieldValue(s_name_start+'_mindays') );
			var n_Max_Trip_Len=Number( getFieldValue(s_name_start+'_maxdays') );
			var s_DOW_Filter_end=getFieldValue(s_name_start+'_dowend');

			//alert(n_Min_Trip_Len);
			//alert(n_Max_Trip_Len);
			//alert(s_DOW_Filter_end);

			var d_min=date_addDays( s_value_StartDate, n_Min_Trip_Len );
			//alert(d_min);

			//which date range are we currently in?
			// find it and use the maximum date specified in that range
			var b_found_daterange;
			var d_max;
			var sa_dateranges=getFieldValue(s_name_start+'_dateranges');
			var a_dateranges=doubleSplit(';',',',sa_dateranges);
			var len_dateranges=a_dateranges.length-1; //forget about the last element because it always empty
			for (var count_dateranges=0; count_dateranges < len_dateranges; count_dateranges++) {
				var d_range_min=date_parseDate(a_dateranges[count_dateranges][0]);
				var d_range_max=date_parseDate(a_dateranges[count_dateranges][1]);

				//alert(d_range_min);
				//alert(d_range_max);


				//does the current start date occur after this min start date
				var n_days_after_min_date=date_diffDays(d_range_min, s_value_StartDate );
				//alert(n_days_after_min_date);
				if (n_days_after_min_date<0){
					continue;
				}


				//does the current start date occur after this min start date
				var n_days_before_max_date=date_diffDays(s_value_StartDate, d_range_max );
				//alert(n_days_before_max_date);
                if (n_days_before_max_date < 0){
					continue;
				}

				b_found_daterange=1;
				d_max=d_range_max;

			}

			//the end date can not exceed the max trip len
			var d_max_trip_len=date_addDays( s_value_StartDate, n_Max_Trip_Len );
			//alert(d_max_trip_len);


			d_max=date_getLessDate(d_max_trip_len, d_max);


			var n_enddays=date_diffDays(d_min,d_max);
			var s_curdate=date_parseDate( d_min );
			for (var count_enddays=0; count_enddays <= n_enddays; count_enddays++) {
				var n_dow=date_getDOW( s_curdate );
				if ( !s_DOW_Filter_end || date_click_checkDOW(n_dow, s_DOW_Filter_end ) ) {
					s_enddates=s_enddates+s_curdate+',';

				}

				var s_curdate_test=s_curdate; /*weird hack to fix an even weirder problem*/
				s_curdate = date_parseDate( date_addDays( s_curdate,1) );
				if (s_curdate_test==s_curdate){
					s_curdate = date_parseDate( date_addDays( s_curdate,2) );
				}
			}
			//alert(s_curdate);
			setFieldValue(s_name_end+'_enddates',s_enddates);


		}
		//alert(b_FixedDate);

/*             my @a_enddates;                                                                                                  */
/*                                                                                                                              */
/*             if ($hash{'FixedDate'}) {                                                                                        */
/*                                                                                                                              */
/*             }else{                                                                                                           */
/*                 #dynamic date logic                                                                                          */
/*                                                                                                                              */
/*                 #the min start is the current value of the start + the min trip length                                       */
/*                 my $d_min=&IRECommon::addDays( $hash{'value_StartDate'}, $hash{'Min_Trip_Len'} );                            */
/*                 #$$h_in{'_Body'}.= "value_StartDate: ".$hash{'value_StartDate'} ." <br>\n";                                  */
/*                 #$$h_in{'_Body'}.= "d_min: ".$d_min ." <br>\n";                                                              */
/*                                                                                                                              */
/*                 #which date range are we currently in?                                                                       */
/*                 # find it and use the maximum date specified in that range                                                   */
/*                 my @a_dateranges=@{$hash{'DateRanges'}};                                                                     */
/*                                                                                                                              */
/*                 my $b_found_daterange;                                                                                       */
/*                 my $d_max;                                                                                                   */
/*                 foreach my $s_daterange ( @a_dateranges ) {                                                                  */
/*                     #the mininum start date in this date range                                                               */
/*                     my $d_range_min=$$s_daterange[0];                                                                        */
/*                                                                                                                              */
/*                     #does the current start date occur after this min start date                                             */
/*                     my $n_days_after_min_date=IRECommon::diffDays($d_range_min, $hash{'value_StartDate'} );                  */
/*                     next if ($n_days_after_min_date<0);                                                                      */
/*                                                                                                                              */
/*                                                                                                                              */
/*                     #the maximum start date in this date range                                                               */
/*                     my $d_range_max=$$s_daterange[1];                                                                        */
/*                                                                                                                              */
/*                     #does the current start date occur after this min start date                                             */
/*                     my $n_days_before_max_date=IRECommon::diffDays($hash{'value_StartDate'}, $d_range_max );                 */
/*                     next if ($n_days_before_max_date < 0);                                                                   */
/*                                                                                                                              */
/*                     $b_found_daterange=1;                                                                                    */
/*                     $d_max=$d_range_max;                                                                                     */
/*                                                                                                                              */
/*                 }                                                                                                            */
/*                 #$$h_in{'_Body'}.= "d_max: ".$d_max ." <br>\n";                                                              */
/*                 #$$h_in{'_Body'}.= "Max_Trip_Len: ".$hash{'Max_Trip_Len'} ." <br>\n";                                        */
/*                                                                                                                              */
/*                 #the end date can not exceed the max trip len                                                                */
/*                 my $d_max_trip_len=&IRECommon::addDays( $hash{'value_StartDate'}, $hash{'Max_Trip_Len'} );                   */
/*                                                                                                                              */
/*                 #$$h_in{'_Body'}.= "d_max_trip_len: ".$d_max_trip_len ." <br>\n";                                            */
/*                                                                                                                              */
/*                 $d_max=IRECommon::getLessDate($d_max_trip_len, $d_max);                                                      */
/*                 #$$h_in{'_Body'}.= "d_max: ".$d_max ." <br>\n";                                                              */
/*                                                                                                                              */
/*                                                                                                                              */
/*                 my $n_enddays=&IRECommon::diffDays($d_min,$d_max);                                                           */
/*                 my $s_curdate=IRECommon::parseDate( $d_min );                                                                */
/*                 for (my $count_enddays=0; $count_enddays <= $n_enddays; $count_enddays++) {                                  */
/*                     my $n_dow=IRECommon_Date::getDOW($s_curdate);                                                            */
/*                     if ( !$hash{'DOW_Filter'} || IRECommon_Date::scnCalendar_checkDayofWeek($n_dow, $hash{'DOW_Filter'}) ) { */
/*                         push @a_enddates,[$s_curdate,$n_dow];                                                                */
/*                     }                                                                                                        */
/*                     $s_curdate = IRECommon::parseDate( &IRECommon::addDays( $s_curdate,1) );                                 */
/*                 }                                                                                                            */
/*                                                                                                                              */
/*             }                                                                                                                */
/*             return @a_enddates;                                                                                              */
/*                                                                                                                              */

	}

	function date_click(po_this, pb_NotClicked, pb_oneDate){

		if (String(pb_NotClicked)=='undefined')
			pb_NotClicked=false;

		if (String(pb_oneDate)=='undefined')
			pb_oneDate=false;


		var s_name_long=String(po_this.name);
		var len_name_long=s_name_long.length;
		var s_name=s_name_long.substr(0,len_name_long-2);

		var o_name_moyr=document.frmMain[s_name+'_0'];
		var o_name_dy=document.frmMain[s_name+'_1'];

		var s_value;

		if (!pb_NotClicked){
			SetupDate(s_name);
		}

		var d1_name=document.frmMain[s_name+'_start'].value;
		var d1_value=String(document.frmMain[d1_name].value);

		var d2_name;
		var d2_value;
		if (!pb_oneDate){
			d2_name=document.frmMain[s_name+'_end'].value;
			d2_value=String(document.frmMain[d2_name].value);
		}else{
			d2_name=d1_name;
			d2_value=d1_value;
		}


		var b_enddate=(d1_name!=s_name);

		var d_min=String(document.frmMain[d1_name+'_min'].value);
		//alert("Minimum:"+d_min);

		var d_max=String(document.frmMain[d1_name+'_max'].value);
		var n_defaultdays=document.frmMain[d1_name+'_defaultdays'].value;
		var n_mindays=document.frmMain[d1_name+'_mindays'].value;
		var n_maxdays=document.frmMain[d1_name+'_maxdays'].value;
		var s_startdates=document.frmMain[d1_name+'_startdates'].value;
		var s_enddates=document.frmMain[d1_name+'_enddates'].value;
		var s_dowstart=document.frmMain[d1_name+'_dowstart'].value;
		var s_dowend=document.frmMain[d1_name+'_dowend'].value;


	    var s_min, s_max, s_dowpattern;
	    if (!b_enddate){
	    	s_min=d_min;
	    	s_max=date_addDays(d_max, -1*n_mindays);
	    	s_dowpattern=s_dowstart;
			s_value=String(d1_value);
	    }else{
	    	s_min=date_addDays(d1_value, n_mindays);
			s_max=date_addDays(d1_value, n_maxdays);
			if (date_diffDays(s_max,d_max)<0){
				s_max=d_max;
			}
			s_dowpattern=s_dowend;
			s_value=String(d2_value);
	    }

		var b_useIndiv_dates=0;
		if (s_startdates != ''){
			b_useIndiv_dates=1;
		}

		var a_value=s_value.split('/');
		var thisMonth=a_value[0]-0,thisDay=a_value[1]-0,thisYear=a_value[2]-0;

		var a_min=s_min.split('/');
		var dmin_mo=a_min[0]-0,dmin_dy=a_min[1]-0,dmin_yr=a_min[2]-0;


		var a_max=s_max.split('/');
		var dmax_mo=a_max[0]-0,dmax_dy=a_max[1]-0,dmax_yr=a_max[2]-0;


		//filtering the years
		var n_count;
		var b_found;
		var a_years=new Array(), a_years_len=0;
		for (n_count=dmin_yr; n_count<=dmax_yr; n_count++){
			a_years[a_years_len++]=n_count-0;
			if (n_count==thisYear){
				b_found=1;
			}
		}
		if (!b_found){
			thisYear=a_years[0]-0;
		}
		var d_selected=new Array();
		d_selected[0]='-1';d_selected[1]='-1';d_selected[2]='-1';

//
//
////		//filtering the months
////		//process is to remove months that are outside the min date


	    var months=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

		var a_monthyr=new Array(), a_monthyr_len=0;
		for (n_count=0; n_count< a_years.length; n_count++){
			var cur_year=a_years[n_count]-0;

			var n_startMo=0;
			var n_endMo=11;
			if (cur_year==dmin_yr){
				n_startMo=dmin_mo-1;
			}
			if (cur_year==dmax_yr){
				n_endMo=dmax_mo-1;
			}
			var cur_month;
			for (cur_month=n_startMo+1; cur_month<=n_endMo+1; cur_month++){
				cur_month=cur_month-0;
				var d_temp=cur_month+'/1/'+cur_year;
				if (date_click_checkMonth(po_this, d_temp, pb_oneDate)){
					if (cur_year==thisYear && cur_month==thisMonth){
						d_selected[0]=thisMonth;
						d_selected[2]=thisYear;
					}
					a_monthyr[a_monthyr_len++]=cur_month+','+cur_year;
				}
			}
		}
		if (d_selected[0]==-1 || d_selected[2]==-1){
			var a_this=String(a_monthyr[0]).split(',');
			var cur_month=a_this[0]-0+1;
			var cur_yr=a_this[1];
			d_selected[0]=cur_month;
			d_selected[2]=cur_yr;
		}



		//filtering the days
		var a_days=new Array(), a_days_len=0;
		//get calendar month characteristics
    	var n_daystart=date_getDayStart(s_value);
    	var n_maxdays=date_getMaxDays(s_value);

	   	if (b_useIndiv_dates){ 	    //individual dates
	    	if (!b_enddate){ 	//startdate
			    var d_cal=thisMonth +'/1/'+thisYear;
		    	var a_startdates=String(s_startdates).split(',');

				for (n_count=0; n_count< a_startdates.length; n_count++){
					var cur_date=a_startdates[n_count];
					if (!cur_date){
						break;
					}
					var n_diff_temp= 1+ date_diffDays(d_cal,cur_date);

					if (n_diff_temp >= 1 && n_diff_temp <= n_maxdays){
		        		//inside the month
						a_days[a_days_len++]=n_diff_temp;
					}else if (n_diff_temp >= n_maxdays){
						//after the month
						break;
					}

				}

			}else{	//end date
		    	//process matches the startdate against d1
		    	var a_startdates=String(s_startdates).split(',');
		    	var a_enddates=String(s_enddates).split(',');
				var len_startdates=a_startdates.length;
				var n_count;
				for (n_count=0; n_count<len_startdates; n_count++){
					if (d1_value == a_startdates[n_count]){
						var n_day=String(a_startdates[n_count]).split('/')[1];
						a_days[a_days_len++]=n_day;
						break;
					}
				}
			}
	    }else{	//min/max dates
			//alert('checkpoint');
			//getting to the maximum day	of the month
			if (dmax_yr==thisYear && dmax_mo==thisMonth){
				n_maxdays=dmax_dy-0;
			}


			//getting to the mininum day of the month
			var n_mindays=1;
			if (dmin_yr==thisYear && dmin_mo==thisMonth){
				n_mindays=dmin_dy-0;
			}


			var n_this_dayofweek;
			for (n_count=n_mindays; n_count<=n_maxdays; n_count++){
				n_this_dayofweek=(n_count+n_daystart-1) % 7;
				//TODO!!: convert code
				if (date_click_checkDOW(n_this_dayofweek, s_dowpattern)){
					a_days[a_days_len++]=n_count-0;
				}
			}
		}


//////		//update screen
//////month year
		options_clear(o_name_moyr);
		var b_found=0;
		for (n_count=0; n_count< a_monthyr.length; n_count++){
			var a_this=String(a_monthyr[n_count]).split(',');
			var cur_month=a_this[0]-0;
			var cur_yr=a_this[1]-0;
			var s_optdisplay=months[cur_month-1]+'  '+cur_yr;
			var s_value=cur_month+','+cur_yr;

			options_add(o_name_moyr, s_optdisplay, s_value);
		}
		options_set(o_name_moyr, d_selected[0]+','+d_selected[2]);

		var date_temp=d_selected[0]+"/"+a_days[0]+"/"+d_selected[2];
		var n_this_daystart=date_getDOW(date_temp);

	    var a_shortdays=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

		//days
		options_clear(o_name_dy);
		b_found=0;
		for (n_count=0; n_count< a_days.length; n_count++){
			var cur_day=a_days[n_count];
			if (cur_day==-1){ //disregard element
				continue;
			}
			if (cur_day==thisDay){ //current day
				b_found=1;
				d_selected[1]=cur_day;
			}
			//var n_this_dayofweek=(n_count+n_this_daystart) % 7;
			date_temp=d_selected[0]+"/"+cur_day+"/"+d_selected[2];
			var n_this_dayofweek=date_getDOW(date_temp);

			var s_dow;
			if (n_this_dayofweek >=0 && n_this_dayofweek <=6)
				s_dow=a_shortdays[n_this_dayofweek];
			if (String(s_dow)=='undefined'){
				s_dow='';
			}
			options_add(o_name_dy, (cur_day-0)+'  -  '+s_dow, cur_day);
		}
	    if (d_selected[1]==-1){ //if a valid incoming date was not found make the first date (the incoming date)
			d_selected[1]=a_days[0];
		}
		var date_selected=d_selected[0]+"/"+d_selected[1]+"/"+d_selected[2];

		options_set(o_name_dy, d_selected[1]);


		SetupDate(s_name);


		if (!pb_oneDate && !b_enddate){
			var s_newEndDate=date_addDays(date_selected, n_defaultdays);
			document.frmMain[d2_name].value=s_newEndDate;

			var o_d2_moyr=document.frmMain[d2_name+'_0'];
			//options_set(o_d2_moyr, d_selected[0]+','+d_selected[2]);
			//options_set(o_d2_moyr, d_selected[1]);

			date_click(o_d2_moyr,1);
		}


	}

	function GDS_goSearch_click(){
		//alert(s_itin);
		document.frmMain.gds_flights.value='';
		document.frmMain.screen.value='scnAirSearch';
		Do_SubmitForm();
	}
	function GDS_bookit_click(s_itin){
		//alert(s_itin);
		document.frmMain.gds_flights.value=s_itin;
		document.frmMain.screen.value='scnAirBooking';
		Do_SubmitForm();
	}
	function GDS_checkpax_click(){
		//alert(document.frmMain.GDS_NumSeats.value);
		var n_GDS_NumSeats=document.frmMain.GDS_NumSeats.value;
		var n_count=0;
		for (;n_count<n_GDS_NumSeats ;n_count++) {
			var o_fname=document.frmMain['GDS_FirstName'+n_count];
			if (isBlank(o_fname ,"Please enter a valid first name. This is required information."))return;

			var o_lname=document.frmMain['GDS_LastName'+n_count];
			if (isBlank(o_lname ,"Please enter a valid first name. This is required information."))return;

		}
		document.frmMain.screen.value='scnAirBooking';
		Do_SubmitForm();
	}

	function GetParams(a_params_in){

		var h_params_return={};
		var n_first_param_element=0;
		var b_copied_obj=false;
		if (isObject(a_params_in[0])){
			h_params_return=a_params_in[0];
			n_first_param_element=1;

			if (isHash(a_params_in[1])){
				h_params_return=CopyObj(h_params_return);
				b_copied_obj=true;
				for (var i in a_params_in[1]) {
					h_params_return[i] = a_params_in[1][i];
				}
				n_first_param_element=2;
			}

			if ( n_first_param_element < a_params_in.length){
				if (!b_copied_obj) { h_params_return=CopyObj(h_params_return); }
				if (isArray(a_params_in)){
					for (var i=n_first_param_element; i+1 < a_params_in.length; i+=2) {
						h_params_return[ a_params_in[i] ] = a_params_in[ i+1 ];
					}
				}
			}

		}else if (isArray(a_params_in)){
			for (var i=n_first_param_element; i+1 < a_params_in.length; i+=2) {
				h_params_return[ a_params_in[i] ] = a_params_in[ i+1 ];
			}

		}

		return h_params_return;
	}
	function isObject(s_var) { return ( typeof(s_var) === "object" && s_var != null ); }
	function isArray(s_var)	 { return ( typeof(s_var) === "object" && typeof(s_var.length) != "undefined" ); }
	function isHash(s_var)	 { return ( typeof(s_var) === "object" && s_var != null && typeof(s_var.length) === "undefined" ); }

	function CopyObj (o_source) {
		var o_new={};
		for (i in o_source) {
			o_new[i] = o_source[i];
		}
		return o_new;
	}

//</script>
	
