// js functions required for pv-gallery page


function photo_selectThumb(thumbIndex) {
    if (thumbIndex == photo_currentThumb) return;
    
	// unselect current thumb
	var thumbObj = document.getElementById("photothumb"+photo_currentThumb);
	thumbObj.style.border="1px solid #ebebeb";

	// set as new current
	photo_currentThumb = thumbIndex;

	thumbObj = document.getElementById("photothumb"+photo_currentThumb);
	thumbObj.style.border="1px solid red";

	photo_showImage(photo_currentThumb);
}
function photo_next() {
	var newThumb = photo_currentThumb;
	newThumb = newThumb % photo_totalThumbs;
	newThumb = newThumb + 1;
	photo_selectThumb(newThumb);
}
function photo_previous() {
	var newThumb = photo_currentThumb;
	newThumb = newThumb - 1;
	if (newThumb==0) newThumb = photo_totalThumbs;
	photo_selectThumb(newThumb);
}
function photo_showImage(thumbIndex) {
	var thumbObj = document.getElementById("photothumb"+thumbIndex);
	var textObj = document.getElementById("phototext");
	var imageObj = document.getElementById("photoimg");
	textObj.innerHTML = thumbObj.getAttribute("text");
	imageObj.src = thumbObj.getAttribute("image");
	imageObj.alt = thumbObj.getAttribute("imagealt");
}
function photo_showLarge() {
	var thumbObj = document.getElementById("photothumb"+photo_currentThumb);
	var urlstr = window.location.toString();
	var languageAddt = urlstr.substring(urlstr.indexOf("ln="), urlstr.length);
	if (urlstr.indexOf("ln=") < 0) {
		popWindow("/gallery-pop.html?image="+thumbObj.getAttribute("limage")+"&amp;alt="+thumbObj.getAttribute("limagealt"),"ImagePopup",640,520,2,0,1);
	} else {
		popWindow("/gallery-pop.html?image="+thumbObj.getAttribute("limage")+"&amp;alt="+thumbObj.getAttribute("limagealt")+"&amp;" + languageAddt,"ImagePopup",640,520,2,0,1);
	}
}


function popVideo(file) {
	popWindow(file,"nissanvideo",320,340,0,0,1);
}
function popFlash(name,file) {
	popWindow(file,"nissanflash",460,470,0,0,1);
}
function popDownload(file) {
	var content="";
	content="";
	content+="<html>\n";
	content+="<head>\n";
	content+="<meta http-equiv='refresh' content='0; URL="+ file +"'>\n";
	content+="</meta>\n";	
	content+="</head>\n";
	content+="</html>\n";

  	var _parms = 'directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes,left=25,top=32,screenx=25,screeny=32,width=600,height=350';

    myWindowHandle=window.open("","",_parms);
    myWindowHandle.document.open();
    myWindowHandle.document.write(content);
    myWindowHandle.document.close();
	myWindowHandle.focus();
}


// ## global.js
// 	Contains code that fixes the resize bug in Netscape, control core functionality for all dynamic layer elements, and sets the appropriate .css file depending on the user's browser. This file is used on all templates.

// FUNCTION LIST:
// 	resizeFix();
// 	popWindow();
// 	popGlossary();
//	BrowserCheck();
// 	DynLayer();
// 	DynLayerMoveTo();
// 	DynLayerMoveBy();
//	DynLayerInit();
// 	DynLayerClipInit();
// 	DynLayerClipTo();
// 	DynLayerClipBy();
//	DynLayerClipValues();
// 	DynLayerWrite();
//	popWindowMagic();
//  resizeWindow();
// 	popEbrochure();


// TEMPLATE(S) USED:
// 	brochure_request.html
// 	coming_veh.html
// 	contact.html
// 	corporate.html
// 	dealer_results.html
// 	gallery.html
// 	galleryPopup.html
// 	line_up.html
// 	main.html
// 	performance.html
// 	specs.html
// 	vehicles_home.html


//This script checks to see if visitor is using Netscape or MSIE browser. 
//If Netscape or MSIE, make sure it is version 4.x or higher
//If not 4.x or above, send to error page.

var browserVer=parseInt(navigator.appVersion); 
 
if(navigator.appName == "Netscape")
	{
	if (browserVer < 4)
	 	{
			document.location="errorpage.html"
		}
	}

if(navigator.appName == "Microsoft Internet Explorer")
	{
	if (browserVer < 4)
	 	{
			document.location="errorpage.html"
		}
	}

// BEGIN RESIZE CODE
// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/
var firstTime = true;
if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
	widthCheck = window.innerWidth
	heightCheck = window.innerHeight
	window.onResize = resizeFix
} else if (navigator.appName=="Microsoft Internet Explorer") {
	window.onresize = adjustPosIE;
} else {
	window.onresize = adjustPos;
}

function meResizeFix() {
	if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
		widthCheck = window.innerWidth
	
		heightCheck = window.innerHeight
		resizeFix();
	} else if (navigator.appName=="Microsoft Internet Explorer") {
		adjustPosIE();
	} else {
		adjustPos();
	}
}
var footerposchange = false;
function adjustPosIE() {
	
	//alert(document.getElementById('footerdiv'));
	
	if (document.getElementById('footerdiv').offsetTop < 518) {
		if(!(document.getElementById('contact_footer') || document.getElementById('div3') || document.getElementById('div3PLP') || document.getElementById('cbfooter')) )
		{
			document.getElementById('footerdiv').style.top = "518px";
			footerposchange = true;
			//document.getElementById('globalcontent').style.height = 450;
		}
	}
	
	if(true) {
		if(firstTime) {
			if(document.getElementById('div1')) {
				var bdrWidth = parseInt(document.getElementById('div1').offsetWidth);
				var leftPos = parseInt(document.getElementById('div1').offsetLeft);
			} else if (document.getElementById('plp')) {
				var bdrWidth = parseInt(document.getElementById('plp').offsetWidth);
				var leftPos = parseInt(document.getElementById('plp').offsetLeft);
			} else if (document.getElementById('headerNav')) {
				var bdrWidth = parseInt(document.getElementById('headerNav').offsetWidth);
				var leftPos = parseInt(document.getElementById('headerNav').offsetLeft);
			} else if (document.getElementById('CBsplash')) {
				var bdrWidth = parseInt(document.getElementById('CBsplash').offsetWidth);
				var leftPos = parseInt(document.getElementById('CBsplash').offsetLeft);
			} else {
				
				//alert(document.getElementById('h_spacerDiv'));
				
				var bdrWidth = parseInt(document.getElementById('h_spacerDiv').offsetWidth);
				var leftPos = parseInt(document.getElementById('h_spacerDiv').offsetLeft);
			}
			if(bdrWidth>1004) {
				//alert("bdrWidth..."+bdrWidth);
				//document.getElementById('div2').style.width = "100%";
				//document.getElementById('footerBorder').style.width = "100%";
				if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "100%";
				if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "100%";
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "100%";
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "100%";
/*
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = leftPos;
					document.getElementById('div2').style.width = "100%";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = "";
					document.getElementById('div1').style.width = "100%";
				}
*/
			} else {
				//alert("bdrWidth..."+bdrWidth);
				//document.getElementById('div2').style.width = "1000px";
				//document.getElementById('footerBorder').style.width = "1000px";
				if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "1004px";
				if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1004px";
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "1004px";
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1004px";
/*
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = "0px";
					document.getElementById('div2').style.width = "1004px";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = "0px";
					document.getElementById('div1').style.width = "1004px";
				}
*/
			}
			firstTime = false;
		} else {
			firstTime = true;
		}
	} else {
		//document.getElementById('h_spacerDiv').style.width = "996px";
		//document.getElementById('footerBorder').style.width = "996px";
		if(document.getElementById('header_shade'))
			document.getElementById('header_shade').style.width = "1004px";
		if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1004px";
		if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "1004px";
		if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1004px";
/*
		if(document.getElementById('div2')) {
			document.getElementById('div2').style.left = "0px";
			document.getElementById('div2').style.width = "1004px";
		}
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "";
			document.getElementById('div1').style.width = "1004px";
		}
*/
	}
/* Fix for the Resizing window */
	if (document.body.offsetWidth < 1024) {
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "1004px";
		}
		if(document.getElementById('plp')) {
			document.getElementById('plp').style.left = "0px";
			document.getElementById('plp').style.width = "1004px";
		}
		if(document.getElementById('headerNav')) {
			document.getElementById('headerNav').style.left = "0px";
			document.getElementById('headerNav').style.width = "1004px";
		}
		if(document.getElementById('CBsplash')) {
			document.getElementById('CBsplash').style.left = "0px";
			document.getElementById('CBsplash').style.width = "1004px";
		}
	} else {
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "100%";
		}
		if(document.getElementById('plp')) {
			document.getElementById('plp').style.left = "0px";
			document.getElementById('plp').style.width = "100%";
		}
		if(document.getElementById('headerNav')) {
			document.getElementById('headerNav').style.left = "0px";
			document.getElementById('headerNav').style.width = "100%";
		}
		if(document.getElementById('CBsplash')) {
			document.getElementById('CBsplash').style.left = "0px";
			document.getElementById('CBsplash').style.width = "100%";
		}
	}
}

function adjustPos() {
	if (document.getElementById('footerdiv').offsetTop < 518) {
		if(!(document.getElementById('contact_footer') || document.getElementById('div3') || document.getElementById('div3PLP') || document.getElementById('cbfooter')) )
		{
			document.getElementById('footerdiv').style.top = "518px";
			footerposchange = true;
		}
	}
	if(true) {
		if(document.getElementById('div1')) {
				var bdrWidth = parseInt(document.getElementById('div1').offsetWidth);
				var leftPos = parseInt(document.getElementById('div1').offsetLeft);
			} else if (document.getElementById('plp')) {
				var bdrWidth = parseInt(document.getElementById('plp').offsetWidth);
				var leftPos = parseInt(document.getElementById('plp').offsetLeft);
			} else if (document.getElementById('headerNav')) {
				var bdrWidth = parseInt(document.getElementById('headerNav').offsetWidth);
				var leftPos = parseInt(document.getElementById('headerNav').offsetLeft);
			} else if (document.getElementById('CBsplash')) {
				var bdrWidth = parseInt(document.getElementById('CBsplash').offsetWidth);
				var leftPos = parseInt(document.getElementById('CBsplash').offsetLeft);
			} else {
				var bdrWidth = parseInt(document.getElementById('h_spacerDiv').offsetWidth);
				var leftPos = parseInt(document.getElementById('h_spacerDiv').offsetLeft);
			}
		if(bdrWidth<1000) {
			//document.getElementById('h_spacerDiv').style.width = "996px";
			//document.getElementById('footerBorder').style.width = "996px";
			if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "1000px";
			if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1000px";
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "1000px";	
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1000px";
/*
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = "0px";
					document.getElementById('div2').style.width = "1000px";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = "0px";
					document.getElementById('div1').style.width = "1000px";
				}
*/
		} else {
			//document.getElementById('h_spacerDiv').style.width = "100%";
			//document.getElementById('footerBorder').style.width = "100%";
			if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "100%";
			if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "100%";
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "100%";
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "100%";
/*
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = leftPos;
					document.getElementById('div2').style.width = "100%";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = leftPos;
					document.getElementById('div1').style.width = "100%";
				}
*/
		}
	} else {
		//document.getElementById('h_spacerDiv').style.width = "996px";
		//document.getElementById('footerBorder').style.width = "996px";
		if(document.getElementById('header_shade'))
			document.getElementById('header_shade').style.width = "1000px";
		if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1000px";
		if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "1000px";
		if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1000px";
/*
		if(document.getElementById('div2')) {
			document.getElementById('div2').style.left = "0px";
			document.getElementById('div2').style.width = "1000px";
		}
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "1000px";
		}
*/
	}
/* Fix for the Resizing window */
	if (document.body.offsetWidth < 1024) {
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "1004px";
		}
		if(document.getElementById('plp')) {
			document.getElementById('plp').style.left = "0px";
			document.getElementById('plp').style.width = "1004px";
		}
		if(document.getElementById('headerNav')) {
			document.getElementById('headerNav').style.left = "0px";
			document.getElementById('headerNav').style.width = "1004px";
		}
		if(document.getElementById('CBsplash')) {
			document.getElementById('CBsplash').style.left = "0px";
			document.getElementById('CBsplash').style.width = "1004px";
		}
	} else {
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "100%";
		}
		if(document.getElementById('plp')) {
			document.getElementById('plp').style.left = "0px";
			document.getElementById('plp').style.width = "100%";
		}
		if(document.getElementById('headerNav')) {
			document.getElementById('headerNav').style.left = "0px";
			document.getElementById('headerNav').style.width = "100%";
		}
		if(document.getElementById('CBsplash')) {
			document.getElementById('CBsplash').style.left = "0px";
			document.getElementById('CBsplash').style.width = "100%";
		}
	}
} 

function resizeFix() {
	if (document.getElementById('footerdiv').offsetTop < 518) {
		if(!(document.getElementById('contact_footer') || document.getElementById('div3') || document.getElementById('div3PLP') || document.getElementById('cbfooter')) )
		{
		document.getElementById('footerdiv').style.top = "518px";
		}
	}
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href;
	if(true) {
		//alert(document.getElementById('footerdiv').offsetTop+" 3");
		if(document.getElementById('div2')) {
				var bdrWidth = parseInt(document.getElementById('div2').offsetWidth);
				var leftPos = parseInt(document.getElementById('div2').offsetLeft);
			} else {
				var bdrWidth = parseInt(document.getElementById('h_spacerDiv').offsetWidth);
				var leftPos = parseInt(document.getElementById('h_spacerDiv').offsetLeft);
			}
		if(bdrWidth<1000) {
			//document.getElementById('h_spacerDiv').style.width = "996px";
			//document.getElementById('footerBorder').style.width = "996px";
			if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "1000px";
			if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1000px";	
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "1000px";
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1000px";
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = "0px";
					document.getElementById('div2').style.width = "1000px";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = "0px";
					document.getElementById('div1').style.width = "1000px";
				}
		} else {
			//document.getElementById('h_spacerDiv').style.width = "100%";
			//document.getElementById('footerBorder').style.width = "100%";
			if(document.getElementById('header_shade'))
					document.getElementById('header_shade').style.width = "100%";
			if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "100%";
				if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "100%";
				if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "100%";
				if(document.getElementById('div2')) {
					document.getElementById('div2').style.left = leftPos;
					document.getElementById('div2').style.width = "100%";
				}
				if(document.getElementById('div1')) {
					document.getElementById('div1').style.left = leftPos;
					document.getElementById('div1').style.width = "100%";
				}
		}
	} else {
		//document.getElementById('h_spacerDiv').style.width = "996px";
		//document.getElementById('footerBorder').style.width = "996px";
		if(document.getElementById('header_shade'))
			document.getElementById('header_shade').style.width = "1000px";
		if(document.getElementById('h_spacerDiv'))
					document.getElementById('h_spacerDiv').style.width = "1000px";
		if(document.getElementById('f_footer'))
					document.getElementById('f_footer').style.width = "100%";
		if(document.getElementById('home_footer'))
					document.getElementById('home_footer').style.width = "1000px";
		if(document.getElementById('div2')) {
			document.getElementById('div2').style.left = "0px";
			document.getElementById('div2').style.width = "1000px";
		}
		if(document.getElementById('div1')) {
			document.getElementById('div1').style.left = "0px";
			document.getElementById('div1').style.width = "1000px";
		}
	}
}


// Function that pops up a window of a specific size on all target browsers
//    Pass the window URL, the width and the height
function popWindow(urlVal,windowName,widthVal,heightVal,scrollBars,menuBar,reSizeable) {
	var paraString
	var wt
	var ht
	
	if ((is.ie) && (is.mac)) {
			wt = widthVal - 16;
			ht = heightVal - 16;
		} else if (is.ns){
			wt = widthVal;
			ht = heightVal + 2;
		} else {
			wt = widthVal;
			ht = heightVal;
		}

	paraString = "width=" + wt + ",height=" + ht;

	if (scrollBars == 0) {
		paraString = paraString + ",scrollbars=no";
		}
	else if (scrollBars == 1) {
		paraString = paraString + ",scrollbars=yes";
		}		
//condition to make scrollbars auto--no currently working so been set to 'yes' so that atleast scrolling is available if required.
	if (scrollBars == 2) {
		paraString = paraString + ",scroll=auto,scrollbars=1";
		}
	// alert(paraString);
	if (menuBar == 0) {
		paraString = paraString + ", menubar=no";
	}
	else if (menuBar == 1) {
		paraString = paraString + ",menubar=yes";
	}
	else{
		paraString = paraString + ",menubar=yes";
	}
	
	
	/*	
	if (reSizeable == 0) {
		paraString = paraString + ", resizable=no";
	}
	else if (reSizeable == 1) {
		paraString = paraString =", resizeble=yes";
	}
	*/
	paraString = paraString + ", resizable=1";
	
	paraString = paraString + ", screenx=25,screeny=32";
	paraString = paraString + ", left=25, top=32";
	poppedWindow = window.open(urlVal,windowName,paraString);
	poppedWindow.focus();
}
	


// Function that passes the appropriate glossary URL, name and size to the popWindow function
function popGlossary(urlVal) {
	popWindow(urlVal,"glossaryWindow",230,310); 
}

// Function that passes the appropriate ebrochure model URL, name and size to the popWindow function
function popEbrochure(modelgroupcode) {
	popWindow("/home/contact/ebrochure/step1.html?ebrochure-request="+modelgroupcode,"ebrochureWindow",440, 450, 1, 0, 0); 
}



// END RESIZE CODE

// BEGIN DYNAMIC LAYERING CODE
// Dynamic Layer Object
// sophisticated layer/element targeting and animation object which provides the core functionality needed in most DHTML applications
// 19990604

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

// Added by D.Owen during warranty -- sets a variable to track when init is complete
var doneLoading = false;

// BrowserCheck Object
function BrowserCheck() {
	// note: this basic function was altered by d.owen to overcome ns4 bug on config page;
	// notes below were added along with changes on 52201.

	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
	this.pc = (this.version.indexOf('Win')>0)
	this.mac = (this.version.indexOf('PPC')>0)

	// next line added by d.owen on 52201
	this.ns408=(parseFloat(this.version)==4.08);
}
var is = new BrowserCheck()

if (!is.min) location.href = '/global/error/browsercheck.html';

function DynLayer(id,nestref,frame) {
	if (!is.ns5 && !DynLayer.set && !frame) DynLayerInit()
	this.frame = frame || self
	if (is.ns) {
		if (is.ns4) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				if (!DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
			this.w = this.css.clip.width
			this.h = this.css.clip.height
			this.x = this.css.left
			this.y = this.css.top
		}
		else if (is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
			this.x = this.elm.offsetLeft
			this.y = this.elm.offsetTop
			this.w = this.elm.offsetWidth
			this.h = this.elm.offsetHeight
		}
	}
	else if (is.ie) {
		this.elm = this.event = this.frame.document.all[id]
		this.css = this.frame.document.all[id].style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = this.elm.offsetWidth
		this.h = this.elm.offsetHeight
	}
	this.id = id
	this.nestref = nestref
	this.obj = id + "DynLayer"
	eval(this.obj + "=this")
}
function DynLayerMoveTo(x,y) {
	if (x!=null) {
		this.x = x
		this.css.left = x;
	}
	if (y!=null) {
		this.y = y
		this.css.top = y;
	}
}
function DynLayerMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)
}
function DynLayerShow() {
	this.css.visibility = (is.ns4)? "show" : "visible"
}
function DynLayerHide() {
	this.css.visibility = (is.ns4)? "hide" : "hidden"
}
DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.moveBy = DynLayerMoveBy
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayerTest = new Function('return true')

// DynLayerInit Function
// Function changed from GSG as NS4 is no longer supported, and NS versions 5+ weren't catered for
function DynLayerInit() {

			if (is.ns) {
				document.getElementsByTagName("DIV").length
				for (var i=0; i<document.getElementsByTagName("DIV").length; i++) {
					var divname = document.getElementsByTagName("DIV")[i].id
					var index = divname.indexOf("Div")
					if (index > 0) {
						eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
					}
				}
			}
			else
			{
			DynLayer.set = true
				for (var i=0; i<document.all.tags("DIV").length; i++) {
					var divname = document.all.tags("DIV")[i].id
					var index = divname.indexOf("Div")
						if (index > 0) {
							eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
						}
				}
			}
doneLoading = true;
return true
}



DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// Clip Methods
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
		else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
	}
}
function DynLayerClipTo(t,r,b,l) {
	if (t==null) t = this.clipValues('t')
	if (r==null) r = this.clipValues('r')
	if (b==null) b = this.clipValues('b')
	if (l==null) l = this.clipValues('l')
	if (is.ns) {
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	}
	else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}
function DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
function DynLayerClipValues(which) {
	if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0])
	if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1])
	if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3])
}
DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipBy = DynLayerClipBy
DynLayer.prototype.clipValues = DynLayerClipValues

// Write Method
function DynLayerWrite(html) {
	if (is.ns) {
		if (is.ns4) {
			this.doc.open()
			this.doc.write(html)
			this.doc.close()
		} else if (is.ns5) {
			this.elm.innerHTML = html;
		}
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}
DynLayer.prototype.write = DynLayerWrite

function popWindowMagic(guid, position){	
	
//	myImage = new Image();
//	myImage.src = popupImage;

	paraString = "&amp;location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes";
	paraString = paraString + ", width=648,height=460";
	paraString = paraString + ", screenx=32,screeny=25";
	paraString = paraString + ", left=32, top=25";	
	paraString = paraString + ",resizable=yes";


	winUrl = guid+'_popup?position=' + position;
	poppedWindow = window.open(winUrl, 'popWin',paraString);
	
	poppedWindow.focus();
}

function resizeWindow(thisImage){


	var thisWidth = thisImage.width;
	thisWidth = thisWidth+28;
	var thisHeight = thisImage.height;
	thisHeight = thisHeight+113;
	
	if (thisWidth > 720)
		{
		thisWidth=720;
		}
	if (thisHeight > 525)
		{
		thisHeight = 525;
		}			
	parent.window.resizeTo(thisWidth,thisHeight);
}


// END DYNAMIC LAYER CODE

// BEGIN CSS STYLE DEFINITION CODE
//## Writes the appropriate CSS link depending on the user's browser.

//styleString = '<link rel="stylesheet" href="css/master' + ((is.ie || is.ns5) ? 'IE': 'NN') + '.css" type="text/css">'
//CSS definition removed by KA 10-09-03, not considered necessary (uncomment if required)
/*var startString = '<link rel="stylesheet" href="css/master';
var endString = '.css" type="text/css">';

if ((is.ie || is.ns5)) styleString = startString + 'IE';
	else styleString = startString + 'NN';
if (is.mac && is.ns) styleString = styleString + 'mac';

styleString = styleString + endString;

document.write(styleString)*/

// END CSS STYLE DEFINITION CODE




//FLASH VERSION DETECTION

	agt = navigator.userAgent.toLowerCase();
	app = navigator.appName.toLowerCase();

	///// OS
	osCode = "";
	osVersion = "";
	osName = "";

  if ( agt.indexOf( "win") != -1) {
	  osCode = "win";
		osName = "Windows";
  	if ( agt.indexOf( "nt 5.1") != -1) {
  	  osVersion = "XP";
  	} else if ( agt.indexOf( "nt 5.0") != -1) {
  	  osVersion = "2000";
  	} else if ( ( agt.indexOf( "nt 4.0") != -1)
						 || ( agt.indexOf( "nt;") != -1)
						 || ( agt.indexOf( "winnt4") != -1)
						 || ( agt.indexOf( "windows nt") != -1)) {
  	  osVersion = "NT";
  	} else if ( agt.indexOf( "98") != -1) {
  	  osVersion = "98";
  	} else if ( agt.indexOf( "windows 95") != -1) {
  	  osVersion = "95";
  	}
	} else if ( agt.indexOf( "mac") != -1) {
	  osCode = "mac";
		osName = "MacOS";
		if ( agt.indexOf( "mac os x") != -1) {
		  osVersion = "X";
		}
	} else if ( agt.indexOf( "linux") != -1) {
	  osCode = "linux";
		osName = "Linux";
	} else {
	  osCode = "win";
		osName = "Windows";
	}

	///// NAV
	navCode = "";
	navVersion = "";
	navName = "";

	if ( agt.indexOf( "msie") != -1) {
		navCode = "ie";
		navName = "Internet Explorer";
		navVersion = agt.substr( agt.indexOf( "msie") + 5, 1);
	} else if ( agt.indexOf( "safari") != -1) {
		navCode = "safari";
		navName = "Safari";
 	  navVersion = "1";
	} else if ( agt.indexOf( "netscape") != -1
				 || ( app.indexOf( "netscape") != -1 && app.indexOf( "safari") == -1)) {
		navCode = "ns";
		navName = "Netscape";
  	if ( agt.indexOf( "netscape/7") != -1) {
  	  navVersion = "7";
  	} else if ( agt.indexOf( "netscape6/6") != -1) {
  	  navVersion = "6";
  	} else if ( agt.indexOf( "mozilla/4") != -1) {
  	  navVersion = "4";
  	} else {
  		navCode = "mozilla";
  		navName = "Mozilla";
   	  navVersion = agt.substr( agt.indexOf( "rv:") + 3, 3);
		}
	} else if ( agt.indexOf( "firebird") != -1) {
		navCode = "firebird";
		navName = "Mozilla Firebird";
 	  navVersion = agt.substr( agt.indexOf( "firebird/") + 9, 3);
	} else if ( agt.indexOf( "firefox") != -1) {
		navCode = "firefox";
		navName = "Mozilla Firefox";
 	  navVersion = agt.substr( agt.indexOf( "firefox/") + 8, 3);
	} else if ( agt.indexOf( "konqueror") != -1) {
		navCode = "konqueror";
		navName = "Konqueror";
	}

	///// WINDOW
  bodyWidth = screen.availWidth;
  bodyHeight = screen.availHeight;
  screenWidth = screen.width;
  screenHeight = screen.height;

	function windowOpen( title, url, x, y, width, height, location, menubar, toolbar, scrollbars, status, resizable, fullscreen) {
		var tmpWindow = window.open( url, title, "left=" + x + ",top=" + y + ",width=" + width + ",height=" + height + ",location=" + location + ",menubar=" + menubar + ",toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",status=" + status + ",resizable=" + resizable + ",fullscreen=" + fullscreen);
    tmpWindow.focus();
		return( tmpWindow);
	}

	function popupOpen( title, url, width, height, scrollbars) {
		var tmpWindow = windowOpen( title, url, ( screenWidth - width) / 2 - 5, ( screenHeight - height) / 2 - 20, width, height, 'no', 'no', 'no', scrollbars, 'no', 'no', 'no');
	}

	function popupOpenFullScreen( title, url, fullscreen) {
		var tmpWidth = bodyWidth;
		var tmpHeight = bodyHeight;
    if ( navCode == "ns" && osCode == "mac") {
      tmpWidth -= 10;
      tmpHeight -= 25;
		}
	  var tmpWindow = windowOpen( title, url, 0, 0, tmpWidth, tmpHeight, 'no', 'no', 'no', 'no', 'no', 'no', fullscreen);
		tmpWindow.resizeTo( tmpWidth, tmpHeight);
	}
	popupOpenFullScreen = popupOpenFullScreen;

	function popupCheck( NoFunctionName, YesFunctionName) {
			tmpTimeoutId = setTimeout( 'if ( tmpPopupCheck == null) { eval( "' + NoFunctionName + '()"); } else { eval( "' + YesFunctionName + '()"); }', 1000);
		  tmpPopupCheck = window.open( "about:blank","tmpPopupCheck","width=100,height=100,left=0,top=5000");
			tmpPopupCheck.document.write( '<scr' + 'ipt type="text/javascript">window.close()</scr' + 'ipt>');
  }

	///// FLASH

	function checkFlashVersionNumber() {

		var flashVersionMin = 4;
		var flashVersionMax = 15;
		var flashVersion = -1;

		for ( var iFlashVersion = flashVersionMin; iFlashVersion <= flashVersionMax; iFlashVersion ++) {
			eval( "aFlash" + iFlashVersion + " = false");
		}

		if( navCode == "ie" && osCode != "mac") {
			document.write('<scr' + 'ipt language=VBScript\> \n');
			document.write('on error resume next \n');
			for ( var iFlashVersion = flashVersionMin; iFlashVersion <= flashVersionMax; iFlashVersion ++) {
				document.write('aFlash' + iFlashVersion + ' = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + iFlashVersion + '"))) \n');
			}
			document.write('</scr' + 'ipt\> \n');
		}

		var aFlash = null;
		for ( var iFlashVersion = flashVersionMin; iFlashVersion <= flashVersionMax; iFlashVersion ++) {
			if ( navCode == "ie" && osCode != "mac") {
				if ( eval( 'aFlash' + iFlashVersion) == true) {
					flashVersion = iFlashVersion;
				}
			} else {
				if ( aFlash == null) {
					aFlash = false;
					for ( var iPlugin = 0; iPlugin < navigator.plugins.length; iPlugin ++) {
						var p = navigator.plugins[ iPlugin];
						if ( p.name == "Shockwave Flash") {
							aFlash = true;
							break;
						}
					}
				}
				if ( aFlash == false) {
					break;
				}
				if( navigator.plugins["Shockwave Flash"].description.indexOf( "Flash " + iFlashVersion) != -1) {
					flashVersion = iFlashVersion;
				}
			}
		}
		return flashVersion;
	}

function checkFlashVersion(redirect_locale, flash_Version) {
	if (flash_Version.length == 0) {
		flash_Version = "8";
	}
	var urlstr = window.location.toString();
	var actualFlashVersion = checkFlashVersionNumber();
	if (urlstr.indexOf('/home/modules/') > 0) {
		if (flash_Version > actualFlashVersion) {
			parent.window.location.href = '/home/redirect/modules/index-no-flash-' + redirect_locale +'.html';
		}
	} else {
		if (checkFlashVersionNumber() < 8) {
			parent.window.location.href = '/redirect/index-no-flash-' + redirect_locale +'.html';
		} 
	}
}