// JavaScript Document
function GetCookie (name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        {
            return getCookieVal (j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function SetCookie (name, value)
{
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    //var expires = (argc > 2) ? argv[2] : null;
	var expires = new Date(2020,01,01,00,00,00,00)
    //var path = (argc > 3) ? argv[3] : null;
	var path = "/";
    var domain = (argc > 4) ? argv[4] : null;
	//var domain = 'www.boatdeck.co.uk';
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

function GetPage(url)
{
	document.location = url.replace("{0}",GetCookie('sCode'));
}

function GetDatesDDL()
{
	var now = new Date();
	var selEML;
	var selMonth;

	switch (now.getDate())
		{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
			case 10:
				selEML = "Early";
				break;
			case 11:
			case 12:
			case 13:
			case 14:
			case 15:
			case 16:
			case 17:
			case 18:
				selEML = "Mid";
				break;
			case 19:
			case 20:
			case 21:
			case 22:
			case 23:
			case 24:
			case 25:
			case 26:
			case 27:
			case 28:
			case 29:
			case 30:
			case 31:
				selEML = "Late";
				break;
		}
	switch (now.getMonth()+1)
		{
			case 1:
				selMonth = "January";
				break;
			case 2:
				selMonth = "Febuary";
				break;
			case 3:
				selMonth = "March";
				break;
			case 4:
				selMonth = "April";
				break;
			case 5:
				selMonth = "May";
				break;
			case 6:
				selMonth = "June";
				break;
			case 7:
				selMonth = "July";
				break;
			case 8:
				selMonth = "August";
				break;
			case 9:
				selMonth = "September";
				break;
			case 10:
				selMonth = "March";
				break;
			case 11:
				selMonth = "March";
				break;
			case 12:
				selMonth = "March";
				break;
		}
		document.write('		<select name="Start" id="Start">');
		if (now.getYear()!=2007)
		{
			var arrDate = new Array(24);
			arrDate[0] = 'Early March';
			arrDate[1] = 'Mid March';
			arrDate[2] = 'Late March';
			arrDate[3] = 'Early April';
			arrDate[4] = 'Mid April';
			arrDate[5] = 'Late April';
			arrDate[6] = 'Early May';
			arrDate[7] = 'Mid May';
			arrDate[8] = 'Late May';
			arrDate[9] = 'Early June';
			arrDate[10] = 'Mid June';
			arrDate[11] = 'Late June';
			arrDate[12] = 'Early July';
			arrDate[13] = 'Mid July';
			arrDate[14] = 'Late July';
			arrDate[15] = 'Early August';
			arrDate[16] = 'Mid August';
			arrDate[17] = 'Late August';
			arrDate[18] = 'Early September';
			arrDate[19] = 'Mid September';
			arrDate[20] = 'Late September';
			arrDate[21] = 'Early October';
			arrDate[22] = 'Mid October';
			arrDate[23] = 'Late October';
			var ddl = '';
			var i = 0;
			for (i=0;i<=23;i++)
				{
					if (selEML + ' ' + selMonth==arrDate[i])
					{
						document.write('			<option selected>' + arrDate[i] + '</option>')
					}
					else
					{
						document.write('			<option>' + arrDate[i] + '</option>')
					}
				}
		}
		else
		{
			document.write('			<option>Early March</option>');
			document.write('			<option>Mid March</option>');
			document.write('			<option>Late March</option>');
			document.write('			<option>Mid April</option>');
			document.write('			<option>Early April</option>');
			document.write('			<option>Late April</option>');
			document.write('			<option>Early May</option>');
			document.write('			<option>Mid May</option>');
			document.write('			<option>Late May</option>');
			document.write('			<option>Early June</option>');
			document.write('			<option>Mid June</option>');
			document.write('			<option>Late June</option>');
			document.write('			<option>Early July</option>');
			document.write('			<option>Mid July</option>');
			document.write('			<option>Late July</option>');
			document.write('			<option>Early August</option>');
			document.write('			<option>Mid August</option>');
			document.write('			<option>Late August</option>');
			document.write('			<option>Early September</option>');
			document.write('			<option>Mid September</option>');
			document.write('			<option>Late September</option>');
			document.write('			<option>Early October</option>');
			document.write('			<option>Mid October</option>');
			document.write('			<option>Late October</option>');	
		}
		document.write('		</select>');
}
function GetPath(URL)
{
		URL.Replace("{0}",getCookieVal("sCode"));
		return URL;
}
function SaveSearch()
{
	var f = document.forms[0];
	var searchParam;
	searchParam = f.berths.selectedIndex +';'+ f.location.selectedIndex +';'+ f.duration.selectedIndex +';'+ f.Start.selectedIndex;
	SetCookie ('search',searchParam);
}
function LoadSearch()
{
	var f = document.forms[0];
	var searchParam	= GetCookie('search');
	if (searchParam!=null)
	{
		searchParam = searchParam.split(";");
		DeleteCookie('search');
		f.berths.selectedIndex = searchParam[0];
		f.location.selectedIndex = searchParam[1];
		f.duration.selectedIndex = searchParam[2];
		f.Start.selectedIndex = searchParam[3];
	}
}
function ShowSearch(sType,sCode,route)
{
	DeleteCookie ('sCode')
	
	//SetCookie ('sCode', sCode)
	SetCookie ('sCode', sCode)
	//var URL = 'http://boatdeck09.imhg.local/';
	var URL = 'http://www.boatdeck.co.uk/';
	var	offersLink  = ''
	var	lateLink  = ''
	var year = '2009'
	switch (sCode)
		{
			case "hukcan":{
				offersLink = 'http://www.holidayuk.co.uk/canals/bonus.htm';
				lateLink = 'http://www.boatdeck.co.uk/hukcan_latedeals.asp';
				break;
			}
			case "hukcru":{
				offersLink = 'http://www.holidayuk.co.uk/afloat/bonus.htm';
				break;
			}
			case "canhol":{
				offersLink = 'http://www.canalholidays.com/canal-holidays-special-offers.htm';
				lateLink = 'http://www.boatdeck.co.uk/canhol_latedeals.asp';
				break;	
			}
			default:{
				offersLink = 'http://www.holidayuk.co.uk/canals/bonus.htm';
				break;
			}
		}
	switch (sType)
		{
			case "canal":{
			document.write('<form method="post" action="' + URL + sCode + '_qasearch.asp" style="height:10px;margin:0px;padding:0px;" name="search">');
			document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" class="searchBox">');
			document.write('<tr>');
			document.write('	<td>');
			document.write('		<p><strong><font size="3">' + year + ' Quick Search:</font></strong> I want a narrowboat for</p>');
			document.write('	</td>');
			document.write('	<td>');
			document.write('		<p align="right"><font size="1"><strong><a name="SearchTop"></a>UK:</strong> 01756 701199</font></p>');
			document.write('	</td>');
			document.write('</tr>');
			document.write('<tr>');
			document.write('	<td colspan="2">');
			document.write('	<p>');
			document.write('		<select name="berths">');
			document.write('			<option selected value="2">2-4</option>');
			document.write('			<option value="4">4-6</option>');
			document.write('			<option value="6">6-8</option>');
			document.write('			<option value="8">8-10</option>');
			document.write('			<option value="10">10-12</option>');
			document.write('		</select>people');
			document.write('		<select name="location">');
			document.write('			<option value="6" selected>Near London</option>');
			document.write('			<option value="7">Near Bath</option>');
			document.write('			<option value="8">Near Oxford</option>');
			document.write('			<option value="22">Near Reading</option>');
			document.write('			<option value="10">Near Stratford</option>');
			document.write('			<option value="23">Near Worcester</option>');
			document.write('			<option value="24">Near Warwick</option>');
			document.write('			<option value="20">In Warwickshire</option>');
			document.write('			<option value="11">Near Birmingham</option>');
			document.write('			<option value="19">In Staffordshire</option>');
			document.write('			<option value="12">Near Chester</option>');
			document.write('			<option value="18">In Cheshire</option>');
			document.write('			<option value="12">Near Llangollen</option>');
			document.write('			<option value="13">Near Manchester</option>');
			document.write('			<option value="14">In Yorkshire</option>');
			document.write('			<option value="16">In N Wales</option>');
			document.write('			<option value="17">In S Wales</option>');
			document.write('			<option value="15">In Scotland</option>');
			document.write('			<option value="21">Going One-way</option>');
			document.write('		</select>for a ');
			document.write('		<select name="duration">');
			document.write('			<option selected>Week</option>');
			document.write('			<option>Weekend</option>');
			document.write('			<option>Midweek</option>');
			document.write('		</select>starting');
			GetDatesDDL();
			document.write('		<input type="submit" name="GO" value="Go" class="formbutton" onClick="SaveSearch();">');
			document.write('	</p>');
			document.write('	</td>');
			document.write('</tr>');
			//document.write('<tr>');
			//document.write('	<td colspan="2">');
			//document.write('		<p><b>' + year + ' Booking Bonus on highlighted boat names - <a href="' + offersLink + '">Special Offers</a></b><br>');
			//document.write('		<b>For canal holidays starting in the next three weeks go to <a href="#" onclick="window.location.href(\''+lateLink+'\');">Late Boats Deals</a></b></p>');
			//document.write('	</td>');
			//document.write('</tr>');
			document.write('</table>');
			document.write('</form>');
			document.write('<img src="/images/1by1.gif" onLoad="LoadSearch();">');
			break;
			}
			case "cruiser":{
			document.write('<form method="post" action="' + URL + sCode + '_qasearch.asp" style="height:10px;margin:0px;padding:0px;" name="search">');
			document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" class="searchBox">');
			document.write('<tr>');
			document.write('	<td><p><strong><font size="3">' + year + ' Quick Search:</font> </strong>I want a cruiser boat for</p></td>');
			document.write('	<td><p align="right"><font size="1"><strong><a name="SearchTop"></a>UK:</strong> 01756 701199</font></p></td>');
			document.write('</tr>');
			document.write('<tr>');
			document.write('	<td colspan="2"><p> ');
			document.write('		<select name="berths">');
			document.write('			<option selected value="2">2-4</option>');
			document.write('			<option value="4">4-6</option>');
			document.write('			<option value="6">6-8</option>');
			document.write('			<option value="8">8-10</option>');
			document.write('			<option value="10">10-12</option>');
			document.write('		</select>people on ');
			document.write('			<select name="location">');
			document.write('			<option value="101">the River Thames</option>');
			document.write('			<option value="104" selected>the Norfolk Broads</option>');
			document.write('			<option value="103">Loch Ness, Scotland</option>');
			document.write('		</select>for a ');
			document.write('		<select name="duration">');
			document.write('			<option selected>Week</option>');
			document.write('			<option>Weekend</option>');
			document.write('			<option>Midweek</option>');
			document.write('		</select>in ');
			GetDatesDDL();
			document.write('	<input type="submit" name="GO" value="Go" class="formbutton" onClick="SaveSearch();">');
			document.write('	<br>');
			document.write('	</p></td>');
			document.write('</tr><tr>');
			//document.write('<td colspan="2">');
			//document.write('	<p>Add boats you like to your shortlist, then book online at direct prices or phone our team for independent advice - <strong>open until 5.30pm weekdays, 10am-4pm Saturdays</strong></p></td>');
			//document.write('		<p><b>' + year + ' Loyalty Booking Bonus - <a href="' + offersLink + '">Latest Offers</a></b></p>');
			document.write('</tr>');
			document.write('</table>');
			document.write('</form>');
			document.write('<img src="/images/1by1.gif" onLoad="LoadSearch();">');
			break;
			}
			case "canalfom":{
			document.write('<form action="' + URL + sCode + '_f_or_m.asp" method="post" name="searchform">');
            document.write('  <table border="0" align="left" cellpadding="2" cellspacing="0" class="fsearchTable" width="580">');
            document.write('    <tr class="fsearchTop">');
            document.write('      <td valign="middle" class="fsearchTop">Duration</td>');
            document.write('      <td valign="middle" class="fsearchTop">Start Day</td>');
            document.write('      <td align="center" valign="middle" class="fsearchTop"><div align="left">Route</div></td>');
            document.write('      <td align="center" valign="middle" class="fsearchTop"><div align="left">Sleeps </div></td>');
            document.write('      <td align="center" valign="middle" class="fsearchTop"><div align="right">');
            document.write('          <select name="max" id="select" style="font-size:9;">');
            document.write('            <option value="0" selected>Select</option>');
            document.write('            <option value="2">2 - 4</option>');
            document.write('            <option value="4">4 - 6</option>');
            document.write('            <option value="6">6 - 8</option>');
            document.write('            <option value="8">8 - 10</option>');
            document.write('            <option value="10">10 - 12</option>');
            document.write('          </select>');
            document.write('        </div>');
            document.write('      </td>');
            document.write('      <td valign="middle">');
            document.write('        <div align="right">');
            document.write('          <input name="search2" type="submit" value="Search">');
            document.write('        </div>');
            document.write('      </td>');
            document.write('    </tr>');
            document.write('    <tr class="fsearchTop">');
            document.write('      <td class="fsearchTop">');
            document.write('          <select name="duration" style="font-size:9;">');
            document.write('            <option>Week</option>');
            document.write('            <option>Weekend</option>');
            document.write('            <option>Midweek</option>');
            document.write('          </select>');
            document.write('      </td>');
            document.write('      <td class="fsearchTop">');
            document.write('          <select name="start" style="font-size:9;">');
            document.write('            <option value="%" selected>Any</option>');
            document.write('            <option value="1">Saturday</option>');
            document.write('            <option value="2">Sunday</option>');
            document.write('            <option value="3">Monday</option>');
            document.write('            <option value="4">Tuesday</option>');
            document.write('            <option value="5">Wednesday</option>');
            document.write('            <option value="6">Thursday</option>');
            document.write('            <option value="7">Friday</option>');
            document.write('          </select>');
            document.write('      </td>');
            document.write('      <td class="fsearchTop">');
            document.write('        <select name="route" id="route">');
            document.write('          <option value="22" selected>Avon Ring</option>');
            document.write('          <option value="39">Cambridgeshire Waterways</option>');
            document.write('          <option value="8">Cheshire Ring</option>');
            document.write('          <option value="13">Four Counties Ring</option>');
            document.write('          <option value="29">Grand Union Canal</option>');
            document.write('          <option value="34">Kennet and Avon Canal</option>');
            document.write('          <option value="2">Leeds-Liverpool Canal</option>');
            document.write('          <option value="27">Leicester Ring</option>');
            document.write('          <option value="11">Llangollen Canal</option>');
            document.write('          <option value="31">London Circuit</option>');
            document.write('          <option value="38">Mon and Brecon Canal</option>');
            document.write('          <option value="41">One Way</option>');
            document.write('          <option value="26">Oxford Canal</option>');
            document.write('          <option value="3">Pennine Canals</option>');
            document.write('          <option value="32">River Thames</option>');
            document.write('          <option value="30">River Wey</option>');
            document.write('          <option value="40">Scotland Canals</option>');
            document.write('          <option value="18">Stourport Ring</option>');
            document.write('          <option value="24">Warwickshire Ring</option>');
            document.write('        </select>');
            document.write('      </td>');
            document.write('      <td align="center" class="fsearchTop"><em><font size="4"><strong>or</strong></font></em></td>');
            document.write('      <td align="center" class="fsearchTop">&nbsp;</td>');
            document.write('      <td class="fsearchTop"></td>');
            document.write('    </tr>');
            document.write('    <tr class="fsearchTop">');
            document.write('      <td colspan="2" class="fsearchTop"><em><font size="4">Boat Search</font></em></td>');
            document.write('      <td class="fsearchTop">');
            document.write('          <div align="right">Double Beds');
            document.write('            <select name="double" style="font-size:9;">');
            document.write('              <option selected>0</option>');
            document.write('              <option>1</option>');
            document.write('              <option>2</option>');
            document.write('              <option>3</option>');
            document.write('              <option>4</option>');
            document.write('              <option>5</option>');
            document.write('              <option>6</option>');
            document.write('            </select>');
            document.write('          </div>');
            document.write('      </td>');
            document.write('      <td colspan="2" align="left" class="fsearchTop">Single Beds');
            document.write('          <select name="single" style="font-size:9;">');
            document.write('            <option selected>0</option>');
            document.write('            <option>1</option>');
            document.write('            <option>2</option>');
            document.write('            <option>4</option>');
            document.write('            <option>6</option>');
            document.write('            <option>8</option>');
            document.write('            <option>10</option>');
            document.write('            <option>12</option>');
            document.write('          </select>');
            document.write('      </td>');
            document.write('      <td align="right" class="fsearchTop"><div align="right">');
            document.write('          <input name="search1" type="submit" id="search12" value="Search">');
            document.write('        </div>');
            document.write('      </td>');
            document.write('    </tr>');
            document.write('  </table>');
            document.write('</form><br clear="left">');
			document.searchform.route.selectedIndex = route;
			break;
			}
			case "cruiserfom":{
			document.write('<script>LoadSearch();</script>');
			document.write('	<form action="' + URL + sCode + '_f_or_m.asp" method="post" name="fsearch">');
            document.write('      <table border="0" align="center" cellpadding="2" cellspacing="0" width="586">');
            document.write('        <tr class="fsearchTop">');
            document.write('          <td valign="middle" class="fsearchTop">Duration</td>');
            document.write('          <td valign="middle" class="fsearchTop">Start Day</td>');
            document.write('          <td align="center" valign="middle" class="fsearchTop"><div align="left">Route</div></td>');
            document.write('          <td align="center" valign="middle" class="fsearchTop"><div align="left">Sleeps ');
            document.write('            </div></td>');
            document.write('          <td align="center" valign="middle" class="fsearchTop"><div align="right"> ');
            document.write('              <select name="max" id="select" style="font size=9">');
            document.write('                <option value="0" selected>Select ');
            document.write('                <option value="2">2 - 4</option>');
            document.write('                <option value="4">4 - 6</option>');
            document.write('                <option value="6">6 - 8</option>');
            document.write('                <option value="8">8 - 10</option>');
            document.write('                <option value="10">10 - 12</option>');
            document.write('              </select>');
            document.write('            </div></td>');
            document.write('          <td valign="middle" class="fsearchTop"> <div align="right">');
            document.write('              <input name="search2" type="submit" id="search23" value="Search">');
            document.write('              </div></td>');
            document.write('        </tr>');
            document.write('        <tr valign="middle" class="fsearchTop"> ');
            document.write('          <td class="fsearchTop">');
            document.write('              <select name="select" style="font size=9">');
            document.write('                <option selected>Week</option>');
            document.write('                <option>Weekend</option>');
            document.write('                <option>Midweek</option>');
            document.write('              </select>');
            document.write('          </td>');
            document.write('          <td class="fsearchTop">');
            document.write('              <select name="start" style="font size=9">');
            document.write('                <option value="%" selected>Any</option>');
            document.write('                <option value="1">Saturday</option>');
            document.write('                <option value="2">Sunday</option>');
            document.write('                <option value="3">Monday</option>');
            document.write('                <option value="4">Tuesday</option>');
            document.write('                <option value="5">Wednesday</option>');
            document.write('                <option value="6">Thursday</option>');
            document.write('                <option value="7">Friday</option>');
            document.write('              </select>');
            document.write('              </td>');
            document.write('          <td align="left" class="fsearchTop"> <select name="route" id="route">');
            document.write('              <option value="101" selected>River Thames</option>');
            document.write('              <option value="103">Caledonian Canal</option>');
            document.write('              <option value="104">Norfolk Broads</option>');
            document.write('            </select> </td>');
            document.write('          <td align="center" class="fsearchTop">or</td>');
            document.write('          <td align="center" class="fsearchTop">&nbsp;</td>');
            document.write('          <td class="fsearchTop"></td>');
            document.write('        </tr>');
            document.write('        <tr valign="middle" class="fsearchTop"> ');
            document.write('         <td colspan="2" class="fsearchTop">Boat Search</td>');
            document.write('          <td class="fsearchTop">');
            document.write('            <div align="right">Double Beds');
            document.write('              <select name="double" style="font size=9">');
            document.write('                <option selected>0</option>');
            document.write('                <option>1</option>');
            document.write('                <option>2</option>');
            document.write('                <option>3</option>');
            document.write('                <option>4</option>');
            document.write('                <option>5</option>');
            document.write('                <option>6</option>');
            document.write('              </select>');
            document.write('          </td>');
            document.write('          <td colspan="2" align="left" class="fsearchTop">Single Beds ');
            document.write('            <select name="single" style="font size=9">');
            document.write('              <option selected>0</option>');
            document.write('              <option>1</option>');
            document.write('              <option>2</option>');
            document.write('              <option>4</option>');
            document.write('              <option>6</option>');
            document.write('              <option>8</option>');
            document.write('              <option>10</option>');
            document.write('              <option>12</option>');
            document.write('            </select> </td>');
            document.write('          <td align="right" class="fsearchTop"><div align="right"> ');
            document.write('              <input name="search1" type="submit" id="search12" value="Search">');
            document.write('            </div></td>');
            document.write('        </tr>');
            document.write('      </table>');
            document.write('   </form><br clear="left">');
			document.fsearch.route.selectedIndex = route;
			break;
			}
			default: { document.write('No search available.'); break }
		}
		document.write('</form>');
}