/* Browser/platform checkers */
var version = navigator.appVersion.charAt(0);

if (navigator.appName.indexOf('Microsoft') != -1)
{
	var isIE = true;
	var isNS = false;
	var isMoz = false;	
} 
else if ((navigator.appName.indexOf('Netscape') != -1) && (version == 4))
{
		var isNS = true;
		var isIE = false;
		var isMoz = false;		
} 
else if ((navigator.appName.indexOf('Netscape') != -1) && (version == 5))
{
		var isNS = false;
		var isIE = false;
		var isMoz = true;		
}

var isWin = navigator.userAgent.indexOf("Win") != -1;
var isMac = navigator.userAgent.indexOf("Mac") != -1;
var isUnix = navigator.userAgent.indexOf("X11") != -1;

/* Make a combo variable to identify */
var iBPmix = 0;
if (isWin)
{
	if (isIE)
	{
		iBPmix = 1;
	}
	if (isNS)
	{
		iBPmix = 2;
	}
}
if (isMac)
{
	if (isIE)
	{
		iBPmix = 3;
	}
	if (isNS)
	{
		iBPmix = 4;
	}
}
/* Proprietary functions for Goldsmiths */
function sendEmail(shortlistID)
{
	emailURL = '/email.asp';
	if (shortlistID > 0)
	{ emailURL += '?slid=' + shortlistID; }
	window.open(emailURL, 'emailer', 'width=360,height=320,scrolling=no');
}
/* End proprietary functions */

function checkrequired(formname)
{
	var pass = 0;
	var box = 0;
	var theForm = document.forms[formname];

	if (document.images)
	{
		for (i=0; i < theForm.length; i++)
		{
			var tempobj=theForm.elements[i];
			if (tempobj.name.substring(0,1) == "*")
			{
				if (((tempobj.type == "text" || tempobj.type == "textarea") && tempobj.value=='') ||
						(tempobj.type.toString().charAt(0) == "s" && tempobj.selectedIndex == 0))
				{
					pass = 1;
					break;
	      }
	    } 
		}
		
		if (pass == 1)
		{		
			shortFieldName = tempobj.name.substring(1,30).toUpperCase();
			alert("Please make sure the " + shortFieldName + " field is properly filled in.");
			tempobj.focus();
		}
		else
		{ theForm.submit(); }
	}			
}

function showBig(filename, imgno, sec, page)
{
	var winID = window.open("pic_viewer.asp?file=" + filename + "&imgnum=" + imgno + "&sec=" + sec + "&page=" + page, 'bigpic', 'width=250,height=250,scrollbars=no,resizable=yes,left=80,top=80');
}

function process_imgs_links( img, caption) {
	if (isNS) { // handle NS		
		document.bigimg.src = img;
		document.bigimg.alt = caption;
	} else if (isIE) { //handle IE
		document.bigimg.src = img;				
		document.bigimg.alt = caption;
	} else { // Handle Mozilla				
		document.getElementById("bigimg").src = img;		
		document.getElementById("bigimg").alt = caption;
	}									
}
/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function flashPopUp()
{
	var winID = window.open('tour.asp', 'bigpic', 'width=700,height=410,scrollbars=no,resizable=yes');
}
function bookingPopUp( ref)
{
	var winID = window.open( ref, 'Booking', 'width=700,height=410,scrollbars=yes,resizable=yes');
}

function showPopUp(page, width, height)
{
	var popUp = window.open( page, 'popup', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=' + width + ',height='+ height);
}
function setFocusOn( sform, sfield) {
	var sForm = document.forms[sform];
	sForm.elements[sfield].focus();
}
function changeBGOn( divID)
{
	document.getElementById(divID).style.background = '#f4f4f4';
}
function changeBGOff( divID)
{
	document.getElementById(divID).style.background = '';
}
function getPage( sUrl)
{
	if(sUrl != "") {
		document.location.href = sUrl;
	}
}