	function displaySearch(strBookingURL,strAffiliateID, strProviderID, strPremisesCode)
	{	
		

		document.write('<FORM id=CheckPremfrm name=CheckPremfrm>')
		
		//hidden controls to hold parameters passed in for button click event below 
		document.write('<input type= "hidden" name="hdnBookingURL" value=' + strBookingURL + '>')
		document.write('<input type= "hidden" name="hdnAffiliateID" value=' + strAffiliateID + '>')
		document.write('<input type= "hidden" name="hdnProviderID" value=' + strProviderID + '>')
		document.write('<input type= "hidden" name="hdnPremisesCode" value=' + strPremisesCode + '>')

		document.write('<TABLE width="50%" cellSpacing="0" cellPadding="0" border="0" class="gulliverborder">')
		document.write('<TR>')
		document.write('<TD>')
		document.write('<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0">')
		document.write('<TR>')
		document.write('<TD valign="top" align="left"><b>Adults</b><br><select name="selNumAdults" style="MARGIN-TOP:1px;">')
		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('</TD>')
		document.write('<TD valign="top" align="left"><b>Children</b><br><select name="selNumChildren" style="MARGIN-TOP:1px;">')
		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('</TD>')
		document.write('<TD valign="top" align="left"><b>Infants</b><br><select name="selNumInfants" style="MARGIN-TOP:1px;">')
		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('</TD>')

		document.write('<TD valign="top" align="left">')
		document.write('<b>Night(s)</b><br>')
		document.write('<select name="selNumNights" style="MARGIN-TOP:1px;">')
		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('</TD>')
		document.write('</TR>')
		document.write('</TABLE>')
		document.write('<table cellSpacing=0 cellPadding=0 border = 0>')
		document.write('<tr>')
		document.write('<TD valign=top align=right><b>Arrival</b></td></tr><tr><td align=right><select name="selDays" style="MARGIN-TOP:1px;">')
		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.write('>' + counter )
			document.write('</option>')
		}
		document.write('</select> ')
		document.write('</TD>')
		document.write('<TD valign=top align=left><select name="selMonthYear" style="MARGIN-TOP:1px;" 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)

					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)

					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('</TD>')
		//split selmonthyear which holds month-year as one value into 2 values
		var str=document.CheckPremfrm.selMonthYear.value;
		var myStr = str.split("-")
		//hidden controls to hold selected year and month from split function
		document.write('<input type="hidden" name="hdnSelectedMonth" value=' + myStr[0] + '>')
		document.write('<input type="hidden" name="hdnSelectedYear" value=' + myStr[1] + '>')

		document.write('<TD>')
		document.write('<img src="http://www.resireland.com/inc/cal.gif" alt="Calendar" style="Cursor:hand;" ONCLICK="JavaScript:createCalendar(document.CheckPremfrm.hdnSelectedMonth.value, document.CheckPremfrm.hdnSelectedYear.value)" >')
		document.write('</TD>')
		document.write('<TD>&nbsp;')
		document.write('</TD>')
		document.write('<TD><INPUT type=button  id=Search_Button value = "Search" alt="Check Availability" onclick="javascript:Search();"></TD>')
		document.write('</TR>')
		document.write('</TABLE>')
		document.write('</TD>')
		document.write('</TR>')
		document.write('</TABLE>')

		document.write('</FORM>')
	}

	//declare variable to hold URL - build URL from controls on page - redirect page to this URL
	function Search() 
	{
		if(isValidDate(document.forms['CheckPremfrm'].selDays.value,document.forms['CheckPremfrm'].hdnSelectedMonth.value-1,document.forms['CheckPremfrm'].hdnSelectedYear.value))
		{
			//variable to hold our deepLink
			var deepLink

			//build the URL for deepLinking
			deepLink = document.forms['CheckPremfrm'].hdnBookingURL.value 	
			deepLink = deepLink + "?affiliateid=" + document.forms['CheckPremfrm'].hdnAffiliateID.value 	
			deepLink = deepLink + "&ProvID=" + document.forms['CheckPremfrm'].hdnProviderID.value 	
			deepLink = deepLink + "&PremisesCode=" + document.forms['CheckPremfrm'].hdnPremisesCode.value 	
			deepLink = deepLink + "&AffiliatevisitID=" + "1"
			deepLink = deepLink + "&selNumAdults=" + document.forms['CheckPremfrm'].selNumAdults.value 	
			deepLink = deepLink + "&selNumChildren=" + document.forms['CheckPremfrm'].selNumChildren.value 
			deepLink = deepLink + "&selNumInfants=" + document.forms['CheckPremfrm'].selNumInfants.value 
			deepLink = deepLink + "&selArriveMonth=" + document.forms['CheckPremfrm'].hdnSelectedMonth.value 
			deepLink = deepLink + "&selArriveYear=" + document.forms['CheckPremfrm'].hdnSelectedYear.value 
			deepLink = deepLink + "&selArriveDay=" + document.forms['CheckPremfrm'].selDays.value 
			deepLink = deepLink + "&selNumNights=" + document.forms['CheckPremfrm'].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 SplitIntoHiddenControls()
	{
		var str=document.CheckPremfrm.selMonthYear.value;
		var myStr = str.split("-")
		//hidden controls to hold selected year and month from split function
		document.forms['CheckPremfrm'].hdnSelectedMonth.value=myStr[0];
		document.forms['CheckPremfrm'].hdnSelectedYear.value=myStr[1];
	}

	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;			
		}
	}
