	function displayDirectSearch(strBookingURL,strAffiliateID, strProviderID, strPremisesCode, strChildren, strInfants, strBackgroundImage,strBackgroundColor)
	{	
		//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="hdnBookingURL" name="hdnBookingURL" value=' + strBookingURL + '>');
		document.write('<input type= "hidden" id="hdnAffiliateID" name="hdnAffiliateID" value=' + strAffiliateID + '>');
		document.write('<input type= "hidden" id="hdnProviderID" name="hdnProviderID" value=' + strProviderID + '>');
		document.write('<input type= "hidden" id="hdnPremisesCode" name="hdnPremisesCode" value=' + strPremisesCode + '>');

        var 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" '+ strGullSurroundStyle + '><!--outer table for border-->');
		document.write('<div class="gullAdult"><div class="gullAdultsTitle">Adults</div><select id="selNumAdults" name="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="selNumChildren" name="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="selNumInfants" name="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="selNumNights" name="selNumNights">');
		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('<option value="9" >9</option>');
		document.write('<option value="10" >10</option>');
		document.write('<option value="11" >11</option>');
		document.write('<option value="12" >12</option>');
		document.write('<option value="13" >13</option>');
		document.write('<option value="14" >14</option>');
		document.write('<option value="15" >15</option>');
		document.write('<option value="16" >16</option>');
		document.write('<option value="17" >17</option>');
		document.write('<option value="18" >18</option>');
		document.write('<option value="19" >19</option>');
		document.write('<option value="20" >20</option>');
		document.write('<option value="21" >21</option>');
		document.write('<option value="22" >22</option>');
		document.write('<option value="23" >23</option>');
		document.write('<option value="24" >24</option>');
		document.write('<option value="25" >25</option>');
		document.write('<option value="26" >26</option>');
		document.write('<option value="27" >27</option>');
		document.write('<option value="28" >28</option>');
		document.write('<option value="29" >29</option>');
		document.write('<option value="30" >30</option>');
		document.write('<option value="31" >31</option>');
		document.write('</select>');
		document.write('</div>');
		
		document.write('<input name="date_sel" type="text" id="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="date_sel_dd" name="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;
					document.getElementById('date_sel').value =  counter;
				}
			document.write('>' + counter );
			document.write('</option>');
		}
		document.write('</select> ');
		
		document.write('<select class="gullMonthYear"  name="date_sel_mm" id="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=' + yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter) );
					if ((monthCounter == parseInt(todaysDate.getMonth()+1)) && (yearCounter == parseInt(todaysDate.getFullYear())))
						{
							document.write(' selected="selected"');
							//document.GullDirectSearchfrm.date_sel.value =  yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter);
						}
					document.write('>' + m_names[monthCounter-1] + '-' + yearCounter);
					document.write('</option>');
				}
			}
			else
			{
				for (var monthCounter = 1; monthCounter<=12;monthCounter++)
				{
					document.write('<option ');
					document.write('value=' + yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter) );

					if ((monthCounter == parseInt(todaysDate.getMonth()+1)) && (yearCounter == parseInt(todaysDate.getFullYear())))
						{
							document.write(' selected="selected"');
							//document.GullDirectSearchfrm.date_sel.value =  yearCounter +'|'+ ((monthCounter+= "").length < 2 ? "0" + monthCounter : monthCounter);
						}
					document.write('>' + m_names[monthCounter-1] + '-' + yearCounter);
					document.write('</option>');
				}
			}
		}
		
		document.write('</select> ');
		document.write('<input name="date_sel_fd_but" type="button" id="date_sel_fd_but" class="gullCalendar" style="width: 20px; height: 20px;" />');
	    document.write('</div>');
	    document.write('<input type=button class="gullBtnSearch" id=Search_Button alt="Check Availability" onclick="Search()" />');
		document.write('</div>');
		//document.write('</from>')
	}
	
	
	
	
	
	
	

	//declare variable to hold URL - build URL from controls on page - redirect page to this URL
	function Search() 
	{
	    //var GullFormStore = document.forms['GullDirectPremSearchfrm'];
        var gullYear = document.getElementById('date_sel');
		var myStr = document.getElementById('date_sel_mm').value.split("|");
		
		var gullYear = myStr[0];
		var gullMonth = myStr[1];
		
		var gullChild; 
		if(document.getElementById('selNumChildren') == undefined)
		{gullChild = 0;}
		else{gullChild = document.getElementById('selNumChildren').value;}
		var gullInfants;
		if(document.getElementById('selNumInfants') == undefined)
		{gullInfants = 0;}
		else
		{gullInfants = document.getElementById('selNumInfants').value;}
		 
	
		//if(isValidDate(gullForm.selDays.value,gullForm.hdnSelectedMonth.value-1,gullForm.hdnSelectedYear.value))
		if(isValidDate(document.getElementById('date_sel_dd').value,gullMonth-1,gullYear))
		{
			//variable to hold our deepLink
			var deepLink;

			//build the URL for deepLinking
			deepLink = document.getElementById('hdnBookingURL').value;
			deepLink = deepLink + "?affiliateid=" + document.getElementById('hdnAffiliateID').value;
			deepLink = deepLink + "&ProvID=" +  document.getElementById('hdnProviderID').value;;
			deepLink = deepLink + "&PremisesCode=" + document.getElementById('hdnPremisesCode').value;
			deepLink = deepLink + "&AffiliatevisitID=" + "1";
			deepLink = deepLink + "&selNumAdults=" + document.getElementById('selNumAdults').value;
			deepLink = deepLink + "&selNumChildren=" + gullChild;
			deepLink = deepLink + "&selNumInfants=" + gullInfants;
			deepLink = deepLink + "&selArriveMonth=" + gullMonth;
			deepLink = deepLink + "&selArriveYear=" + gullYear;
			deepLink = deepLink + "&selArriveDay=" + document.getElementById('date_sel_dd').value;
			deepLink = deepLink + "&selNumNights=" + document.getElementById('selNumNights').value;
			deepLink = deepLink + "&isAdvanced=" + "1";
			deepLink = deepLink + "&hdnAction=" + "search";
			deepLink = deepLink + "&SelCurrency=" + "978";

			//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;			
		}
	}