 TheCookieName = 'NETSCAPE_LIVEWIRE.BigCookieinthesky';
 numDays       = 360;  //Days 'till Cookie expires.(eg. 183 days = 6 months)
 
 // Write One Big Cookie with all the values in it.
 function WriteOneBigCookie () {
    var expire = new Date ();
    expire.setTime (expire.getTime() + (numDays * 24 * 3600000)); //6 months from now!
 //                                     (dd) (hr) (ms in hr)
    var WholeCookie = expire ;
 
 //Text entry
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.childrenages.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.r_name.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.r_address.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.r_town.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.r_postcode.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.telephone.value;
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.re_email.value;
 
 
 //Select Form (title)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.title.selectedIndex;

 //Select Form (from_mday)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.from_mday.selectedIndex;

 //Select Form (from_mon)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.from_mon.selectedIndex;

 //Select Form (from_year)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.from_year.selectedIndex;


 //Select Form (Nights)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.nights.selectedIndex;

 //Select Form (Adults)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.adults.selectedIndex;

 //Select Form (Children)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.children.selectedIndex;
 
 //Select Form (country)
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.country.selectedIndex;
 
 
 //Textarea
    WholeCookie = WholeCookie + '`' + document.onrequest_availability.comments.value;
 
 //Put cookie in the Oven Bake 'till done.
   document.cookie = TheCookieName +"=" + escape (WholeCookie) +
                     "; expires=" + expire.toGMTString() ;
 
 }
 
 function UpdateForm () {
 
 //Get the Cookievalue then use a Cookie Cutter to slice it up in an array.
 MakeCookieArray(GetCookie(TheCookieName));
 
 //TEXT input Form
 
 //alert('ckArray: ' + ckArray[0]);
  if (ckArray[0] != "*") {
   document.onrequest_availability.ExpDate.value  = ckArray[0];
 
   document.onrequest_availability.childrenages.value   = ckArray[1];
   document.onrequest_availability.r_name.value   = ckArray[2];
   document.onrequest_availability.r_address.value   = ckArray[3];
   document.onrequest_availability.r_town.value  = ckArray[4];
   document.onrequest_availability.r_postcode.value  = ckArray[5];
   document.onrequest_availability.telephone.value = ckArray[6];
   document.onrequest_availability.re_email.value = ckArray[7];
 
 //Select Form (title)
   if (ckArray != "*" )  
         document.onrequest_availability.title.selectedIndex = ckArray[8];
//Select Form (from_mday)
   if (ckArray != "*" )  
         document.onrequest_availability.from_mday.selectedIndex = ckArray[9];
//Select Form (from_mon)
   if (ckArray != "*" )  
         document.onrequest_availability.from_mon.selectedIndex = ckArray[10];
//Select Form (from_year)
   if (ckArray != "*" )  
         document.onrequest_availability.from_year.selectedIndex = ckArray[11];

 //Select Form (Nights)
   if (ckArray != "*" )  
         document.onrequest_availability.nights.selectedIndex = ckArray[12];

 //Select Form (Adults)
   if (ckArray != "*" )  
         document.onrequest_availability.adults.selectedIndex = ckArray[13];

 //Select Form (Children)
   if (ckArray != "*" )  
         document.onrequest_availability.children.selectedIndex = ckArray[14];
 
 //Select Form (country)
   if (ckArray != "*" )  
         document.onrequest_availability.country.selectedIndex = ckArray[15];
 
 //Textarea
   document.onrequest_availability.comments.value = ckArray[16];
  }
 }
 
 //Get and return the index of THE checked radio button
  function setChkIndx(theName) { 
    for (var i=0; i < theName.length; i++ ) {
    if (theName[i].checked == true) return i; 
    }
  return "*"; // One item is always supposed to be checked but... 
  }
 
 //Find and return list of indexes of *all* the selected MULTIPLE selects. YUCK.
 //Return list of indexes, seperated by ",".
  function findChkIndx_MS(theName) { 
  var indxlist = "";
    for (var i=0; i < theName.options.length; i++ ) {
    if (theName.options[i].selected == true) indxlist = indxlist + "," + i; 
    }
  return (indxlist == "")?indxlist = "*":indxlist;
  }
 
 //Use the list to SET all stored MULTIPLE selects.
 // Most efficient storage for a very long list, but messy.
 // Requires clearing all before loading to get only those checked.
  function setChkIndx_MS(formObj,theList) {
    for (var i=0; i < formObj.options.length; i++) { 
    formObj.options[i].selected = false;} //clear all.
    var ilen = 0;
    while ( ilen < theList.length-1 ) { 
     var indxstart = theList.indexOf(',',ilen);
     if (indxstart == -1) return;
 
     ilen = theList.indexOf(',',indxstart+1);
     if (ilen == -1) ilen = theList.length;
 
     //make sure its an integer before using as subscript
     var indx = parseInt(theList.substring(indxstart+1,ilen) ,10);
     formObj.options.selected = true;
    }
  }
 
 //Get the cookie from a list of possible cookies. Honest!
 function GetCookie (CookieName) {
   var cname = CookieName + "=";
   var i = 0;
   while (i < document.cookie.length) {
     var j = i + cname.length;
     if (document.cookie.substring(i, j) == cname){
 	var leng = document.cookie.indexOf (";", j);
 	if (leng == -1) leng = document.cookie.length;
 	return unescape(document.cookie.substring(j, leng));
     }
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break; //thats -1 plus 1, duh.
   }
   return "*";
 }
 
 //Set the Cookie with expire date in the past - 2 days to get it for sure.
 function DelEatCookie (name) {
   var expire = new Date();
   expire.setTime (expire.getTime() - 2 * 86400001);  //-2 days ago. Stale Cookie
   document.cookie = name + "=*; expires=" + expire.toGMTString();
 }
 
 //Parse Big  Cookie. A CookieCutter if you will.
 function MakeCookieArray(cookieValue) {
   var i = 0,indx = 0, citemlen =0;
   ckArray = new Array();
    if ( cookieValue == null ) {ckArray[0]= "*";return}//Data has expired or never entered.
    if ( cookieValue == "*"  ) {ckArray[0]= "*";return}//Data has expired or never entered.
   while (citemlen < cookieValue.length) {
     citemlen=(cookieValue.indexOf("`", indx)>0)
 	     ?cookieValue.indexOf("`", indx):cookieValue.length;
     ckArray[i]= cookieValue.substring(indx, citemlen); i++;
     indx = citemlen + 1;
   }
 }
 
 // end script -->


	function check_onrequest_availability()
				{
				if ((document.onrequest_availability.from_mday.selectedIndex == 0) || (document.onrequest_availability.from_mon.selectedIndex == 0))
					{
					alert('Please specify your check-in date.');
					document.onrequest_availability.from_mday.focus();
					return false;
					}
	var r_name = document.onrequest_availability.r_name.value;
			if ((!r_name) || (r_name.match(/^\\\s+\$/)))
				{
				alert('Please enter your name.');
				document.onrequest_availability.r_name.focus();
				return false;
				}
	var r_address = document.onrequest_availability.r_address.value;
			if ((!r_address) || (r_address.match(/^\\\s+\$/)))
				{
				alert('Please enter your address.');
				document.onrequest_availability.r_address.focus();
				return false;
				}
	var re_email = document.onrequest_availability.re_email.value;
			if ((!re_email) || (re_email.match(/^\\\s+\$/)))
				{
				alert('Please enter a valid email address.');
				document.onrequest_availability.re_email.focus();
				return false;
				}
				}
	function check_secure_booking()
				{
				if ((document.onrequest_availability.from_mday.selectedIndex == 0) || (document.onrequest_availability.from_mon.selectedIndex == 0))
					{
					alert('Please specify your check-in date.');
					document.onrequest_availability.from_mday.focus();
					return false;
					}
	var r_name = document.onrequest_availability.r_name.value;
			if ((!r_name) || (r_name.match(/^\\\s+\$/)))
				{
				alert('Please enter your name.');
				document.onrequest_availability.r_name.focus();
				return false;
				}
	var r_address = document.onrequest_availability.r_address.value;
			if ((!r_address) || (r_address.match(/^\\\s+\$/)))
				{
				alert('Please enter your address.');
				document.onrequest_availability.r_address.focus();
				return false;
				}
	var re_email = document.onrequest_availability.re_email.value;
			if ((!re_email) || (re_email.match(/^\\\s+\$/)))
				{
				alert('Please enter a valid email address.');
				document.onrequest_availability.re_email.focus();
				return false;
				}
	var ccNum = document.onrequest_availability.ccNum.value;
			if ((!ccNum) || (ccNum.match(/^\\\s+\$/)))
				{
				alert('Please enter a valid Credit Card Number.');
				document.onrequest_availability.ccNum.focus();
				return false;
				}
	if ((document.onrequest_availability.start_mon.selectedIndex == 0) || (document.onrequest_availability.start_year.selectedIndex == 0))
					{
					alert('Please specify your Credit Card Start date.');
					document.onrequest_availability.start_mon.focus();
					return false;
					}
	if ((document.onrequest_availability.expiry_mon.selectedIndex == 0) || (document.onrequest_availability.expiry_year.selectedIndex == 0))
					{
					alert('Please specify your Credit Card Expire date.');
					document.onrequest_availability.expiry_mon.focus();
					return false;
					}
	var validation_code = document.onrequest_availability.validation_code.value;
			if ((!validation_code) || (validation_code.match(/^\\\s+\$/)))
				{
				alert('Please enter a valid Credit Card Validation Code.');
				document.onrequest_availability.validation_code.focus();
				return false;
				}
var checkobj=onrequest_availability.agreecheck
if (checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

// 727417091948
// stbec1975

	
	var font='<font face="arial, helvetica" size=1 color=white>';
	var headerColor="#BBBBBB";
	var lightHeaderColor="#CCCCCC";
	var monthDaysColor="#EEEEEE";
	var url = "http://www.blackpoolhotelsdirectory.com/offer/special/index.cgi";
	var dayName=new Array(	"Sunday",
				"Monday",
				"Tuesday",
				"Wednesday",
				"Thursday",
				"Friday",
				"Saturday")
				
	var monthName=new Array("January",
				"February",
				"March",
				"April",
				"May",
				"June",
				"July",
				"August",
				"September",
				"October",
				"November",
				"December")
	
	
// 727417091948
				
	var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
	var now=new Date
	var nowd=now.getDate()
	var nowm=now.getMonth()
	var nowy=now.getYear()
	var NN4 = document.layers? true : false;
	var IE4 = document.all? true : false;
	
	
	function prevCalendar(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendar(nowd,nowm,nowy)
	}
	
	function nextCalendar(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendar(nowd,nowm,nowy)
	}
	
	function startDate(day,month,year)
	{
	var yearIndex=year - now.getYear()
	
	
	document.onrequest_availability.from_mon.selectedIndex=month
	document.onrequest_availability.from_mday.selectedIndex=day
	document.onrequest_availability.from_year.selectedIndex=yearIndex
	document.all['calendar'].style.visibility = "hidden";
	
	}
	
	function showCalendar(day,month,year)
	{
	var monthNumber = month + 1;
	var monthIndex= now.getMonth()
	var yearIndex = now.getYear()
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var startCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	startCalCode+="<TR>"
	startCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	startCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	startCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	startCalCode+="</TR>"
	startCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) startCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	startCalCode+="</TR>"
	startCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) startCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) startCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="Javascript:startDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		else startCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="Javascript:startDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		
		startCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) startCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) startCalCode+="<TD>&nbsp;</TD>"
	startCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide_start()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar.innerHTML=startCalCode
	document.all['calendar'].style.visibility = "visible";
	
	
	}

	function display() {
	    document.all['calendar'].style.visibility = "visible";
	}
	
	function hide_start() {
	    document.all['calendar'].style.visibility = "hidden";
	}	
	
	
// ENDING DATE CALENDAR ROUTINES


	function prevCalendar_end(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendarEnd(nowd,nowm,nowy)
	}
	
	function nextCalendar_end(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendarEnd(nowd,nowm,nowy)
	}
	
	function endDate(day,month,year)
	{
	var yearIndex=year - now.getYear()
	
	document.onrequest_availability.to_mon.selectedIndex=month
	document.onrequest_availability.to_mday.selectedIndex=day
	document.onrequest_availability.to_year.selectedIndex=yearIndex
	document.all['calendar_end'].style.visibility = "hidden";
	
	}
	    
	function showCalendarEnd(day,month,year)
	{
	var monthNumber = month + 1;
	var monthIndex = now.getMonth()
	var yearIndex = now.getYear()
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var endCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	endCalCode+="<TR>"
	endCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar_end(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	endCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	endCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar_end(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	endCalCode+="</TR>"
	endCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) endCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	endCalCode+="</TR>"
	endCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) endCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) endCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="Javascript:endDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;		
		else endCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="Javascript:endDate('+dayCount+','+monthNumber+','+year+')">'+dayCount++;
		endCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) endCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) endCalCode+="<TD>&nbsp;</TD>"
	endCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide_end()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar_end.innerHTML=endCalCode
	document.all['calendar_end'].style.visibility = "visible";
	
	}



	function display_end() {
	    document.all['calendar_end'].style.visibility = "visible";
	}
	

	
	function hide_end() {
	    document.all['calendar_end'].style.visibility = "hidden";
	}


// MAIN CALENDAR DATE DISPLAY

	function showMainCalendar(day,month,year)
	{
		
	var monthNumber = month + 1;
	var monthIndex= now.getMonth()
	var yearIndex = now.getYear()
	var session = GetCookie('session')
	
	if ((year%4 == 0)&&(year%100 != 0) || (year%400 == 0)) monthDays[1]=29; else monthDays[1]=28 // test for leap years
	var firstDay=new Date(year,month,1).getDay()
	var mainCalCode="<table cellpadding=1 bgcolor=" +headerColor+ "><tr><td><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 width=150 height=175 bgcolor=white>"
	mainCalCode+="<TR>"
	mainCalCode+="<TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:prevCalendar_main(nowd,nowm,nowy)\">"+font+"<font size=2><b><<</b></a></TD>"
	mainCalCode+="<TD height=20 bgcolor="+headerColor+" COLSPAN=5 ALIGN=center>"+font+"<font size=2><b>"+monthName[month]+" "+year
	mainCalCode+="</TD><TD height=20 bgcolor="+headerColor+" ALIGN=center><a href=\"javascript:nextCalendar_main(nowd,nowm,nowy)\">"+font+"<font size=2><b>>></b></a></TD>"
	mainCalCode+="</TR>"
	mainCalCode+="<TR>"
	for (var i=0;i<dayName.length;i++) mainCalCode+="<TD bgcolor="+lightHeaderColor+" ALIGN=center>"+font+dayName[i].substring(0,1)+"</TD>"
	var dayCount=1
	mainCalCode+="</TR>"
	mainCalCode+="<TR>"
	for (var i=0;i<firstDay;i++) mainCalCode+="<TD>&nbsp;</TD>"
	for (var i=0;i<monthDays[month];i++)
	{
		
		if ((nowd == (i+1))&&(nowm == monthIndex)&&(nowy == yearIndex)) mainCalCode+='<TD bgcolor='+lightHeaderColor+' ALIGN=center>'+font+'<a href="'+url+'?request=display_specific_date_events&website=default&month='+monthNumber+'&day='+dayCount+'&year='+year+'&category_id=&set=1&session='+session+'">'+dayCount++;
		else mainCalCode+='<TD bgcolor='+monthDaysColor+' ALIGN=center>'+font+'<a href="'+url+'?request=display_specific_date_events&website=default&month='+monthNumber+'&day='+dayCount+'&year='+year+'&category_id=&set=1&session='+session+'">'+dayCount++;
		
		mainCalCode+="</a></TD>"
		if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) mainCalCode+="</TR><TR>"
	}
	var totCells=firstDay+monthDays[month]
	for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) mainCalCode+="<TD>&nbsp;</TD>"
	mainCalCode+='</TR><TR><TD COLSPAN=7 BGCOLOR='+lightHeaderColor+'><center>'+font+'( <a href="javascript:void()" onMouseDown="javascript:hide()">close</a> )</center></TD></TR></TABLE></td></tr></table><BR>'
	calendar_main.innerHTML=mainCalCode
	document.all['calendar_main'].style.visibility = "visible";
	}

	function display() {
	    document.all['calendar_main'].style.visibility = "visible";
	}
	
	function hide() {
	    document.all['calendar_main'].style.visibility = "hidden";
	}	
	
	function prevCalendar_main(day,month,year)
	{
	nowm--; if (nowm<0) { nowy--; nowm=11; } showMainCalendar(nowd,nowm,nowy)
	}
	
	function nextCalendar_main(day,month,year)
	{
	nowm++; if (nowm>11) { nowy++; nowm=0; } showMainCalendar(nowd,nowm,nowy)
}	

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

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;
}



