
	
	function displayDirectSearch(strBookingURL,strAffiliateID, strProviderID, strPremisesCode, strChildren, strInfants, strBackgroundImage,strBackgroundColor, strStyle, strNumNightsDefault, strCalNumber)
	{		
	    var strGullSurroundStyle;
        var strGullSurroundType;
        strGullSurroundStyle = "";
        strGullSurroundStyle = "";
        if(strBackgroundColor!="")
        {
           strGullSurroundStyle = 'style="background-color:' + strBackgroundColor + '"';
        }
        if(strBackgroundImage!="")
        {
           strGullSurroundStyle = 'style="background:transparent url(' + strBackgroundImage + ') no-repeat 0 0"';
        }       
        
        
		document.write('<div class="gullSurround'+ strStyle + '" '+ strGullSurroundStyle + '><!--outer table for border-->')
	
	
		document.write('<form id="GullDirectPremSearchfrm" name=GullDirectPremSearchfrm>')
		//hidden controls to hold parameters passed in for button click event below 
		document.write('<input type= "hidden" id="' + strCalNumber + '_hdnBookingURL" name="' + strCalNumber + '_hdnBookingURL" value=' + strBookingURL + '>')
		document.write('<input type= "hidden" id="' + strCalNumber + '_hdnAffiliateID" name="' + strCalNumber + '_hdnAffiliateID" value=' + strAffiliateID + '>')
		document.write('<input type= "hidden" id="' + strCalNumber + '_hdnProviderID" name="' + strCalNumber + '_hdnProviderID" value=' + strProviderID + '>')
		document.write('<input type= "hidden" id="' + strCalNumber + '_hdnPremisesCode" name="' + strCalNumber + '_hdnPremisesCode" value=' + strPremisesCode + '>')

       
		document.write('<div class="gullAdult"><div class="gullAdultsTitle">Adults</div><select id="' + strCalNumber + '_selNumAdults" name="' + strCalNumber + '_selNumAdults">')
		document.write('<option value="1">1</option>')
		document.write('<option value="2" selected>2</option>')
		document.write('<option value="3">3</option>')
		document.write('<option value="4">4</option>')
		document.write('<option value="5">5</option>')
		document.write('<option value="6">6</option>')
		document.write('<option value="7">7</option>')
		document.write('<option value="8">8</option>')
		document.write('</select>')
		document.write('</div>')
		
		
		if(strChildren =='yes') 
		{
		    document.write('<div class="gullChild"><div class="gullChildrenTitle">Children</div><select id="' + strCalNumber + '_selNumChildren" name="' + strCalNumber + '_selNumChildren">')
		    document.write('<option value="0" selected>0</option>')
		    document.write('<option value="1">1</option>')
		    document.write('<option value="2">2</option>')
		    document.write('<option value="3">3</option>')
		    document.write('<option value="4">4</option>')
		    document.write('<option value="5">5</option>')
		    document.write('<option value="6">6</option>')
		    document.write('<option value="7">7</option>')
		    document.write('<option value="8">8</option>')
		    document.write('</select>')
		    document.write('</div>')
		}
		
		if(strInfants =='yes') 
		{
		    document.write('<div class="gullInfants"><div class="gullInfantsTitle">Infants</div><select id="' + strCalNumber + '_selNumInfants" name="' + strCalNumber + '_selNumInfants">')
		    document.write('<option value="0" selected>0</option>')
		    document.write('<option value="1">1</option>')
		    document.write('<option value="2">2</option>')
		    document.write('<option value="3">3</option>')
		    document.write('<option value="4">4</option>')
		    document.write('<option value="5">5</option>')
		    document.write('<option value="6">6</option>')
		    document.write('<option value="7">7</option>')
		    document.write('<option value="8">8</option>')
		    document.write('</select>')
		    document.write('</div>')
		}

		document.write('<div class="gullNights">')
		document.write('<div class="gullNightsTitle">Night(s)</div>')
		document.write('<select id="' + strCalNumber + '_selNumNights" name="' + strCalNumber + '_selNumNights">')
		    for (var counter = 1; counter<=31;counter++)
		    {
			    document.write('<option ')  
			    document.write('value=' + counter)
			    if (counter == parseInt(strNumNightsDefault)) 
				    {
					    document.write(' selected="selected"');
				    }
			    document.write('>' + counter )
			    document.write('</option>')
		    }
		document.write('</select> ')
		document.write('</div>')
		
		
		
		document.write('<input name="' + strCalNumber + '_date_sel" type="text" id="' + strCalNumber + '_date_sel" class="split-date no-transparency range-low-2008-03-06 range-high-2010-03-28 lang-en" style="display:none;" />')

		document.write('<div class="gullArrival"><div class="gullArrivalTitle">Arrival</div><select class="gullDays" id="' + strCalNumber + '_date_sel_dd" name="' + strCalNumber + '_date_sel_dd_Day">')
		var todaysDate = new Date();		

		for (var counter = 1; counter<=31;counter++)
		{
			document.write('<option ')  
			document.write('value=' + counter)
			if (counter == parseInt(todaysDate.getDate())) 
				{
					document.write(' selected');
					//document.GullDirectPremSearchfrm.date_sel.value =  counter;
					var gullDateSel = document.getElementById(strCalNumber + '_date_sel');
					gullDateSel.calue = counter;
				}
			document.write('>' + counter )
			document.write('</option>')
		}
		document.write('</select> ')
		
		document.write('<div class="gullSpace">&nbsp;</div><select class="gullMonthYear"  name="' + strCalNumber + '_date_sel_mm" id="' + strCalNumber + '_date_sel_mm">')
		//document.write('<select id="selMonthYear" name="selMonthYear" ONCLICK="JavaScript:SplitIntoHiddenControls()">')
		var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

		for (var yearCounter = todaysDate.getFullYear(); yearCounter<2012; yearCounter++ )
		{
			if(yearCounter == todaysDate.getFullYear())
			{
				for (var monthCounter = todaysDate.getMonth()+1; monthCounter<=12;monthCounter++)
				{
					document.write('<option ')
					//document.write('value=' + monthCounter + '-' + yearCounter)
                    document.write('value=' + yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter) )
					if ((monthCounter == parseInt(todaysDate.getMonth()+1)) && (yearCounter == parseInt(todaysDate.getFullYear())))
						{
							document.write(' selected')
						}
					document.write('>' + m_names[monthCounter-1] + '-' + yearCounter)
					document.write('</option>')
				}
			}
			else
			{
				for (var monthCounter = 1; monthCounter<=12;monthCounter++)
				{
					document.write('<option ')
					//document.write('value=' + monthCounter + '-' + yearCounter)
                    document.write('value=' + yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter) )
					if ((monthCounter == parseInt(todaysDate.getMonth()+1)) && (yearCounter == parseInt(todaysDate.getFullYear())))
						{
							document.write(' selected')
						}
					document.write('>' + m_names[monthCounter-1] + '-' + yearCounter)
					document.write('</option>')
				}
			}
		}
		document.write('</select> ')
		document.write('<input name="' + strCalNumber + '_date_sel_fd_but" type="button" id="' + strCalNumber + '_date_sel_fd_but" class="gullCalendar" style="width: 20px; height: 20px;" />')
	    document.write('</div>')
	    document.write('<input type=button class="gullBtnSearch" id=Search_Button value = "Search" alt="Check Availability" onclick="Search(' + strCalNumber + ')" />')
		
		document.write('</from>')
		document.write('</div>')
	}
	
	//declare variable to hold URL - build URL from controls on page - redirect page to this URL
	function Search(relatedCalender) 
	{
	    var gullDaySel = document.getElementById(relatedCalender + '_date_sel_dd');
	    var gullDateSel = document.getElementById(relatedCalender + '_date_sel');
	    var gullMonthSel = document.getElementById(relatedCalender + '_date_sel_mm');
	    var gullNumAdults = document.getElementById(relatedCalender + '_selNumAdults');
	    var gullNumChildren = document.getElementById(relatedCalender + '_selNumChildren');
	    var gullNumInfants = document.getElementById(relatedCalender + '_selNumInfants');
	    var gullNumNights = document.getElementById(relatedCalender + '_selNumNights');
	    
	    var gullBookingUrl = document.getElementById(relatedCalender + '_hdnBookingURL');
	    var gullAffiliateID = document.getElementById(relatedCalender + '_hdnAffiliateID');
	    var gullProviderID = document.getElementById(relatedCalender + '_hdnProviderID');
	    var gullPremisesCode = document.getElementById(relatedCalender + '_hdnPremisesCode');
	    
	    var gullForm = document.forms['GullDirectPremSearchfrm'];
	    //var GullFormStore = document.forms['GullDirectPremSearchfrm'];
        //var gullYear = gullForm.date_sel.value;
        var gullYear = gullDateSel.value;
		var myStr = gullMonthSel.value.split("|");
		var gullYear = myStr[0];
		var gullMonth = myStr[1];
		
		var gullChild; 
		if(gullNumChildren == undefined)
		{gullChild = 0;}
		else{gullChild = gullNumChildren.value;}
		var gullInfants;
		if(gullNumInfants == undefined)
		{gullInfants = 0;}
		else
		{gullInfants = gullNumInfants.value;}
		 
	
		//if(isValidDate(gullForm.selDays.value,gullForm.hdnSelectedMonth.value-1,gullForm.hdnSelectedYear.value))
		if(isValidDate(gullDaySel.value,gullMonth-1,gullYear))
		{
			//variable to hold our deepLink
			var deepLink

			//build the URL for deepLinking
			deepLink = gullBookingUrl.value 	
			deepLink = deepLink + "?affiliateid=" + gullAffiliateID.value 	
			deepLink = deepLink + "&provID=" + gullProviderID.value 	
			deepLink = deepLink + "&premisesCode=" + gullPremisesCode.value 	
			deepLink = deepLink + "&affiliatevisitID=" + "1"
			deepLink = deepLink + "&selNumAdults=" + gullNumAdults.value 	
			deepLink = deepLink + "&selNumChildren=" + gullChild 
			deepLink = deepLink + "&selNumInfants=" + gullInfants 
			deepLink = deepLink + "&selArriveMonth=" + gullMonth
			deepLink = deepLink + "&selArriveYear=" + gullYear 
			deepLink = deepLink + "&selArriveDay=" + gullDaySel.value 
			deepLink = deepLink + "&selNumNights=" + gullNumNights.value 
			deepLink = deepLink + "&SelCurrency=" + "978"
			deepLink = deepLink + "&isAdvanced=" + "1"
			deepLink = deepLink + "&hdnAction=" + "search"

			//redirect page to our deepLink URL
			window.location.href = deepLink;
			//	document.write(deepLink);
		}
	}


	function isValidDate(day,month,year)
	{
		/*
		Purpose: return true if the date is valid, false otherwise

		Arguments: day integer representing day of month
		month integer representing month of year
		year integer representing year

		Variables: dteDate - date object

		*/
		var dteDate;
		var todaysDateTime;
		todaysDateTime = new Date();

		//set up a Date object based on the day, month and year arguments
		//javascript months start at 0 (0-11 instead of 1-12)
		dteDate=new Date(year,month,day,"23","59","59");
		
		if (dteDate>=todaysDateTime)
		{
			/*
			Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
			*/
			return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));

		}
		else
		{
			return false;			
		}
	}