/*** Javascript www.bsw.de functions.js ***/

function openNewWindow(url)
{
	if(url.length > 5)
		window.open(url, '_blank');
}

function checkPlzOrt()
{
  if(document.suchform_karte.SearchLocation.value == '')
    alert('Bitte PLZ oder Ort angeben!');
  else
    document.suchform_karte.submit();
}

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_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_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;
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function findeL(obj){
  var lPos=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      lPos+=obj.offsetLeft
      obj=obj.offsetParent;
    }
  }
  else if(obj.x)lPos += obj.x;
  return lPos;
}

function findeO(obj){
  var oPos=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      oPos+=obj.offsetTop
      obj=obj.offsetParent;
    }
  }
  else if(obj.y)oPos+=obj.y;
  return oPos;
} 

function DivSetVisible(el,state){
  var DivRef=el.getElementsByTagName('ul')[0];
  var IfrRef=document.getElementById('DivShim');
  if(DivRef){
    if(state){
      DivRef.style.display="block";
      IfrRef.style.width=DivRef.offsetWidth+'px';
      IfrRef.style.height=DivRef.offsetHeight+'px';
      IfrRef.style.top=findeO(DivRef)+'px';
      IfrRef.style.left=findeL(DivRef)+'px';
      IfrRef.style.zIndex=1;
      IfrRef.style.display="block";
    }
    else{
      DivRef.style.display="none";
      IfrRef.style.display="none";
      
    }
  }
} 

function startMenu(aktuell){
        cssmenu = document.getElementById("csstopmenu");

        if ( cssmenu ) {
	        for (i=0; i<cssmenu.childNodes.length; i++) {
            node = cssmenu.childNodes[i];
             
            if (node.nodeName=="LI" && node.className.substring(0,9) == "mainitems" ) {
              node.onmouseover=function() { 
  							this.className = "mainitems_" + this.name + "_on over";
                DivSetVisible(this,true); 
              }

              if ( node.className.length > "mainitems".length ) { 
                node.onmouseout=function(){ 
                  this.className=this.className.replace("_on", "_off");
                  this.className=this.className.replace(" over", "");
                  DivSetVisible(this,false); 
                  if ( this.name == aktuell){
                    this.className=this.className.replace("_off", "_on");                          
                  }                     
  						  }
  	          }
    
	          }
	        }
	
    }
}

function PopUp(w,h,ziel) {
  h = h - 20; var x=0, y=0, parameter="";
  if (w < screen.availWidth || h < screen.availHeight) {
    x = (screen.availWidth - w - 12) / 2;
    y = (screen.availHeight - h - 104) / 2;
    if (window.opera) y = 0; // Opera positioniert unter den Symbolleisten
    if (x<0 || y<0) { x=0; y=0; }
    else parameter = "width=" + w + ",height=" + h + ",";
  }
  parameter += "left=" + x + ",top=" + y;
  parameter += ",menubar=yes,location=yes,toolbar=no,status=no";
  parameter += ",resizable=yes,scrollbars=yes";
  var Fenster = window.open(ziel,"PopUp",parameter);
  if (Fenster) Fenster.focus();
  return !Fenster;
}

/* Einkaufswelten Highlight */

function highlight_schalter(nr){
  document.getElementById("schalter_"+nr).className = "schalter_nummer_on";
} 

function highlight_schalter_aus(nr){
  if (nr != (curindex-1)) document.getElementById("schalter_"+nr).className = "schalter_nummer_off";
} 

function getslidehtml(theslide){
  var slidehtml=""
  if (theslide[1]!="")
    slidehtml='<a href="'+theslide[1]+'" target="'+theslide[2]+'">'
    slidehtml+='<img src="'+theslide[0]+'" border="0">'
  if (theslide[1]!="")
    slidehtml+='</a>'
  return slidehtml
}

function moveslide(){
  if (curpos<0){
    curpos=Math.min(curpos+degree,0)
    tempobj.style.left=curpos+"px"
  }
  else{
    clearInterval(dropslide)
  nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
  tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
  tempobj.innerHTML=getslidehtml(slideshowcontent[curindex])
  nextindex=(nextindex<slideshowcontent.length-1)? nextindex+1 : 0
  
  temp2=window.setTimeout("rotateslide()",pause);
//  setTimeout("rotateslide()",pause)
  }
}

function jumptoslide(which){
  curindex=which
  tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
  tempobj.innerHTML=getslidehtml(slideshowcontent[curindex])
  nextindex=(curindex<slideshowcontent.length-1)? curindex+1 : 0
  
  window.clearTimeout(temp2);
  rotateslide()
}

function rotateslide(){
//    alert("bild "+curindex);
  
  for (var i = 0; i < schalter_anzahl; i++){
    if (i==curindex) {
      document.getElementById("schalter_"+i).className = "schalter_nummer_on";
    }
    else{
      document.getElementById("schalter_"+i).className = "schalter_nummer_off";
    }
  }
  

  if (ie4||dom){
    resetit(curcanvas)
    crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
    crossobj.style.zIndex++
    var temp='setInterval("moveslide()",50)'
    dropslide=eval(temp)
    curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
  }
  else if (document.layers){
    crossobj.document.write(getslidehtml(slideshowcontent[curindex]))
    crossobj.document.close()
  }
  curindex=(curindex<slideshowcontent.length-1)? curindex+1 : 0
}


function resetit(what){
  curpos=parseInt(trans_width)*(-1)
  var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
  crossobj.style.left=curpos+"px"
}

function startit(){
  crossobj=ie4? eval("document.all."+curcanvas) : dom? document.getElementById(curcanvas) : document.tickernsmain.document.tickernssub
  if (ie4||dom){
    crossobj.innerHTML=getslidehtml(slideshowcontent[curindex])
    rotateslide()
  }
  else{
    document.tickernsmain.visibility='show'
    curindex++
    setInterval("rotateslide()",pause)
  }
}

/*ab hier kommen eigene Funktionen*/
//checkt die Email Adresse auf Gültigkeit
function emailCheck (emailStr) {

	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		return false;
   		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		return false;
   		}
	}

	if (user.match(userPat)==null) {
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
			return false;
   			}
		}
		return true;
	}
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			return false;
   		}
	}

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		return false;
	}

	if (len<2) {
		return false;
	}
			return true;
}

/* ekw-reise_reise�berblick_02 START */

function wonach_suchen_sie_highlight(nr){
  document.getElementById("wonach_suchen_sie_"+nr).className = "wonach_suchen_sie_on unten_abstand_5";
} 

function wonach_suchen_sie_highlight_off(nr){
  document.getElementById("wonach_suchen_sie_"+nr).className = "wonach_suchen_sie_off unten_abstand_5";
} 


/* ekw-reise_reise�berblick_02 ENDE */

function changeLoc()
{
  location.href=document.suchform_partner.partner.value + "?oss_str=" + document.suchform_partner.partner.options[document.suchform_partner.partner.selectedIndex].text;
}