empfehlung1off = new Image();
empfehlung1off.src = "frontend/grafx/empfehlung/romane.gif";
empfehlung1on = new Image();
empfehlung1on.src = "frontend/grafx/empfehlung/romane_over.gif";

empfehlung2off = new Image();
empfehlung2off.src = "frontend/grafx/empfehlung/kinderbuecher.gif";
empfehlung2on = new Image();
empfehlung2on.src = "frontend/grafx/empfehlung/kinderbuecher_over.gif";

empfehlung3off = new Image();
empfehlung3off.src = "frontend/grafx/empfehlung/ratgeber.gif";
empfehlung3on = new Image();
empfehlung3on.src = "frontend/grafx/empfehlung/ratgeber_over.gif";

empfehlung4off = new Image();
empfehlung4off.src = "frontend/grafx/empfehlung/sachbuecher.gif";
empfehlung4on = new Image();
empfehlung4on.src = "frontend/grafx/empfehlung/sachbuecher_over.gif";

empfehlung5off = new Image();
empfehlung5off.src = "frontend/grafx/empfehlung/bsondris.gif";
empfehlung5on = new Image();
empfehlung5on.src = "frontend/grafx/empfehlung/bsondris_over.gif";

function img_act(imgName, id) {
	document.getElementById(id).src = eval(imgName +".src");
}

function visibleEdit(me, id)  {
	if (document.getElementById) {
	    var mydiv = document.getElementById(me);
	    var myeditdiv = document.getElementById(id);
	    mydiv.style.display = (mydiv.style.display=='block'?'none':'block');
	    myeditdiv.style.display = (myeditdiv.style.display=='block'?'none':'block');
	}
}

function checkFormSuche() {
	var myText = document.frmquicksearch.quicksearch.value;
	
	if ((myText == 'Suchtext hier eingeben...') || (myText == '')) {
		alert("Bitte geben Sie einen Suchtext an!");
		return false;
	} else {
		document.frmquicksearch.submit();
		return true;
	}
}

function checkFormKontakt() {
	if (document.frmkontakt.name.value == "") {
		alert("Bitte geben Sie Ihren Namen an!");
		document.frmkontakt.name.focus();
		return false;
	}
	
	if (document.frmkontakt.msg.value == "") {
		alert("Bitte geben Sie einen Nachrichtentext ein!");
		document.frmkontakt.msg.focus();
		return false;
	}
	
	var address = document.frmkontakt.email.value;
	if (address == "") {
		alert("Bitte geben Sie Ihre Emailadresse an!");
		document.frmkontakt.email.focus();
		return false;
	} else {
        	if (!checkEmail(address, true)) {
          		alert ("Ihre EMail Adresse ist syntaktisch falsch!");
          		document.frmkontakt.email.focus();
          		return false;
          	} else {
          		return true;
          	}
	}
}

function checkAnmeldung() {
	if (document.frmanmeldung.anrede.value == "") {
		alert("Bitte geben Sie Ihre Anrede an!");
		document.frmanmeldung.anrede.focus();
		return false;
	}
	
	if (document.frmanmeldung.vname.value == "") {
		alert("Bitte geben Sie ihren Vornamen an!");
		document.frmanmeldung.vname.focus();
		return false;
	}
	
	if (document.frmanmeldung.nname.value == "") {
		alert("Bitte geben Sie ihren Nachnamen an!");
		document.frmanmeldung.nname.focus();
		return false;
	}
	
	if (document.frmanmeldung.strasse.value == "") {
		alert("Bitte geben Sie ihre Straße an!");
		document.frmanmeldung.strasse.focus();
		return false;
	}
	
	if (document.frmanmeldung.plz.value == "") {
		alert("Bitte geben Sie ihre Postleitzahl an!");
		document.frmanmeldung.plz.focus();
		return false;
	}
	
	if (document.frmanmeldung.ort.value == "") {
		alert("Bitte geben Sie ihren Wohnort an!");
		document.frmanmeldung.ort.focus();
		return false;
	}
	
	if (document.frmanmeldung.land.value == "") {
		alert("Bitte geben Sie ihr Land an!");
		document.frmanmeldung.land.focus();
		return false;
	}
	
	if (document.frmanmeldung.tel.value == "") {
		alert("Bitte geben Sie ihre Telefonnummer an!");
		document.frmanmeldung.tel.focus();
		return false;
	}
	
	var address = document.frmanmeldung.email.value;
	var addresswdh = document.frmanmeldung.emailwdh.value;
	
	if (address == "") {
		alert("Bitte geben Sie Ihre Emailadresse an!");
		document.frmanmeldung.email.focus();
		return false;
	} else {
        	if (!checkEmail(address, true)) {
          		alert ("Ihre EMail Adresse ist syntaktisch falsch!");
          		document.frmanmeldung.email.focus();
          		return false;
          	} else {
          		if (address != addresswdh) {
				alert("Die angegebenen Emailadressen stimmen nicht überein!");
				document.frmanmeldung.emailwdh.focus();
				return false;
			}
          	}
	}
	
	var pwd = document.frmanmeldung.pwd.value;
	var pwdwdh = document.frmanmeldung.pwdwdh.value;
	
	if (pwd != pwdwdh) {
		alert("Sie haben nicht zweimal das selbe Passwort angegeben!");
		document.frmanmeldung.pwdwdh.focus();
		return false;
	}
	
	if (document.frmanmeldung.agb.checked) {
		return true;
	} else {
		alert("Zum Fortfahren müssen Sie die AGB mit Anhacken der Auswahlbox akzeptieren!");
		document.frmanmeldung.agb.focus();
		return false;
	}
}

function checkFormAbholbereit() {
	if (document.frmabholung.name.value == "") {
		alert("Bitte geben Sie Ihren Namen an!");
		document.frmabholung.name.focus();
		return false;
	}
	
	if (document.frmabholung.wert.value == "") {
		alert("Bitte geben Sie einen Gutscheinwert ein!");
		document.frmabholung.wert.focus();
		return false;
	}
	
	var address = document.frmabholung.email.value;
	if (address == "") {
		alert("Bitte geben Sie Ihre Emailadresse an!");
		document.frmabholung.email.focus();
		return false;
	} else {
        	if (!checkEmail(address, true)) {
          		alert ("Ihre EMail Adresse ist syntaktisch falsch!");
          		document.frmabholung.email.focus();
          		return false;
          	} else {
          		return true;
          	}
	}
}

function isDigit( ch ) {
    if ( (ch >= '0') && (ch <= '9') )
      return true;
    else
      return false;
}


  function isAlpha( ch )
  {
    if ( ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) )
      return true;
    else
      return false;
  }


  function isAlnum( ch )
  {
    if ( isAlpha( ch ) || isDigit( ch ) )
      return true;
    else
      return false;
  }


  function notIn( str1, str2 )
  {
    var i = 0;
    var j = str2.length;
    for( ; i<j; i++ )
    {
      var str3 =  str2.charAt(i);
      if( str1.indexOf( str3 ) != -1 )
        return false;
    }
    return true;
  }


  function checkUsername( username, mustBeQuoted )
  {
    var i = 0;
    var j = username.length;
    if ( username.charAt(0) != '"' )
    {
      if ( (username.charAt(0) <  ' ') || (username.charAt(0) >  '~')
            || !notIn( mustBeQuoted, username.charAt(0) ) )
        return false;
      for( i=1; i<j; i++ )
      {
        if ( ( (username.charAt(i) < ' ') || (username.charAt(i) >  '~')
              || !notIn ( mustBeQuoted, username.charAt(i) ) )
             && ( username.charAt(i-1) != '\\' ) )
          return false;
      }
    }
    else
    {
      if ( username.charAt( j-1 ) != '"' )
        return false;
      for( i=1; i<j-1; i++ )
      {
        if ( ( (username.charAt(i) == '\n') || (username.charAt(i) == '\r')
              || (username.charAt(i) == '\"') )
            && (username.charAt(i-1) != '\\') )
          return false;
      }

    }
    return true;
  }


  function checkNr ( nr )
  {
    var i=0;
    var j=nr.length;

    if( j < 1 )
      return false;

    for( ; i<j; i++ )
      if( ( nr.charAt(i) < '0' ) || ( nr.charAt(i) > '9' ) )
        return false;

    return true;
  }


  function checkIpnr( ipnr )
  {
    var iL=0;
    var iC=0;
    var i=0;
    var sNr = "";

    for( ; i< ipnr.length; i++ )
    {
      if ( ipnr.charAt(i) == '.' )
      {
        if ( !iL || (iL> 3) || parseInt( sNr,10 ) > 255 )
          return false;
        iC++;
        iL = 0;
        sNr = "";
        continue;
      }
      if ( isDigit ( ipnr.charAt(i) ) )
      {
        iL++;
        sNr = sNr + ipnr.charAt(i);
        continue;
      }
      return false;
    }

    if ( parseInt( sNr,10 ) > 255 )
      return false;
    if ( ( (iC==3) && (iL>=1) && (iL<=3) ) || ( (iC==4) && (!iL) )  )
      return true;
    else
      return false;
  }


  function checkFqdn( fqdn )
  {
    var iL=0;
    var iC=0;
    var i=fqdn.length-1;

    if ( (fqdn.charAt(0) == '.') || (fqdn.charAt(0) == '-') )
      return false;
    if ( fqdn.charAt(i) == '.' )
      i=i-1;

    for( ; i>=0; i-- )
    {
      if ( fqdn.charAt(i) == '.' )
      {
        if ( iL < 2 && iC < 2 )
          return false;
        if ( fqdn.charAt(i-1) == '-' )
          return false;
        iC++;
        iL = 0;
        continue;
      }
      if ( isAlnum ( fqdn.charAt(i) ) )
      {
        iL++;
        continue;
      }
      if ( fqdn.charAt(i) == '-' )
      {
        if ( !iL )
          return false;
        iL++;
        continue;
      }
      return false;
    }

    if ( !iC || ( iL == 1 && iC < 2 ) || ( !iL && iC==1 ) ) {
      return false;
    }

    return true;

  }


  function checkHostname( hostname )
  {
    if ( hostname.charAt(0) == '[' )
    {
      if ( hostname.charAt(hostname.length-1) != ']' )
        return false;
      var ipnr = hostname.substring( 1, hostname.length -1 );
        return checkIpnr( ipnr );
    }

    if ( hostname.charAt(0) == '#' )
    {
      var nr = hostname.substring( 1, hostname.length );
        return checkNr( nr );
    }

    return checkFqdn( hostname );
  }


  function checkEmailAdr( address )
  {
    var status = true;
    var username = "";
    var hostname = "";

    if ( address.length < 8 )
      return false;

    var seperate = address.lastIndexOf("@");
    if ( seperate == -1 )
      return false;

    username = address.substring(0, seperate );
    if ( ! checkUsername( username, "<>()[],;:@\" " ) )
      return false;

    hostname = address.substring(seperate+1, address.length );
    if ( ! checkHostname( hostname ) )
      return false;

    return true;
  }


  function checkEmail( email, allowFullname )
  {
    var existFullname = false;
    var status = true;
    var fullname = "";
    var adress = "";
    if ( email.length < 8 )
      return false;
    var emailBegin = email.indexOf("<");
    var emailEnd = email.lastIndexOf(">");

    if ( (emailBegin == -1) && (emailEnd == -1) )
      return checkEmailAdr( email );

    if ( ( (emailBegin == -1) && (emailEnd != -1) )
        || ( (emailBegin != -1) && (emailEnd == -1) ) )
      return false;

    adress = email.substring( emailBegin+1, emailEnd );

    if ( ! checkEmailAdr( adress ) )
      return false;

    if ( email.length == adress.length + 2 )
      return true;
    else
      if ( ! allowFullname )
        return false;

    if ( emailEnd == email.length - 1 )
    {
      if ( emailBegin == 0 )
        return true;
      if ( email.charAt( emailBegin -1 ) != ' ' )
        return false;
      fullname = email.substring( 0, emailBegin-1 );
      return checkUsername ( fullname, "<>()[],;:@\"" );
    }

    return false ;

  }
  
  function showDetailSuche() {
  	document.getElementById("knoframe").src = "http://www.buchkatalog.de/kod-bin/isuche.cgi?uid=studia%2D22072007%2D223617434%2DC04332&amp;aktion=suche&amp;location=&amp;lang=deutsch&amp;dbname=Buchkatalog&amp;navigaktiv=&amp;caller=studia&amp;usecookie=ja&amp;callerdata=&amp;dbrestrict=&amp;savedbanner=&amp;ordVonWerbung=&amp;nojs=&amp;seteinzelpreis=&amp;pgchoice=&amp;naviggif=&amp;dbchoice=";
  	new Effect.Appear('kno', {duration: 1});
  }
