			var hasShownOnce=false;
			$(function () {
			    var inputKW = document.form1.inputKW.value;
			    $(".SearchTypeInactive:first").css({ backgroundColor: "white" });
			    $(".SearchTypeInactive:not(:first)").css({ backgroundColor: "#EFEEEE" })
			    $(".sb1_radio").attr("checked", "checked");
			    $("#countryCity").focus(function () {
			        SBchange(1);
			    });
			    $(".DynamicInput").one("focus", function () {
			        var focusFunc = $.proxy(function () {
			            var val = $(this).val();
			            if (val == $(this).attr("_o_val")) $(this).val("").css({ color: "black" });
			        }, this);
			        $(this).attr("_o_val", $(this).val());
			        focusFunc();

			        $(this).focus(focusFunc);
			    }).blur(function () {
			        var val = $(this).val();
			        if (val == "") $(this).css({ color: "#AAA9A9" }).val($(this).attr("_o_val"));
			    })
			    if (inputKW != '') {
			        SBchange(1);
			        document.form1.countryCity.value = inputKW;
			        document.form1.submit();
			    }

			    $("#cloestLoc").geo_autocomplete({ geocoder_types: "locality,political,sublocality,neighborhood,country,premise,street_address,postal_code,subpremise,airport", mapwidth: 100, mapheight: 70, geocoder_address: true });

			    function setDateLiveAvailDate(dayFormatted, monthFormatted, yearFormatted) {
			        
			        $("#live_start_day").val(dayFormatted);
			        $("#live_start_month").val(monthFormatted);
			        $("#live_start_year").val(yearFormatted);
			        
			    }

			    $("#dpick").datepicker(
                {
                    minDate: '-3y',
                    maxDate: '+1y',
                    defaultDate: +7,
                    dateFormat: 'd-MM-yy',
                    showOn: "both",
                    buttonImage: "images/calendar.gif",
                    changeMonth: true,
                    changeYear: true,
                    buttonImageOnly: true,
                    onSelect: function (dateText, inst) {

                        var theDate = new Date(Date.parse($(this).datepicker('getDate')));
                        var dayFormatted = $.datepicker.formatDate('d', theDate);
                        var monthFormatted = $.datepicker.formatDate('m', theDate);
                        var yearFormatted = $.datepicker.formatDate('yy', theDate);

                        setDateLiveAvailDate(dayFormatted, monthFormatted, yearFormatted)

                    },
                    beforeShow: function (input, inst) {
                        $(this).val(this.defaultDate);


                    }
                });
                

                var now = new Date();
                now.setDate(now.getDate() + 7);
                var formattedDate = $.datepicker.formatDate('d-MM-yy', now);

                        

                var dayFormatted = $.datepicker.formatDate('d', now);
                var monthFormatted = $.datepicker.formatDate('m', now);
                var yearFormatted = $.datepicker.formatDate('yy', now);
                    
                setDateLiveAvailDate(dayFormatted, monthFormatted, yearFormatted)

                   
                $("#dpick").val(formattedDate);
                $("#liveStartTime").val("90am");

			});
        
			
			function updateBookMultiple() {
				$("#MultiSiteSelected").attr("checked", true);
			}
			
			
			function LHSUpdateMultisiteOptions(chk) {
				if(chk.checked) {
					hideVCLHSOptions();
					$("#LHSMultisiteOptions").slideDown(500);
				} else {
					$("#LHSMultisiteOptions").slideUp(500);
					if($("#FindTele").attr("checked")) {
						updateSearchType(document.getElementById("FindTele"));
					} else {
						updateSearchType(document.getElementById("FindVC"));
					}
				}
			}
			
			function hideVCLHSOptions() {
				$("#SearchBkFrmOptions").hide();
				$("#BookTelepresence").hide();
				$("tr.ImmersiveTelepresenceRow").css("display", "none");
			}
			
			function submitSiteBooking(numberOfSites) {
				//intermediate on-page form between page actions and data submission
				var msFormProxy = document.multisite_start_booking;
				
				msFormProxy.LocationNumber.value = numberOfSites;
				msFormProxy.MultiSiteSelected.value = "Y";
				
				msFormProxy.submit();
				return false;
			}
			
			function submitMultisite() {
				//get the number of rooms the user has selected.
		
				var locationFormElement = document.form1._LocationNumber;
				var selectedRoomCount   = locationFormElement.value;
				
				//submit it
				submitSiteBooking( selectedRoomCount );
			}
			
			function doSinglesiteSubmit() {
				return submitSiteBooking( 1 );
			}
			
			var _dss = doSinglesiteSubmit;
			
			function openTelepresencePopup(URL) {
				day = new Date();
				id = day.getTime();
				eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600');");
			}

			function SBchange(TypeIn) {
			
				TypeInVal = TypeIn;
				if (TypeIn > 0) {
					$(".SearchTypeInactive:eq("+(TypeInVal-1)+")").css({backgroundColor:"white"});
					$(".SearchTypeInactive:not(:eq("+(TypeInVal-1)+"))").animate({backgroundColor:"#EFEEEE"});
				}
                
				if (TypeInVal == 1) {
					document.form1.ZipSearch.checked = false;
					document.form1.g.checked = false;
					document.form1.avaSearch.checked = false;
					$("#LNavAvailStyle").slideUp();
					$("#LNavZipPost").slideUp();
					$("#LNavClosest").slideUp();
					$("#LNavCountryCity").slideDown();
					document.form1.ChkAvl.value='';
					document.form1.latLngSearch.value='Y';
					$("#countryCity").attr('name', 'kw') 
					$("#cloestLoc").attr('name', "");
					$("#avaLoc").attr('name', "");
					
	
					document.form1.pcode.value='';
                    $("#thisSearchType").val("countryCity");
				}

				if (TypeInVal == 2) {
					document.form1.DLSearch.checked = false;
					document.form1.ZipSearch.checked = false;
					document.form1.avaSearch.checked = false;
					$("#gmap").attr("checked", true);
					$("#LNavClosest").slideDown();
					$("#LNavZipPost").slideUp();
					$("#LNavCountryCity").slideUp();
					$("#LNavAvailStyle").slideUp();
					document.form1.ChkAvl.value='';
					document.form1.latLngSearch.value='Y';
					$("#countryCity").attr('name', "");
					$("#cloestLoc").attr('name', "kw");
					$("#avaLoc").attr('name', "");
					
					document.form1.pcode.value='';
				}

				if (TypeInVal == 3) {
					document.form1.DLSearch.checked = false;
					document.form1.ZipSearch.checked = false;
					document.form1.g.checked = false;
					$("#LNavAvailStyle").slideDown();
					$("#LNavCountryCity").slideUp();
					$("#LNavZipPost").slideUp();
					$("#LNavClosest").slideUp();
					document.form1.ChkAvl.value='Y';
					document.form1.latLngSearch.value='Y';
					$("#countryCity").attr('name', '')
					$("#cloestLoc").attr('name', "");
					$("#avaLoc").attr('name', 'kw');
					
					document.form1.pcode.value='';
                    
                    $("#thisSearchType").val("liveAvail");
				}
				
				if (TypeInVal == 4) {
					document.form1.DLSearch.checked = false;
					document.form1.avaSearch.checked = false;
					document.form1.g.checked = false;
					document.form1.ChkAvl.value='';
					document.form1.latLngSearch.value='';
					document.form1.countryCity.value = '';
					document.form1.CountryID.selectedIndex = 1;
					document.form1.StateID.selectedIndex = 0;
					document.form1.keyword.selectedIndex = 0;
					$("#LNavZipPost").slideDown();
					$("#LNavCountryCity").slideUp();
					$("#LNavClosest").slideUp();
					$("#LNavAvailStyle").slideUp();
                   
                    
					document.form1.pcode.value='Enter Zip / Postcode Here';
				}
			}

			function setCountryList() {
				for (var i = document.form1.CountryID.options.length; i > 0; i--)
				{
					document.form1.CountryID.options[0] = null;
				}
	   			 document.form1.CountryID.options[0] = new Option("Please Select", "0", false, false);
				 ii=0;
				 for (var i = 0; i < CountryArray.length; i++) {
				 	
					ii=ii+1;
					document.form1.CountryID.options[ii] = new Option(CountryArray[i][1], CountryArray[i][0], false, false);
					
				 }
				 
			}
