// --------------------- formulardaten validieren -----------------
// ----------------------------------------------------------------

function checksuchform(){

        var ok;
        var csval = document.suchform.zieltld.value;

        with (document.suchform){
                if (isBlank(callplz,'Bitte geben Sie eine Postleitzahl ein.')){
                        return false;}
                if (!min1(callplz,'Bitte geben Sie mindestens die erste Ziffer der Postleitzahl ein.')){
                        return false;}
                if ((csval == "de") || (csval == "fr") || (csval == "it")) {
                   if (!isNumber(callplz,'Bitte geben Sie eine Postleitzahl ein - nur Zahlen sind erlaubt.',0)) {
                        return false;
                   }
                } else {
                   if (!isNumber(callplz,'Bitte geben Sie eine Postleitzahl ein - nur Zahlen sind erlaubt.',1)) {
                        return false;
                   }
                }
                if ((csval == "de") || (csval == "fr") || (csval == "it")) {
                   if (!isMax(callplz,'Bitte geben Sie eine Postleitzahl ein - maximal fünf Ziffern.',5)) {
                        return false;
                   }
                } else {
                   if (!isMax(callplz,'Bitte geben Sie eine Postleitzahl ein - maximal vier Ziffern.',4)) {
                        return false;
                   }
                }
        }
}

function isBlank(s,message){
        var checkStr = s.value;
        checkStr = checkStr.replace(/^\s+|\s+$/g, '') ;
        document.suchform.callplz.value = checkStr;

        if ((checkStr.length > 0) && (checkStr != null) && (checkStr != "")) {
                return false;
        }
        alert(message);
        s.focus();
        return true;
}

function isNumber(s,message,pfirst){

  var checkOK = "1234567890";
  var checkStr = s.value;

  checkStr = checkStr.replace(/^\s+|\s+$/g, '') ;
  document.suchform.callplz.value = checkStr;

  if (pfirst == 1) {
     ch = checkStr.charAt(0);
     if (ch==0) {
        alert('Bitte geben Sie eine Postleitzahl ein - führende Null nicht erlaubt.');
        s.focus();
        return false;
     }
  }

  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
 {
   if (s.value == "2. Postleitzahl eingeben") {
      s.value = "";
   }
   alert(message);
   s.focus();
    return false;
  }
return true;
}

function min1(s,message){
  var checkStr = s.value;
  var allValid = true;
  if (checkStr.length < 1){
      allValid = false;
  }
  if (!allValid){
    alert(message);
    s.focus();
    return false;
  }
return true;
}

function isMax(s,message,pmax){
  var checkStr = s.value;
  var allValid = true;
  if (checkStr.length > pmax){
      allValid = false;
  }
  if (!allValid){
    alert(message);
    s.focus();
    return false;
  }
return true;
}

function isDefaultText(s,message) {

         if ((s.value != "nan1") && (s.value != "nan2")) {
                return false;
         }
        alert(message);
        s.focus();
        return true;
}

function isLeer(s,message) {

         if (s.value != "leer") {
                return false;
         }
        alert(message);
        s.focus();
        return true;
}


function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function clearcallplz() {
         document.suchform.callplz.value = '';

}
function resetcallplz() {
         document.suchform.callplz.value = ' Postleitzahl eingeben ';

}

// --------------------- mouseover kp-bild ------------------------
// ----------------------------------------------------------------

function linkinfo_on() {

         moving=true;
         showlayer();
         movelayer();
}
function linkinfo_off() {
		
         hidelayer();
         moving=false;
}

xpos=0;
ypos=0;
if(document.layers) {
        window.captureEvents(Event.MOUSEMOVE);
        window.onmousemove = koordinaten;
        }
        else {
             document.onmousemove = koordinaten;
        }
function koordinaten(e) {
        xpos = (document.layers || (document.getElementById && !document.all)) ? e.pageX : document.body.scrollLeft + event.clientX;
        ypos = (document.layers || (document.getElementById && !document.all)) ? e.pageY : document.body.scrollTop + event.clientY;
}

function movelayer() {
         thisxpos=xpos+20;

        if (top.IE4) {
           hg.style.left = xpos+20+'px';
           hg.style.top = ypos+20+'px';
        }
        if ((top.MOZ) || (top.OP5)) {
           document.getElementById('hg').style.left = xpos+20+'px';
           document.getElementById('hg').style.top = ypos+20+'px';
        }
        if (top.NS4) {
           document.layers['hg'].left = xpos+20;
           document.layers['hg'].top = ypos+20;
        }
        setTimeout('restartmove()',25);
}

function restartmove() {
         if (moving==true) {
            movelayer();
         }
}

function showlayer() {
        if (top.IE4) {
           hg.style.visibility = "visible";
        }
        if ((top.MOZ) || (top.OP5)) {
           document.getElementById('hg').style.visibility = "visible";
        }
}

function hidelayer() {
        if (top.IE4) {
           hg.style.visibility = "hidden";
        }
        if ((top.MOZ) || (top.OP5)) {
           document.getElementById('hg').style.visibility = "hidden";
        }
        moving=false;
}

// --------------------- popup kp-bild ----------------------------
// ----------------------------------------------------------------

var plink='';
var pfenster='';
var phoehe;
var pbreite;
var popenstring;

function pop(kpid,img,wi,he,tld) {

    plink = "../expo/expo_kp.php?kpid=" + kpid + "&img=" + img + "&zieltld=" + tld;

    pbreite = wi+100;
    if (pbreite>top.fbreite) {
       pbreite=top.fbreite;
    }

    phoehe = he+116;
    if (phoehe>top.fhoehe) {
       phoehe =top.fhoehe-30;
    }

    if (pfenster.closed == false) {
            pfenster.close();
    }
    popenstring = "toolbar=no,locationbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+pbreite+",height="+phoehe;
    setTimeout('popnow()',400);
}

function popnow() {
         pfenster = window.open(plink,'PROXXON',popenstring);
         pfenster.focus();
}
// ----------------------------------------------------------------
// ----------------------------------------------------------------