if (top.location != self.location)
{
top.location = self.location
}

//convert everything to lowercase to make testing easier
var agt = navigator.userAgent.toLowerCase(); 

//get the major and minor version numbers
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

//get the platform
var is_mac = (agt.indexOf("mac")!=-1);
var is_win = (agt.indexOf("win")!=-1);

//get the Netscape version
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1)); 
var is_nav4 = (is_nav && (is_major == 4)); 
var is_nav4up = (is_nav && (is_major >= 4)); 

//get the Internet Explorer version
var is_ie = (agt.indexOf("ie")!=-1) && (agt.indexOf('opera')==-1);  
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1)); 
var is_ie4up  = (is_ie  && (is_major >= 4)); 

//get the Opera Browser
var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);



//browser and platform detection
if (is_ie4 || is_ie4up || is_nav4up || is_nav4 || is_opera || is_opera2 || is_opera3 || is_opera4 || is_opera5 || is_opera5up)
{
  if (is_win)
	{
	//they have windows and are using a suitable browser
	
	}
	else if (is_mac)
	{
	//they have mac and are using a suitable browser
	
	}
	else 
	{
	
		location = "ZDisplayStaticTemplate-Start?templateName=platformerror";
	} // because they don't have a supported platform
}
else 
{
	
	location = "ZDisplayStaticTemplate-Start?templateName=browsererror";
} //because they don't have a supported browser

/*function to submit forms in divs in Netscape*/

function subForm(formName,layerName) {
	if (is_nav4) {
		document.layers[layerName].document.forms[formName].submit()
	} else {
			document.forms[formName].submit()
	}
}

//change image when clicking on button

function clickRoll(imagename,objectsrc,layerName) {
	if (is_nav4) {
		document.layers[layerName].document.images[imagename].src=objectsrc;
	} 
	else {
		document.images[imagename].src=objectsrc;
	}
}

//function to popup descriptive text on rollover
// Set up variables
var docObj;
var styleObj;
var topVal;

				
// initalizes our Generic DOM based on the browser
if (is_nav4up){
	docObj = (is_nav4) ? 'document' : 'document.all';
	styleObj = (is_nav4) ? '' : '.style';
	}		

function popUp(evt,currElem){
	// checks to see if this is a DHTML browser 
	// and that currElem is not set to 0 in which case 
	// this was triggered by the HREF and can not be treated as an event
	if ((is_nav4up || is_ie4up) && currElem != 0){
		dom = eval(docObj +  '.' + currElem + styleObj);
		state = dom.visibility;
		if (state == "visible" || state == "show")
			{dom.visibility = "hidden";}
			else 
			// finds the position of the mouse 
			// and then offsets the coordinates slightly
				{
			if (is_nav4up) {
				topVal = eval(evt.pageY + 5);
				leftVal = eval(evt.pageX - 0);}
			if (is_ie4up) {
				topVal = eval(event.y + 5);
				leftVal = eval(event.x - 0);}
			// keeps the element from going off screen tothe left
			if(leftVal < 2) {leftVal = 2;}	
			dom.top = topVal;
			dom.left = leftVal;
			dom.visibility = "visible";
				}
			}
		}

//function to open popup window
function openWin(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=no,width=716,height=400,status=no,scrollbars=yes,resizable=no,menubar=no");
}

//function to open popup window with scrollbars
function openWinScroll(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=yes,status=no,scrollbars=yes,resizable=yes,menubar=yes");
}

//function to open popup window for flash demos
function openWinFlash(URL) {
  aWindow = window.open(URL,"theflashwindow","toolbar=no,width=718,height=352,status=no,scrollbars=no,resizable=yes,menubar=no,screenx=100,screeny=100");
}

//function to open popup window for basket
function openBasketWin(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=no,width=500,height=320,status=no,scrollbars=no,resizable=no,menubar=no");
}

//function to open popup window for information
function openInfoWin(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=no,width=450,height=320,status=no,scrollbars=auto,resizable=no,menubar=no");
}

//function to open a larger popup window for information
function openInfoWin2(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=no,width=340,height=377,status=no,scrollbars=auto,resizable=no,menubar=no");
}

//function to open popup window for information with scrollbars
function openInfoWinScroll(URL) {
  aWindow = window.open(URL,"thewindow","toolbar=no,width=450,height=280,status=no,scrollbars=yes,resizable=no,menubar=no");
}

//function to open popup window for longer information - e.g. lookup model number
function openInfoWinLong(URL) {
  aWindow = window.open(URL,"infolong","toolbar=no,width=450,height=540,status=no,scrollbars=auto,resizable=no,menubar=no");
}

//function to open popup window for country purchase
function openLargePopupWin(URL) {
  aWindow = window.open(URL,"largepopup","toolbar=no,width=750,height=620,status=no,scrollbars=auto,resizable=no,menubar=no");
}

//function to open popup window for Right Now Integration
function openLargePopupWin2(URL) {
  aWindow = window.open(URL,"largepopup","toolbar=no,width=750,height=580,status=no,scrollbars=yes,resizable=yes,menubar=no");
}


//function to close a window
function closeWin(){
 aWindow = window.close()
}

//function to replace text in a string
function replace(target,oldTerm,newTerm,caseSens,wordOnly) {

var work = target;
var ind = 0;
var next = 0;

if (!caseSens) {
	oldTerm = oldTerm.toLowerCase();
	work = target.toLowerCase();
}

while ((ind = work.indexOf(oldTerm, next)) >= 0) {
	if (wordOnly) {
		var before = ind - 1;
		var after = ind + oldTerm.length;
		if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
			next = ind + oldTerm.length;
			continue;
		}
	}
	target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length, target.length);
	work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length, work.length);
	next = ind + newTerm.length;
	if (next >= work.length) { break; }
}
return target;
}

//function to open popup window for accessories to basket
function openAccessWin(URL) {
  return window.open(URL,"sub","toolbar=no,width=450,height=288,status=no,scrollbars=auto,resizable=no,menubar=no");
}

function removeSpaces(networkName)
{
	// remove spaces
	for(i=0;i<networkName.length;i++)
	{
		if(networkName.substr(i,1) == " ")
		{
			networkName = networkName.substr(0,i) + networkName.substr(i+1,100);
		}	
	}
	return networkName;
}



function getCookie(name) {
	var index = document.cookie.indexOf(name + "=");
	if (index == -1) {
		return null;
	}
	index = document.cookie.indexOf("=", index) + 1;
	var endstr = document.cookie.indexOf(";", index);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(index, endstr));
}


function countryselector(layerName,formName)
	{
		if (is_nav4) {
		document.location=document.layers[layerName].document.forms[formName].select.options[document.layers[layerName].document.forms[formName].select.selectedIndex].value;
		} 
		else {
		document.location=document.forms[formName].select.options[document.forms[formName].select.selectedIndex].value;
		}
	}

//func to generate a random number based on the session id

function getSIDCookie(value,tempValue)
{
var allcookies = document.cookie;
var cookie_name = "sid";
var cookie_pos = allcookies.indexOf(cookie_name);

	//initialise with some default value if no SID exists SID is 32 chars long
	
	//alert("value is:"+ value +":");
	if(value == 'null')
	{
		if(cookie_pos != -1)
		{
			//alert("Doing cookie value is:"+ value +":");
			cookie_pos += cookie_name.length + 1;
			var cookie_end = allcookies.indexOf(";", cookie_pos);
			if (cookie_end == -1)
			{
			cookie_end = allcookies.length;
			}
			value = unescape(allcookies.substring(cookie_pos, cookie_end));
		}
		else //if(value.length == 0)
		{
		//USE JSP TO BUILD A RANDOM 32 CHAR STRING THIS IS SERVER JSP SCRIPT DO NOT GET CONFUSED WITH CLINET SCRIPT
		//alert("Doing time session: value is:"+ value +":");
		value = "tempValue";
		}
	}
	return value;
}


