//layer popup on/off
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

//fixed popup - delivery
function DeliveryPopup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=820,height=640,scrollbars=yes');
return false;
}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=820,height=640,scrollbars=yes');
return false;
}


//centered popup
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle,imageText){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width)+40;');
writeln('height=300-(document.body.clientHeight-document.images[0].height)+110;');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=#FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<div align="center" style="font-family:arial; font-weight:bold; font-size:14px; color:#000000; background-color:#FFFFFF; padding:8px 5px 5px 5px; height:35px; background-image:url(CENTRE3.jpg); background-position: center center; background-repeat:no-repeat; " >'+imageTitle+'</div>');
writeln('<div style="padding:20px;"><img name="George" src='+imageURL+' style="display:block;"></div>');
writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr style="background-image:url(CENTRE2A.jpg); background-position: center center; background-repeat:no-repeat;"><td><img src="global/1.gif" width="1" height="35" /></td><td style="height:35px; vertical-align:middle;font-family:arial; font-weight:bold; font-size:14px; color:#000000; background-color:#FFFFFF; padding:0px 0px 0px 0px;"><div align="center">'+imageText+'</div></td></tr></table>');
writeln('</body></html>');

close();		
}}

function detailImage(imageURL,imageTitle,imageText){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width)+40;');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
if (imageText != '')
{
writeln('height = height+145;');
writeln('heightNNa = 145;');
}
if (imageText == '')
{
writeln('height = height+40;');
writeln('heightNNa = 40;');
}
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width+40;');
writeln('window.innerHeight=document.images["George"].height+heightNNa;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=#FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<div style="padding:20px;"><img name="George" src='+imageURL+' style="display:block;"></div>');
if (imageText != '')
{
writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr style="background-image:url(CENTRE2.jpg); background-position: center center; background-repeat:no-repeat;"><td><img src="global/1.gif" width="1" height="70" /></td><td style="height:35px; vertical-align:middle;font-family:arial; font-weight:bold; font-size:13px; color:#000000; background-color:#FFFFFF; padding:6px;background-image:url(CENTRE2.jpg); background-position: center center; background-repeat:no-repeat;"><div align="center">'+imageText+'</div></td></tr></table>');
}
close();		
}}


/////////////////FIND VIEWPORT SIZE////////////////////
 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 if (typeof window.innerWidth != 'undefined')
 { viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 
 { viewportwidth = document.documentElement.clientWidth,
  viewportheight = document.documentElement.clientHeight }
 

 // older versions of IE
 else
 { viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
  viewportheight = document.getElementsByTagName('body')[0].clientHeight }
//////////////////////////////////////////////////////////

 ///////////SCROLL FUNCTION/////////////////
 //to determine how far down the page a user has scrolled 
 function f_scrollTop() 
 	{
	return f_filterResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0);
	}
	function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
	}
		
	function f_filterResults(n_win, n_docel, n_body) 
		{
			var n_result = n_win ? n_win : 0;
			if (n_docel && (!n_result || (n_result > n_docel)))	n_result = n_docel;
			return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
		}
 ///////////////END SCROLL FUNCTION/////////////////


/////////////BIGIMAGE POPUP FUNCTION //////////////////////
// function for all large image popups (horizontally centered by viewport width, vertically centred by scroll position (see function f_scrollTop() )
document.write('<div id="POPUPIMAGE" style="display:none; height:0px;"></div>'); // write empty popup div for popup info to be put in to.
function bigimage(imageSrc, imageText, imageWidth, imageHeight, style, bigim)
	{
	document.getElementById('POPUPIMAGE').style.display = "block"; //display standard popup window
	var fullwidth = parseInt(imageWidth)+22; //set width of initial div
	var halfwidth = (fullwidth/2)-37; //set width of 'loading' div
	var halfheight = (imageHeight/2)-10; //set width of 'loading' div
	
	//even bigger image
	var bigimagesection = '';
	if (bigim != '') {var bigimagesection = '<div id="MAG" style="position:absolute; left:'+(imageWidth-25)+'px; top:'+(imageHeight-25)+'px; width:37px; height:37px; z-index:90;"><a href="'+bigim+'" target="blank"><img src="global/MAG.png" width="37" height="37" border="0" onclick="" style="cursor:hand; cursor:pointer"/></a></div>';}

	//popup content
	document.getElementById('POPUPIMAGE').innerHTML='<div id="IMAGECONTAINER" style="; z-index:1000; background-color:#8893e4; background-image:url(global/BLUEIMAGEPOPUP.png); background-position:center; background-repeat:repeat-y; border:2px solid black; position:absolute; left:0px; top:0px; width:'+fullwidth+'px; display:block;" onclick="document.getElementById(\'IMAGECONTAINER\').style.display = \'none\'; document.getElementById(\'POPUPIMAGE\').style.display = \'none\';"><div style="position:relative;"><div class="DefaultFont" style="position:absolute; left:'+halfwidth+'px; top:'+halfheight+'px; padding:8px; width:75px; background-color:#000000; border:1px solid; #FFFFFF; " align="center">loading...</div><div style="position:absolute; left:0px; top:0px;"><img id="BigImage1" width="'+imageWidth+'px" height="'+imageHeight+'px" src="'+imageSrc+'" style="border:1px solid #444444; margin:10px 10px 7px 10px;"/></div><div class="DefaultFont" style="font-size:12px; font-weight:bold; position:absolute; right:10px; top:10px; background-color:#CCCCCC; border:1px solid #444444; padding:2px 6px 2px 6px; color:#333333; cursor:hand; cursor:pointer;">close</div> '+bigimagesection+' </div><img id="BigImageSizer" width="'+imageWidth+'px" height="'+imageHeight+'px" src="global/1.gif" style="border:1px solid #444444; background-color:#CCCCCC; margin:10px 10px 7px 10px;"/><div id="imagetextbox" class="DefaultFont" style="font-size:12px; font-weight:normal; padding:0px 10px 10px 10px; color:#000000;" align="center">'+imageText+'</div></div>'; //popup content
	
			//###############set styles############
			if (style == 'MAIN') 
				{
				document.getElementById('IMAGECONTAINER').style.backgroundColor = "#000000";
				document.getElementById('IMAGECONTAINER').style.borderColor = "#FFFFFF";
				document.getElementById('IMAGECONTAINER').style.backgroundImage = "none";
				}
			//###############set styles############
	
	var trueleft = parseInt((viewportwidth/2)-(imageWidth/2)); //define left position for centering depending on viewport
	
	var objectheight = document.getElementById('IMAGECONTAINER').offsetHeight; //popup true height
	var scrolltop = f_scrollTop() //position of scroll
	var truetop = parseInt(((viewportheight/2)+scrolltop)-(objectheight/2)); //define top position for centering depening on scroll position.
	
	if (truetop <0) truetop = 0;  //restrict popup to top of screen if it overspills.
	
	if (imageText == '') {document.getElementById('imagetextbox').style.display = "none"; document.getElementById('BigImageSizer').style.marginBottom="10px";} //set text box to display:none if no text presents
	
	document.getElementById('IMAGECONTAINER').style.left = trueleft + "px"; //set left of popup
	document.getElementById('IMAGECONTAINER').style.top = truetop + "px"; //set top of popup
	}
///END POPUP FUNCTION

/////////////////////////////////////////////////////////////////////
//////////////////load info into iframe
/////////////////////////////////////////////////////////////////////
function IframeInfo(iframeSrc, iframeWidth, iframeHeight, iframeScroll)
	{
	if (iframeScroll == null) {iframeScroll = '';}

	document.getElementById('POPUPIMAGE').style.display = "block"; //display standard iframe window
	var mode = '1';
	if (iframeWidth == '') {iframeWidth = '500'; mode = '2'} // if blank, set popup width default + set mode
	if (iframeHeight == '') {iframeHeight = '200'; mode = '2'}; // if blank, set popup height default + set mode
	
	var fullwidth = parseInt(iframeWidth)+22; //set width of initial div

	if (iframeScroll == '' || iframeScroll == 0)	var iframeScrollonoff = 'no';
	if (iframeScroll == 1)	var iframeScrollonoff = 'auto';
	if (iframeScroll == 2)	var iframeScrollonoff = 'vertical';
	
	//iframe content
	var initalcontent = '';
	if (mode == '2') initalcontent = 'loading...';
	document.getElementById('POPUPIMAGE').innerHTML='<div id="IFRAMECONTAINER" style="; z-index:1000; background-color:#bdd2ff; background-image:url(global/BLUEIMAGEPOPUP.png); background-position:center; background-repeat:repeat-y; border:2px solid black; position:absolute; left:0px; top:0px; width:'+fullwidth+'px; display:block;" onclick="document.getElementById(\'IFRAMECONTAINER\').style.display = \'none\';top.frames[\'iframe1\'].location.replace(\'\');"><div style="position:relative;"><div id="loading" name="loading" class="DefaultFont" style="position:absolute; left:15px; top:15px; padding:8px; width:75px; background-color:#000000; border:1px solid; #FFFFFF; display:none; " align="center">loading...</div><div class="DefaultFont" style="font-size:12px; font-weight:bold; position:absolute; right:-2px; top:-10px; background-color:#CCCCCC; border:1px solid #444444; padding:2px 6px 2px 6px; color:#333333; cursor:hand; cursor:pointer; font-family: Arial, Helvetica, sans-serif;">close</div></div><div style="position:relative;"><div name="inital" id="inital" style="display:block; position:absolute; left:190px; top:90px; padding:10px; border:1px solid #000; background-color:#ccc; color:#000; font-weight:bold;">'+initalcontent+'</div></div><iframe id="iframe1" name="iframe1" src="'+iframeSrc+'" scrolling="'+iframeScrollonoff+'" width="'+iframeWidth+'" height="'+iframeHeight+'" frameborder="0" style="z-index:10;margin:10px; border:1px solid #000000; background-color:#fff;">[Content for browsers that don\'t support iframes goes here.]</iframe><div style="position:absolute; left:20px; top:20px; z-index:0"></div></div>'; //iframe content
	
	var trueleft = parseInt((viewportwidth/2)-(iframeWidth/2)); //define left position for centering depending on viewport
	
	//top.frames['iframe1'].location.replace(iframeSrc);
	
	var objectheight = document.getElementById('IFRAMECONTAINER').offsetHeight; //popup true height
	var scrolltop = f_scrollTop() //position of scroll
	var truetop = parseInt(((viewportheight/2)+scrolltop)-(objectheight/2)); //define top position for centering depening on scroll position.
	
	if (truetop <0) truetop = 0;  //restrict popup to top of screen if it overspills.
	
	if (mode == '1') document.getElementById('inital').style.display = "none";
	
	document.getElementById('IFRAMECONTAINER').style.left = trueleft + "px"; //set left of popup
	document.getElementById('IFRAMECONTAINER').style.top = truetop + "px"; //set top of popup
	}
function closeloading()
	{
	document.getElementById('loading').style.backgroundColor = "#00FF00";
	document.getElementById('loading').style.display = "none";
	}
