
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
 	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
 	  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 	if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function jah(url,target, userlevel, pageid, typ) 
{
    // native XMLHttpRequest object
    document.getElementById(target).innerHTML = 'Laddar...';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {jahDone(target, userlevel, pageid, typ);};
        req.open("GET", url, true);
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {jahDone(target, userlevel, pageid, typ);};
            req.open("GET", url, true);
            req.send();
        }
    }
}    

function jahDone(target, userlevel, pageid, typ) 
{
    // only if req is "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            results = req.responseText;
            
            drawpen = "";
            if(userlevel > 0)
            {
              Onclick="EditP";
              if(typ == "ml")
              {
                Onclick="EditML";
              }
              
              drawpen = "<br /><br /><a href='javascript:void(0);' onclick='" + Onclick + "(" + pageid + ");'><img border='0' src='/PS/PS_Images/icons/redigera.gif'></a>"
            }
            
            document.getElementById(target).innerHTML = results + drawpen;
        } else {
            document.getElementById(target).innerHTML="Fel:\n" +
                req.statusText;
        }
    }
}
	
function changeFlik(tabid, totalitems, userlevel) 
{
	for(j=1;j<=totalitems;j++) { 
		document.getElementById(j+"tab").className = "hiddendiv" 
		document.getElementById("tab"+j).className = "";
	};
	document.getElementById(tabid+"tab").className = "container";
	document.getElementById("tab"+tabid).className="selected";
	
	typ = document.getElementById(tabid+"tab").getAttribute("type");
	pageid = document.getElementById(tabid+"tab").getAttribute("pageid");
	jah("/PS/PS_Includes/pshttprequest.asp?" + typ + "=" + pageid, tabid+"tab", userlevel, pageid, typ)
}



var xmlhttp
function updateheading(itemtabid, itemheading, tabid)
{
  var url = '/PS/PS_Includes/TabbedboxAHAFunctions.asp?itemtabid=' + itemtabid + '&heading=' + itemheading;
  //alert(url);
  // code for Mozilla, etc.
  if (window.XMLHttpRequest)
    {
    xmlhttp=new XMLHttpRequest()
    /*
    xmlhttp.onreadystatechange=function() {state_UpdateEditor(tabid);};
    xmlhttp.open("GET",url,true)
    xmlhttp.send(null)
    */
   
    // The string to POST (Taken from the community)
    send = 'itemtabid=' + itemtabid + '&heading=' + itemheading;

    // We send the data to our function “nullfunction” 
    xmlhttp.onreadystatechange=function() {state_UpdateEditor(tabid);};

    // Send it to the right page
    xmlhttp.open("POST", "/PS/PS_Includes/TabbedboxAHAFunctions.asp", true);
    // Sending as form data
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", send.length);
    xmlhttp.setRequestHeader("Connection", "close");
    // Send
    xmlhttp.send(send);
    }
  // code for IE
  else if (window.ActiveXObject)
    {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
      if (xmlhttp)
      {
        // The string to POST (Taken from the community)
        send = 'itemtabid=' + itemtabid + '&heading=' + itemheading;

        // We send the data to our function “nullfunction” 
        xmlhttp.onreadystatechange=function() {state_UpdateEditor(tabid);};

        // Send it to the right page
        xmlhttp.open("POST", "/PS/PS_Includes/TabbedboxAHAFunctions.asp", true);
        // Sending as form data
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-length", send.length);
        xmlhttp.setRequestHeader("Connection", "close");
        // Send
        xmlhttp.send(send);

        /*
        xmlhttp.onreadystatechange=function() {state_UpdateEditor(tabid);};
        xmlhttp.open("GET",url,true)
        xmlhttp.send()*/
      }
    }
}

function state_UpdateEditor(tabid)
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
    // if "OK"
    if (xmlhttp.status==200)
    {
    //alert("XML data OK")
    document.location.href="/PS/PS_includes/TabbedEditor.asp?tabid=" + tabid;
    }
    else
    {
      alert("Problem retrieving XML data:" + xmlhttp.statusText)
    }
  }
}
