
function openWindow(url,width,height) 
{
	popupWin = window.open(url, 'remote','menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=yes, dependent, width='+width+', height='+height+', left=50, top=50')
}

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_validateForm() { //v4.0

  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);

    if (val) { nm=val.name; if ((val=val.value)!="") {

      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

      } else if (test!='R') { num = parseFloat(val);

        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

          min=test.substring(8,p); max=test.substring(p+1);

          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

  } if (errors) alert('The following error(s) occurred:\n'+errors);

  document.MM_returnValue = (errors == '');

}



function MM_goToURL() { //v3.0

  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");

}


function AreYouSure() {

	return confirm("Please confirm you wish to abandon this booking");
}

var date = new Date();


var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");


var month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");


function makeMonthSelect(selectOptions)
{

	document.write("<select "+selectOptions+">");

	for(i=0;i<24;i++)
	{
		m	= month[(i%12)];
		y	= parseInt(i/12)+date.getFullYear();


		if(date.getMonth() == (i%12) && i<12)
		{
			document.write("<OPTION VALUE='"+m+" : "+y+"' SELECTED>"+m+" : "+y);
		}
		else
		{
			document.write("<OPTION VALUE='"+m+" : "+y+"'>"+m+" : "+y);
		}
	}


	document.write("</select>");
}

function makeDaySelect(offset,selectOptions)
{
	document.write("<select "+selectOptions+">");

	for(i=1;i<=31;i++)
	{
		if(date.getDate() == (i-offset))
		{
			document.write("<option selected>"+i);
		}
		else
		{

			document.write("<option>"+i);
		}
	}

	document.write("</select>");
}


function PopUp(url,x,y) {
	window.status = "Loading PopUp . . ."			
	var hWnd = window.open(url,"PopUp","screenX=300,screenY=200,top=200,left=300,width=" + x + " height=" + y + ",dependant");
	hWnd.focus();
	window.status = ""			
	if (!hWnd.opener)
		hWnd.opener = self;
}			


function doSubmit(frm) {
	return true;
}

function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function MakeFloatingWindow(url,w,h) {
	window.status ="Loading Floating window . . ."	
    myFloater=window.open(url,"myWindow","width="+w+",height="+h+" top=200,screenY=200, left=300,screenX=300" );
}	

function UpdateiFrame()
{
var url;
var dday;
var dmonth;
var dyear;
var pos;

	dday = document.main.StartDay.selectedIndex + 1;
	dmonth = document.main.StartMonth[document.main.StartMonth.selectedIndex].value.substr(0,3).toLowerCase();
	// This needs to be coded properly
	if (dmonth=='jan') 
		dmonth=1;
	if (dmonth=="feb") 
		dmonth=2;
	if (dmonth=="mar") 
		dmonth=3;
	if (dmonth=="apr") 
		dmonth=4;
	if (dmonth=="may") 
		dmonth=5;
	if (dmonth=="jun") 
		dmonth=6;
	if (dmonth=="jul") 
		dmonth=7;
	if (dmonth=="aug") 
		dmonth=8;
	if (dmonth=="sep") 
		dmonth=9;
	if (dmonth=="oct") 
		dmonth=10;
	if (dmonth=="nov") 
		dmonth=11;
	if (dmonth=="dec") 
		dmonth=12;
		
	pos = document.main.StartMonth[document.main.StartMonth.selectedIndex].value.indexOf(':',0) ; // find :
	dyear = document.main.StartMonth[document.main.StartMonth.selectedIndex].value.slice(pos+2) ;// pick up year part
	
	url = 		"https://www.guestmaster.com/onlinelive/m_viewdiary.asp?DiaryMode=20" ;
	url = url + "&SerialNo=GM201596" + "&dday=" + dday + "&dmonth=" +dmonth + "&dyear=" + dyear ;
	frames['diaryviewspace'].location.href= url ;
}

// Take user here after session timed out
timedouturl = "./AbandonBooking.asp";
var TimeOutEnabled = true;

function Minutes(data) {
for (var i = 0; i < data.length; i++)
if (data.substring(i, i + 1) == ":")
break;
return (data.substring(0, i));
}

function Seconds(data) {
for (var i = 0; i < data.length; i++)
if (data.substring(i, i + 1) == ":")
break;
return (data.substring(i + 1, data.length));
}

function Display(min, sec) {
var disp;
if (min <= 9) disp = " 0";
else disp = " ";
disp += min + ":";
if (sec <= 9) disp += "0" + sec;
else disp += sec; 
return (disp);
}

function Down() { 

	if (TimeOutEnabled == true)
	{
		sec--;      
		if (sec == -1) { sec = 59; min--; }
		document.main.clock.value = Display(min, sec);
		window.status = "Session will time out in: " + Display(min, sec);
		if (min == 0 && sec == 0) {
		//alert("Session has timed out.");
		window.status = "";
		window.location.href = timedouturl;		
		}
		else down = setTimeout("Down()", 1000);
	}
}
	
function timeIt() {
	min = 1 * Minutes(document.main.clock.value);
	sec = 0 + Seconds(document.main.clock.value);
	Down();
}


function ReportClick() {

	TimeOutEnabled = false;
	window.status = "Your availability request is being processed . . .";
}


function UpdateDepartDays() {

	document.main.EndDay.selectedIndex = document.main.StartDay.selectedIndex+1;
	UpdateiFrame();
}

function UpdateDepartMonth() {
	document.main.EndMonth.selectedIndex = document.main.StartMonth.selectedIndex;
	UpdateiFrame();
}


function PopUp(a_url)
{
    window.open(a_url,"name", "dependant=1,resizable=1,menubar=1,width=400,height=300,scrollbars=1,top=200,left=200") ;
}


/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
* http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm
***********************************************/

var iframeids=["diaryviewspace"]

var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight + 20 ;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

