﻿    function proc_datecheckout(comp_obj, comp_obj_frame) {
        var from_date=document.getElementById('datecheckin').value;
                if (from_date.length>4) {
                    from_date_arr=from_date.split('/');
                    dateStart=new Date(from_date_arr[2],from_date_arr[0]-1,from_date_arr[1]);
                    init_hfdp2(dateStart);
                    }
                else {
                    var my_today=new Date();
                    init_hfdp2(my_today);
                }
                myChild = document.getElementById('calendarContainercheckout').appendChild(H_fDP2.calendar());
                present('calendarContainercheckout','iframecheckout', comp_obj, comp_obj_frame);
    }
	
	function myEnum(source, args) 
    {
        var property, propCollection = "";
        for(property in source.parentElement)
            {
               propCollection += (property + ": " + source[property] + "\n");
            }
        alert(propCollection);
        // For now, show the entry as invalid
        args.IsValid = false;
    }
	
	function proc_datereturn(comp_obj, comp_obj_frame) {
	    var from_date=document.getElementById('dateLeave').value;
				if (from_date.length>4) {
				    from_date_arr=from_date.split('/');
				    var dateStart=new Date(from_date_arr[2],from_date_arr[0]-1,from_date_arr[1]);
				    init_afdp2(dateStart);
				    }
				else {
				    var my_today=new Date();
				    init_afdp2(my_today);
				}

            	myChild = document.getElementById('calendarContainerreturn').appendChild(A_fDP2.calendar()) //id=fastDatePickerTable
				present('calendarContainerreturn','iframereturn', comp_obj, comp_obj_frame);
	}
	
	function proc_datedropoff(comp_obj, comp_obj_frame) {
	    var from_date=document.getElementById('datePickup').value;
				    if (from_date.length>4) {
				        from_date_arr=from_date.split('/');
				        dateStart=new Date(from_date_arr[2],from_date_arr[0]-1,from_date_arr[1]);
				        init_cfdp2(dateStart);
				    }
				    else {
				        var my_today=new Date();
				        init_cfdp2(my_today);
				    }
            		myChild = document.getElementById('calendarContainerdropoff').appendChild(C_fDP2.calendar()) //from tabs.js onload				    
				    present('calendarContainerdropoff','iframedropoff', comp_obj, comp_obj_frame);
	}
	
	function search_Flights(vendor){
		//if (popups=="blocked") {if (!(confirm("It appears you have pop-ups blocked.  Would you like to proceed?"))) {return false}}
		var myinputs = document.getElementById("checkbox_air").getElementsByTagName("input")
		var myinput_checked = false
		numPopups = 0;
		for (i=0;i<myinputs.length;i++)
            {
             if (myinputs[i].checked) {numPopups=numPopups+1; myinput_checked = true}
            }
		if (document.getElementById('txtFrom').value.length<1 || document.getElementById('txtTo').value.length<1 || document.getElementById('dateLeave').value=='' || document.getElementById('dateReturn').value=='')
		{
			alert("Please ensure you have selected Departure and Arrival cities and dates.  Thanks!")
		}
		else
		{
			if (!(myinput_checked))
			{
				alert("Please check at least one site to search.  Thanks!")
			}
			else
			    {
			    reset_popup();
			    if (vendor!='')
			        {
			        numPopups=1;
			        eval("popup_"+vendor+"_air()");
			        }
			    else
			        {			    
			        if (document.getElementById("ckbox_air_tvly").checked) {popup_tvly_air()}
			        if (document.getElementById("ckbox_air_hotw").checked) {popup_hotw_air()}
			        if (document.getElementById("ckbox_air_orbitz").checked) {popup_orb_air()}
			        if (document.getElementById("ckbox_air_ctix").checked) {popup_ctix_air()}
			        if (document.getElementById("ckbox_air_exp").checked) {popup_exp_air()}
			        if (document.getElementById("ckbox_air_kayak").checked) {popup_kayak_air()}
			        }
			    }
			    
		}
	}

	function search_Hotels(vendor){
		//if (popups=="blocked") {if (!(confirm("It appears you have pop-ups blocked.  Would you like to proceed?"))) {return false}}
		var myinputs = document.getElementById("checkbox_hotel").getElementsByTagName("input")
		var myinput_checked = false
		numPopups = 0;
		for (i=0;i<myinputs.length;i++)
            {
             if (myinputs[i].checked) {numPopups=numPopups+1; myinput_checked = true}
            }
		if (document.getElementById('txtHotelDest').value.length<1 || document.getElementById('datecheckin').value.length<1 || document.getElementById('datecheckout').value=='')
		{
			alert("Please ensure you have selected a destination, as well as check-in and check-out dates.  Thanks!")
		}
		else
		{
			if (!(myinput_checked))
			{
				alert("Please check at least one site to search.  Thanks!")
			}
			else
			    reset_popup();
			    if (vendor!='')
			        {
			        numPopups=1;
			        eval("popup_"+vendor+"_hotel()");
			        }
			    else
			        {
			        if (document.getElementById("ckbox_h_tvly").checked) {popup_tvly_hotel()}
			        if (document.getElementById("ckbox_h_hotw").checked) {popup_hotw_hotel()}
			        if (document.getElementById("ckbox_h_orbitz").checked) {popup_orb_hotel()}
			        if (document.getElementById("ckbox_h_ctix").checked) {popup_ctix_hotel()}
			        if (document.getElementById("ckbox_h_exp").checked) {popup_exp_hotel()}
			        if (document.getElementById("ckbox_h_hotels").checked) {popup_hotels_hotel()}
			        if (document.getElementById("ckbox_h_kayak").checked) {popup_kayak_hotel()}
			        }
		}
	}
	
	function search_Cars(vendor){
		//if (popups=="blocked") {if (!(confirm("It appears you have pop-ups blocked.  Would you like to proceed?"))) {return false}}
		var myinputs = document.getElementById("checkbox_car").getElementsByTagName("input")
		var myinput_checked = false
		numPopups = 0;
		for (i=0;i<myinputs.length;i++)
            {
             if (myinputs[i].checked) {numPopups=numPopups+1; myinput_checked = true}
            }
		if (document.getElementById('txtCarDest').value.length<1 || document.getElementById('datePickup').value.length<1 || document.getElementById('dateDropoff').value=='')
		{
			alert("Please ensure you have selected a destination, as well as pickup and dropoff dates.  Thanks!")
		}
		else
		{
			if (!(myinput_checked))
			{
				alert("Please check at least one site to search.  Thanks!")
			}
			else
			    reset_popup();
			    if (vendor!='')
			        {
			        numPopups=1;
			        eval("popup_"+vendor+"_car()");
			        }
			    else
			        {			    
			        if (document.getElementById("ckbox_c_tvly").checked) {popup_tvly_car()}
			        if (document.getElementById("ckbox_c_hotw").checked) {popup_hotw_car()}
			        if (document.getElementById("ckbox_c_orbitz").checked) {popup_orb_car()}
			        if (document.getElementById("ckbox_c_ctix").checked) {popup_ctix_car()}
			        if (document.getElementById("ckbox_c_exp").checked) {popup_exp_car()}
			        if (document.getElementById("ckbox_c_kayak").checked) {popup_kayak_car()}
			        }
		}
	}

	function search_Deals(){
		if (popups=="notblocked") {if (!(confirm("It appears you have pop-ups blocked.  Would you like to proceed?"))) {return false}}
		var myinputs = document.getElementById("checkbox_car").getElementsByTagName("input")
		var myinput_checked = false
		for (i=0;i<myinputs.length;i++)
            {
             if (myinputs[i].checked) {myinput_checked = true}
            }
		if (document.getElementById('txtCarDest').value.length<1 || document.getElementById('datePickup').value.length<1 || document.getElementById('dateDropoff').value=='')
		{
			alert("Please ensure you have selected a destination, as well as pickup and dropoff dates.  Thanks!")
		}
		else
		{
			if (!(myinput_checked))
			{
				alert("Please check at least one site to search.  Thanks!")
			}
			else
			    if (document.getElementById("ckbox_c_tvly").checked) {popup_tvly_car()}
		}
	}
	
	
	//google tdz.com maps key: ABQIAAAA3n793ffarWeHR1pYbQCRBhRcmsuiH9LdPpScACJffklU_g9h_xSMu1pjgQwilWSJYfE_GUZgD-yfpA
	

	
	
	function init_afdp2(start_date) {
		var mylist=document.getElementById('calendarContainerreturn').childNodes;
		for (i=0; i<mylist.length; i++)
		    {document.getElementById('calendarContainerreturn').removeChild(mylist[i])}
		A_fDP2 = new FDP(start_date, "A", "end");
		//alert("init:" + A_fDP2.date); //works
        }

	function init_hfdp2(start_date) {
		var mylist=document.getElementById('calendarContainercheckout').childNodes;
		for (i=0; i<mylist.length; i++)
		    {document.getElementById('calendarContainercheckout').removeChild(mylist[i])}
		H_fDP2 = new FDP(start_date, "H", "end");
	}

	function init_cfdp2(start_date) {
		var mylist=document.getElementById('calendarContainerdropoff').childNodes;
		for (i=0; i<mylist.length; i++)
		    {document.getElementById('calendarContainerdropoff').removeChild(mylist[i])}
		C_fDP2 = new FDP(start_date, "C", "end");
	}
	
	function present(obj, obj_frame, comp_obj, comp_obj_frame) { //iframe is a lot wider, a bit shorter
		//calcontainer, iframe
		//moveObject(obj, event, ref_field);
		//moveObject(obj_frame, event, ref_field);
		show_hide(obj);
		document.getElementById(obj_frame).style.display="block";
		if (firefox){
		    document.getElementById(obj_frame).width=document.getElementById(obj).offsetWidth-4;
		    document.getElementById(obj_frame).height=document.getElementById(obj).offsetHeight-4;
		}
		else{
		    document.getElementById(obj_frame).style.width=document.getElementById(obj).offsetWidth;
		    document.getElementById(obj_frame).style.height=document.getElementById(obj).offsetHeight;	
		}
		
		document.getElementById(obj).style.zIndex=1000; document.getElementById(obj_frame).style.zIndex=900;
		//turn off complementary calendar
	    if (el = document.getElementById(comp_obj)) {el.style.display='none';}
		if (el = document.getElementById(comp_obj_frame)) {el.style.display='none';}
	}
	
	
	// This function will be called when the user selects a date:
	function handleSelection_A() {
		document.getElementById("dateLeave").value=A_fDP.date.getMonth()+1+"/"+A_fDP.date.getDate()+"/"+A_fDP.date.getFullYear()
		show_hide('calendarContainerleave');
		show_hide('iframeleave');
	}
	function handleSelection2_A() {
		document.getElementById("dateReturn").value=A_fDP2.date.getMonth()+1+"/"+A_fDP2.date.getDate()+"/"+A_fDP2.date.getFullYear()
		show_hide('calendarContainerreturn');
		show_hide('iframereturn');
	}    
	function handleSelection_H() {
		document.getElementById("datecheckin").value=H_fDP.date.getMonth()+1+"/"+H_fDP.date.getDate()+"/"+H_fDP.date.getFullYear()
		show_hide('calendarContainercheckin');
		show_hide('iframecheckin');
	}
	function handleSelection2_H() {
		document.getElementById("datecheckout").value=H_fDP2.date.getMonth()+1+"/"+H_fDP2.date.getDate()+"/"+H_fDP2.date.getFullYear()
		show_hide('calendarContainercheckout');
		show_hide('iframecheckout');
	}   
	function handleSelection_C() {
		document.getElementById("datePickup").value=C_fDP.date.getMonth()+1+"/"+C_fDP.date.getDate()+"/"+C_fDP.date.getFullYear()
		show_hide('calendarContainerpickup');
		show_hide('iframepickup');
	}
	function handleSelection2_C() {
		document.getElementById("dateDropoff").value=C_fDP2.date.getMonth()+1+"/"+C_fDP2.date.getDate()+"/"+C_fDP2.date.getFullYear()
		show_hide('calendarContainerdropoff');
		show_hide('iframedropoff');
	}   


	function swapstyle(obj) {
		//alert("swap")
		obj.style.display=obj.style.display=="block"? "none" : "block"
	}
	
	function toggle_ckb(obj) {
	    //alert(obj);
	    //alert(document.getElementById(obj).checked);
	    document.getElementById(obj).checked=!(document.getElementById(obj).checked)
	}


