// 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_preloadImages() 
{
	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 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);
}

strBaseURL	= 'www.klio.co.uk';
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;
	}
	
	yPos = document.documentElement.scrollTop + yPos;
}

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 is_int(strValue)
{
	var i;

	if (isEmpty(strValue.value))
	{
		return 'empty';
	}

	for (iCount = 0; iCount < strValue.value.length; iCount++)
	{
		var strThisChar = strValue.value.charAt(iCount);

		if (!isDigit(strThisChar))
		{
			return false;
		}
	}
	
	return true;
}

function isEmpty(strValue)
{
	return ((strValue == null) || (strValue.length == 0))
}

function isDigit(iValue)
{
	return ((iValue >= "0") && (iValue <= "9"))
}

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 getCheckedValue(radioObj) 
{
	if(!radioObj)	return "";
	
	var radioLength = radioObj.length;
	
	if(radioLength == undefined)
	{
		if(radioObj.checked)
		{
			return radioObj.value;
		}
		else
		{
			return "";
		}
	}
	
	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) 
		{
			alert(radioObj[i].value);
			return radioObj[i].value;
		}
	}
	return "";
}




// General
function showFullImage(strCase, iImage)
{
	strImageURL	=	'/images/casestudies/' + strCase + '/image' + iImage + '.jpg';
	
	// Make forward and back links
	if(iImage < 6)
	{
		iNext		=	eval(iImage) + 1;
		strNextLink	=	'&nbsp;&nbsp;<a href="javascript:showFullImage(\'' + strCase + '\', \'' + iNext + '\');" class="jsclose">next >></a>';
	}
	else
	{
		strNextLink	=	'';
	}
	
	if(iImage > 1)
	{
		iPrev		=	eval(iImage) - 1;
		strPrevLink	=	'<a href="javascript:showFullImage(\'' + strCase + '\', \'' + iPrev + '\');" class="jsclose"><< previous</a>&nbsp;&nbsp;';
	}
	else
	{
		strPrevLink	=	'';
	}
	
	// Show the image
	strContent 	= 	'<table width="768" border="0" cellpadding="0" cellspacing="0"><tr><td><a href="javascript:hideActionDiv();"><img src="' + strImageURL + '" width="768" height="768" border="0"></a></td></tr><tr><td align="right" bgcolor="#FFF">' + strPrevLink + '<a href="javascript:hideActionDiv();" class="jsclose">close</a>' + strNextLink + '</td></tr></table>';

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

	changeActionDiv(strContent, 'visible', iXPos, 20);

}


function showFullImageContact(iImage)
{
	strImageURL	=	'/images/contact/contact' + iImage + '.jpg';
	
	// Make forward and back links
	if(iImage < 5)
	{
		iNext		=	eval(iImage) + 1;
		strNextLink	=	'&nbsp;&nbsp;<a href="javascript:showFullImageContact(\'' + iNext + '\');" class="jsclose">next >></a>';
	}
	else
	{
		strNextLink	=	'';
	}
	
	if(iImage > 1)
	{
		iPrev		=	eval(iImage) - 1;
		strPrevLink	=	'<a href="javascript:showFullImageContact(\'' + iPrev + '\');" class="jsclose"><< previous</a>&nbsp;&nbsp;';
	}
	else
	{
		strPrevLink	=	'';
	}
	
	// Show the image
	strContent 	= 	'<table width="720" border="0" cellpadding="0" cellspacing="0"><tr><td><a href="javascript:hideActionDiv();"><img src="' + strImageURL + '" width="720" height="600" border="0"></a></td></tr><tr><td align="right" bgcolor="#FFF">' + strPrevLink + '<a href="javascript:hideActionDiv();" class="jsclose">close</a>' + strNextLink + '</td></tr></table>';

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

	changeActionDiv(strContent, 'visible', iXPos, 50);

}


function showFullImageDev(iImage)
{
	strImageURL	=	'/images/development/dev' + iImage + '.jpg';
	
	// Make forward and back links
	if(iImage < 5)
	{
		iNext		=	eval(iImage) + 1;
		strNextLink	=	'&nbsp;&nbsp;<a href="javascript:showFullImageDev(\'' + iNext + '\');" class="jsclose">next >></a>';
	}
	else
	{
		strNextLink	=	'';
	}
	
	if(iImage > 1)
	{
		iPrev		=	eval(iImage) - 1;
		strPrevLink	=	'<a href="javascript:showFullImageDev(\'' + iPrev + '\');" class="jsclose"><< previous</a>&nbsp;&nbsp;';
	}
	else
	{
		strPrevLink	=	'';
	}
	
	// Show the image
	strContent 	= 	'<table width="720" border="0" cellpadding="0" cellspacing="0"><tr><td><a href="javascript:hideActionDiv();"><img src="' + strImageURL + '" width="720" height="600" border="0"></a></td></tr><tr><td align="right" bgcolor="#FFF">' + strPrevLink + '<a href="javascript:hideActionDiv();" class="jsclose">close</a>' + strNextLink + '</td></tr></table>';

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

	changeActionDiv(strContent, 'visible', iXPos, 50);

}



// Stock Check
function getSomething()
{
	var strURL	= 'http://' + strBaseURL + '/admin/stocks/getweeks.php?venueid=' + iVenueID + '&type=' + strType + '&dummy=' + new Date().getTime();

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

function showSomething()
{
	if(week.readyState == 4)
	{
		handle = document.getElementById("weekDropSpan");
		handle.innerHTML = week.responseText;
	}
}

function popupWindow()
{
	strContent = '<table width="250" border="0" cellpadding="2" cellspacing="0"><tr><td align="center"><span class="subheader">Change Hours</span></td></tr><tr><td align="center">Enter times as 00:00 in 24 hour format<br><br>In: <input type="text" name="in" value="' + strIn +'" size="6" id="in">&nbsp;&nbsp;&nbsp;Out: <input type="text" name="out" value="' + strOut +'" size="6" id="out"><br><br><a href="javascript:updateHoursWorked(\'' + strDay + '\', \'' + iRowID + '\')" class="subheaderlink">Submit</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onClick="hideActionDiv(); return false;" class="subheaderlink">Cancel</a></td></tr></table>';
		
	changeActionDiv(strContent, 'visible', xPos - 150, yPos - 75);
}













