/*---------------------------------------------------------------------------------------------------------------------------
Functions from Dreamweaver
---------------------------------------------------------------------------------------------------------------------------
*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

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_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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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;
}


/*---------------------------------------------------------------------------------------------------------------------------
Own functions by McRobots (norbert@bissmeyer.de)
---------------------------------------------------------------------------------------------------------------------------
*/
// Set the preview window visible and fix it to the cursor
function movePreviewWindow(windowID,pictureHeight,evt){
	var leftBuffer = 0;
	if(document.getElementById(windowID)){
		if (!evt) var evt = window.event;
		document.getElementById(windowID).style.display = "block";
		
		if (window.innerWidth) leftBuffer = (window.innerWidth/2)-510;
    	else if (document.body && document.body.offsetWidth) leftBuffer = (document.body.offsetWidth/2)-510;
    	if(leftBuffer < 0) leftBuffer = 0;
    	
    	if (evt.pageX || evt.pageY){
    		// this doesn't work on IE6!! (works on FF,Moz,Opera7)
			document.getElementById(windowID).style.top = evt.pageY-pictureHeight+"px";
			document.getElementById(windowID).style.left = evt.pageX-leftBuffer+5+"px";	
    	}
    	else if (evt.clientX || evt.clientY){
    		// works on IE6,FF,Moz,Opera7
    		document.getElementById(windowID).style.top = evt.clientY+document.documentElement.scrollTop-pictureHeight+"px";
    		document.getElementById(windowID).style.left = evt.clientX+document.documentElement.scrollLeft-leftBuffer+5+"px";
    	}	
	}
}

function disappearPreviewWindow(windowID){
	if(document.getElementById(windowID)){
		document.getElementById(windowID).style.display = "none";
	}
}

// This function sets the complete page in the center and call the cookie function. Needed on the consumersite
function setCenter(){
	var leftBuffer = 0;
    if (window.innerWidth) leftBuffer = (window.innerWidth/2)-510;
    else if (document.body && document.body.offsetWidth) leftBuffer = (document.body.offsetWidth/2)-510;
    if(leftBuffer < 0) leftBuffer = 0;
	document.getElementById("body").style.backgroundPosition=leftBuffer+"px 0px";
	document.getElementById("footer").style.left=leftBuffer+"px";
	document.getElementById("content").style.left=leftBuffer+"px";
	setCookie(leftBuffer);
	//alert(leftBuffer);
}

// This function writes an cookie with the left value to center the page. Needed on the consumersite
function setCookie(value){
	var leftBuffer = 0;	if (value != ""){
		if (window.innerWidth) leftBuffer = (window.innerWidth/2)-510;
    	else if (document.body && document.body.offsetWidth) leftBuffer = (document.body.offsetWidth/2)-510;
    	if(leftBuffer < 0) leftBuffer = 0;	  	document.cookie = "Homann_PageAdjust="+leftBuffer+"; path=/";	}
}

function urlencode(str){
	str = str.replace(/ö/,"&ouml;");
	str = str.replace(/ü/,"&uuml;");
	str = str.replace(/ä/,"&auml;");
	str = str.replace(/Ö/,"&Ouml;");
	str = str.replace(/Ü/,"&Uuml;");
	str = str.replace(/Ä/,"&Auml;");	
	str = str.replace(/ß/,"&szlig;");
	return str;
}


function activateTab(tabID, contentID){
	// first all contents are set invisible
	for(var i=0; i < document.getElementsByTagName("div").length; i++){	
		if(document.getElementsByTagName("div")[i].id.search(/^content_[0-9]$/) == 0){
			document.getElementsByTagName("div")[i].style.display = "none";
		}
	}
	// first all tabs are not active
	for(var i=0; i < document.getElementsByTagName("a").length; i++){
		if(document.getElementsByTagName("a")[i].id.search(/^tab_[0-9]$/) == 0){
			document.getElementsByTagName("a")[i].style.backgroundColor="#FFFFFF";
			document.getElementsByTagName("a")[i].style.borderColor="#CCCCCC";
			document.getElementsByTagName("a")[i].style.top = "0px";
		}
	}
	// set the appropriate content visible, the color to the active tab...
	if(document.getElementById(contentID)) document.getElementById(contentID).style.display="block";
	if(document.getElementById(tabID)){
		document.getElementById(tabID).style.display="inline";
		document.getElementById(tabID).style.backgroundColor="#EEEEEE";
		document.getElementById(tabID).style.borderColor="#999999";
		document.getElementById(tabID).style.top = "-3px";
	}
	if(document.getElementsByName("tab")[0]) document.getElementsByName("tab")[0].value = tabID;
}

function leaveTab(tabID, contentID){
	var test;
	for(var i=0; i < document.getElementsByTagName("a").length; i++){
		if(document.getElementsByTagName("a")[i].id.search(/^tab_[0-9]$/) == 0){
			if(document.getElementsByTagName("a")[i].style.borderColor != "rgb(153, 153, 153) rgb(153, 153, 153) rgb(153, 153, 153) rgb(153, 153, 153)" && document.getElementsByTagName("a")[i].style.borderColor != "#999999"){ 
				document.getElementsByTagName("a")[i].style.backgroundColor="#FFFFFF";
				document.getElementsByTagName("a")[i].style.borderColor="#CCCCCC";
			}else document.getElementsByTagName("a")[i].style.backgroundColor="#EEEEEE";
		}
	}
}

function sendSubmit(errorText, normalBackgroundColor, errorBackgroundColor, formID){
	
	var countErrors = 0, firstError = 99999, firstErrorTagName = "", group1 = 0, noGroup = 1;
         var reg;
         var value, message;
         /* Check all input fields which are set with the demand class
         arguments[0] = Error text
         arguments[1] = normal background color
         arguments[2] = error background color
         arguments[3] = name or number of the form
          */
          
         for(j=0;j < document.forms[formID].getElementsByTagName("input").length;j++){
         	/* clear all fields */
                 if((document.forms[formID].getElementsByTagName("input")[j].className.indexOf("demand") >= 0) ||
                    (document.forms[formID].getElementsByTagName("input")[j].className.indexOf("email") >= 0) ||
                    (document.forms[formID].getElementsByTagName("input")[j].className.indexOf("file") >= 0) ||
                    (document.forms[formID].getElementsByTagName("input")[j].className.indexOf("number") >= 0))
                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor=normalBackgroundColor;

         	/* Check all field with a demand class */
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("demand") >= 0){
                  	if(document.forms[formID].getElementsByTagName("input")[j].type == "text" && document.forms[formID].getElementsByTagName("input")[j].value == ""){
                    	if(countErrors == 0 && firstError > j) firstError = j;
                        countErrors++;
                        document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
                    }
                  	if(document.forms[formID].getElementsByTagName("input")[j].type == "password" && document.forms[formID].getElementsByTagName("input")[j].value == ""){
                    	if(countErrors == 0 && firstError > j) firstError = j;
                        countErrors++;
                        document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
                    }                    
                  	if(document.forms[formID].getElementsByTagName("input")[j].type == "file" && document.forms[formID].getElementsByTagName("input")[j].value == ""){
                    	if(countErrors == 0 && firstError > j) firstError = j;
                        countErrors++;
                        document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
                    }
					if(document.forms[formID].getElementsByTagName("input")[j].type == "checkbox" && !document.forms[formID].getElementsByTagName("input")[j].checked){
                    	if(countErrors == 0 && firstError > j) firstError = j;
                        countErrors++;
                        document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
                    }                   
                 }
                 /* Check all fields with a day class of wrong values*/
                 reg = /\D/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("day") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text"){
	                         		if(value > 31 || value < 1){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         		}
	                         }
                         }
                 }
                 
                 /* Check all fields with a day class of wrong values*/
                 reg = /\D/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("month") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text"){
	                         		if(value > 12 || value < 1){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         		}
	                         }
                         }
                 }
                 
                 /* Check all fields with a year class of wrong values*/
                 reg = /\D/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("year") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text"){
	                         		if(value < 1000){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         		}
	                         }
                         }
                 }

                 /* Check all fields with a number class of wrong values*/
                 reg = /\D/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("number") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text" && reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         }
                         }
                 }
                 
                 /* Check all fields with a float class of wrong values*/
                 reg = /[a-zA-Z\+\-\s\*#öäüÖÄÜ\\\[\]\(\)ß\&\%]/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("float") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text" && reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         }
                         }
                 }                 

                 /* Check all fields with a email class of wrong values*/
                 reg = /.+@.+\..+/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("email") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "text" && !reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         }
                         }
                 }

                 /* Check all fields with a picture class of wrong values*/
                 reg1 = /.+.jpg/;
                 reg2 = /.+.gif/;
                 reg3 = /.+.png/;
                 reg4 = /.+.JPG/;
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("picture") >= 0){
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
	                         if(document.forms[formID].getElementsByTagName("input")[j].type == "file" && !reg1.test(value) && !reg2.test(value) && !reg3.test(value) && !reg4.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.forms[formID].getElementsByTagName("input")[j].style.backgroundColor =errorBackgroundColor;
	                         }
                         }
                 }

                 /* Check all fields which are in group1 */
                 if(document.forms[formID].getElementsByTagName("input")[j].className.indexOf("group1") >= 0){
                 	noGroup = 0;
                 	if((value = document.forms[formID].getElementsByTagName("input")[j].value) != ""){
                                  group1++;
                         }
                 }
         }

         for(j=0;j < document.forms[formID].getElementsByTagName("select").length;j++){
         	/* clear all fields */
            if(document.forms[formID].getElementsByTagName("select")[j].className.indexOf("demand") >= 0) document.forms[formID].getElementsByTagName("select")[j].style.backgroundColor=normalBackgroundColor;

         	/* Check all field with a demand class */
                 if(document.forms[formID].getElementsByTagName("select")[j].className.indexOf("demand") >= 0){
                  	if(document.forms[formID].getElementsByTagName("select")[j].value == ""){
                         	if(countErrors == 0 && firstError > j) firstError = j;
                         	countErrors++;
                            document.forms[formID].getElementsByTagName("select")[j].style.backgroundColor =errorBackgroundColor;
                         }
                 }
         }
         
         for(j=0;j < document.forms[formID].getElementsByTagName("textarea").length;j++){ 
         	if(document.forms[formID].getElementsByTagName("textarea")[j].className.indexOf("demand") >= 0){  
         		document.forms[formID].getElementsByTagName("textarea")[j].style.backgroundColor=normalBackgroundColor; 	       
	         	if(document.forms[formID].getElementsByTagName("textarea")[j] && document.forms[formID].getElementsByTagName("textarea")[j].value == ""){
	            	if(countErrors == 0 && firstError > j) firstError = j;
	                	countErrors++;
	                    document.forms[formID].getElementsByTagName("textarea")[j].style.backgroundColor =errorBackgroundColor;
	            }
         	}
         }                     
         
         if(group1 <= 0 && noGroup <= 0){
         	message = "Bitte wählen Sie mindestens ein Produkt aus.";
                 countErrors++;
         }
         else message = errorText;
         	
		 if (countErrors > 0){
			var parentTab = document.forms[formID].getElementsByTagName("input")[firstError].parentNode;
            while(parentTab.tagName != "BODY"){   
             	if(parentTab.tagName == "DIV"){         	
	                if(parentTab.id.search(/^content_[0-9]$/) == 0){
	                 		var part = parentTab.id.split("_");
	                 		activateTab("tab_"+part[1], parentTab.id);
	                 		break;
	                 }
                 }
                 parentTab = parentTab.parentNode;
            }
                          
            // marks the input field
            alert(message);                 
            if(document.forms[formID].getElementsByTagName("input")[firstError].type != "file") document.forms[formID].getElementsByTagName("input")[firstError].focus();
         	return false;         	
         }
         else{
         	return true;
         }
}

function send(){
	var countErrors = 0, firstError = 99999, firstErrorTagName = "", group1 = 0, noGroup = 1;
         var reg;
         var value, message;
         /* Check all input fields which are set with the demand class
         arguments[0] = Error text
         arguments[1] = normal background color
         arguments[2] = error background color
          */

         for(j=0;j < document.getElementsByTagName("input").length;j++){
         	/* clear all fields */
                 if((document.getElementsByTagName("input")[j].className.indexOf("demand") >= 0) ||
                    (document.getElementsByTagName("input")[j].className.indexOf("email") >= 0) ||
                    (document.getElementsByTagName("input")[j].className.indexOf("file") >= 0) ||
                    (document.getElementsByTagName("input")[j].className.indexOf("number") >= 0))
                 document.getElementsByTagName("input")[j].style.backgroundColor=arguments[1];


         	/* Check all field with a demand class */
                 if(document.getElementsByTagName("input")[j].className.indexOf("demand") >= 0){
                  	if(document.getElementsByTagName("input")[j].type == "text" && document.getElementsByTagName("input")[j].value == ""){
                         	if(countErrors == 0 && firstError > j) firstError = j;
                         	countErrors++;
                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
                         }
                  	if(document.getElementsByTagName("input")[j].type == "file" && document.getElementsByTagName("input")[j].value == ""){
                         	if(countErrors == 0 && firstError > j) firstError = j;
                         	countErrors++;
                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
                         }
					if(document.getElementsByTagName("input")[j].type == "checkbox" && !document.getElementsByTagName("input")[j].checked){
                         	if(countErrors == 0 && firstError > j) firstError = j;
                                 countErrors++;
                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
                    }                   
                 }

                 /* Check all fields with a day class of wrong values*/
                 reg = /\D/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("day") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text"){
	                         		if(value > 31 || value < 1){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         		}
	                         }
                         }
                 }
                 
                 /* Check all fields with a day class of wrong values*/
                 reg = /\D/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("month") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text"){
	                         		if(value > 12 || value < 1){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         		}
	                         }
                         }
                 }
                 
                 /* Check all fields with a year class of wrong values*/
                 reg = /\D/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("year") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text"){
	                         		if(value < 1000){
		                                 if(countErrors == 0 && firstError > j) firstError = j;
		                                 countErrors++;
		                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         		}
	                         }
                         }
                 }

                 /* Check all fields with a number class of wrong values*/
                 reg = /\D/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("number") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text" && reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         }
                         }
                 }
                 
                 /* Check all fields with a float class of wrong values*/
                 reg = /[a-zA-Z\+\-\s\*#öäüÖÄÜ\\\[\]\(\)ß\&\%]/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("float") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text" && reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         }
                         }
                 }                 

                 /* Check all fields with a email class of wrong values*/
                 reg = /.+@.+\..+/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("email") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "text" && !reg.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         }
                         }
                 }

                 /* Check all fields with a picture class of wrong values*/              
                 reg1 = /.+.jpg/;
                 reg2 = /.+.gif/;
                 reg3 = /.+.png/;
                 reg4 = /.+.JPG/;
                 reg5 = /.+.PNG/;
                 if(document.getElementsByTagName("input")[j].className.indexOf("picture") >= 0){
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
	                         if(document.getElementsByTagName("input")[j].type == "file" && !reg1.test(value) && !reg2.test(value) && !reg3.test(value) && !reg4.test(value) && !reg5.test(value)){
	                                 if(countErrors == 0 && firstError > j) firstError = j;
	                                 countErrors++;
	                                 document.getElementsByTagName("input")[j].style.backgroundColor =arguments[2];
	                         }
                         }
                 }

                 /* Check all fields which are in group1 */
                 if(document.getElementsByTagName("input")[j].className.indexOf("group1") >= 0){
                 	noGroup = 0;
                 	if((value = document.getElementsByTagName("input")[j].value) != ""){
                                  group1++;
                         }
                 }
         }

         for(j=0;j < document.getElementsByTagName("select").length;j++){
         	/* clear all fields */
            if(document.getElementsByTagName("select")[j].className.indexOf("demand") >= 0) document.getElementsByTagName("select")[j].style.backgroundColor=arguments[1];

         	/* Check all field with a demand class */
                 if(document.getElementsByTagName("select")[j].className.indexOf("demand") >= 0){
                  	if(document.getElementsByTagName("select")[j].value == ""){
                         	if(countErrors == 0 && firstError > j) firstError = j;
                         	countErrors++;
                            document.getElementsByTagName("select")[j].style.backgroundColor =arguments[2];
                         }
                 }
         }
         
         for(j=0;j < document.getElementsByTagName("textarea").length;j++){ 
         	if(document.getElementsByTagName("textarea")[j].className.indexOf("demand") >= 0){  
         		document.getElementsByTagName("textarea")[j].style.backgroundColor=arguments[1]; 	       
	         	if(document.getElementsByTagName("textarea")[j] && document.getElementsByTagName("textarea")[j].value == ""){
	            	if(countErrors == 0 && firstError > j) firstError = j;
	                	countErrors++;
	                    document.getElementsByTagName("textarea")[j].style.backgroundColor =arguments[2];
	            }
         	}
         }                     

         if(group1 <= 0 && noGroup <= 0){
         	message = "Bitte wählen Sie mindestens ein Produkt aus.";
                 countErrors++;
         }
         else message = arguments[0];

		 if (countErrors > 0){
                 

                 var parentTab = document.getElementsByTagName("input")[firstError].parentNode;
                 while(parentTab.tagName != "BODY"){   
                 	if(parentTab.tagName == "DIV"){          	
                 	if(parentTab.id.search(/^content_[0-9]$/) == 0){
                 		var part = parentTab.id.split("_");
                 		activateTab("tab_"+part[1], parentTab.id);
                 		break;
                 	}}
                 	parentTab = parentTab.parentNode;
                 }               
                 // marks the input field
                 alert(message);                 
                 if(document.getElementsByTagName("input")[firstError].type != "file") document.getElementsByTagName("input")[firstError].focus();
         }
         else document.forms[0].submit();
}

function checker(){
	var changes = 0;
	var i=0;
	for(i=0; i<document.getElementsByName(arguments[0].name).length; i++){
         	 /* Set color on leave */
	         if(document.getElementsByName(arguments[0].name)[i].className.indexOf("demand") >= 0){
                  	if(document.getElementsByName(arguments[0].name)[i].value != "")
	                	document.getElementsByName(arguments[0].name)[i].style.backgroundColor=arguments[1];
	         }
             else document.getElementsByName(arguments[0].name)[i].style.backgroundColor=arguments[1];
    }
}

function loeschen(){
         var res = confirm(arguments[0]);
         if(res == true) location.href = arguments[1];
}

function Counter(){
	switch(arguments[0]){
         	case "inc":
                 	document.getElementById("changeCounter").value++;
                         changeStatusFeld("ungesichert", "#BF0000");
                         break;
         	case "dec":
                 	document.getElementById("changeCounter").value--;
                         break;
         	case "set":
                 	document.getElementById("changeCounter").value = arguments[1];
                         break;
         	case "get":
                 	return document.getElementById("changeCounter").value;
                         break;
         	case "reset":
                 	document.getElementById("changeCounter").value = 0;
                         break;
         	case "check":
                 	if(document.getElementById("changeCounter").value > 0){
                         	var res = confirm("Es sind Daten geändert worden aber noch nicht gespeichert!");
                         	if(res == false) location.reload();
                         }
                         break;
                 default:
                 	break;
         }
}

function changeStatusFeld(text, bgColor){
         if(document.getElementById("statusFeld")){
               var st = document.getElementById("statusFeld");
               if(bgColor != "#FFFFFF" || bgColor != "#ffffff"){
               	st.style.backgroundColor = bgColor;
               	st.style.color = "#FFFFFF";
               	st.className = "verdena8weiss";
               }else {
               	st.style.backgroundColor = bgColor;
               	st.className = "verdena8grau";
               }
               var rd_Laenge = st.firstChild.nodeValue.length;
               st.firstChild.replaceData(0, rd_Laenge, text);
               document.getElementById("statusFeld").style.display = "block";
               //st.style.display = "block";
         }
}

/* Class to open a little note window
	onMouseOver = open_note()
         onMouseOut = close_note()
   The dealy for open the window is set on 1 secound as default
*/
var NOTE = {
	 container: null,
          wait: null,
          step: null,
          delay: null,
          maxWidth: null,
          maxWindowWidth: null,
          maxHeight: null,
          maxWindowHeight: null,
	 erzeugen: function(text, delay, bgcolor){
                  NOTE.step = 0;
                  NOTE.maxWidth = 150;
                  if(text.length <= 20) NOTE.maxHeight = 20;
                  if(text.length > 20 && text.length <= 40) NOTE.maxHeight = 40;
                  if(text.length > 40 && text.length <= 60) NOTE.maxHeight = 60;
                  if(text.length > 60 && text.length <= 80) NOTE.maxHeight = 80;
                  if(text.length > 80) NOTE.maxHeight = 100;
                  NOTE.delay = parseInt(delay);

	         NOTE.container = document.createElement("div");
	         NOTE.container.id = "fenster";
                  NOTE.container.style.display = "none";
                  NOTE.container.style.overflow = "hidden";
                  var img = document.createElement("img");
                  img.src = "images/pfeil1.gif";
                  img.style.width = "17px";
                  img.style.height = "35px";
                  img.style.position = "absolute";
                  img.style.left = "0px";
                  img.style.top = "0px";
                  img.style.zIndex = "98";
                  NOTE.container.appendChild(img);
                  var p = document.createElement("p");
                  p.style.margin = "0px";
                  p.style.paddingLeft = "2px";
                  p.style.paddingRight = "2px";
                  p.style.width = NOTE.maxWidth - 22 +"px";
                  p.style.height = NOTE.maxHeight -2 +"px";
                  p.style.position = "absolute";
                  p.style.left = "16px";
                  p.style.top = "0px";
                  p.style.backgroundColor = bgcolor;
                  p.style.border = "1px solid black";
                  p.appendChild(document.createTextNode(text));
                  NOTE.container.appendChild(p);

                  NOTE.wait = window.setInterval("NOTE.open()", 500);
                  document.onmousemove = NOTE.ziehen;
                  document.getElementsByTagName("body")[0].appendChild(NOTE.container);
	         return NOTE.container;
	 },
          ziehen: function(ereignis){
                 if (window.event){                                              /* Für Firefox */
                 	NOTE.container.style.left = window.event.x + 10 + "px";
                         NOTE.container.style.top = window.event.y + 10 + "px";
                 }
                 else{                                                           /* Für IE */
                         NOTE.container.style.left = ereignis.clientX + 10 + "px";
                 	NOTE.container.style.top = ereignis.clientY + 10 + "px";
                 }
          },
          open: function(){
          	NOTE.step++;
          	if(NOTE.step >= NOTE.delay){
                 	NOTE.container.style.width = NOTE.maxWidth +"px";
                  	NOTE.container.style.height = NOTE.maxHeight +"px";
                 	NOTE.container.style.display = "block";
                         window.clearInterval(NOTE.wait);
                 }
          },
          close: function(){
          	window.clearInterval(NOTE.wait);
                 document.getElementsByTagName("body")[0].removeChild(NOTE.container);
          }
}

function open_note(text){
	if(document.getElementById("fenster") == null) NOTE.erzeugen(text,1,'#FEFEE5');
}
function close_note(){
	if(document.getElementById("fenster") != null) NOTE.close();
}