var edItem;

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/webeditor2/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 resizeIframe(frameID) {
	var frameObj=document.getElementById(frameID);
  	var height=frameObj.contentWindow.document.body.scrollHeight;
	frameObj.style.height=height+"px";
	frameObj.style.width='100%';
}

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) {
  switch (action) {
    case 'init'     : {document.write('<div ID=PopupDivLayer2 style="z-index:120;visibility:hidden;background-color:#FFFFFF;left:1;top:1;width:1px;height:1px;position:absolute;border:1px solid silver;padding:5px;"><iframe src="/blank.htm" frameborder="no" width="98%" height="99%" name="PopupDivInfo2" ID=PopupDivInfo2></iframe></div>');break;}
    case 'execute'  : {document.getElementById('PopupDivInfo2').src=i_url;break;}
    case 'hide'     : {document.getElementById('PopupDivLayer2').style.visibility='hidden';break;}
    case 'show'     : {
		/*------------------------------------------------------*/
		var i_div   = document.getElementById('PopupDivLayer2');
		var i_frame = document.getElementById('PopupDivInfo2');       	
		/*------------------------------------------------------*/
		if (l) {l=l;} else {l=(document.body.clientWidth-w)/2;}
		if (t) {t=t;} else {t=(document.body.clientHeight-h)/2;}
		/*------------------------------------------------------*/
		if (i_url!='') {i_frame.src=i_url;}
		/*------------------------------------------------------*/
		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';
	   	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 openServiceWindow(url,h,w) {
  var i=1;var winOK=false;
  try {var winleft=(screen.width-w)/2;var winup=(screen.height-h)/2;} catch(e) {winleft=0;winup=0;}
  while (!winOK && i<=5) {
      if (i==1)  {if (!navigator.ServiceWnd1  || navigator.ServiceWnd1.closed)  {navigator.ServiceWnd1  = window.open(url,"ServiceWnd1","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.ServiceWnd1.window.focus();winOK=true;} else {i++;}}
      if (i==2)  {if (!navigator.ServiceWnd2  || navigator.ServiceWnd2.closed)  {navigator.ServiceWnd2  = window.open(url,"ServiceWnd2","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.ServiceWnd2.window.focus();winOK=true;} else {i++;}}
      if (i==3)  {if (!navigator.ServiceWnd3  || navigator.ServiceWnd3.closed)  {navigator.ServiceWnd3  = window.open(url,"ServiceWnd3","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.ServiceWnd3.window.focus();winOK=true;} else {i++;}}
      if (i==4)  {if (!navigator.ServiceWnd4  || navigator.ServiceWnd4.closed)  {navigator.ServiceWnd4  = window.open(url,"ServiceWnd4","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.ServiceWnd4.window.focus();winOK=true;} else {i++;}}
      if (i==5)  {if (!navigator.ServiceWnd5  || navigator.ServiceWnd5.closed)  {navigator.ServiceWnd5  = window.open(url,"ServiceWnd5","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.ServiceWnd5.window.focus();winOK=true;} else {i++;}}
  }
}

function openServiceWindow2(url,h,w) {openServiceWindow(url,h,w)}

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 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 ShowCommunities() { 
  var ZoomLayer=top.document.getElementById('ZoomLayer');
  ZoomLayer.style.top=68;    
  var objZoom = document.getElementById('Zoom');
  if ((objZoom.src.indexOf('blank.htm')>-1) || (objZoom.src.indexOf('/Services.asp')>-1)) {
    objZoom.src='/VaihdaYhteiso.asp?action=show';ZoomLayer.style.display='block';
  } else {  
    if (ZoomLayer.style.display=='none') {ZoomLayer.style.display='block';} else {ZoomLayer.style.display='none';}
  }
}   

function ShowServices() {
  var ZoomLayer=top.document.getElementById('ZoomLayer');
  ZoomLayer.style.top=68;    
  var objZoom = document.getElementById('Zoom');
  if (objZoom.src.indexOf('blank.htm')>-1 || objZoom.src.indexOf('/VaihdaYhteiso.asp')>-1) {
    objZoom.src='/Services.asp?action=show';ZoomLayer.style.display='block';
  } else {
    if (ZoomLayer.style.display=='none') {ZoomLayer.style.display='block';} else {ZoomLayer.style.display='none';}
  }
}  
