//runinit();

function runinit(){
	if (document.cookie.indexOf('style=') != -1) {
		mystyle = readCookie('style');
		setActiveStyleSheet(mystyle);
	}
	if (navigator.appName == "Microsoft Internet Explorer" && (parseInt(navigator.appVersion) >= 4) && (parseInt(navigator.appVersion) < 7) && navigator.userAgent.indexOf('Opera') == -1) window.onload = fixpngalphaforshittybrowser;
	if (window.name == 'left') {
		styleswitcher();
		if (document.cookie.indexOf('style=') != -1) stylemenuactive(mystyle); //don't call before styleswitcher() has run
	}
}

function fixpngalphaforshittybrowser(){    // Fix PNG alpha transparency for all images for IE. Thanks http://homepage.ntlworld.com/bobosola/pnghowto.htm
//alert(document.images.length);
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
//	alert(imgName);
      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 imgwidth=img.width + "px";
//if (imgName.substring(imgName.length-6, imgName.length) == "HR.PNG") {imgwidth='100%';}
//alert(img.width);
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}

function fixpngie(img) {    // Fix PNG alpha transparency for one image for IE.
    if (navigator.appName == "Microsoft Internet Explorer" && (parseInt(navigator.appVersion) >= 4) && (parseInt(navigator.appVersion) < 7) && navigator.userAgent.indexOf('Opera') == -1) {
	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 mOver = (img.onmouseover) ? "onmouseover='" + img.onmouseover + "' " : ""
//	 alert('ok:' + img.onmouseover);
//	 alert(mOver);
	 var mOver = "";
	 if (img.id == 'up') var mOver = "onmouseover='uphover();' onmousedown='uppress();' onmouseup='upexitpress();' onmouseout='upexithover();'";
	 if (img.id == 'down') var mOver = "onmouseover='downhover();' onmousedown='downpress();' onmouseup='downexitpress();' onmouseout='downexithover();'";
	var strNewHTML = "<span " + imgID + imgClass + imgTitle + mOver
	+ " style=\"" + "width:" + img.width + "; height:" + img.height + "px;" + imgStyle + ";"
	+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
	img.outerHTML = strNewHTML
    }
}
