// Javascript
// Magnus Hillerdal

var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) && navigator.platform == 'Win32';
var show = 0;
var abort = 1;
function init()
{
        size = document.getElementById('main').offsetHeight-9;
        if(size<document.getElementById('menu').offsetHeight) {
        		size = document.getElementById('menu').offsetHeight-9;
        }
        document.getElementById('main').style.height = size+'px';
        document.getElementById('menu').style.height = size+'px';
}

function fixPNG() // fix PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (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 mouseonmenu(me) {
         me.style.cursor='pointer';
	if(!supported) {
		me.style.background = 'url(Design/knappnere.png)';
         } else {
		me.style.background = 'none';//'url(Design/knappnere.png)';
         	me.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='Design/knappnere.png',sizingMethod='scale')";
	}
}
function mouseoffmenu(me) {
         me.style.cursor='default';
	if(!supported) {
		me.style.background = 'url(Design/knapp.png)';
         } else {
		me.style.background = 'none';//'url(Design/knappnere.png)';
 	        me.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='Design/knapp.png',sizingMethod='scale')";
	}
}

function swap(meny) {
	if(document.getElementById){
		document.getElementById(meny).style.display=(document.getElementById(meny).style.display=='block')?'none':'block';
	}
	init();
}

function highlight(me) {
	me.id="highlight";
}
function highlightrow(obj,newcolor) {
	if(!document.getElementById) { return true; }
	obj.style.background=newcolor;
}

function unhighlight(me) {
	me.id="normal";
}

function showTooltip(me,file) {
         highlight(me);
         var url = "Tyger/tooltip"+file+".php";
 	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		}
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e) { }
		}
	}
	else {
		return false
         }
	page_request.onreadystatechange=function(){
	         if (document.getElementById || document.all) {
	                  var el = document.getElementById? document.getElementById('thetooltip'): document.all['thetooltip'];
	                  if (el && typeof el.innerHTML != "undefined") {
                                try {
	                           if(page_request.status == 200)
	                                    el.innerHTML = page_request.responseText;
	                       } catch (e) {}
	                  }
	         }
	}

         page_request.open('GetNoCache', url, true);
         page_request.setRequestHeader("Pragma", "no-cache");
	page_request.send('');
}

function hideTooltip(me) {
	unhighlight(me);
	if (document.getElementById || document.all) {
	         var el = document.getElementById? document.getElementById('thetooltip'): document.all['thetooltip'];
	         if (el && typeof el.innerHTML != "undefined") {
	                  try {
	                           el.innerHTML = "<b></b><br>&nbsp;<br>&nbsp;";
	                  } catch (e) {}
	         }
	}
}

function confirmLink(theLink, theItem, theAction)
{
    var is_confirmed = confirm('Vill du tabort "' + theItem + '"?');
    if (is_confirmed) {
        theLink.href += theAction;
    }
    return is_confirmed;
}

// Popup med bild
var bildID=0;
function popupimage(image) {
	window.open('popupimage.php?'+image,'popup'+bildID,'width=200,height=200');
}

onload=function()
{
//         init();
	fixPNG();
}

setTimeout("afterLoad()", 500);
