

//___________Global variables and events___________//
var edItem;var mouseX=0;var mouseY=0;document.onmousemove = getMouseXY;

//___________Global trappable events______________//
if (!document.all) document.captureEvents(Event.MOUSEMOVE);

//___________Helper functions____________________//
function IsNum(sText) {
	var ValidChars = "0123456789.";
	for (i = 0; i < sText.length; i++) { 
		if (ValidChars.indexOf(sText.charAt(i)) == -1) {return false;}
	}
	return true;
}

function getY(oElement)	{
	var iReturnValue = 0;var topY=((window.pageYOffset) ? window.pageYOffset : document.body.scrollTop);
	while(oElement!=null) {iReturnValue += oElement.offsetTop;oElement = oElement.offsetParent;}
	return iReturnValue-topY;
}

function getX(oElement)	{
	var iReturnValue = 0;
	while(oElement!=null) {iReturnValue += oElement.offsetLeft;oElement = oElement.offsetParent;}
	return iReturnValue;
}

function getMouseXY(e) {
  	if (document.all) {
    		try {
    			mouseX = event.clientX + document.body.scrollLeft;
    			mouseY = event.clientY + document.body.scrollTop;
    		} catch (err) {}
  	   } else {
			mouseX = e.pageX;
    		mouseY = e.pageY;
  	}  
  	if (mouseX < 0){mouseX = 0}
  	if (mouseY < 0){mouseY = 0}  
  	return true
}

function getViewportSize(imode) {
	var w,h;
	if (self.innerHeight) {
		w = self.innerWidth;
		h = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else if (document.body) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	if (imode=='w') return w; else return h;
}

function ACC_fullSreen(winSize) {

	if (document.getElementById('ACC_GUI_container1').currentStyle.borderWidth == '0px') 
	{
		if (document.getElementById('ACC_GUI_container1').style.width=='100%') {
			document.getElementById('ACC_GUI_container1').style.width=winSize+100+'px';
			document.getElementById('ACC_GUI_application').style.width=winSize+'px';
		} else {
			document.getElementById('ACC_GUI_container1').style.width='100%';
			document.getElementById('ACC_GUI_application').style.width='auto';
			document.getElementById('ACC_GUI_application').style.marginLeft='50px';
			document.getElementById('ACC_GUI_application').style.marginRight='50px';
		}	
	}
	else
	{
		if (document.getElementById('ACC_GUI_application').style.width=='98%') {
			document.getElementById('ACC_GUI_application').style.width=winSize+'px';
		} else {
			document.getElementById('ACC_GUI_container1').style.width='100%';
			document.getElementById('ACC_GUI_application').style.width='98%';
		}
	}
}

function ACC_setAppSize() {
	var guicontainer=document.getElementById('ACC_GUI_container');
	var wpcontent=document.getElementById('ACC_GUI_main');
	var headerHeight=document.getElementById('ACC_GUI_header').offsetHeight;
	wpcontent.style.height=(getViewportSize('h')-headerHeight-28)+'px';
 	//guicontainer.style.overflow='auto';
}


function _blockMode(id) {
  	var elemObj = document.getElementById(id);  
  	var elemImg = eval('document.img'+id);
  	if (elemObj.style.display=='none') {  	
		elemObj.style.display='block';elemImg.src='/images/windowsXP/XP_closeBlock.gif';
  	} else {
		elemObj.style.display='none';elemImg.src='/images/windowsXP/XP_openBlock.gif';
  	}    
}

function METADATA_OnChange(inputObj,outputObj) {
	if(inputObj) {var SelParams='0';for(i = 0; i < inputObj.length; i++) {if (inputObj[i].checked) {SelParams=SelParams+','+inputObj[i].value;}}}	
	outputObj.value=SelParams;
}


function OpenService(service_url,appID,appwindow) {
	parent.PopupDiv2('hide');if (appwindow) {openServiceWindow(service_url,680,880,appID);} else {if (parent.main) {parent.main.location.href=service_url;} else {top.location.href=service_url;}}
} 


function MouseClick(e) {
	if (document.all)    {if (event.button == 2) {if (window.confirm(message)) {top.location.reload()} else {return false;}}}
	if (document.layers) {if (e.which == 3)      {if (window.confirm(message)) {top.location.reload()} else {return false;}}}
}

function resizeIframe(frameID) {
	var frameObj=document.getElementById(frameID);
  	var height=frameObj.contentWindow.document.body.scrollHeight;
	frameObj.style.height=height+"px";
	frameObj.style.width='100%';
}

function RefreshGUI(accframe) {
  try {if (background_services_active && eval(accframe)) {eval(accframe).document.location.reload();}} catch(e) {}}

function openImgGallery(initfold) {
	var winleft=(screen.width-720)/2;var winup=(screen.height-600)/2;
	ImgGallery=window.open('/_acc/_components/WebEditor/imggallery.asp?mode=application&initID='+initfold,600,720,true,"ImgGallery","left="+winleft+",top="+winup+",height=600,width=720");
}

function ImgWnd(url) {
	var winleft=(screen.width-340)/2;var winup=(screen.height-340)/2;
	ImgPopup = window.open(url,"ImgPopup","left="+winleft+",top="+winup+",height=300,width=300");
	try {ImgPopup.window.focus();} catch(e) {}
}

function PopupDiv(action,i_url,w,h) {  
	switch (action) {
		case 'init'     	: {document.write('<div ID=PopupDivLayer style="z-index:120;visibility:hidden;background-color:FFFFFF;position:absolute;border:2px solid gray;padding:5px;"><iframe src="/blank.htm" frameborder="no" width="98%" height="99%" name="PopupDivInfo" ID=PopupDivInfo></iframe></div>');break;}
		case 'execute'  	: {top.PopupDivInfo.location.href= i_url;break;}
		case 'hide'     	: {PopupDivLayer.style.visibility='hidden';break;}
		case 'show'     	: {
		   top.PopupDivInfo.location.href      = i_url;
		   top.PopupDivLayer.style.left        = (top.document.body.clientWidth-w)/2;
		   top.PopupDivLayer.style.top         = (top.document.body.clientHeight-h)/2;
		   top.PopupDivLayer.style.width       = w;
		   top.PopupDivLayer.style.height      = h;
		   top.PopupDivLayer.style.visibility  = 'visible';
		   break;
		}
	}
}

function PopupDiv2(action,i_url,w,h,t,l) {
	var i_div   	= document.getElementById('PopupDivLayer2');
	var i_frame 	= document.getElementById('PopupDivInfo2'); 
	var i_content	= document.getElementById('dialogcontent'); 

	switch (action) {
		case 'init'     	: {document.write('<link href="/_ACC/_dialogs/style.css" rel="stylesheet" type="text/css"><div class="dialog_basic IsFloated" style="visibility:hidden;" id="PopupDivLayer2"><div id="dialogcontent"><iframe style="width:99%;height:99%;margin:10px 2px 10px 2px;" src="#" frameborder="no" name="PopupDivInfo2" ID=PopupDivInfo2></iframe></div></div>');break;}
		case 'initdialog'   : {document.write('<link href="/_ACC/_dialogs/style.css" rel="stylesheet" type="text/css"><div class="dialog IsFloated isTransparent" style="visibility:hidden;" id="PopupDivLayer2"><div id="dialogcontent" class="content"><div class="t"></div><div id="dialogmenu" style="height:9px;"><img onclick="PopupDiv2(\'hide\');" style="cursor:pointer;vertical-align:middle;margin:auto;padding:auto;margin:5px 0px 0px 10px;float:right;border:0px;" src="/_ACC/_dialogs/icon_close.gif"></div><iframe style="background:transparent;width:100%;height:100%;min-height:250px;margin:15px 0px 0px 0px;" ALLOWTRANSPARENCY="true" src="#" frameborder="no" name="PopupDivInfo2" ID=PopupDivInfo2></iframe></div><div class="b"><div></div></div></div>');break;}
		case 'execute'  	: {i_frame.src=i_url;break;}
		case 'hide'     	: {
			i_div.style.visibility='hidden';
			break;
		}
		case 'show'     : {
			/*------------------------------------------------------*/
			var topY=((window.pageYOffset) ? window.pageYOffset : document.body.scrollTop);      	
			/*------------------------------------------------------*/
			if (IsNum(w)) {if (getViewportSize('w')<w) 	{w=getViewportSize('w')-50;}}
			if (IsNum(h)) {if (getViewportSize('h')<h) 	{h=getViewportSize('h')-50;}}
			/*------------------------------------------------------*/
			if (l) {l=l;} else {l=(document.body.clientWidth-w)/2;}
			if (t) {t=t+topY;} else {t=((document.body.clientHeight-h)/2)+topY-15;}
			/*------------------------------------------------------*/
			if (i_url!='') {i_frame.src=i_url;}
			/*------------------------------------------------------*/
			if (IsNum(l)) l=l+'px';
			if (IsNum(t)) t=t+'px';
			if (IsNum(w)) w=w+'px';
			if (IsNum(h)) h=h+'px';
			/*------------------------------------------------------*/
			i_div.style.left   		= l;
			i_div.style.top     	= t;
		   	i_div.style.width       = w;
		   	i_div.style.height      = h;
		   	i_div.style.visibility  = 'visible';
			/*------------------------------------------------------*/		   	
		   	//i_frame.style.width=(i_content.offsetWidth-12)+'px'
		   	i_frame.style.height=(i_content.offsetHeight-12)+'px'
			/*------------------------------------------------------*/
		   	break;
		}
	}
}

function globalSearchForm(action,w,h,t,l) {
	switch (action) {
		case 'init'     : {document.write('<div style="z-index:120;visibility:hidden;background-color:#FFFFFF;left:1px;top:1px;width:1px;height:1px;position:absolute;border:1px solid silver;padding:3px;" id="_searchForm"><iframe style="width:99%;height:99%;margin:0px;" src="/search/" frameborder="no" name="_searchFormFrame" ID=_searchFormFrame></iframe></div>');break;}
		case 'hide'     : {
			document.getElementById('_searchForm').style.visibility='hidden';
			break;
		}
		case 'show' : {
			var i_div   = document.getElementById('_searchForm');		   	
			i_div.style.visibility  = 'visible';
			break;
		}
		case 'open'     : {
			/*------------------------------------------------------*/
			var topY=((window.pageYOffset) ? window.pageYOffset : document.body.scrollTop); 
			/*------------------------------------------------------*/
			var i_div   = document.getElementById('_searchForm');
			var i_frame = document.getElementById('_searchFormFrame');       	
			/*------------------------------------------------------*/
			if (l) {l=l;} else {l=(document.body.clientWidth-w)/2;}
			if (t) {t=t;} else {t=(document.body.clientHeight-h)/2;}		
			/*------------------------------------------------------*/
			i_div.style.left   		= l+'px';
			i_div.style.top     	= (topY+t)+'px';
		   	i_div.style.width       = w+'px';
		   	i_div.style.height      = h+'px';
		   	i_div.style.visibility  = 'visible';
		   	break;
		}
	}
}

function HilighSelection(item,action) {
	if (edItem) edItem.style.background='transparent';
	if (action==1) {item.style.background='#E2EBFA';} else {item.style.background='transparent';}
	edItem=item;
}

function openPopup(url,h,w,new_instance) {
	var winleft=(screen.width-w)/2;var winup=(screen.height-h)/2;var i=1;var winOK=false;
	if (new_instance) {
		while (!winOK && i<=12) {
		  if (i==1)  {if (!navigator.popup1  || navigator.popup1.closed)  {navigator.popup1  = window.open(url,"popup1","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup1.window.focus();winOK=true;} else {i++;}}
		  if (i==2)  {if (!navigator.popup2  || navigator.popup2.closed)  {navigator.popup2  = window.open(url,"popup2","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup2.window.focus();winOK=true;} else {i++;}}
		  if (i==3)  {if (!navigator.popup3  || navigator.popup3.closed)  {navigator.popup3  = window.open(url,"popup3","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup3.window.focus();winOK=true;} else {i++;}}
		  if (i==4)  {if (!navigator.popup4  || navigator.popup4.closed)  {navigator.popup4  = window.open(url,"popup4","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup4.window.focus();winOK=true;} else {i++;}}
		  if (i==5)  {if (!navigator.popup5  || navigator.popup5.closed)  {navigator.popup5  = window.open(url,"popup5","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup5.window.focus();winOK=true;} else {i++;}}
		  if (i==6)  {if (!navigator.popup6  || navigator.popup6.closed)  {navigator.popup6  = window.open(url,"popup6","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup6.window.focus();winOK=true;} else {i++;}}
		  if (i==7)  {if (!navigator.popup7  || navigator.popup7.closed)  {navigator.popup7  = window.open(url,"popup9","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup7.window.focus();winOK=true;} else {i++;}}
		  if (i==8)  {if (!navigator.popup8  || navigator.popup8.closed)  {navigator.popup8  = window.open(url,"popup8","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup8.window.focus();winOK=true;} else {i++;}}
		  if (i==9)  {if (!navigator.popup9  || navigator.popup9.closed)  {navigator.popup9  = window.open(url,"popup9","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup9.window.focus();winOK=true;} else {i++;}}
		  if (i==10) {if (!navigator.popup10 || navigator.popup10.closed) {navigator.popup10 = window.open(url,"popup10","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup10.window.focus();winOK=true;} else {i++;}}
		  if (i==11) {if (!navigator.popup11 || navigator.popup11.closed) {navigator.popup11 = window.open(url,"popup11","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup11.window.focus();winOK=true;} else {i++;}}
		  if (i==12) {if (!navigator.popup12 || navigator.popup12.closed) {navigator.popup12 = window.open(url,"popup12","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");navigator.popup12.window.focus();winOK=true;} else {i++;}}
		}
	} else {
	 	popup = window.open(url,"popup","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");
	 	try {popup.window.focus();} catch(e) {}    
	}
}

function openServiceWindow2(url,h,w) {openServiceWindow(url,h,w)}

function openServiceWindow(iurl,h,w,appID) {
	var applicationID=appID.replace(/-/g,'_');
	try {var winleft=(screen.width-w)/2;var winup=(screen.height-h)/2;} catch(e) {winleft=0;winup=0;}
	eval("var win" + applicationID +"=window.open('" + iurl + "','" + applicationID + "','left="+winleft+",top="+winup+",height="+h+",width="+w+",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0');");
}

function openAdminConsole(url,h,w) {
	var winleft = (screen.width - w) / 2;
	var winup = (screen.height - h) / 2;
	admin = window.open(url,"admin","left="+winleft+",top="+winup+",height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");
	try {admin.window.focus();} catch(e) {}  
}

function PrintPage() {
	if (valikko) {valikko.style.display='none';}
	window.print();
	if (valikko) {valikko.style.display='block';}
}

function OpenPage(i_url,h,w) {
	CloseMenu();
	if (h && w) {
		popup = window.open(i_url,"popup","height=" + h +",width=" + w +",toolbar=0,directories=0,menubar=1,status=0,resizable=1,scrollbars=1,location=0,copyhistory=0");
	} else {
		if (parent.main) {parent.main.location.href=i_url;} else {main.location.href=i_url;};
	}
	return true;
}

function InstrCheck(ivalues,ival) {
	if (ivalues) {
		ivalues=ivalues.replace(/ /g,'');ival=ival.replace(/ /g,'');
		ivalues=','+ivalues+',';ival=','+ival+',';
		if (ivalues.indexOf(ival)>=0) return true; else return false;
	} else {
		return false;
	}
}

function opacity(id,opacStart,opacEnd,millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

function changeOpac(opacity,id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}