﻿//function deactivates button
function deactivateButton(){
	document.getElementById('save_button').disabled = "false";
}


function init () {

// Bilder vorausladen (fremdsprachige Buttons spaeter hinzufuegen !!!)
/*
	MM_preloadImages('../../../../images/public/buttons/de/hauptnavi_produkte_bauart_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_unternehmen_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_infocenter_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_karriere_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_einkauf_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_kontakt_on-2.gif',
					 '../../../../images/public/buttons/de/hauptnavi_assistent_on-2.gif',
					 '../../../../images/public/buttons/de/abbrechen_on.gif',
					 '../../../../images/public/buttons/de/aendern_on.gif',
					 '../../../../images/public/buttons/de/aktualisieren_on.gif',
					 '../../../../images/public/buttons/de/alle_ergebnisse_on.gif',
					 '../../../../images/public/buttons/de/anzeigen_on.gif',
					 '../../../../images/public/buttons/de/bestellung_fortsetzen_on.gif',
					 '../../../../images/public/buttons/de/drucken_on.gif',
					 '../../../../images/public/buttons/de/kontakt_on.gif',
					 '../../../../images/public/buttons/de/senden_on.gif',
					 '../../../../images/public/buttons/de/starten_on.gif',
					 '../../../../images/public/buttons/de/startseite_on.gif',
					 '../../../../images/public/buttons/de/suchen_on.gif',
					 '../../../../images/public/buttons/de/warenkorb_leeren_on.gif',
					 '../../../../images/public/buttons/de/weiter_on.gif',
					 '../../../../images/public/buttons/de/zurueck_zum_warenkorb_on.gif',
					 '../../../../images/public/buttons/hauptnavi_lupe_on.gif',
					 '../../../../images/public/common/listenpunkt_menue_on.gif',
					 '../../../../images/public/common/listenpunkt_menue_off.gif');
*/
}


function P7_autoLayers() { //v1.5 by PVII - Ebenen ein- und ausblenden
 var g,b,k,f,u,k,j,args=P7_autoLayers.arguments,a=parseInt(args[0]);

 if(isNaN(a))a=0;
 if(!document.p7setc)
 {
 	p7c=new Array();
 	document.p7setc=true;
 	for(u=0;u<10;u++){
 		p7c[u]=new Array();
 	}
 }
 
 for(k=0;k<p7c[a].length;k++)
 {
 	if((g=MM_findObj(p7c[a][k]))!=null){
 		if(g.id != 'topsuche_hinweis' && g.id != do_not_auto_layer){
 			b=(document.layers)?g:g.style;b.visibility="hidden";
 		}
 	}
 }
 
 for(k=1;k<args.length;k++){
 	//blend out active layer do_not_auto_layer
 	if(do_not_auto_layer != ""){
 		theLayer = document.getElementById(do_not_auto_layer);
		theLayer.style.visibility = 'hidden';
 		do_not_auto_layer = ""
 		window.clearTimeout(timeout_id);
 		timeout_id = 0;
 	}
 	
	if((g=MM_findObj(args[k]))!=null)
 	{
 		b=(document.layers)?g:g.style;
 		b.visibility="visible";
 		f=false;
 		for(j=0;j<p7c[a].length;j++)
 		{
 			if(args[k]==p7c[a][j]) {f=true;}
 		}
 	if(!f){
 		p7c[a][p7c[a].length++]=args[k];}
 	}
 }
 
// Produkt-Assistenten verstecken, falls angezeigt 
// 	if (document.getElementById('topassistent').style.top == "0px") {
//		document.getElementById('topassistent').style.top = "-550px";
//	}

// Flash-Bühnenelement einblenden, falls vorhanden 
	ShowFlash();
}


function P7_autoLayersAssistent() { //v1.5 by PVII - nur für den Assistenten

// Produkt-Assistenten sichtbar positionieren
 //document.getElementById('topassistent').style.top = "0px";
 
 var g,b,k,f,u,k,j,args=P7_autoLayersAssistent.arguments,a=parseInt(args[0]);
 if(isNaN(a))a=0;
 if(!document.p7setc)
 {
 	p7c=new Array();
 	document.p7setc=true;
 	for(u=0;u<10;u++){
 		p7c[u]=new Array();
 	}
 }
 
 for(k=0;k<p7c[a].length;k++)
 {
 	if((g=MM_findObj(p7c[a][k]))!=null){
 		if(g.id != 'topsuche_hinweis' && g.id != do_not_auto_layer){
 			b=(document.layers)?g:g.style;b.visibility="hidden";
 		}
 	}
 }
 
 for(k=1;k<args.length;k++){
 	//blend out active layer do_not_auto_layer
 	if(do_not_auto_layer != ""){
 		theLayer = document.getElementById(do_not_auto_layer);
		theLayer.style.visibility = 'hidden';
 		do_not_auto_layer = ""
 		window.clearTimeout(timeout_id);
 		timeout_id = 0;
 	}
 	 
 	if((g=MM_findObj(args[k]))!=null)
 	{
 		b=(document.layers)?g:g.style;
 		b.visibility="visible";
 		f=false;
 		for(j=0;j<p7c[a].length;j++)
 		{
 			if(args[k]==p7c[a][j]) {f=true;}
 		}
 	if(!f){
 		p7c[a][p7c[a].length++]=args[k];}
 	}
 }
 
// Flash-Bühnenelement ausblenden, falls vorhanden 
HideFlash();
}

function selectSearch(IdOfChosen){
	//set back highlighting
	IdOfChosen = IdOfChosen.replace('src_','');
	IdOfChosen = "src_" + IdOfChosen;
	
	allATags = document.getElementsByName('search_category');
	for (i = 0 ; i < allATags.length ; i++){
		allATags[i].className = "";
	}

	//set highlighting
	theChosenElement = document.getElementById(IdOfChosen);
	theChosenElement.className = "aktiv";
	
	//set search_category in document
	theChosenElementField = document.getElementById('search_category');
	
	//clean idofchosen src_ 
	clean_IdOfChosen = IdOfChosen.replace('src_','');
	theChosenElementField.value = clean_IdOfChosen;
}

function doHighlight(bodyText, searchTerm)
{

  highlightStartTag = "<font style='color:black; background-color:#FFD876;'>";
  highlightEndTag = "</font>";

  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();

  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }

  return newText;
}

function PosLayer(LAYER_IN, NEW_XPOS, NEW_YPOS,ADDITIONAL_OFFSET) {
	//by mki - admin version
	//AKA 160805 -> added HTML as border tag
	var aTag, my_layer, my_img, lastTag;
	var leftpos = 0;
	var toppos = 0;
	var ie = document.all;
	my_layer = window.document.getElementById(LAYER_IN).style;
	my_img = window.document.getElementById('errorposimg');
	
	//2005-10-27 mki: added som fake values (120)
	NEW_XPOS = NEW_XPOS + 2 + ADDITIONAL_OFFSET;
	NEW_YPOS = NEW_YPOS - 120;
	
	//2005-10-28 mki: calc correct xpos cuz we have a variable width
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
		}
	}
	
	NEW_XPOS = NEW_XPOS - ((winW - 900) / 2) + 5 //900 is project depending
	
	my_layer.left = NEW_XPOS + 'px';
	my_layer.top =  NEW_YPOS + 'px';
}

function highlightSearchTerms(searchText)
{

	if (window.location.search != "") {
		var getParams = window.location.search.substr(1, window.location.search.length);
		var values = getParams.split('&');

		 shouldHighlight = 'false'

		for(i = 0 ; i < values.length ; i++){
			var shouldHighlightString = values[i].split('=');
			 if (shouldHighlightString[0] == 'highlight'){
			 	if(shouldHighlightString[1] == 'true'){
			 		shouldHighlight = 'true';
			 	}else{
			 		shouldHighlight = 'false';
			 	}

			 }
		}

		//alert(shouldHighlight);

		if (shouldHighlight == "true"){
		  //var rExp = /!!/gi;
		  //searchText = searchText.replace(rExp," ");
		  //var rExp1 = /!/gi;
		  //searchText = searchText.replace(rExp1,"");
		  searchArray = searchText.split("!");

		  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
			return false;
		  }

		  var bodyText = document.body.innerHTML;
		  for (var i = 0; i < searchArray.length; i++) {
		  	//alert("hier:" + searchArray[i]);
		  	
		  	if (searchArray[i] != ""){
				bodyText = doHighlight(bodyText, searchArray[i]);
			}
		  }

		  document.body.innerHTML = bodyText;
		  return true;
		}
	}

    return true
}


//show layer for x seconds
var do_not_auto_layer = "";
var timeout_id = 0;

function show_layer(layer_in, time_in){
	do_not_auto_layer = layer_in;
	theLayer = document.getElementById(layer_in);
	theLayer.style.visibility = 'visible';
	timeout_id = window.setTimeout('close_layer(\'' + layer_in + '\')',time_in);
}

function close_layer(layer_in){
	theLayer = document.getElementById(layer_in);
	theLayer.style.visibility = 'hidden';
	do_not_auto_layer = "";
}

function CloseAllPopups() {
	if (typeof(abbildung) == 'object') {
		abbildung.close();
	}
	if (typeof(properties) == 'object') {
		properties.close();
	}

	if (typeof(accessory) == 'object') {
		accessory.close();
	}
}

function HighLightFormField(ERROR_IN) {
	var element_name = new String();

	//check what kind of form field we have
	for (j=0; j<document.forms.length; j++) {

		formLength = window.document.forms[j].elements.length;
		for (i=0; i<formLength; i++) {
			thisElement = window.document.forms[j].elements[i];
			element_name = thisElement.name;

			if (element_name.indexOf(ERROR_IN) >= 0) {
				if (thisElement.type == 'select-multiple' ||thisElement.type == 'select-one' || thisElement.type == 'radio' || thisElement.type == 'checkbox') {
					if (thisElement.type == 'select-multiple' ||thisElement.type == 'select-one') {
						thisElement.className = 'dropDownerror';
					} else {
						//now try to get the table arround!
						table_tmp_id = element_name.replace(/r_req_/, '');
						table_id = table_tmp_id.replace(/c_req_/, '');
						thisTable = document.getElementById(table_id);
						if (thisTable.type == 'radio') {
							thisElement.className = 'radioncheckboxerror';
						} else {
							thisTable.className = 'radioncheckboxerror';
						}
					}
				} else {
					//'normal' other field
					thisElement.className = thisElement.className + 'error';
					thisElement.focus();
				}
			}
		}
	}
}

/* hides <select> and <applet> objects (for IE only) */
function hideElementLayer(elmID, overDivID) {
	if(document.all) {
		//set layer by id
		overDiv = document.getElementById(overDivID);
		overDivoL = overDiv.offsetLeft + ((document.body.clientWidth - 900 ) / 2);
		overDivoT = overDiv.offsetTop + 120
		
		//alert(overDivoL + ' ' + overDivoT);
		
		for( i = 0; i < document.all.tags( elmID ).length; i++ ) {
			obj = document.all.tags(elmID)[i];
			if( !obj || !obj.offsetParent ) {
				continue;
			}

			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
		
			//// no need to check till the Body-Tag
			while( objParent.tagName.toUpperCase() != "BODY" ) {
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			
			objHeight = obj.offsetHeight;
			objWidth = obj.offsetWidth;
			
			//alert('overDivID:' + overDivID +'\nLayer Pos:\noverDiv.offsetLeft = ' + (overDiv.offsetLeft + parLayLeft) + '\noverDiv.offsetWidth = ' + overDiv.offsetWidth + '\noverDiv.offsetTop = ' + (overDiv.offsetTop + 120) + '\noverDiv.offsetHeight = ' + overDiv.offsetHeight + '\n\nDrop Pos:\nobjLeft = ' + objLeft + '\nobjWidth = ' + objWidth + '\nobjTop = ' + objTop + '\nobjHeight = ' + objHeight);

			if(( overDivoL + overDiv.offsetWidth ) <= objLeft );			
			else if(( overDivoT + overDiv.offsetHeight ) <= objTop );
			else if( overDivoT >= ( objTop + objHeight ));
			else if( overDivoL >= ( objLeft + objWidth ));
			else
			{
				obj.style.visibility = "hidden";
			}
		}
	}
}

 /* unhides <select> and <applet> objects (for IE only)  */
function showElement( elmID )
{
  if(document.all)
  {
	for( i = 0; i < document.all.tags( elmID ).length; i++ )
	{
	  obj = document.all.tags( elmID )[i];

	  if( !obj || !obj.offsetParent )
	  {
		continue;
	  }

	  obj.style.visibility = "";
	}
  }
}

function FocusInputField(obj) {
 //by mki
 obj.className = obj.className + '-focus';
}

function BlurInputField(obj) {
 //by mki
 var current_class = obj.className;
 obj.className = current_class.replace(/-focus/, '');
}	

// Flash-Element ein- und ausblenden

function ShowFlash() {
if (document.getElementById('flash')) {
  document.getElementById('flash').style.visibility = 'visible'  
  }
}

function HideFlash() {
if (document.getElementById('flash')) {
  document.getElementById('flash').style.visibility = 'hidden'  
  }
}

function showHideLayer(chosenLayer){
	if(document.getElementById(chosenLayer).style.display== 'block'){
		document.getElementById(chosenLayer).style.display='none';
	}
	else {document.getElementById(chosenLayer).style.display='block';}
}