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

function check_finish_form_reservation()
{
var letter = /^[a-zA-Z\s]+$/;
var today = new Date();
var expiry_date = new
Date(form_reservation.expiry_year.options[form_reservation.expiry_year.selectedIndex].value, form_reservation.expiry_mon.options[form_reservation.expiry_mon.selectedIndex].value);
var ccNum = form_reservation.ccNum.value; //Card number
var ccNum = ccNum.replace(/ /g, "");
var msg = 'The Credit Card Number You Entered Could Not Be\n Validated.\n Please Check The Card Number and Card Type And Try Again.';
var msgissue_number = 'Please Specify Your Credit Card Issue Number.\n\n(Switch/Maestro and Solo Cards only)';
var msg_type = 'Please Specify Your Credit Card Type ';
var msg_cc_start = 'Please Specify Your Credit Start Date ';
var msg_cc_expire = 'Please Specify Your Credit Expire Date ';
var msg_cc_security = 'Please Enter Your Credit Card Security Code.\n a 3 - or 4 - digit number\n\n(usually in the signature field). ';
var msg_cc_number = 'Please Enter Your Credit Card Number. ';

//########## Get the card type ##########
	for (var i=0; i<form_reservation.ccType.length; i++){
		if (form_reservation.ccType.options[i].selected){            
			var ccType=form_reservation.ccType.options[i].value;      
		}
}

//########## Check Dates & Name ##########
		if (!letter.test(form_reservation.name.value)){
			window.alert("Please Enter Your Name \n As It Appears On The Credit Card.");
			form_reservation.name.focus();
	return false;
	}
if (!form_reservation.address.value){
	window.alert("Please Enter Your Address.");
	form_reservation.address.focus();
	return false;
	}
if (!form_reservation.town_city.value){
	window.alert("Please Enter Your Town / City.");
	form_reservation.town_city.focus();
	return false;
	}
if (!form_reservation.postcode.value){
	window.alert("Please Enter Your Zip Or PostCode.");
	form_reservation.postcode.focus();
	return false;
	}
if (!form_reservation.telephone.value){
	window.alert("Please Enter Your Telephone Number.");
	form_reservation.telephone.focus();
	return false;
	}	
if (document.form_reservation.ccType.selectedIndex == 0)
					{
				alert(msg_type); 	
					document.form_reservation.ccType.focus();
					return false;
					}
if (!form_reservation.ccNum.value){
	alert(msg_cc_number); 	
	form_reservation.ccNum.focus();
	return false;
	}
	if ((document.form_reservation.start_mon.selectedIndex == 0) || (document.form_reservation.start_year.selectedIndex == 0))
					{
				alert(msg_cc_start); 	
					document.form_reservation.start_mon.focus();
					return false;
					}
				if ((document.form_reservation.expiry_mon.selectedIndex == 0) || (document.form_reservation.expiry_year.selectedIndex == 0))
					{
				alert(msg_cc_expire); 					document.form_reservation.expiry_mon.focus();
					return false;
					}
if(expiry_date < today){
			alert('Your Credit Card Has Expired!');
			form_reservation.expiry_year.focus();
	return false;
	}
if (!form_reservation.validation_code.value){
	alert(msg_cc_security); 	
	form_reservation.validation_code.focus();
	return false;
	}
	
//########## Check VISA ##########
	if(ccType.indexOf('VISA') !=-1){
		if ((ccNum.length == 13 || ccNum.length == 16) && (ccNum.substring(0,1) == 4)){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check DELTA ##########
	if(ccType.indexOf('DELTA') !=-1){
		if ((ccNum.length==16) && (ccNum.match(/^(413733|413734|413735|413736|413737|4462|453978|453979|454313|454313|454432|454433|454434|454435|454742|456725|456726|456727|456728|456729|45673|456740|456741|456742|456743|456744|456745|46583|46584|46585|46586|46587|484409|484410|49096|49097|492181|492182|498824)/))){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check SOLO ##########
	if(ccType.indexOf('SOLO') !=-1){
if (document.form_reservation.issue_number.selectedIndex == 0)
					{
 				alert(msgissue_number);  	
					document.form_reservation.issue_number.focus();
		return false;	
					}
		if ((ccNum.length==16 || ccNum.length==18 || ccNum.length==19) && (ccNum.match(/63345|63346|63347|63348|63349|6767/))){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check MASTERCARD ##########
	if(ccType.indexOf('MASTERCARD') !=-1){
		var firstdig=ccNum.substring(0,1);
		var seconddig=ccNum.substring(1,2);
		if ((ccNum.length == 16 || ccNum.length == 19) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5))){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check DINERS ##########
	if(ccType.indexOf('DINERS') !=-1){
		firstdig = ccNum.substring(0,1);
		seconddig = ccNum.substring(1,2);
		if ((ccNum.length == 14 || ccNum.length == 17)  && (firstdig == 3) && ((seconddig == 0) || (seconddig == 6) || (seconddig == 8))){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check AMEX ##########
	if(ccType.indexOf('AMEX') !=-1){
		firstdig = ccNum.substring(0,1);
		seconddig = ccNum.substring(1,2);
		if (((ccNum.length == 15)  || (ccNum.length == 18)) && (firstdig == 3) && ((seconddig == 4) || (seconddig == 7))){   
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}
//########## Check SWITCH MAESTRO ##########
	if(ccType.indexOf('SWITCH/MAESTRO') !=-1){
if (document.form_reservation.issue_number.selectedIndex == 0)
					{
 				alert(msgissue_number);  	
					document.form_reservation.issue_number.focus();
		return false;	
					}
		if ((ccNum.length==16) && (ccNum.match(/^(491101|491102|564182|633300|633302|633303|633304|633305|633306|633307|633308|633309|633310|633311|633312|633313|633314|633315|633316|633317|633318|633319|633320|633321|633322|633323|633324|633325|633326|633327|633328|633329|633330|633331|633332|633333|633334|633335|633336|633337|633338|633339|633340|633341|633342|633343|633344|633345|633346|633347|633348|633349|675900|675902|675903|675904|675906|675907|675908|675909|675910|675911|675912|675913|675914|675915|675916|675917|675919|675920|675921|675922|675923|675924|675925|675926|675927|675928|675929|675930|675931|675932|675933|675934|675935|675936|675937|675941|675942|675943|675944|675945|675946|675947|675948|675949|675963|675964|675965|675966|675967|675968|675969|675970|675971|675972|675973|675974|675975|675976|675977|675978|675979|675980|675981|675982|675983|675984|675985|675986|675987|675988|675989|675990|675991|675992|675993|675994|675995|675996|675997|675999)/))||
		(ccNum.length==18) && (ccNum.match(/^(675938|675939|675940|490302|490303|490304|490305|490306|490307|490308|490309|490335|490336|490337|490338|490339|491174|491175|491176|491177|491178|491179|491180|491181|491182)/))||
		(ccNum.length==19) && (ccNum.match(/^(4936|633301|675901|675905|675918|675950|675951|675952|675953|675954|675955|675956|675957|675958|675959|675960|675961|675962|675998)/)))

{
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
	}
}

//########## Check JCB ##########
	if(ccType.indexOf('JCB') !=-1){
		if ((ccNum.length==16) && (ccNum.match(/^(3088|3096|3112|3158|3337|3528)/))){
	return true
	}
		else{
			alert(msg);  
			form_reservation.ccNum.focus();
	return false;
		}
	}
}

function check_deals_room_quantity()
						{
if (document.form_reservation.quantity.selectedIndex == 0)
					{
				alert("You Have Not Selected Any Rooms.\n\nPlease Select The Number Of Rooms You Wish To Book."); 	
					document.form_reservation.quantity.focus();
					return false;
					}
						}

function check_room_types_form()
						{
						var count = 0;
						for (i=0,n=document.form_reservation.elements.length;i<n;i++)
							{
	   						if ((document.form_reservation.elements[i].name.indexOf('quantity_') !=-1) && (document.form_reservation.elements[i].value))
								{
								count++;
								}
							}

						if (count == 0)
							{
							alert('You Have Not Selected Any Rooms.\n\nPlease Select The Number Of Rooms You Wish To Book.');
							return false;
							}
						}

// 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.form_reservation.from_mon.selectedIndex=month
	document.form_reservation.from_mday.selectedIndex=day
	document.form_reservation.from_year.selectedIndex=yearIndex + 1;
	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.form_reservation.to_mon.selectedIndex=month
	document.form_reservation.to_mday.selectedIndex=day
	document.form_reservation.to_year.selectedIndex=yearIndex + 1;
	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;
}



