	 var alreadySubmitted=false;
	 function bestaetigen()
	 {
	 	var doSubmit=!alreadySubmitted;
	 	alreadySubmitted=true;
	 	return doSubmit;
	 }
      function changeImage(index)
      {
       // document.bild.src=imageURL(index);
        
      }

      function submitDeleteKonfigurationen()
      {
        document.angebote.submit();
      }
		function openDetail(adresse)
		{
		   Fenster = window.open(adresse, "Detail", "width=601,height=250,dependent=yes,resizable=yes,location=no,scrollbars=yes");
		   Fenster.focus();
		   return false;
		}
	 function reload(adresse)
	 {
	    if (!alreadySubmitted)
		{
	       self.location.href=adresse;
		   alreadySubmitted=true;
		}
		return false;
	 }
	  function klappen(element)
	  {
// while(element!=null)
// {
// element=element.nextSibling;
// var test=element.firstChild.getAttributeNode('class');
//
// if (test!=null && test.nodeValue=='ausstattung_border')
// {
// break;
// }
// element.style.display='none';
// }
			if(element!=null)
			{
				if(element.className=='klappeOffen')
				{  
				  element.className='klappeZu';
				  setCookie("showAusstattungen","true");
				}
				else
				{
					element.className='klappeOffen';
				  setCookie("showAusstattungen","false");
				}
			}
			
	  }
	  // Wenn hier ein Formular übergeben wird, wird die action des Formulars auf
    // die url geändert
	  // und das Formular versandt, solange die Ziel-URL auf ein ItemPM gerichtet
    // ist(erkennbar an model_id).
	  function ladeLink( url, target,formular ) 
		{
	 		/* Bugfix EASYSG-284 Form wird beim ersten Request nicht abgesetzt. */
			var formCurrent=document.forms[formular];
			
			/* @bugfix 11.05.2011 EASYFRAPORT-15 */
			var formEncoding = formCurrent.encoding;
			if ( (formEncoding != "application/x-www-form-urlencoded" ) && (formEncoding != "" ) )
			{
				formCurrent.encoding = "application/x-www-form-urlencoded";
			}
			
			var action=formCurrent.action;
			if( formular!=null && url.indexOf("model_id")!=-1)
			{
				url=url.replace(/#/g,"%23");
				if( url.indexOf("action/")==-1 && url.indexOf("action=")==-1)
				{
					if( url.indexOf("?")==-1 )
					{
						url = url + "?";
					}
					else
					{
						url = url + "&";
					}
					url = url + "action=AngebotItemAction";
				}
				formCurrent.action=url;
				if( target!="")
				{
				  formCurrent.target=target;
				}
				formCurrent.submit();
				formCurrent.target="";
				if(target!="")
				{
				   target="";
				   /**@ bugfix 09-nov-2010 EASYSCA-241 */
				   formCurrent.action=action;
				}
			}
			else
			{
				if( target!="")
				{
					window.open( url, "Fahrzeugkonfigurator","");
				}
				else
				{
					document.location.href=url;
				}
			}
			if ( formEncoding != formCurrent.encoding ) 
			{
				formCurrent.encoding = formEncoding;
			}
		}
	  
	    function checkMaxSizeOfSelected(checkboxes, maxSize,message)
	    {
	      var anzahl=0;
	      for (var i = 0; i < checkboxes.length; i++)
	      {
	        if(checkboxes[i].checked)
	        {
	          anzahl++;
	        }
	        if(anzahl>maxSize)
	        {
	          alert(message);
	          return false;
	        }
	      }
	      return true;
	    }
	    
      function checkMinSizeOfSelected(checkboxes, minSize,message)
      {
        var anzahl=0;
        for (var i = 0; i < checkboxes.length; i++)
        {
          if(checkboxes[i].checked)
          {
            anzahl++;
          }
          if(anzahl>=minSize)
          {
            return true;
          }
        }
        alert(message);
        return false;
      }

	  
      function searchTypen()
      {
        document.typauswahl.search.value = "true";
        document.typauswahl.submit();
      }
      function getPosition(element)
      {
        while(element!=null && (element.className==null || 
        element.nodeName != "DIV" || element.className.indexOf("scrollpane")==-1))
        {
          element=element.parentNode;
        }
        if(element!=null)
        {
	      	return element.scrollTop;
      	}
      	else
      	{
      	  return document.documentElement.scrollTop;
      	}
      }
      function savepositionlink(element)
      {
	      var link=element;
        position=getPosition(element);
        if(link.href.indexOf("scrollpane")!=-1)
        {
          link.href=link.href.replace(/scrollPane=\d*&/,"scrollPane="+position+"&");
        }
        else
        {
        	link.href=link.href.replace("?","?scrollPane="+position+"&");
        }
      }
      function savepositionform(form)
      {
        var position=getPosition(null);
        if(form!=null)
        {
	        if(form.action.indexOf("scrollPane")!=-1)
	        {
	          form.action=form.action.replace(/scrollPane=\d*&/,"scrollPane="+position+"&");
	        }
	        else
	        {
	        	form.action=form.action.replace("?","?scrollPane="+position+"&");
	        }
        }

      }
      function savePositionAndSubmit(element,form)
      {
         // Prüfe ob schon submitted wurde
         if(bestaetigen())
         {
           savepositionform(element);
           form.submit();
           return true;
         }
         else
         { 
           return false;
         }
      }
      function savePositionSelectCheckbox(element,url)
      {
         // Prüfe ob schon submitted wurde
         if(bestaetigen())
         {
           var position=getPosition(element);
           var parameter;
           if(url.indexOf("?")==-1)
           {
             parameter="?";
           }
           else
           {
             parameter="&";
           }
           parameter=parameter+element.name+"="+element.checked;
           parameter=parameter.replace(/#/g,"%23");
           var link=url+parameter;
           if(link.indexOf("scrollpane")!=-1)
           {
             document.location.href=link.replace(/scrollPane=\d*&/,"scrollPane="+position+"&");
           }
           else
           {
             document.location.href=link.replace("?","?scrollPane="+position+"&");
           }
           return true;
         }
         else
         { 
           return false;
         }
      }
      
      
      function setCookie(name,value)
      {
      	document.cookie=name+"="+value;
      }
			function selectPackage(selectedBox)
			{
			  if(selectedBox.checked)
			  {
	  	    zell=selectedBox.parentNode;
	  	    if( zell.className.indexOf("gruen")>-1)
	  	    {
				  	anfang=false;
				  	for (var i = selectedBox.form.length-1; i >-1 ; i--)
				  	{
				  	  box=selectedBox.form.elements[i];
				  	  if(anfang)
				  	  {
				  	    zell=box.parentNode;
				  	    if( zell.className.indexOf("gruen")==-1)
				  	    {
				  	    	box.checked=true;
				  	      break;
				  	    }
				  	    
				  	  }
				  	  if(box==selectedBox)
				  	  {
				  	    anfang=true;
				  	  }
				  	}
	  	    }
			  	else
			  	{
				  	anfang=false;
				  	for (var i = 0; i < selectedBox.form.length; i++)
				  	{
				  	  box=selectedBox.form.elements[i];
				  	  if(anfang)
				  	  {
				  	    zell=box.parentNode;
				  	    if( zell.className.indexOf("gruen")==-1)
				  	    {
				  	      break;
				  	    }
				  	    box.checked=true;
				  	  }
				  	  if(box==selectedBox)
				  	  {
				  	    anfang=true;
				  	  }
				  	}
				  }
			  }
			  
}
		  function resetField(field)
		  {
		    if(field)
		    {
		      field.value=-1;
		    }
		  }
			
if(window.navigator.systemLanguage && !window.navigator.language) {
  function hoverIE() {
    var LI = sucheUL(document.getElementById("nav_main").firstChild).firstChild;
    do { 
      if (sucheUL(LI.firstChild)) {
        LI.onmouseover=einblenden; LI.onmouseout=ausblenden;
      }
      LI = LI.nextSibling;
    }
    while(LI);
  }

  function sucheUL(UL) {   
  
    do {
      if(UL) UL = UL.nextSibling;
      if(UL && UL.nodeName == "UL") return UL;
    }
    while(UL);
    return false;
  }
  
  function einblenden() {
    var UL = sucheUL(this.firstChild);
    UL.style.display = "block"; UL.style.backgroundColor = "#F6D332";
  }
  function ausblenden() {
  	
    sucheUL(this.firstChild).style.display = "none";
  }
  // [ip] Bei Dropdown wieder einkommentieren
  // window.onload=hoverIE;
 
 	function setValueOf(id, value)
 	{
		field = document.getElementById(id);
		field.value = value;
  	}
 	
}



/********************************************************
 * Update: ladeLink kann ueberschrieben werden.
 ********************************************************/

// grays out the page and calls the real ladeLink-method
function ladeLink2(url, target,formular) {  
	
	grayOut(true, {/*'container':'page_margins',*/'zindex':'70', 'bgcolor':'#D6E8EF', 'opacity':'70'});
	
	// rufe referenz auf (self.ladeLink waere jetzt endlosschleife)
	origLadeLink(url, target,formular);
}

function grayOutDefault(){
  
  grayOut(true, {/*'container':'page_margins',*/'zindex':'70', 'bgcolor':'#D6E8EF', 'opacity':'70'});
}

// Pass true to gray out screen, false to ungray
// options are optional.  This is a JSON object with the following (optional) properties
// opacity:0-100         // Lower number = less grayout higher = more of a blackout
// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order.  Pass only the properties you need to set.
function grayOut(vis, options, extra) 
{
  var options = options || {};
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
	if( options.container != undefined )
		tbody = document.getElementById(options.container); 
	
    var tnode = document.createElement('div'); 
        tnode.className = "loading_overlay";
		tnode.id='darkenScreenObject';  

	// create box inside loading-overlay	
	var msgnode = document.createElement('div'); 
		msgnode.className = "icon";
		msgnode.id='box';   
        msgnode.style.display='none'; 
         
	// add element	 
	tnode.appendChild(msgnode); 
    tbody.appendChild(tnode); 
    dark=document.getElementById('darkenScreenObject'); 
  }
  if (vis) {
    // Calculate the page width and height
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;
    dark.style.MozOpacity=opaque;
    dark.style.filter='alpha(opacity='+opacity+')';
    dark.style.zIndex=zindex;
    dark.style.backgroundColor=bgcolor;
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';
	if(extra == 'Y')
		document.body.style.overflow =  'hidden'; 
	
	document.getElementById("box").style.zIndex = zindex+10; 
	document.getElementById("box").style.display = "block"; 

		
  } else {
     dark.style.display='none';
  }
}

