	
	function displayDirectSearch(strBookingURL, strAffiliateID, strProviderID, strLocation, strLocationShowHide, strTownLevel,strPremType, strPremTypeShowHide, strSharing,strPremName,strGrade,strPrice,strFacilities,strChildren,strInfants,stroptional, strBackgroundImage,strBackgroundColor)
	{	
		//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" name="hdnLocation2" value=' + strLocation + ' />')
		//document.write('<input type= "hidden" name="hdnLocation2" value=' + strLocation + ' />')
		document.write('<input type= "hidden" id="hdnTownLevel"name="hdnTownLevel" value=' + strTownLevel + ' />');
		document.write('<input type= "hidden" id="hdnPremType" name="hdnPremType" value=' + strPremType + ' />');
		document.write('<input type= "hidden" id="hdnSharing" name="hdnSharing" value=' + strSharing + ' />');
		document.write('<input type= "hidden" id="hdnPremName" name="hdnPremName" value=' + strPremName + ' />');
		document.write('<input type= "hidden" id="hdnGrade" name="hdnGrade" value=' + strGrade + ' />');
		document.write('<input type= "hidden" id="hdnPrice" name="hdnPrice" value=' + strPrice + ' />');
		document.write('<input type= "hidden" id="hdnFacilities" name="hdnFacilities" value=' + strFacilities + ' />');
		document.write('<input type= "hidden" id="hdnoptional" name="hdnoptional" value=' + stroptional + ' />');
		document.write('<input type= "hidden" id="hdnPremTypeShowHide" name="hdnPremTypeShowHide" value=' + strPremTypeShowHide + ' />');

        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 + '>')

		if(strLocationShowHide=="show"){
		document.write('<div class="gullLocation"><div class="gullLocationTitle">Location:</div>')

		//location combo (mandatory)
		if(strTownLevel=="yes")
			{document.write('<select class="gullTownCombo" id="hdnLocation" name="hdnLocation" onchange="showTowns(this.value)">')}
		else
			{document.write('<select name=hdnLocation>')}
		
		document.write('<option value="" ' + ((strLocation=="")?"selected='selected'":"") + '>please select</option>') 
		document.write('<option value="DU,,,0" ' + ((strLocation=="DU,,,0")?"selected='selected'":"") + '>Dublin County</option>') 
		document.write('<option value="DU,D1,,0" ' + ((strLocation=="DU,D1,,0")?"selected='selected'":"") + '>Dublin City</option>') 
		document.write('<option value="DU,D1,DCC,0" ' + ((strLocation=="DU,D1,DCC,0")?"selected='selected'":"") + '>Dublin City Centre</option>') 
		document.write('<option value="DU,N,D089,0" ' + ((strLocation=="DU,N,D089,0")?"selected='selected'":"") + '>Dublin Airport</option>') 
		//document.write('<option value="DU,N,,0" ' + ((strLocation=="DU,N,,0")?"selected='selected'":"") + '>Dublin County North</option>') 
		//document.write('<option value="DU,S,,0" ' + ((strLocation=="DU,S,,0")?"selected='selected'":"") + '>Dublin County South</option>') 
		//document.write('<option value="DU,W,,0" ' + ((strLocation=="DU,W,,0")?"selected='selected'":"") + '>Dublin County West</option>') 
	    document.write('<option value="GY,,,0" ' + ((strLocation=="GY,,,0")?"selected='selected'":"") + '>Galway County</option>') 
		document.write('<option value="KY,,,0" ' + ((strLocation=="KY,,,0")?"selected='selected'":"") + '>Kerry County</option>') 
		document.write('<option value="CK,,,0" ' + ((strLocation=="CK,,,0")?"selected='selected'":"") + '>Cork County</option>') 
		document.write('<option value="CE,,,0" ' + ((strLocation=="CE,,,0")?"selected='selected'":"") + '>Clare County</option>') 
		document.write('<option value="" ' + ((strLocation=="")?"":"") + '>---------------------------</option>') 
		
		document.write('<option value="AM,,,0" ' + ((strLocation=="AM,,,0")?"selected='selected'":"") + '>Antrim County</option>') 
		document.write('<option value="AH,,,0" ' + ((strLocation=="AH,,,0")?"selected='selected'":"") + '>Armagh County</option>') 
		document.write('<option value="AM,BC,B719,0" ' + ((strLocation=="AM,BC,B719,0")?"selected='selected'":"") + '>Belfast City</option>') 
		document.write('<option value="CW,,,0" ' + ((strLocation=="CW,,,0")?"selected='selected'":"") + '>Carlow County</option>') 
		document.write('<option value="CN,,,0" ' + ((strLocation=="CN,,,0")?"selected='selected'":"") + '>Cavan County</option>') 
		document.write('<option value="CE,,,0" ' + ((strLocation=="CE,,,0")?"selected='selected'":"") + '>Clare County</option>') 
		document.write('<option value="CK,C1,,0" ' + ((strLocation=="CK,C1,,0")?"selected='selected'":"") + '>Cork City</option>') 
		//document.write('<option value="CK,N,,0" ' + ((strLocation=="CK,N,,0")?"selected='selected'":"") + '>Cork(North) County</option>') 
		document.write('<option value="CK,,,0" ' + ((strLocation=="CK,,,0")?"selected='selected'":"") + '>Cork County</option>') 
		document.write('<option value="DY,FV,L709,0" ' + ((strLocation=="DY,FV,L709,0")?"selected='selected'":"") + '>Derry City</option>') 
		document.write('<option value="DY,,,0" ' + ((strLocation=="DY,,,0")?"selected='selected'":"") + '>Derry County</option>') 
		document.write('<option value="DL,,,0" ' + ((strLocation=="DL,,,0")?"selected='selected'":"") + '>Donegal County</option>') 
		document.write('<option value="DN,,,0" ' + ((strLocation=="DN,,,0")?"selected='selected'":"") + '>Down County</option>') 
		document.write('<option value="FH,,,0" ' + ((strLocation=="FH,,,0")?"selected='selected'":"") + '>Fermanagh County</option>') 
		document.write('<option value="GY,G1,,0" ' + ((strLocation=="GY,G1,,0")?"selected='selected'":"") + '>Galway City</option>') 
		document.write('<option value="GY,,,0" ' + ((strLocation=="GY,,,0")?"selected='selected'":"") + '>Galway County</option>') 
		document.write('<option value="KY,,,0" ' + ((strLocation=="KY,,,0")?"selected='selected'":"") + '>Kerry County</option>') 
		document.write('<option value="KE,,,0" ' + ((strLocation=="KE,,,0")?"selected='selected'":"") + '>Kildare County</option>') 
		document.write('<option value="KK,,K037,0" ' + ((strLocation=="KK,,K037,0")?"selected='selected'":"") + '>Kilkenny City</option>') 
		document.write('<option value="KK,,,0" ' + ((strLocation=="KK,,,0")?"selected='selected'":"") + '>Kilkenny County</option>') 
		document.write('<option value="LS,,,0" ' + ((strLocation=="LS,,,0")?"selected='selected'":"") + '>Laois County</option>') 
		document.write('<option value="LM,,,0" ' + ((strLocation=="LM,,,0")?"selected='selected'":"") + '>Leitrim County</option>') 
		document.write('<option value="LK,L1,,0" ' + ((strLocation=="LK,L1,,0")?"selected='selected'":"") + '>Limerick City</option>') 
		document.write('<option value="LK,,,0" ' + ((strLocation=="LK,,,0")?"selected='selected'":"") + '>Limerick County</option>') 
		document.write('<option value="DY,FV,L709,0" ' + ((strLocation=="DY,FV,L709,0")?"selected='selected'":"") + '>Londonderry City</option>') 
		document.write('<option value="DY,,,0" ' + ((strLocation=="DY,,,0")?"selected='selected'":"") + '>Londonderry County</option>') 
		document.write('<option value="LD,,,0" ' + ((strLocation=="LD,,,0")?"selected='selected'":"") + '>Longford County</option>') 
		document.write('<option value="LH,,,0" ' + ((strLocation=="LH,,,0")?"selected='selected'":"") + '>Louth County</option>') 
		document.write('<option value="MO,,,0" ' + ((strLocation=="MO,,,0")?"selected='selected'":"") + '>Mayo County</option>') 
		document.write('<option value="MH,,,0" ' + ((strLocation=="MH,,,0")?"selected='selected'":"") + '>Meath County</option>') 
		document.write('<option value="MN,,,0" ' + ((strLocation=="MN,,,0")?"selected='selected'":"") + '>Monaghan County</option>') 
		document.write('<option value="OY,,,0" ' + ((strLocation=="OY,,,0")?"selected='selected'":"") + '>Offaly County</option>') 
		document.write('<option value="RN,,,0" ' + ((strLocation=="RN,,,0")?"selected='selected'":"") + '>Roscommon County</option>') 
		document.write('<option value="CE,,S020,0" ' + ((strLocation=="CE,,S020,0")?"selected='selected'":"") + '>Shannon Airport</option>') 
		document.write('<option value="SO,,,0" ' + ((strLocation=="SO,,,0")?"selected='selected'":"") + '>Sligo County</option>') 
		document.write('<option value="TI,,,0" ' + ((strLocation=="TI,,,0")?"selected='selected'":"") + '>Tipperary County</option>') 
		document.write('<option value="TE,,,0" ' + ((strLocation=="TE,,,0")?"selected='selected'":"") + '>Tyrone County</option>') 
		document.write('<option value="WD,W1,,0" ' + ((strLocation=="WD,W1,,0")?"selected='selected'":"") + '>Waterford City</option>') 
		document.write('<option value="WD,,,0" ' + ((strLocation=="WD,,,0")?"selected='selected'":"") + '>Waterford County</option>') 
		document.write('<option value="WH,,,0" ' + ((strLocation=="WH,,,0")?"selected='selected'":"") + '>Westmeath County</option>') 
		document.write('<option value="WX,,,0" ' + ((strLocation=="WX,,,0")?"selected='selected'":"") + '>Wexford County</option>') 
		document.write('<option value="WW,,,0" ' + ((strLocation=="WW,,,0")?"selected='selected'":"") + '>Wicklow County</option>') 

		document.write('</select>') 
		//document.write('<div class="gullColumn"><!-- Prem Type -->')
		document.write('</div>')
		}
		else
		{
			document.write('<input type= "hidden" name="hdnLocation"  value=' + strLocation + ' />')
		}
		if(strTownLevel=="yes"){
		//town level combo (optional) - see event on location combo - also remove event from body onload on your html page to initially display town level combo
		document.write('<div class="gullTown" id="txtTowns"></div>')
		}
		
		if(strPremTypeShowHide=="show"){
		//premises type combo (mandatory)
		document.write('<div class="gullType"><div class="gullTypeTitle">Property Type:</div>')
		document.write('<select class="gullPremType" id="gullSelAccomType" name="gullSelAccomType"> ')
		document.write('<option value="1" ' + ((strPremType=="1" || strPremType=="")?"selected='selected'":"") + '>All serviced accommodation</option>') 
		document.write('<option value="2" ' + ((strPremType=="2")?"selected='selected'":"") + '>All self-catering accommodation</option>') 
		document.write('<option value="3" ' + ((strPremType=="3")?"selected='selected'":"") + '>Hotel</option>') 
		document.write('<option value="4" ' + ((strPremType=="4")?"selected='selected'":"") + '>Guesthouse</option>') 
		document.write('<option value="5" ' + ((strPremType=="5")?"selected='selected'":"") + '>Bed and breakfast</option>') 
		document.write('<option value="6" ' + ((strPremType=="6")?"selected='selected'":"") + '>Hostel</option>') 
		document.write('<option value="7" ' + ((strPremType=="7")?"selected='selected'":"") + '>University accommodation</option>') 
		document.write('<option value="20" ' + ((strPremType=="20")?"selected='selected'":"") + '>Hotel &amp; guesthouse</option>') 
		document.write('<option value="21" ' + ((strPremType=="21")?"selected='selected'":"") + '>Townhouse</option>') 
		document.write('<option value="22" ' + ((strPremType=="22")?"selected='selected'":"") + '>Country house</option>') 
		document.write('<option value="23" ' + ((strPremType=="23")?"selected='selected'":"") + '>Farmhouse</option>') 
		document.write('<option value="24" ' + ((strPremType=="24")?"selected='selected'":"") + '>Country house of character</option>') 
		document.write('<option value="25" ' + ((strPremType=="25")?"selected='selected'":"") + '>Entertainment</option>') 
		document.write('<option value="26" ' + ((strPremType=="26")?"selected='selected'":"") + '>Health farm</option>') 
		document.write('<option value="27" ' + ((strPremType=="27")?"selected='selected'":"") + '>Historic house</option>') 
		document.write('<option value="28" ' + ((strPremType=="28")?"selected='selected'":"") + '>Pub accommodation</option>') 
		document.write('<option value="29" ' + ((strPremType=="29")?"selected='selected'":"") + '>Residential activities</option>') 
		document.write('<option value="30" ' + ((strPremType=="30")?"selected='selected'":"") + '>Residential language school</option>') 
		document.write('<option value="31" ' + ((strPremType=="31")?"selected='selected'":"") + '>Restaurant with rooms</option>') 
		document.write('<option value="32" ' + ((strPremType=="32")?"selected='selected'":"") + '>Specialist accommodation</option>') 

		document.write('</select></div>')
		}
		else
		{
			document.write('<input type= "hidden" id="hdnPremType2" name="hdnPremType2"  value=' + strPremType + ' />')
		}
		
		//sharing combo (optional)
		if(strSharing=='yes')
		{
			document.write('<div class="gullShare"><div class="gullShareTitle">Sharing:</div>')
			document.write('<select id="gullSelSharing" name="gullSelSharing">')
			document.write('<option value=1 selected="selected">Sharing Bedroom</option>')
			document.write('<option value=2>Own bed</option> ')
			document.write('<option value=3>Own room</option>')
			document.write('</select></div>')
		}

		//party details (mandatory)
		//document.write('<div class="gullRow">')
		document.write('<div class="gullParty">')
		document.write('<div class="gullPartyTitle">Party:</div>')
		document.write('<div class="gullAdult">Adults')
		document.write('<select class="gullNumAdults" id="gullSelNumAdults" name="gullSelNumAdults">')
		document.write('<option value=1>1</option> ')
		document.write('<option value=2 selected="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></div>')
	
		if(strChildren=='yes')
		{
		    document.write('<div class="gullChild">Children')
		    document.write('<select class="gullNumChildren" name=selNumChildren>')
		    document.write('<option value=0></option>')
		    document.write('<option value=0 selected="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></div>')
		}
		if(strInfants=='yes')
		{
		    document.write('<div class="gullInfants">Infants')
		    document.write('<select class="gullNumInfants" name=selNumInfants>')
		    document.write('<option value=0></option>')
		    document.write('<option value=0 selected="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></div>')
		}
		
		document.write('</div>')
		//document.write('</div><!-- Arrival Details -->')

		//Arrival Date (mandatory)
		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="selected"');
					var gullDateSel = document.getElementById('date_sel');
					gullDateSel = counter;
				}
			document.write('>' + counter )
			document.write('</option>')
		}
		document.write('</select> ')
        
		document.write('<select class="gullMonthYear"  name="date_sel_mm" id="date_sel_mm">')
		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> ')
		
		//split selmonthyear which holds month-year as one value into 2 values
		////////var str=document.GullDirectSearchfrm.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('<input name="date_sel_fd_but" type="button" id="date_sel_fd_but" class="gullCalendar" style="width: 20px; height: 20px;" /></div>')
    

		
		///////document.write('<img src="http://www.resireland.com/inc/cal.gif" alt="Calendar" style="Cursor:hand;" ONCLICK="JavaScript:createCalendar(document.GullDirectSearchfrm.hdnSelectedMonth.value, document.GullDirectSearchfrm.hdnSelectedYear.value)" >')

		if(strTownLevel=="yes"){
		var gullLocation = document.getElementById('hdnLocation');
		showTowns(gullLocation.value);
		
		}
		
		//num nights (mandatory)
		document.write('<div class="gullNight"><div class="gullNightTitle">Night(s):</div>')
		document.write('<select class="gullNumNight" id="gullSelNumNights" name="gullSelNumNights">')
		document.write('<option value=1 selected="selected">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></div>')

		//property name (optional)
		if(strPremName=='yes')
		{
			document.write('<div class="gullProperty"><div class="gullPropertyTitle">Property Name:</div>')
			document.write('<div class="gullPropName"><input maxLength="30" id="txtPremName" name="txtPremName" /></div></div>')
		}

		//grade (optional)
		if(strGrade=='yes')
		{
			document.write('<div class="gullGrade"><div class="gullGradeTitle">Grade:</div>')
			
			document.write('<div class="gullGrdFive"><input type="checkbox" value="Y" id="chkGrade5" name="chkGrade5" />5* Five Star</div>')
			document.write('<div class="gullGrdFour"><input type="checkbox" value="Y" id="chkGrade4" name="chkGrade4" />4* Four Star</div>')
			document.write('<div class="gullGrdThree"><input type="checkbox" value="Y" id="chkGrade3" name="chkGrade3" />3* Three Star</div>')
			document.write('<div class="gullGrdFive"><input type="checkbox" value="Y" id="chkGrade2" name="chkGrade2" />2* Two Star</div>')
			document.write('<div class="gullGrdOne"><input type="checkbox" value="Y" id="chkGrade1" name="chkGrade1" />1* One Star</div>')
			document.write('<div class="gullGrdAll"><input type="checkbox" value="Y" id="chkGradeAll" name="chkGradeAll" checked />All Grades</div></div>')
		}
		//price (optional)
		if(strPrice=='yes')
		{
			document.write('<div class="gullPrice"><div class="gullPriceTitle">Price:</div>')
			document.write('<div class="gullPriFrom"><div class="gullPriFromTitle">From: </div><input id="txtPriceFrom" name="txtPriceFrom" class="txtPriceFrom"/></div>')
			document.write('<div class="gullPriTo"><div class="gullPriToTitle">To: </div><input id="txtPriceTo" name="txtPriceTo" class="txtPriceFrom"/></div></div>')
		}

		//facilities (optional)
		if (strFacilities=='yes') 
		{
			document.write('<div class="gullFac"><div class="gullFacTitle">Facilities:</div>')
			document.write('<div class="gullAccDis"><input type="checkbox" value="Y" id="checkAccess" name="checkAccess" />Access For Disabled</div>')
			document.write('<div class="gullSpa"><input type="checkbox" value="Y" id="checkSpa" name="checkSpa" />Spa</div>')
			document.write('<div class="gullBaby"><input type="checkbox" value="Y" id="checkBaby" name="checkBaby" />Babysitting Facilities</div>')
			document.write('<div class="gullHenStag"><input type="checkbox" value="Y" id="checkHenStag" name="checkHenStag" />Hen/Stag Welcome</div>')
			document.write('<div class="gullBed"><input type="checkbox" value="Y" id="checkBedroom" name="checkBedroom" />Ground Floor Bedrooms</div>')
			document.write('<div class="gullConf"><input type="checkbox" value="Y" id="checkConference" name="checkConference" />Conference Facilities</div>')
			document.write('<div class="gullFam"><input type="checkbox" value="Y" id="checkFamily" name="checkFamily" />Family Friendly</div>')
			document.write('<div class="gullPets"><input type="checkbox" value="Y" id="checkPetsinside" name="checkPetsinside" />Pets Welcome Inside</div>')
			document.write('<div class="gullWiFi"><input type="checkbox" value="Y" id="checkWIFI" name="checkWIFI" />WIFI Internet Access</div>')
			document.write('<div class="gullSwim"><input type="checkbox" value="Y" id="checkSwimming" name="checkSwimming" />Swimming pool</div>')
			document.write('<div class="gullLeis"><input type="checkbox" value="Y" id="checkLeisure" name="checkLeisure" />Leisure Complex on Property</div>')
			document.write('<div class="gullPriv"><input type="checkbox" value="Y" id="checkPrivate" name="checkPrivate" />Private Car Parking</div>')
			document.write('<div class="gullFacilHid"><input type="hidden" id="strfacilities" name="strfacilities" /></div>')
		}

		document.write('<input type=button class="gullBtnSearch" id=Search_Button value = "Search" alt="Check Availability" onclick="subx()" /></div>')
		
		//document.write('</div>')
		//document.write('</div>')
	}


	function subx() 
	{
		var gullYearMonth = document.getElementById('date_sel_mm').value.split("|");
		var gullYear = gullYearMonth[0];
		var gullMonth = gullYearMonth[1];
		var gullDaySel = document.getElementById('date_sel_dd').value;
		var gullLocation = document.getElementById('hdnLocation');
		var gullUrl = document.getElementById('hdnBookingURL').value;
	    var gullAffiliateID = document.getElementById('hdnAffiliateID').value;
	    var gullProviderID = document.getElementById( 'hdnProviderID').value;
	    var gullNumAdults = document.getElementById('gullSelNumAdults').value;
	    var gullNumChildren = document.getElementById('selNumChildren');
	    var gullNumInfants = document.getElementById('selNumInfants');
	    var gullNumNights = document.getElementById('gullSelNumNights');
		
		
	    if(isValidDate(gullDaySel,gullMonth-1,gullYear))
		{
			//variable to hold our deepLink
			var deepLink

			if (( gullLocation.value == '' ))
				{
					alert('Please select a location.')
					gullLocation.focus();
					return;
				}

			//build the URL for deepLinking
			deepLink = gullUrl
			deepLink = deepLink + "?affiliatevisitid=1"
			deepLink = deepLink + "&affiliateid=" + gullAffiliateID
			deepLink = deepLink + "&ProvID=" + gullProviderID
			deepLink = deepLink + "&IsAdvanced=1" 

            var gullTypeShowHide = document.getElementById('hdnPremTypeShowHide');
			if(gullTypeShowHide.value=="show"){
			    var gullAccomType = document.getElementById('gullSelAccomType');
				deepLink = deepLink + "&selAccomType=" + gullAccomType.value;
		    }
			else
			{			
			    var gullAccomType = document.getElementById('hdnPremType2');
				deepLink = deepLink + "&selAccomType=" + gullAccomType.value;
			}
			deepLink = deepLink + "&selArriveDay=" + gullDaySel;
			deepLink = deepLink + "&selArriveMonth=" + gullMonth;
			deepLink = deepLink + "&selArriveYear=" + gullYear;
			deepLink = deepLink + "&selNumAdults=" + gullNumAdults;	
			
			if(gullNumChildren == undefined)
			{ 
			    deepLink = deepLink + "&selNumChildren=0";
			}
			else
			{
			    deepLink = deepLink + "&selNumChildren=" + gullNumChildren.value;
			}
			if(gullNumInfants == undefined)
			{ 
			    deepLink = deepLink + "&selNumInfants=0"; 
			}
			else
			{
			    deepLink = deepLink + "&selNumInfants=" + gullNumInfants.value;
			}
			
			
			deepLink = deepLink + "&selNumNights=" + gullNumNights.value 
            
            var gullFacilities = document.getElementById('hdnFacilities');
			if(gullFacilities.value =='yes')
			{
			    var gullFacPri = document.getElementById('checkPrivate');
			    var gullFacLes = document.getElementById('checkLeisure');
			    var gullFacAcc = document.getElementById('checkAccess');
			    var gullFacSpa = document.getElementById('checkSpa');
			    var gullFacBab = document.getElementById('checkBaby');
			    var gullFacHen = document.getElementById('checkHenStag');
			    var gullFacBed = document.getElementById('checkBedroom');
			    var gullFacCon = document.getElementById('checkConference');
			    var gullFacFam = document.getElementById('checkFamily');
			    var gullFacWif = document.getElementById('checkWIFI');
			    var gullFacSwm = document.getElementById('checkSwimming');
			    var gullFacPet = document.getElementById('checkPetsinside');
			
				var s  = new String('');
				if ((gullFacPri) && (gullFacPri.checked))
					s += "PC,";
				if ((gullFacLes) && (gullFacLes.checked))
					s += "XO,";
				if ((gullFacAcc) && (gullFacAcc.checked))
					s += "AD,";
				if ((gullFacSpa) && (gullFacSpa.checked))
					s += "S2,";
				if ((gullFacBab) && (gullFacBab.checked))
					s += "BS,";
				if ((gullFacHen) && (gullFacHen.checked))
					s += "HW,";
				if ((gullFacBed) && (gullFacBed.checked))
					s += "GB,";
				if ((gullFacCon) && (gullFacCon.checked))
					s += "CF,";
				if ((gullFacFam) && (gullFacFam.checked))
					s += "FF,";
				if ((gullFacWif) && (gullFacWif.checked))
					s += "WI,";
				if ((gullFacSwm) && (gullFacSwm.checked))
					s += "SO,";
				if ((gullFacPet) && (gullFacPet.checked))
					s += "PW,";

				//if ((GullFormStore.checkMaster) && (GullFormStore.checkMaster.checked))
				//	s += "AM,";
				//if ((GullFormStore.checkAmex) && (GullFormStore.checkAmex.checked))
				//	s += "AE,";
				//	if ((GullFormStore.checkDiners) && (GullFormStore.checkDiners.checked))
				//	s += "DE,";

				if (s!='')
				{
					deepLink = deepLink + "&strfacilities=" + s;
				}
			}
			
			var gullIsShare = document.getElementById('hdnSharing');
			if(gullIsShare.value == 'yes')
			{	
			    var gullShare = document.getElementById('gullSelSharing');
			
				deepLink = deepLink + "&selSharing=" + gullShare.value
			}


            var gullTownLevel = document.getElementById('hdnTownLevel'); 
			var gullTown = document.getElementById('gullSelTowns');     
			if (window.ActiveXObject)
			{		
				if(gullTownLevel.value=='yes' && gullTown.value != '')
				{
					deepLink = deepLink + "&hdnLocation=" + gullTown.value
				}
				else
				{
					var gullLocation = document.getElementById('hdnLocation');
					deepLink = deepLink + "&hdnLocation=" + gullLocation.value
				}
			}
			else if (document.implementation && document.implementation.createDocument)
			{
				if(gullTownLevel.value=='yes' && gullTown.value != 'please select')
				{
					deepLink = deepLink + "&hdnLocation=" + gullTown.value
				}
				else
				{
				    var gullLocation = document.getElementById('hdnLocation');
					deepLink = deepLink + "&hdnLocation=" + gullLocation.value
				}
			}
            
            var gullShowPrice = document.getElementById('hdnPrice');
			if(gullShowPrice.value=='yes')
			{
			    var gullPriceFrom = document.getElementById('txtPriceFrom');
			    var gullPriceTo = document.getElementById('txtPriceTo');
				if(gullPriceTo.value == '')
					{
						deepLink = deepLink + "&selPriceUpper=5000"
					}
				else
					{
						deepLink = deepLink + "&selPriceUpper=" + gullPriceTo.value
					}

				if(gullPriceFrom.value == '')
					{
						deepLink = deepLink + "&selPriceLower=0" 
					}
				else
					{
						deepLink = deepLink + "&selPriceLower=" + gullPriceFrom.value
					}
			}

            var gullShowPremName = document.getElementById('hdnPremName');
            var gullPremName = document.getElementById('txtPremName');
			if(gullShowPremName.value=='yes' && gullPremName.value!='')
			{
				deepLink = deepLink + "&txtPremName=" + gullPremName.value
			}
			
			var gullShowPremGrade = document.getElementById('hdnGrade');
			if(gullShowPremGrade.value=='yes')
			{
			    var gullGradeAll = document.getElementById('chkGradeAll');
			    var gullGrade1 = document.getElementById('chkGrade1');
			    var gullGrade2 = document.getElementById('chkGrade2');
			    var gullGrade3 = document.getElementById('chkGrade3');
			    var gullGrade4 = document.getElementById('chkGrade4');
			    var gullGrade5 = document.getElementById('chkGrade5');
			    
				if (gullGradeAll.checked){
					deepLink = deepLink + "&chkGradeAll=" + gullGradeAll.value}
				else{deepLink = deepLink + "&chkGradeAll=N"}
				if (gullGrade1.checked){
					deepLink = deepLink + "&chkGrade1=" + gullGrade1.value}
				else{deepLink = deepLink + "&chkGrade1=N"}
				if (gullGrade2.checked){
					deepLink = deepLink + "&chkGrade2=" + gullGrade2.value}
				else{deepLink = deepLink + "&chkGrade2=N"}
				if (gullGrade3.checked){
					deepLink = deepLink + "&chkGrade3=" + gullGrade3.value}
				else{deepLink = deepLink + "&chkGrade3=N"}
				if (gullGrade4.checked){
					deepLink = deepLink + "&chkGrade4=" + gullGrade4.value}
				else{deepLink = deepLink + "&chkGrade4=N"}
				if (gullGrade5.checked){
					deepLink = deepLink + "&chkGrade5=" + gullGrade5.value}
				else{deepLink = deepLink + "&chkGrade5=N"}
			}
			
			var gullHasOptional = document.getElementById('hdnoptional');
			if (gullHasOptional.value!='' && gullHasOptional.value!='/')
			{
				deepLink = deepLink + "&" +  gullHasOptional.value;
			}
			deepLink = deepLink + "&strAction=" + "search"
			
			//redirect page to our deepLink URL
			//document.write(deepLink);
			window.location.href = 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");
		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;			
		}
	}


