function changeImage(path, name, action, instNrStr)
{
  if(document.images)
  {
    document.images[instNrStr + name].src = path + name + '_' + action + '.gif';
    if(document.images[instNrStr + name+'1'])
      document.images[instNrStr + name+'1'].src = path + 'blank_' + action + '.gif';
    if(document.images[instNrStr + name+'2'])
      document.images[instNrStr + name+'2'].src = path + 'blank_' + action + '.gif';
  }
}

function validateAndWait(method, form)
{
  return eval(method(form)) && wait();
}

function wait()
{
  document.body.style.cursor = "wait";

  id = null;
  imageCompChange = null;
  if (id!=null)
  	id = getEle("mainMapImageID");
  imageCompChange = eval(id);
  if (imageCompChange!=null)
	  imageCompChange.style.cursor = 'wait';

  id = null;
  imageCompChange = null;
  id = getEle("clickImageID");
  if (id!=null)
  	imageCompChange = eval(id);
  if (imageCompChange!=null)
  	imageCompChange.style.cursor = 'wait';

  return true;
}

// function sets focus on a textfield, defined by parameter
// used for login field
function setFocus(formname,fieldname) {
  window.document.forms[formname].elements[fieldname].focus();
}



	
	// Ruft eine Funktion, zur Bestimmung der Grosse des iFrames, in der dem iFrame uebergeordneten Instanz auf ...
	function UpdatePageHeight() {
//		if (top.MakeHeight) {
//			top.MakeHeight(document.body.scrollHeight + 5);
//		}
	}
	
	// Oeffnet, bzw. schliesst, die Toolbarboxen ...
	function OpenCloseLayer(layer, on) {
	  elementOn = document.getElementById(layer+"On");
	  elementOff = document.getElementById(layer+"Off");
	  if (elementOn && elementOff){
		  if (on.toUpperCase() == "ON"){
	  	  elementOn.style.display	= "block";
		    elementOff.style.display	= "none";	  
		  } else {
	  	  elementOff.style.display	= "block";
		    elementOn.style.display	= "none";	  
		  }
	  }
	  		
		UpdatePageHeight();
		
    storeLayerVisibility(layer, on);
	}
	
  function storeLayerVisibility(layer, on){
    key = getCookie('JSESSIONID') + '-' +layer;
    setCookie(key,on);
  }
	
  function restoreLayerVisibility(layer){
	  key = getCookie('JSESSIONID') + '-' +layer;
	  visible = getCookie(key);
    if (visible){
      OpenCloseLayer(layer, visible);
    }
  }
		
	// Faerbt die Suchergebnisse bei MouseOver (/-Out) ein ...
	function MakeColor(obj, mode) {
		if (mode == "on") {
      obj.classNameOrig=obj.className;
      obj.className="mouseOver";
      tdCollection = obj.getElementsByTagName("TD");
      tdCount=tdCollection.length;
      for (i = 0; i < tdCount; i++) {
        tdCollection.item(i).origColor = tdCollection.item(i).style.color;
        tdCollection.item(i).style.color = "#FFFFFF";
//        tdCollection.item(i).classNameOrig = tdCollection.item(i).className;
//        tdCollection.item(i).className = "mouseOver";
      }
		} else {
      obj.className=obj.classNameOrig;
      tdCollection = obj.getElementsByTagName("TD");
      tdCount=tdCollection.length;
      for (i = 0; i < tdCount; i++) {
        tdCollection.item(i).style.color = tdCollection.item(i).origColor;
      }
		}
	}
	
  function openLink(url) {
    window.location.href=url;    
    wait();
  }
  
  /**
   * Opens the url in the parent window (if one exists). 
   * If no parent window exists, the url will be opened in the 
   * current window
   */   
  function openLinkInParent(url){
      if (window.opener){
        window.opener.document.location.href=url;
        wait();
      } else {
        window.location.href=url;    
        wait();
      }
    }
  
  /**
   * Sets a Cookie with the given name and value.
   *
   * name       Name of the cookie
   * value      Value of the cookie
	 */
  function setCookie(name, value)
  {
    document.cookie= name + "=" + escape(value);
  }
	
  /**
   * Gets the value of the specified cookie.
   * name  Name of the cookie.
   */
  function getCookie(name)
  {
    var cookie = document.cookie;
    var prefix = name + "=";
    var begin = cookie.indexOf("; " + prefix);
    if (begin == -1)
    {
      begin = cookie.indexOf(prefix);
      if (begin != 0) return null;
    }
    else
    {
      begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
      end = cookie.length;
    }
    return unescape(cookie.substring(begin + prefix.length, end));
  }
	
  /**
   * Deletes the specified cookie.
   * name      name of the cookie
   */
  function deleteCookie(name)
  {
    if (getCookie(name))
    {
      document.cookie = name + "=" + 
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

  function selectAllCheckboxes(obj){
    inputCollection = obj.getElementsByTagName("INPUT");	  
  }
  
  function preloadimages(images) {
    var imagesArray = new Array();
    for (i=0;i<arguments.length;i++) {
      imagesArray[i]=new Image();
      imagesArray[i].src=arguments[i];
    }
  }

  /** 
   * Setzt den Tab f?r die anzuzeigende Map bei Personal Coverage Checker um.
   */
  function updateCurrentlyShownMap(footerName, mainMapName, instNr)
  {
    var otherNum1 = 1;
    var otherNum2 = 2;
    
    if (instNr == "1") {
      otherNum1 = 0;
      otherNum2 = 2;
    } else if (instNr == "2") {
      otherNum1 = 0;
      otherNum2 = 1;
    }
    
    OpenCloseLayer(footerName+instNr, 'ON');
    OpenCloseLayer(footerName+otherNum1, 'OFF');
    OpenCloseLayer(footerName+otherNum2, 'OFF');
    
    OpenCloseLayer(mainMapName+instNr, 'ON');
    OpenCloseLayer(mainMapName+otherNum1, 'OFF');
    OpenCloseLayer(mainMapName+otherNum2, 'OFF');
    return true;
  }
  
