function ohjepopup() {
    window.open('ohje.html','ohjeet','scrollbars=no,toolbar=no,titlebar=no,personalbar=no,fullscreen=no,directories=no,width=370,height=450');
}
function popup(url, height, width) {
    window.open(url,'ohjeet','scrollbars=no,toolbar=no,titlebar=no,personalbar=no,fullscreen=no,directories=no,width='+width+',height='+height);
}

function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
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.01
    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 && d.getElementById) x=d.getElementById(n); return x;
}
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 openWindow(sivu, x, y, width, height, scrollbars, resizable) {
	splashWin = window.open(sivu, "", "width="+width+",height="+height+",top="+y+",left="+x+",location=0,directories=0,status=0,titlebar=0,menubar=0,personalbar=0,scrollbars=" + scrollbars + ",resizable=" + resizable +",toolbar=0");
	if( splashWin ) {
		splashWin.focus();
	}
}

function openToolkitWindow(param) {
    var params = param.split (',');
    
    if (params[0] == "popup")
    {
        openWindow(params[1], params[2], params[3], params[4], params[5], params[6], params[7]);
	}
	else
	{
	    if (param != "")
	    {
	        document.location.href=param;
	    }
	}
}

// Mainosgalleria popup opener

var windowAvaaToimiala
function go(whichURL) {
    windowAvaaToimiala=window.open(whichURL,'AvaaToimiala','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,//resizable=no,width=722,height=629');
    windowAvaaToimiala.focus();
}

// Mainosgalleria popup opener v1.0 + 9.5.2005 Modified by mvalk99: CR#4231

function openGallery(form, dropDownName) {
    var winProps = "height=750,width=722,location=no," + "scrollbars=no,menubars=no,toolbars=no,resizable=yes";
    
    var urls=(form.elements[dropDownName].options[form.elements[dropDownName].selectedIndex].value);
    if (form.elements[dropDownName].selectedIndex > 0) {
        myWin = window.open(urls,'myWin',winProps);
        myWin.focus();
        menuReset(form, dropDownName);
    } else {
        return false;
    }
}

function menuReset(form, dropDownName) {
    form.elements[dropDownName].selectedIndex = 0;
}

function ReadLoggedInCookie (){
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var CookieValue = "";
  var x = 0;
  var SessionCookieName = "SMSESSION";
  var LoginSiteCookie = "HSLOGINSITE";
  var SessionExists = "FALSE";
  var SiteIsMedianetti = "FALSE";

  for (x = 0; (x < SetSize); x++) {

    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }
    if (CookiePieces[0] == SessionCookieName) {
      CookieValue = CookiePieces[1];
      if (CookieValue.length > 10 && CookieValue != "LOGGEDOFF") {
          SessionExists = "TRUE"; 	 	    	
      }      
    }
    if (CookiePieces[0] == LoginSiteCookie) {
      CookieValue = CookiePieces[1];
      if (CookieValue == "Medianetti") {
      	 SiteIsMedianetti = "TRUE";	 	 
      }      
    }
  }
  if (SiteIsMedianetti == "TRUE" && SessionExists == "TRUE") {
     return true;	
  }      
  return false;
}
