/*

js functions
pclancey
02-04-2003

*/

var childWin = 0;
function launchBrowser(url,w,h) {
	/*  launch popup window in centre screen function  */
	var settings = "";
	var browserWidth = 618;
	var browserHeight = 299;
	if (w != null) {browserWidth = w};
	if (h != null) {browserHeight = h};
	if (document.getElementById) {
		var buffer = 60;
		var posX = (screen.width - browserWidth) / 2;
		var posY = (screen.height - browserHeight) / 2 - buffer;
		settings+= "height="+ browserHeight +",width="+ browserWidth +",";
		settings+= "left="+ posX +",top="+ posY +",";
	} else {
		settings+= "height="+ browserHeight +",width="+ browserWidth +",";
		settings+= "screenX=40,screenY=40,";
		settings+= "left=40,top=40,";
	}
	settings+= "fullscreen=0,location=0,menubar=0,resizable=1,";
	settings+= "scrollbars=1,status=1,toolbar=0";
	var myRemote = open(url, childWin +"myRemote"+ childWin, settings);
	childWin++; // uncomment this line to get a new window each time.
}

function newBrowser(url){
	window.open(url,"newWin", "");
}

var linklib = new Array;
function prloadImg(url,name){
	// preload images for image rollover
	var i = linklib.length;
	urldecoded = url.replace('&#95;','_')
	linklib[name] = new Image;
	linklib[name].src = urldecoded;
}
function swapImage(name){
	// don't do the image swap for older browsers
	if (!document.getElementById){return;}
	if (!document.getElementById(name).originalsrc){
		document.getElementById(name).originalsrc = document.getElementById(name).src;
	}
	document.getElementById(name).src = linklib[name].src
}
function repare(name){
	// set to original src
	if (!document.getElementById){return;}
	if (document.getElementById(name)){
		obj = document.getElementById(name);
		obj.src = obj.originalsrc;
	}
}

function gotoCPage(p1,p2,p3,p4,p5,p6,activepage,lang)
{
	window.location.href = '/campaign/default.asp?p1=' + p1 + '&p2=' + p2 + '&p3=' + p3 + '&p4=' + p4 + '&p5=' + p5 + '&p6=' + p6 + '&contentItemID=' + activepage + '&lang=' + lang;
}

function openExternal(url)
{
	window.open(url);
}

function changeLang()
{
	chosenLang = document.getElementById("lang").options[document.getElementById("lang").selectedIndex].value;
	window.location.href = '..' + chosenLang;
}

//language array holds all the languages in the cms so that we can refer to them in the javascript
var languages = new Array()
languages[1] = "en"
languages[2] = "fr"
languages[3] = "de"
languages[4] = "nl"
languages[5] = "es"
languages[6] = "it"
languages[7] = "pt"


function gotoChild(subPage)
{
	//build the url string
	urlstring = 'default.asp?p1=' + cPageArray[0] + '&p2=' + cPageArray[1] + '&p3=' + cPageArray[2];
	//need to check to see if there are six pages or the default set of three and not carry the other three if there aren't
	if(cPageArray[3] > 1)
	{
		urlstring = urlstring + '&p4=' + cPageArray[3]
	}
	if(cPageArray[4] > 1)
	{
		urlstring = urlstring + '&p5=' + cPageArray[4]
	}
	if(cPageArray[5] > 1)
	{
		urlstring = urlstring + '&p6=' + cPageArray[5]
	}
	urlstring = urlstring + '&contentItemID='+ subPage;
	window.location.href = urlstring;
}

if (navigator.vendor)
{
	//fix the NS.6x CSS unwanted white space bug
	if (navigator.vendor.toLowerCase().indexOf('netscape6')!=-1){
		document.writeln('<sty'+'le type="text/css" media="all">#splash img{float:left;}</sty'+'le>')
	}
}
	
function gotoSibling(sibling)
{
	thesibling = sibling - 1;
	//build the url string
	urlstring = 'default.asp?p1=' + cPageArray[0] + '&p2=' + cPageArray[1] + '&p3=' + cPageArray[2];
	//need to check to see if there are six pages or the default set of three and not carry the other three if there aren't
	if(cPageArray[3] > 1)
	{
		urlstring = urlstring + '&p4=' + cPageArray[3]
	}
	if(cPageArray[4] > 1)
	{
		urlstring = urlstring + '&p5=' + cPageArray[4]
	}
	if(cPageArray[5] > 1)
	{
		urlstring = urlstring + '&p6=' + cPageArray[5]
	}
	urlstring = urlstring + '&contentItemID=' + cPageArray[thesibling];
	window.location.href = urlstring;
}

var tandcLinkText = "";
	
if(currentLanguage == 1)
{
	langPath = "/en/";
}
else if(currentLanguage == 2)
{
	langPath = "/fr/";
}
else if(currentLanguage == 3)
{
	langPath = "/de/";
}
else if(currentLanguage == 4)
{
	langPath = "/nl/";
}
else if(currentLanguage == 5)
{
	langPath = "/es/";
}
else if(currentLanguage == 6)
{
	langPath = "/it/";
}
else if(currentLanguage == 7)
{
	langPath = "/pt/";
}

var backTopImgPath = "<img src=\"/img" + langPath + "backtopbw.gif\" border=\"0\" alt=\"back to top\">";

var backImgPath = "<img src=\"/img" + langPath + "backbw.gif\" border=\"0\" alt=\"back\">";

pageString = "default.asp?p1=" + cPageArray[0] + "&p2=" + cPageArray[1] + "&p3=" + cPageArray[2] + "&p4=" + cPageArray[3] + "&p5=" + cPageArray[4] + "&p6=" + cPageArray[5] + "&contentItemID=" + currentPage + "&lang=" + currentLanguage;

var formString = "<input type=\"hidden\" value=\"" + pageString + "\" name=\"sender\">";

function privPop()
{
	var templangPath = langPath.substring(1,4);
	var url = templangPath + 'privacy.html'
	window.open(url,"privacy","width=392,height=514,scrollbars=yes,resizeable=no");
}
function tandcPop()
{
	var templangPath = langPath.substring(1,4);
	var url = templangPath + 'tandc.html'
	window.open(url,"tandc","width=392,height=514,scrollbars=yes,resizeable=no");
}
