
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;

}

}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];

}

}

}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
markkina_over = newImage("/Resource.phx/menu/navi/markkina-over.gif");
tapahtumat_over = newImage("/Resource.phx/menu/navi/tapahtumat-over.gif");
pressi_over = newImage("/Resource.phx/menu/navi/pressi-over.gif");
jarjesta_over = newImage("/Resource.phx/menu/navi/jarjesta-over.gif");
napalvelut_over = newImage("/Resource.phx/menu/navi/napalvelut-over.gif");
heme_over = newImage("/Resource.phx/menu/navi/heme-over.gif");
english_over = newImage("/Resource.phx/menu/navi/english-over.gif");
logo_over = newImage("/Resource.phx/menu/kuvat/logo-over.gif");
preloadFlag = true;

}

}

function MM_findObj(n, d) { //v3.0
  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); return x;
}

function tmt_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}

function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}

var l1;
var l2;
var l3;
var l4;
var l5;
var l6;
var l7;
var l8;
var hide;
var HideTimer;
function ShowMenu(l1,l2,l3,l4,l5,l6,l7){
		MM_showHideLayers('pika','',l1,'pkanava','',l2,'tapahtumat','',l3,'pressi','',l4,'napalvelut','',l5,'tilapalvelut','',l6,'heme','',l7,'admin','',l8);
		Hide();
}

function Hide(hide){
	if (hide == true){
		HideTimer=setTimeout("ShowMenu('hide','hide','hide','hide','hide','hide','hide','hide','hide');", 100);
	} else clearTimeout(HideTimer);
}


function doSearchMain(f)
{
  //This function splits words using spaces and recombines
  //as words prefixed by + operators meaning 'must include'
  //in search expressions.
  //Finally the selected Fair eid is added using the + notation.
  var search = "";

  if (f.searchTerms.value != "") {
    var loop = 0;
    var word_array = f.searchTerms.value.split(" ");
    for (loop=0; loop < word_array.length; loop++) {
	search = search + " +" + word_array[loop];
    }
  }
      var search2 =  f.searchTerms.value;
  f.queryString.value = escape(search);
  f.searchTerms.value = escape(search2);
  alert(f.searchTerms.value);

  f.submit();
}



function doSearchMains(m)
{
  var searchTermsString = m.searchTerms.value;
  var thisCharacter = "";
  var inQuotes = false;
  var terms = new Array();
  var currentTerm = "";
  var foundTerm = false;
  var selectedFair = "";
  var queryString = "";
  //Iterate through the string
  for (index = 0; index < searchTermsString.length; index ++) {
    //Get the character at the current position
    thisCharacter = searchTermsString.charAt(index);
    if (thisCharacter != " ") {
      //Append this character to the current term...
     currentTerm = currentTerm + thisCharacter;
      //...and if it's a quote, toggle the flag
     if (thisCharacter == "\"") 
       inQuotes = !inQuotes;
    } else {
      
      /*
      * This character is whitspace.  If we're within quotes
       * add it to the current term.
      */
      if (inQuotes)
        currentTerm = currentTerm + thisCharacter;
      else {
              /*
         * If we've got a current term then this
         * terminates it and so we've found a complete term.
         * If not, then we'll ignore it. 
        */ 
       if (currentTerm.length > 0 )
         foundTerm = true;
      } 
   }  
    /* 
     * If this character is the last character and we've got a
     * current term then it is terminated and we've got a 
     * complete term.
     */ 
    if (!foundTerm && ((index == (searchTermsString.length - 1)) && currentTerm != "")) {
      foundTerm = true;
    }
    if (foundTerm) {
     //Add the current term to our list of terms
     terms[terms.length] = currentTerm;
      foundTerm = false;
      currentTerm = "";
    }  
  } 
  //From our list of terms, generate the query string
 for (i = 0; i < terms.length; i++) {
   if (queryString.length == 0)
     queryString = "+" + terms[i];
   else
     queryString = queryString + " +" + terms[i];
 }


}
var Map = 0;
var active = 1;


function MapValue(Map) {

active = Map;

}

function openMap() {
  if (active == 1 || Map == 1)
   { window.open("/Resource.phx/community/opastus/kartta.htx?helsinki","PopMap","left=10,top=10,width=620,height=498,location=0,status=0,navigation=0,scrollbars=0,resizable=1");}
  if (active == 2 || Map == 2)
{    window.open("/Resource.phx/community/opastus/kartta.htx?asema-ws","PopMap","left=10,top=10,width=795,height=589,location=0,status=0,navigation=0,scrollbars=0,resizable=1");}
  if (active == 3 || Map == 3)
{    window.open("/Resource.phx/community/opastus/kartta.htx?katajanokka","PopMap","left=10,top=10,width=620,height=437,location=0,status=0,navigation=0,scrollbars=0,resizable=1");}
  if (active == 0 || Map == 0)
{return;}
}



function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE");
   var versioni = parseFloat(arVersion[1]);
   if ((versioni < 7) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i];
         var imgName = img.src.toUpperCase();
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgStyle = "display:inline-block;" + img.style.cssText ;
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" ;
            img.outerHTML = strNewHTML;
            i = i-1;
         }
      }
   }    
}

		function CustomerInfo(id,visibility) {
			if (visibility == "show") {
				document.getElementById(id).style.visibility="visible";
			} else {
				document.getElementById(id).style.visibility="hidden";
			}
		}
		function ajaxFunction(x,y){
		  var xmlHttp;
		  var url = x;
		  var target = y;
		  try
		    {
		    // Firefox, Opera 8.0+, Safari
		    xmlHttp=new XMLHttpRequest();
		    }
		  catch (e)
		    {
		    // Internet Explorer
		    try
		      {
		      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		      }
		    catch (e)
		      {
		      try
			{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		      catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
		      }
		    }
		    xmlHttp.onreadystatechange=function()
		      {
			      if(xmlHttp.readyState==4)
				{
				document.getElementById(target).innerHTML=xmlHttp.responseText;
				}
		      }
		    xmlHttp.open("GET",url,true);
		    xmlHttp.send(null);
		  }
correctPNG();
//window.attachEvent("onload", correctPNG);