 // last modified 27/5/05


  
 var iHeight, iWidth;
 var agt=navigator.userAgent.toLowerCase();

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_tv = (agt.indexOf("tv") != -1);
 
 
 /* DO NOT TOUCH! - this was really nasty to discover */
 if(is_tv)
{
	document.write('<'+'link rel="stylesheet" type="text/css" href="styles/maintv.css" />');
	/* only way to get webtv css is through this, media="tv,webtv" doesn't work*/
}

/* get height for dynamic placing, useful for the shop as well */
function getDimensions()
{
	if(typeof(window.innerWidth)=='number') /*non-IE */
	{
		iHeight = window.innerHeight; 
		iWidth =window.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientWidth) /* IE 6 Strict*/
	{
		iHeight = document.documentElement.clientHeight;
		iWidth = document.documentElement.clientWidth;
	}	
	else if( document.body && document.body.clientWidth) /* IE all */
	{
		iHeight = document.body.clientHeight;
		iWidth = document.body.clientWidth;
	}
}

window.onload = start; 

function start()	
{


	
	getDimensions();
	if(iHeight<500)
	{
		document.getElementsByTagName("body")[0].style.margin="5px 0px"; 
		/* absolute position gives problems, but the relative has a huge gap, we fix that dynamically if possible */
	}
	preloadGifs("home,range,health,buy,news,contact","images/buttons/on");  /* preload nav-gifs at least here otherwise ppl get a 5 second blank wait */
	

		
	extras(); /* run specific page scripts */
	
	var oPrivacy= document.getElementById("lnkPrivacy");
	oPrivacy.onclick = privacy;
	oPrivacy.onkeypress = privacy;
	
	var oTerms= document.getElementById("lnkTerms");
	oTerms.onclick = terms;
	oTerms.onkeypress = terms;	
	
	var oCopyright= document.getElementById("lnkCopyright");
	oCopyright.onclick = copyright;
	oCopyright.onkeypress = copyright;		
}

function preloadGifs(sData,sPath)	
{
	var Data = sData.split(",");
	var iMax = Data.length;
	var Gifs = new Array(iMax);
	for(var i=0;i<iMax;i++)
	{
		if(Data[i]!=null)
		{
			Gifs[i]=new Image();
			Gifs[i].src=sPath+"/"+Data[i]+".gif";
		}
	}
}

function popLegal(sURL)
{
	var iheight = iHeight*.95;
// 	var iwidth =.7 * iWidth;
	var itop = .01*iHeight;
	var ileft= .01*iWidth;
	var wnd = window.open(sURL,null,'height='+iHeight+',width=720,left='+ileft+',top='+itop+',location=no,menubar=no,status=no,toolbar=no,resizeable=yes,scrollbars=yes,titlebar=no');
	return(wnd==null);
}

function terms()
{
	return (popLegal("terms.htm"));
}

function privacy()
{
	return (popLegal("privacy.htm"));
}

function copyright()
{
	return (popLegal("copyright.htm"));
}
