function MoveCursor(iLevel) {
	if(iLevel == 0)
	{			
		iLevel = 1;
		if(lastState == 3) { iLevel = 1; } 
		if(lastState == 4) { iLevel = 2; }
		if(lastState == 5 || lastState == 6) { iLevel = 3; }
	}
	var imgObj = document.getElementById('imgFontSize');
	imgObj.src = "/img/Common/ControlPanel/FontSize/step" + iLevel + ".gif";
}		
function ChgSize(iSize, bSetCookie){
	var oElement;
	var iLevel = getFontLevel(iSize);
	oElement = document.getElementsByTagName("body");
	if(bSetCookie == true){ setFontCookie(iSize); document.location = document.location.href;}
	else{ oElement[0].style.fontSize = iLevel +"%";}
}

function getFontLevel(iLevel){
	var arLevels = new Array("46","56","76","86","100","105");
	return arLevels[iLevel-1];
}

//Cookie Stuff
function setCookie (name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
function getFontCookie (fontSize) {
	var prefix = 'KBBankiFontLevel=';
	var c = document.cookie;
	var cookieStartIndex = c.indexOf(prefix);
	if (cookieStartIndex == -1) {return 3; }
	var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) { cookieEndIndex = c.length; }
	return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
function setFontCookie(newSize)
{
	var now = new Date();
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0) { now.setTime(now.getTime() - skew); }
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	setCookie('KBBankiFontLevel', newSize, now, '/', document.location.host, '');
}
function zoom_in(){ if(lastState != null) { if(lastState < 5) { ChgSize(parseInt(lastState)+1,true); } } }
function zoom_out(){ if(lastState != null) { if(lastState > 3) { ChgSize(parseInt(lastState)-1,true); } }}		

function NBKPrentvaent( PrentvaentSectionName, PrentvaentPage, HasParameters )
{
 NBKPrentvaent( PrentvaentSectionName, PrentvaentPage, HasParameters, false );
}
function NBKPrentvaent( PrentvaentSectionName, PrentvaentPage, HasParameters, PrintNow)
{
	var oPrentVaentControl, sInnerText; 
	
	oPrentVaentControl = GetElement( PrentvaentSectionName ); 
	if(oPrentVaentControl)
	{
		sInnerText = oPrentVaentControl.innerHTML; 
		var height = 480;
		var width = 640;
		var top = screen.height/2 - height/2;
		var left = screen.width/2 - width/2;
		var prentGluggi;
		
		if(HasParameters == true){
			prentGluggi = window.open(PrentvaentPage + '&PrentvaentSectionName=' + PrentvaentSectionName,'HelpWindow', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=1,resizable=1' );
		}else{
			prentGluggi = window.open(PrentvaentPage + '?PrentvaentSectionName=' + PrentvaentSectionName,'HelpWindow', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=1,resizable=1' );
		}
		
		if(prentGluggi)
		{
			if(PrintNow == true)
			{
				prentGluggi.print();
			}
        }
		
		if(prentGluggi.document)
		{
	          var obj;
		  try
		  {
		    if( prentGluggi.document.getElementById )
		    {
		      prentGluggi.focus();
		      obj = prentGluggi.document.getElementById( 'm_oPrentvaentBody' );
  		    }
		    else if( prentGluggi.document.all )
		    {
		      prentGluggi.focus();
		      obj = prentGluggi.document.all( 'm_oPrentvaentBody' );
	    	    }
		    else if( prentGluggi.document.layers )
		    {
		      prentGluggi.focus();
		      obj = prentGluggi.document.layers[ 'm_oPrentvaentBody' ];
		     }
	 	  }
		  catch(e)
		  {
		    alert('villa:' + e);
	 	  }
	 	}
	 	else
	 	{
	 	  alert('ekkert document');
	 	}
		if(obj)
		{
		  obj.innerHTML = sInnerText;
		  if(obj.parent)
		  {
			obj.parent.focus();
		  }		
		}
		else
		{
		}
		  
		
	}

}

function GetElement( nafn )
{
	var obj;
	if( !nafn ) { return false; }
	if( document.getElementById ) { obj = document.getElementById( nafn ); }
	else if( document.all ) { obj = document.all( nafn ); }
	else if( document.layers ) { obj = document.layers[ nafn ]; }
	if(obj) { return obj; }else{ return false;}
}

function GetParentElement( nafn, gluggi )
{
	var obj;
	if( gluggi )
	{
		if( gluggi.opener.document.getElementById )
		{
			obj = gluggi.opener.document.getElementById( nafn );
		}
		else if( gluggi.opener.document.all )
		{
			obj = gluggi.opener.document.all( nafn );
		}
		else if( this.opener.document.layers )
		{
			obj = gluggi.opener.document.layers[ nafn ];
		}
	}
	return obj;
}

function fixSizes() {
  if (document.layers == null)
  {
    var pxContent; 
    var pxLeft;
    pxContent = document.getElementById("CenterContent").offsetHeight;
    pxLeft = document.getElementById("Left").offsetHeight;
    if(pxContent < pxLeft) { document.getElementById("CenterSpace").style.height = pxLeft + 10 + "px"; }
  }
}

function SizeOMatic() {	
	var hLeft = 0;
	var hRight = 0;
	var hCenter = 0;
	hLeft = document.getElementById('Left').offsetHeight;
	if(document.getElementById('Right')){hRight = document.getElementById('Right').offsetHeight;}
	hCenter = document.getElementById('Content').offsetHeight;
	var hFixer = ((hLeft > hRight) ? hLeft : hRight);	
	hCenter = (hFixer > hCenter) ? hFixer : hCenter;
	document.getElementById('CenterContent').style.height = hCenter + "px";
}