/* is called with <input type="text" onKeyup="this.value=withoutNonZipcodeCharacters(this.value)" (...) > */
var notAlertedYet = true;
function withoutNonZipcodeCharacters(text) {
   textWithout = text.replace(/[^\d]/gim,"");
   if (notAlertedYet && text != textWithout) {
     alert("The German zip code is numeric with 5 digits. (non-digit characters are deleted)");
     notAlertedYet = false;
   }
   return textWithout;
}
/* is called with <form onsubmit="return alertOnEmptyValue(this.datafieldname.value, 'text');" (...) > */
function alertOnEmptyValue(value, text) {
  if (value != '') {
    return true;
  } else {
    alert (text);
    return false;
  }
}
/* is called with <form onsubmit="return checkPlzBeforeSubmit(this.datafieldname.value);" (...) > */
function checkPlzBeforeSubmit(value) {
  if (value != '') {
    if (value.length == 5) {
      return true;
    } else {
      alert ('Bitte geben sie alle 5 Ziffern der Postleitzahl ein.');
      return false;
    }
  } else {
    alert ('Bitte geben sie eine 5-stellige Postleitzahl ein.');
    return false;
  }
}


/********************************************************************************
 
Name:     Flash plugin detect
 
*********************************************************************************/
var flashdetect = false;
function fnFlashDetect() {
 if (navigator.plugins && navigator.plugins.length) {
  for (x=0; x < navigator.plugins.length; x++) {
   if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
     flashdetect = true;      
    break;
   }
  }
 }
 else if (window.ActiveXObject) {
  for (x = 2; x <= 20; x++) {
   try {
    oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
    if(oFlash) {
     flashdetect = true;  
    }
   }
   catch(e) {}
  }
 }
}
fnFlashDetect(); // run on file load; 



/********************************************************************************
Name:     Flash embed einbindung
Beschreibung:  Schreibt flashcode raus.
@param swf       String path to swf file
@param width     Number value of movie width
@param height    Number value of movie height
@param alternateContent String of HTML to be served if flash is not installed
*********************************************************************************/
 
flash = new Object();
flash.insert = function(swf,width,height,alternateContent) {
	swf = swf.replace(/\./g,"%2E") // encode periods as %2e	
 if(flashdetect) {
 flashObject = '<embed src="'+swf+'" menu="false" quality="high" width="'+width+'px" height="'+height+'px" bgcolor="#f31c0a" align="middle" type="application/x-shockwave-flash" wmode="transparent" salign="T" pluginspage="http://www.adobe.com/shockwave/download/index.cgi" />'
 } else {
  flashObject = alternateContent;
 }
 document.write(flashObject);
}

