// Standard Dreamweaver functions
function MM_swapImgRestore() 
{
	var i, x, a = document.MM_sr; 
	for (i = 0; a&&i < a.length&&(x=a[i])&&x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) 
{
  	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_swapImage() 
{
	var i, j=0, x, a = MM_swapImage.arguments; 
	document.MM_sr = new Array; 
	for (i=0; i < (a.length-2); i+=3)
   	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++] = x; 
		if (!x.oSrc) x.oSrc = x.src; x.src = a[i+2];
	}
}

function MM_jumpMenu(targ,selObj,restore)
{
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) 
{
	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 && document.getElementById) x=document.getElementById(n); 
	return x;
}

function MM_showHideLayers() 
{
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) 
  	{ 
		v=args[i+2];
		if (obj.style) 
		{ 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}
		obj.visibility=v; 
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{ 
	if (newWindow) newWindow.close(); 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
} 

function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{ 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
	newWindow.focus(); 
}

function MM_openBrWindow(theURL,winName,features) 
{
	window.open(theURL,winName,features);
}

function MM_popupMsg(msg) 
{
	alert(msg);
}

var isNS4;
var isNS6;
var isIE4;
var isIE5;
var strPlatform;

isNS4 		= (document.layers) ? true : false;
isIE4 		= (document.all && !document.getElementById) ? true : false;
isIE5 		= (document.all && document.getElementById) ? true : false;
isNS6 		= (!document.all && document.getElementById) ? true : false;

Browser 	= navigator.appName
Net 		= Browser.indexOf("Netscape")
Micro 		= Browser.indexOf("Microsoft")
Netscape 	= false
IE 			= false

if(Net >= 0) 
{
	Netscape = true
}

if(Micro >= 0) 
{
	IE = true
}

var xPos;
var yPos;
document.onmousemove = XYpos;

var updateRequest = createMultiRequest();

function createRequest()
{
	try
	{
		request = new XMLHttpRequest();
	}
	catch (trymicrosoft)
	{
		try
		{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (othermicrosoft)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed)
			{
				request = null;
			}
		}
	}

	if(request == null)
	{
		alert("Error creating request object");
	}

	return request;
}

function createMultiRequest()
{
	try
	{
		request = new XMLHttpRequest();
	}
	catch (trymicrosoft)
	{
		try
		{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (othermicrosoft)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed)
			{
				request = null;
			}
		}
	}
 
	if(request == null)
	{
		alert("Error creating request object");
	}
 
	return request;
}

function XYpos(e) 
{
	if (IE == true) 
	{
		xPos = event.screenX
		yPos = event.screenY
	}
	else
	{
		xPos = e.clientX;
		yPos = e.clientY;
	}
}

function getMouseXY(e) 
{
	if (IE) 
	{ // grab the x-y pos.s if browser is IE
		xPos = event.clientX + document.body.scrollLeft
		yPos = event.clientY + document.body.scrollTop
	} 
	else
	{  // grab the x-y pos.s if browser is NS
		xPos = e.pageX
		yPos = e.pageY
	}  
	// catch possible negative values in NS4
	if (xPos < 0){xPos = 0}
	if (yPos < 0){yPos = 0}  
  
  	return true
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft
		curtop 	= obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft
			curtop 	+= obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function changeActionDiv(strContent, strVisibleStatus, leftPos, topPos)
{
	hActionDiv 					= document.getElementById("actionDiv");
	hActionDiv.innerHTML		= strContent;
	hActionDiv.style.visibility	= strVisibleStatus;
	hActionDiv.style.top		= topPos + 'px';
	hActionDiv.style.left		= leftPos + 'px';
}

function showActionLayer(iLeft, iTop, iWidth, iHeight)
{
	hALayer						= document.getElementById("actionLayer");
	hALayer.style.background	= '#FFFFFF';
	hALayer.style.visibility	= 'visible';
	hALayer.style.left			= iLeft + 'px';
	hALayer.style.top			= iTop + 'px';
	hALayer.style.width			= iWidth + 'px';
	hALayer.style.height		= iHeight + 'px';
}

function hideActionLayer()
{
	hALayer 					= document.getElementById("actionLayer");
	hALayer.style.visibility	= 'hidden';
}

function hideActionDiv()
{
//	if(IE)
//	{
//		upload					= document.getElementById("actionLayer");
//		upload.style.visibility	= 'hidden';
//	}

	handle 						= document.getElementById("actionDiv");
	handle.style.visibility 	= "hidden";
}

function changeBookingDiv(strContent, strVisibleStatus, leftPos, topPos)
{
	hBookDiv 					= document.getElementById("bookingForm");
	hBookDiv.innerHTML			= strContent;
	hBookDiv.style.visibility	= strVisibleStatus;
	hBookDiv.style.top			= topPos + 'px';
	hBookDiv.style.left			= leftPos + 'px';
	hBookDiv.style.left			= leftPos + 'px';
}

function hideBookingForm()
{
	handle 						= document.getElementById("bookingForm");
	handle.style.visibility 	= "hidden";
}



function showMap(strImageURL, iImageWidth, iImageHeight)
{
	iLeftCellWidth	= iImageWidth - 30;
	
	strContent = '<table width="' + iImageWidth + '" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="' + strImageURL + '" width="' + iImageWidth + '" height="' + iImageHeight + '" border="0"></td></tr><tr><td align="right" bgcolor="#000"><a href="#" onClick="javascript:hideActionDiv();return false;" class="normallink"><span class="normaltext">close</span></a></td></tr></table>';

	iTotalWidth	= document.body.clientWidth;
	iXPos		= (iTotalWidth - iImageWidth) / 2;

	changeActionDiv(strContent, 'visible', iXPos, 180);
}



function showInside(strImageURL, iImageWidth, iImageHeight)
{
	iLeftCellWidth	= iImageWidth - 30;
	
	strContent = '<table width="' + iImageWidth + '" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="' + strImageURL + '" width="' + iImageWidth + '" height="' + iImageHeight + '" border="0"></td></tr><tr><td align="right" bgcolor="#000"><a href="#" onClick="javascript:hideActionDiv();return false;" class="normallink"><span class="normaltext">close</span></a></td></tr></table>';

	iTotalWidth	= document.body.clientWidth;
	iXPos		= (iTotalWidth - iImageWidth) / 2;

	changeActionDiv(strContent, 'visible', iXPos, 100);
}


function showBoothSelection(strRoom)
{
	// Get the selected Date
	hDay		= document.getElementById("theday");
	iDay		= hDay.value;
	hMonth		= document.getElementById("themonth");
	iMonth		= hMonth.value;
	hYear		= document.getElementById("theyear");
	iYear		= hYear.value;
	
	// Make the date nice, get today's date and the opening night
	var strTheDate 		= new Date;
	var strToday		= new Date();
	var strOpeningNight	= new Date;
	strTheDate.setDate(iDay);
	strTheDate.setMonth(iMonth);
	strTheDate.setFullYear(iYear); 	
	strOpeningNight.setDate(5);
	strOpeningNight.setMonth(11);
	strOpeningNight.setFullYear(2007); 
	strShortDate		= iDay + '-' + iMonth;
	
	// Get a handle to the error span
	hErrorSpan 	= document.getElementById("errorspan");
	
	// Check the date is in the future
	if(strTheDate < strToday)
	{
		hErrorSpan.innerHTML	= '<br><br>Please enter a date in the future';
		return;
	}
	
	// Check the date is Wed, Thu, Fri, Sat
	iToday		= strTheDate.getDay();	
	if((iToday == 7) || (iToday == 2) || (iToday == 1))
	{
		if((strShortDate == '31-11') || (strShortDate == '24-11'))
		{
		}
		else
		{
			hErrorSpan.innerHTML	= '<br><br>Booth Reservations are only available on Wednesdays, Thursdays, Fridays and Saturdays';
			return;
		}
	}
	hErrorSpan.innerHTML	= '&nbsp;';

	// Check the date is after the 5th of Dec 2007- opening night
	if((strTheDate < strOpeningNight) && (strShortDate != '31-11'))
	{
		hErrorSpan.innerHTML	= '<br><br>We open on the 5th Deceember 2007, please book after this date';
		return;
	}
	hErrorSpan.innerHTML	= '&nbsp;';
	
	// No errors. Find out what the booth situation is
	strPrefix	= 'www';
	var strURL	= 'http://www.jjwhispers.co.uk/bookingstatus.php?room=' + strRoom + 
																'&day=' + iDay + 
																'&month=' + iMonth + 
																'&year=' + iYear + 
																'&dummy=' + new Date().getTime();

	qBooking	= createRequest();
	qBooking.open("GET", strURL, true);
	qBooking.onreadystatechange = MakeBookingSelection;
	qBooking.send(null);
}


function MakeBookingSelection()
{
	if(qBooking.readyState == 4)
	{
		aContent	= qBooking.responseText.split('|');
		iXPos		= (document.body.clientWidth - aContent[0]) / 2;
		
		showActionLayer(iXPos, 170, aContent[0], 500);
		changeActionDiv(aContent[1], 'visible', iXPos, 170);
		
	}
}


function BookingForm(strBooth, strDate, strNiceDate)
{
	strContent	= '<form method="post" name="booking" action="book.php?m=save"><table width="310" border="0" cellpadding="2" cellspacing="2"><tr><td><span class="normaltext">Booth: </span></td><td><span class="normaltext">' + strBooth + '</span></td></tr><tr><td><span class="normaltext">Date: </span></td><td><span class="normaltext">' + strNiceDate + '</span></td></tr><tr><td valign="top"><span class="normaltext">First Name: </span></td><td valign="top"><input type="text" name="firstname" size="39" class="bookinginputbox" id="firstname"/><span class="listformstar">&nbsp;*</span><span class="listformerror" id="firstnameerror"></span></td></tr><tr><td valign="top"><span class="normaltext">Surname: </span></td><td valign="top"><input type="text" name="surname" size="39" class="bookinginputbox" id="surname" /><span class="listformstar">&nbsp;*</span><span class="listformerror" id="surnameerror"></span></td></tr><tr><td valign="top"><span class="normaltext">email: </span></td><td valign="top"><input type="text" name="email" size="39" class="bookinginputbox" id="email" /><span class="listformstar">&nbsp;*</span><span class="listformerror" id="emailerror"></span></td></tr><tr><td valign="top"><span class="normaltext">Telephone: </span></td><td valign="top"><input type="text" name="telephone" size="39" class="bookinginputbox" id="telephone" /><span class="listformstar">&nbsp;*</span><span class="listformerror" id="telephoneerror"></span></td></tr><tr><td colspan="2"><input type="radio" name="car" value="transport" />&nbsp;&nbsp;&nbsp;<span class="normaltext">Require Transport: </span></td></tr><tr><td colspan="2"><input type="radio" name="car" value="valet" />&nbsp;&nbsp;&nbsp;<span class="normaltext">Require Valet: </span></td></tr><tr><td><span class="normaltext">Further Requests: </span></td><td><textarea name="notes" cols="35" rows="5" class="bookingarea" id="notes"></textarea></td></tr><tr><td colspan="2"><span class="normaltext">A minimum spend applies to all bookings. Your reservation is not confirmed until one of our customer services team has spoken to you.</span></td></tr><tr><td colspan="2" align="center"><input type="hidden" name="booth" value="' + strBooth + '" /><input type="hidden" name="thedate" value="' + strDate + '" /><input type="button" value="     reserve     " onclick="javascript:checkBookingForm();" class="bookingbutton" />&nbsp;&nbsp;<input type="button" value="     cancel     " onclick="javascript:hideBookingForm();" class="bookingbutton"/></td></tr></table></form>';
	
	hActionDiv 	= document.getElementById("actionDiv");

	iLeft		= hActionDiv.style.left.substr(0, hActionDiv.style.top.length - 2);
	iTop		= hActionDiv.style.top.substr(0, hActionDiv.style.top.length - 2);
	
	iTop		= parseFloat(iTop) + 78;
	iLeft		= parseFloat(iLeft) + 255;
	
	changeBookingDiv(strContent, 'visible', iLeft, iTop);
}


function checkBookingForm()
{
	var bFormGood	= true;
	
	hFirstName		= document.getElementById("firstname");
	hFirstNameE		= document.getElementById("firstnameerror");
	strFirstName	= hFirstName.value;
	bFormGood		= validateBookingField(hFirstNameE, 1, strFirstName, 'first name', bFormGood);
	
	hSurname		= document.getElementById("surname");
	hSurnameE		= document.getElementById("surnameerror");
	strSurname		= hSurname.value;
	bFormGood		= validateBookingField(hSurnameE, 3, strSurname, 'surname', bFormGood);
	
	hEmail			= document.getElementById("email");
	hEmailE			= document.getElementById("emailerror");
	strEmail		= hEmail.value;
	bFormGood		= validateBookingField(hEmailE, 10, strEmail, 'email address', bFormGood);
	
	hTelephone		= document.getElementById("telephone");
	hTelephoneE		= document.getElementById("telephoneerror");
	strTelephone	= hTelephone.value;
	bFormGood		= validateBookingField(hTelephoneE, 11, strTelephone, 'telephone number', bFormGood);
	
	if(bFormGood)
	{
		document.booking.submit();
	}
}


function validateBookingField(hHandle, iLength, strValue, strElement, bFormGood)
{
	if(strValue.length == 0)
	{
		hHandle.innerHTML	= '<br>Please enter your ' + strElement;
		return false;
	}
	else if (strValue.length < iLength)
	{
		hHandle.innerHTML	= '<br>Please complete your ' + strElement;
		return false;
	}
	else
	{
		hHandle.innerHTML	= '';
		if(bFormGood)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}


function showPic(strImageURL, iImageWidth, iImageHeight)
{
	iLeftCellWidth	= iImageWidth - 30;
	
	strContent = '<table width="' + iImageWidth + '" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="' + strImageURL + '" width="' + iImageWidth + '" height="' + iImageHeight + '" border="0"></td></tr><tr><td align="right" bgcolor="#000"><a href="#" onClick="javascript:hideActionDiv();return false;" class="normallink"><span class="normaltext">close</span></a></td></tr></table>';

	iTotalWidth	= document.body.clientWidth;
	iXPos		= (iTotalWidth - iImageWidth) / 2;

	changeActionDiv(strContent, 'visible', iXPos, 180);
}


function changeBlackImage(iMemberID)
{
	strContent = '<form method="POST" enctype="multipart/form-data" action="index.php?m=newimage&iMemberID=' + iMemberID + '"><table width="200" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFF33"><tr><td colspan="2" align="center"><span class="mainheader">Change Member Image</span></td></tr><tr><td valign="top">Image:</td><td><input type="file" name="thephoto" size="45" onFocus="select()"></td></tr><tr><td colspan="2" align="center"><input type="submit" name="submit" value="Save">&nbsp;&nbsp;&nbsp;<input type="button" onClick="hideActionDiv(); return false;" value="Cancel"></td></tr></table></form>';

	changeActionDiv(strContent, 'visible', xPos - 100, yPos - 50);
}






















