var onloads		= new Array();

function addOnLoad(funcstr){
	onloads.push(funcstr);
}

addOnLoad("correctPNG()");

onload = function(){
	for (var i in onloads){
		eval(onloads[i]);
	}
}


function track_Debug(CSid, pagetitle, combinedPageId){
	alert (CSid + "\n" + pagetitle + "\n" + combinedPageId);
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5 && (version < 7)) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

function setLocale(){
	if (window.location.search.indexOf('locale=') > -1){
		var locale = (window.location.search.split('locale=')[1]).split('&')[0];
		if (locale.indexOf('_') > -1){
			defLang 	= locale.split('_')[0];
			defCountry 	= locale.split('_')[1];
		} else {
			locale = "";
		}
	}
}

function combinePage(pageid, _country, _lang){
	if (locale == "") setLocale();
	if (!_country) 	_country = defCountry;
	if (!_lang) 	_lang = defLang;
	return (basename + "/" + _country.toLowerCase() + "/" + site + "/" + _lang.toLowerCase() + "/" + pageid);
}

function track_sendInfo(pageid, _country, _lang){
	var combinedPageId = combinePage(pageid, _country, _lang);
	if (typeof Instadia_sendInfo == "function" && trackActive) {
		Instadia_sendInfo(CSid, pagetitle, combinedPageId);
	} else {
		track_Debug(CSid, pagetitle, combinedPageId);
	}
}

function track_sendEvent(pageid, _country, _lang) 	{
	var combinedPageId = combinePage(pageid, _country, _lang);
	if (typeof Instadia_sendInfo == "function" && trackActive) 		{
		Instadia_sendEvent(CSid, pagetitle, combinedPageId);
	} else {
		track_Debug(CSid, pagetitle, combinedPageId);
	}
}
/* End Tracking */
	

// toggle scrollbars depending on window size
var minW = 1014;
var minH = 656;

function getColorDepth() {
  var d;
  d = screen.pixelDepth;
  if(d != undefined && d != null) {
    return d;
  }
  d = screen.colorDepth;
  if(d != undefined && d != null) {
    return d;
  }
  return 16;
}

function openPopupWindow(url, type){
	switch (type){
		case "GD":
			openWindow(url, '1014', '658', 'yes', 'no', 'no', 0, 0, 'yes', type);
		break;
	}
}

function addArgumentsToLink(id){
	var link = document.getElementById(id);
	var url = link.href;
	var params = attachParams();
	var sep = "";
	if (params.length > 0) sep = ((url.indexOf('?') > -1)?'&':'?');
	link.href = url + sep + params;
}


function openFSWindow(url){
	var w = screen.availWidth;
	var h = screen.availHeight;
	if (document.layers){
		var tmp1 = window.outerWidth - window.innerWidth;
		var tmp2 = window.outerHeight - window.innerHeight;
		w -= tmp1;
		h -= tmp2;
	}
	var params = attachParams();
	var sep = "";
	if (params.length > 0) sep = ((url.indexOf('?') > -1)?'&':'?');
	openWindow(url + sep + params, w, h, 'yes', 'no', 'yes', 0, 0, 'no', 'A4MS');
	correctPNG();
}
			
function openWindow(url, w, h, re, st, sc, le, to, center, type) {
	if (center == 'yes'){
		le = screen.width/2 - w/2;
	    to = screen.height/2 - h/2;
	}
	var params = 'width='+w+',height='+h+',scrollbars='+sc+',status='+re+',resizable='+re;
	newWin = window.open(url, type, params);
	newWin.moveTo(le, to);
	window.setTimeout("newWin.focus()", 250);
}

function attachParams(){
	var paramString = window.location.search;
	var paramStringBuff = paramString.slice(1,paramString.lastIndexOf(""));
	return paramStringBuff;
}
			
function addAllQueryParams(fo){
	
	//parsing variables out of the url
	var paramString = window.location.search;
	var paramStringBuff = paramString.slice(1,paramString.lastIndexOf(""))
	var variable = new Array();
	var	parameter = new Array();
	var paraSplit = new Array();
	
	if(paramString.charAt(0) == '?'){
		//alert("found parameters")
		parameter = paramStringBuff.split("&");
		for(var i = 0; i < parameter.length; i++){
			paraSplit[i] = parameter[i].split("=");
			variable[i] = paraSplit[i][0];

			//add variables to SWFObject (fo)	
			fo.addVariable(variable[i], getQueryParamValue(variable[i]));		
			//alert(variable[i] + "=" +  getQueryParamValue(variable[i]));				
			
		}
	}//else alert('no parameters - no "?" ')
}

//function hideScroll(){
//	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
//}

function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
	return navigator.userAgent.substr(0,agt.indexOf(' '));
	else return navigator.userAgent;
}

function styleChange(){
	switch(whichBrs()){
		case 'Internet Explorer':
				document.getElementById("upper").style.width = '0px';
				document.getElementById("container").style.left = '2px';
		break;
		case 'Safari':
			document.getElementById("upper").style.width = '1px';
			document.getElementById("container").style.left = '2px';
		break;
		case 'Opera':
			document.getElementById("upper").style.width = '1px';
			document.getElementById("container").style.left = '0px';
		break;
		case 'Firefox':
			document.getElementById("upper").style.width = '0px';
			document.getElementById("container").style.left = '2px';
		break;
			
	}
}
//
//function checkSize() {
	//
	//var w;
	//var h;
	//if (whichBrs()=="Internet Explorer") {
		//w = document.body.offsetWidth;
		//h = document.body.offsetHeight;	
	//} else {
		//w = window.innerWidth;
		//h = window.innerHeight;
	//}
	//
	//if (h<minH || w<minW) {
		//document.getElementsByTagName('html')[0].style.overflow = 'auto';
	//} else {
		//document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	//}	
//}

