/*
   Globale funksjoner for WebSnap og ExpressWEB

   eks. OpenReport('pdf',14,'Ekey=13&Okey=12')
*/

  function OpenReport(aFormat, aItemID, aQuery)
	{
	aurl = "PMReport."+aFormat+"?ItemId="+aItemID+"&"+aQuery;
    aTitle = 'Rapport';
   	aSize = 'width=225, height=400';
	wndemp=self.open(aurl);
   	wndemp.Status=aTitle;
   	wndemp.focus();
	}	
	       
  function OpenTranselate(aPagename,aId)
	{
	aurl = "AdmTransStr?Pagename="+aPagename+"&Id="+aId;
    aTitle = 'Translate';
   	aSize = 'width=600, height=520';
	wndTranslate=self.open(aurl,aTitle,aSize);
   	wndTranslate.Status=aTitle;
   	wndTranslate.focus();
	}
  
  function OpenXLateEdit(aTable, aField, aKeyValue)
    {
	aurl = "AdmXLatLangEdit?RefTable="+aTable+"&RefField="+aField+"&RefKeyValue="+aKeyValue;
	aTitle = 'Translate value';
	aSize = 'width=600, height=520';
	wndXLateEdit=self.open(aurl,'',aSize);
   	wndXLateEdit.Status=aTitle;
   	wndXLateEdit.focus();
	}
	
	
function SetEkeyForm(aActionName,aShowAll, aEkey) 
 {
 	var s = "PostActionName="+aActionName;
 	if (aShowAll) s=s+"&ShowAll=1";
 	if (aEkey) s=s+"&Ekey="+aEkey;
	
 	ShowSetEkeyForm2("",s);
 }
function SetOkeyForm(aActionName) {ShowSetOkeyForm("PostActionName="+aActionName)}
function SetQmQkeyForm(aActionName) {ShowSetQmQkeyForm("PostActionName="+aActionName)}
function SetDocKeyForm(aActionName) {ShowSetDocKeyForm("PostActionName="+aActionName)}
	
function ShowSetEkeyForm2(aNextPage, aParam)
{
	aUrl = 'SetEkeyForm';
	aTitle = 'Velg ansatt';
	aSize = 'width=225, height=400';
	sParam = '';
	
	if (aNextPage) {
		sParam = aParam + '&' + 'NextPage=' + aNextPage;
	} else {
		if (aParam) sParam = aParam; 
	  }
		
	if (sParam) {
		aUrl = aUrl + '?' +sParam;
	}	
	wndemp=self.open(aUrl,'Select',aSize);
  	wndemp.Status=aTitle;
  	wndemp.focus();
}

function ShowSetEkeyForm()
{
 ShowSetEkeyForm2('','');
}

function ShowSetOkeyForm(aParams)
{
	aUrl = 'SetOkeyForm';
	/*aUrl = 'test'*/
	aTitle = 'Velg avdeling';
	aSize = 'width=425, height=575';
			
	if (aParams) {
		aUrl = aUrl + '?' +aParams;
	}	
	wndemp=self.open(aUrl,'Select',aSize);
  	wndemp.Status=aTitle;
  	wndemp.focus();
}
function ShowSetQmQkeyForm(aParams)
{
	aUrl = 'SetQmQkeyForm';
	/*aUrl = 'test'*/
	aTitle = 'Velg Spørsmål';
	aSize = 'width=425, height=575';
			
	if (aParams) {
		aUrl = aUrl + '?' +aParams;
	}	
	wndemp=self.open(aUrl,'Select',aSize);
  	wndemp.Status=aTitle;
  	wndemp.focus();
}

function ShowSetDocKeyForm(aParams)
{
	aUrl = 'SetDocKeyForm';
	aTitle = 'Velg dokument';
	aSize = 'width=425, height=575';
			
	if (aParams) {
		aUrl = aUrl + '?' +aParams;
	}	
	wndemp=self.open(aUrl,'Select',aSize);
  	wndemp.Status=aTitle;
  	wndemp.focus();
}

function ShowCompEditWindow(vEkey,vCkey,vTkey)
{
	aurl = 'CmpEmpCompRec?ekey='+vEkey+'&tkey='+vTkey+'&ckey='+vCkey;
	aTitle = 'Kompetanse';
	aSize = 'width=500, height=400';
	wndempComp=self.open(aurl, aTitle, aSize);
  wndempComp.Status="Kompetanse";
  wndempComp.focus();
}

// Eks. addEvent(window,'load',init)
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
  }
} 

function SetElementFocus(aName) {
  cmp = document.getElementById(aName);
  if (cmp) {cmp.focus()};
}



var pmPage = {};

pmPage.init = function() {
 if (typeof this.onLoad != "undefined") alert('1');	
 alert(typeof this.onLoad);
}



