window.name="neumann_main";
var zoomWin,searchWin;

function urlEncode(rawText){
      // this converts the rawText into x-www-form-urlencoded format (and space to "%20")
      var encoded = "";
      for(var n=0; n<rawText.length; n++) {
        var c=rawText.charCodeAt(n);
        // all chars in range 0-127 => 1byte   without (A-Z, a-z, 0-9, *, -, ., _)
        if (c<128) {
            if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || (c==42) || (c==45) || (c==46) || (c==95))
                encoded += String.fromCharCode(c);
            else 
                encoded += '%' + c.toString(16);
        }
        // all chars in range 127 to 2047 => 2byte
        else if((c>127) && (c<2048)) {
          encoded += '%' + ((c>>6)|192).toString(16);
          encoded += '%' + ((c&63)|128).toString(16);
        }
        // all chars in range 2048 to 66536 => 3byte
        else {
          encoded += '%' + ((c>>12)|224).toString(16);
          encoded += '%' + (((c>>6)&63)|128).toString(16);
          encoded += '%' + ((c&63)|128).toString(16);
        }
      }
      return encoded;
    }
	
function overMenu1(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					obj.className=cname+"Over";
				}
			}
		}
	}
	
	function outMenu1(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					pos=cname.indexOf("Over");
					if(pos>0){
						obj.className=cname.substring(0,pos);
					}
				}
			}
		}
	}
	
	function overIconMenu(id){
		if(document.getElementById){
			obj=document.getElementById("top"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					obj.className=cname+"Over";
				}
			}
			obj=document.getElementById("label"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					obj.className=cname+"Over";
				}
			}
			obj=document.getElementById("link"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					obj.className=cname+"Over";
				}
			}
		}
	}
	
	function outIconMenu(id){
		if(document.getElementById){
			obj=document.getElementById("top"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					pos=cname.indexOf("Over");
					if(pos>0){
						obj.className=cname.substring(0,pos);
					}
				}
			}
			obj=document.getElementById("label"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					pos=cname.indexOf("Over");
					if(pos>0){
						obj.className=cname.substring(0,pos);
					}
				}
			}
			obj=document.getElementById("link"+id);
			if(obj){
				if(obj.className){
					cname=obj.className;
					pos=cname.indexOf("Over");
					if(pos>0){
						obj.className=cname.substring(0,pos);
					}
				}
			}
		}
	}
	
	function showStartTeaserImg(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.display="block";
			}
		}
	}
	function hideStartTeaserImg(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.display="none";
			}
		}
	}
	
	function setVerticalMenuImg(pic){
		if(document.getElementById){
			obj=document.getElementById("contentLeftCell");
			if(obj){
				obj.style.backgroundImage="url("+pic+")";
			}
		}
	}
	
	function zoom(zoomImg,zoomLabel,w,h){
		if(typeof(zoomWin)!="undefined"){
			if(zoomWin){
				zoomWin.close();
			}
		}
		zoomWin=window.open("zoom.php?zoomimg="+escape(zoomImg)+"&zoomlabel="+escape(zoomLabel)+"&w="+w+"&h="+h,"zoom","width="+w+",height="+h);
	}
	
	function showContact(id){
		if(formArray){
			for(i=0;i<formArray.length;i++){
				if(id==formArray[i]){
					document.getElementById("cf_"+formArray[i]).style.display="block";
					document.getElementById("arrow_"+formArray[i]).src="shared/arrow1_down.gif"
				}else{
					document.getElementById("cf_"+formArray[i]).style.display="none";
					document.getElementById("arrow_"+formArray[i]).src="shared/arrow1.gif"
				}
			}
		}
	}
	
	function overFooterButton(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.backgroundColor="#E68B0C";
			}
		}
	}
	
	function outFooterButton(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.backgroundColor="#969898";
			}
		}
	}
	function overFrButton(id){
		var obj=document.getElementById("langMsg");
		if (obj){
			var objBtn=document.getElementById(id);
			if(objBtn){
				var t =getTop(objBtn);
				var l =getLeft(objBtn);
				obj.style.top=t+21;
				obj.style.display="block";
				obj.style.left=l-133;
			}
		}
	}
	function outFrButton(id){
		var obj=document.getElementById("langMsg");
		if (obj){
			var objBtn=document.getElementById(id);
			if(objBtn){
				
				obj.style.top=-500;
				obj.style.display="none";
			}
		}
	}
	
	function overMicFinderButton(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.backgroundColor="#E68B0C";
			}
		}
	}
	
	function outMicFinderButton(id){
		if(document.getElementById){
			obj=document.getElementById(id);
			if(obj){
				obj.style.backgroundColor="#374A51";
			}
		}
	}
	
	function textLinkOut(obj){
		if(obj){
			if(obj.className){
				obj.className="textLink";
			}
		}
	}
	
	function textLinkOver(obj){
		if(obj){
			if(obj.className){
				obj.className="textLinkOver";
			}
		}
	}
	
	function checkUserEmail(lang){
		
		var ret=false;
		if(document.login.useremail){
			
			ret=validateEmail(document.login.useremail.value);
		}else{
			ret=true;
		}
		if (ret==false){
			alert(emailValidate);
			
		}
		return ret;
	}
	function checkNewsMailer(lang){
		var errx=false;
		var errxe=false;
		/* Auskommentiert von Matthias, 14.08.2009 var ff= document.newsmailer.forename;
		if(ff.value.length < 1){errx=true;}
		var ff= document.newsmailer.lastname;
		if(ff.value.length < 1){errx=true;}
		var ff= document.newsmailer.company;
		if(ff.value.length < 1){errx=true;}
		
		var ff= document.newsmailer.city;
		if(ff.value.length < 1){errx=true;}
		var ff= document.newsmailer.country;
		if(ff.value.length < 1){errx=true;}
		var ff= document.newsmailer.business;
		if(ff.value.length < 1){errx=true;}
		var ff= document.newsmailer.position;
		if(ff.value.length < 1){errx=true;} */
		ff= document.newsmailer.email;
		if(validateEmail(ff.value)==false){errxe=true;}
		
		if(errx==true){
		  	
			alert(formValidate);
			return false;
		}else{
			if(errxe==true){
		  		
				alert(emailValidate);
				return false;
			}else{
				return true;
			}
		}
	}
	
	openCount = 0;
  popupRef = null;

  /* opens new window */
  function popupSizedCentered(location, width, height) {

    LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-height)/2 : 0;

    ref = window.open(location, 'stefanmaycom', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width="+width+",height="+height+",top="+TopPosition+",left="+LeftPosition);

    ref.focus();
    return ref;

  }



  // opens new window for microphone finder
  function startMicFinder(lang) {

    url = "micfinder/micfinder.php?lang="+lang;
    width = 1016;
    height = 606;

    if( openCount == 0 ) {

      popupRef = popupSizedCentered(url, width, height);

    } else {

      if ( popupRef.closed == true ) {

        popupRef = popupSizedCentered(url, width, height);

      }

    }

    openCount++;

    popupRef.focus();

  }
  
  function checkContactForm(id,lang){
  	var errx=false;
	var errxe=false;
	var ff= document.forms["contactform"+id].firstname;
	if(ff.value.length < 1){
		errx=true;
	}
	ff= document.forms["contactform"+id].name;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].subject;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].message;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].street;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].city;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].zip;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].telephone;
	if(ff.value.length<1){errx=true;}
	ff= document.forms["contactform"+id].email;
	if(validateEmail(ff.value)==false){errxe=true;}
	if(errx==true){
	  	
		alert(formValidate);
		return false;
	}else{
		if(errxe==true){
	  	
			alert(emailValidate);
			return false;
		}else{
			return true;
		}
	}
	
  }
  
  function validateEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function openPopup(url){
		window.open(url,"popup","width=800,height=647,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=no");
	}
function doSearch(url,xlang,ul,auth){
		url+="xlang="+xlang;
		url+="&ul=lang%3D"+xlang;
		url+="&auth="+auth;
		q= urlEncode(document.searchengine.q.value);
		url+="&q="+q;
		if(typeof(searchWin)!="undefined"){
			if(searchWin){
				searchWin.close();
			}
		}
		searchWin=window.open(url,"popup","width=800,height=647,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=no");
	}
function navResultPage(url){
	if(window.opener){
		opener.focus();
		window.opener.document.location.href=url;
		return true;
	}
}
	
function openforum(){
	var ah=screen.availHeight;
	var aw=screen.availWidth;
	var url="forums/index.php?site=neumann&lang=en";
	window.open(url,"forum","width="+aw+",left=0,top=0,height=700,toolbar=yes,location=no,directories=no,scrollbars=yes,status=no,menubar=yes,resizable=yes");
}

function getLeft(l){
  if (l.offsetParent) return (l.offsetLeft + getLeft(l.offsetParent));
  else return (l.offsetLeft);
}

function getTop(l){
  if (l.offsetParent) return (l.offsetTop + getTop(l.offsetParent));
  else return (l.offsetTop);
}


function getMTo(tld,d,n,s,l){
	var e=n + '&#64;' + d + '&#46;' + tld;
	var a ="mailto:" +e;
	if(typeof s != 'undefined'){
		a = a + '?subject='+s;
	}
	if(typeof l == 'undefined'){
		l=e;
	}
	a= '<img src="shared/arrow_or.gif" width="8" border="0" height="8" alt=""/><a onmouseout="textLinkOut(this)" onmouseover="textLinkOver(this)" class="textLink" href="' +a+ '">'+l+'</a>';
	document.write(a);
}
