// save handlers for onload-execution
var onloads		= new Array();

function addOnLoad(funcstr){
	onloads.push(funcstr);
}
onload = function(){
	for (var i in onloads){
		eval(onloads[i]);
	}
};

addOnLoad("correctPNG()");

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 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 addArgumentsToLink(id){
	var link = document.getElementById(id);
	var url = link.href;
	var params = attachParams();
	var sep = "";
	if (url.length < 1) return;
	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', 'Q5MS');
	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;
	}
	day = new Date();
	id = day.getTime();
	var params = 'width='+w+',height='+h+',scrollbars='+sc+',location=no,menubar=no,status='+re+',resizable='+re;
	newWin = window.open(url, id, 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 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 = '1px';
			document.getElementById("container").style.left = '0px';
		break;
		case 'Safari':
			document.getElementById("upper").style.width = '0px';
			document.getElementById("container").style.left = '0px';
		break;
		case 'Opera':
			document.getElementById("upper").style.width = '0px';
			document.getElementById("container").style.left = '0px';
		break;
		case 'Firefox':
			document.getElementById("upper").style.width = '0px';
			document.getElementById("container").style.left = '0px';
		break;
			
	}
}
