var DepthInfoWindow;
var BookingDetailWindow;
var ContactRequestWindow;
var MapDetailWindow;
var MiniInfoWindow;
var HelpWindow;
var PicturesWindow;
var MiniInfoImagesWindow;

/*
function getRandomData()
{
	var mDate = new Date();
	
	var dString = "";
	'dString = "" + mDate.getMonth + mDate.getDay + mDate.getFullYear + mDate.getHours + mDate.getMinutes + mDate.getSeconds + mDate.getMilliseconds + "";
	dString = "" + (Math.random() * 5000) + "";
	return dString;				
}
*/

function OpenPicturesWindow(URLToOpen)
{
	PicturesWindow = window.open(URLToOpen, "PicturesWindow", "width=800, height=600,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0, resizable=1"); // , resizable=1
	PicturesWindow.focus();
}

function clear_textbox(textboxid, comparestring)
{
var textbox = document.getElementById(textboxid);
if (textbox.value == comparestring){
textbox.value = "";
textbox.style.fontStyle="normal"}
} 
function set_textbox(textboxid, text)
{
var textbox = document.getElementById(textboxid);
if (textbox.value == ""){
textbox.value = text;
textbox.style.fontStyle="italic"}
} 

function OpenWindowFocused(URLToOpen)
{
	if (window.opener)
	{
		window.opener.location.href="" + URLToOpen + "";
		window.opener.focus();
	} else {
		booking = window.open(URLToOpen,"booking");
		booking.focus();		
	}
}

function OpenExternalBookingWindow(URLToOpen)
{
	DepthInfoWindow = window.open(URLToOpen, "ExternalBookingWindow"); // , resizable=1
	DepthInfoWindow.focus();
}

function OpenReceiptWindow(URLToOpen)
{
	DepthInfoWindow = window.open(URLToOpen, "ReceiptWindow", "width=806, height=750,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0"); // , resizable=1
	DepthInfoWindow.focus();
}

function OpenDepthInfoWindow(URLToOpen)
{
	DepthInfoWindow = window.open(URLToOpen, "DepthInfoWindow", "width=806, height=750,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0"); // , resizable=1
	DepthInfoWindow.focus();
}

function OpenDisclaimerWindow(URLToOpen)
{
	DepthInfoWindow = window.open(URLToOpen, "DisclaimerWindow", "width=806, height=750,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0"); // , resizable=1
	DepthInfoWindow.focus();
}

function OpenMiniInfoImagesWindow(URLToOpen)
{
	MiniInfoImagesWindow = window.open(URLToOpen, "MiniInfoImagesWindow", "width=800, height=500,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0"); // , resizable=1
	MiniInfoImagesWindow.focus();
}

function OpenMiniInfo(URLToOpen) 
{
	MiniInfoWindow = window.open(URLToOpen, "MiniInfoWindow", "width=500, height=180,location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0"); // , resizable=1
	MiniInfoWindow.focus();
}

function OpenHelpWindow(URLToOpen)
{
	HelpWindow = window.open(URLToOpen, "HelpWindow", "width=810, height=750, scrollbars=0, status=1"); //, location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0, resizable=1");
	HelpWindow.focus();
}

function OpenBookingDetailWindow(URLToOpen)
{
	BookingDetailWindow = window.open(URLToOpen, "BookingDetailWindow", "width=744, height=750, scrollbars=1, status=1"); //, location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0, resizable=1");
	BookingDetailWindow.focus();
}

function OpenContactRequestWindow(URLToOpen)
{
	ContactRequestWindow = window.open(URLToOpen, "CRW", "width=750, height=600, scrollbars=1, status=1"); //, location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0, resizable=1");
	ContactRequestWindow.focus();
}

function OpenMapDetailWindow(URLToOpen)
{
	MapDetailWindow = window.open(URLToOpen, "MapWindow", "width=810, height=798, scrollbars=1, status=1"); //, location=0, menubar=0, directories=0, scrollbars=1, status=1, toolbar=0, resizable=1");
	MapDetailWindow.focus();
}


function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }

if (navigator.appName == "Microsoft Internet Explorer")
{   
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (version < 7.0) && (document.body.filters)) 
	{
		window.attachEvent("onload", correctPNG);
	}
}

    function doClick(buttonName,e)
    {
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
   }

