// Main Utilities

function launchImpressum() {
	var WndImpressum = window.open("/impressum.html","Impressum", 
		  "width=510,height=600,screenX=20,screenY=20,resizable=0,toolbar=1,location=0,status=0,scrollbars=yes");
	WndImpressum.focus();
}
function launchRecht() {
	var WndRecht = window.open("/recht.html","Rechtliche_Hinweise", 
		  "width=500,height=600,screenX=20,screenY=20,resizable=0,toolbar=1,location=0,status=0,scrollbars=yes");
	WndRecht.focus();
}
function launchDatenschutz() {
	var WndDaten = window.open("/datenschutz.html","Datenschutz", 
		  "width=500,height=600,screenX=20,screenY=20,resizable=0,toolbar=1,location=0,status=0,scrollbars=yes");
	WndDaten.focus();
}
/**
 Function to launch "Shop AGB" window
*/
function launchShopAGB()
{
  var agbWindow = "";
  agbWindow = launchWindow( "/eShopping/user/AGBFrame.html", "AGB", 600, 625,
                'left=185,top=125,status=no,toolbar=no,menubar=no,directories=no,scrollbars=yes');
  agbWindow.focus();
}

function openCheck(){
        newwin=open("/systemCheck/preLauncher.jsp","sysCheck1","width=720,height=600,left=100,top=50,scrollbars=yes");
        newwin.top.focus();
}

function openTipps(){
        newwin=open("/systemCheck/tipps/tipps.jsp","tipps","width=720,height=600,left=100,top=50,scrollbars=yes");
        newwin.top.focus();
}

function launchKursDescription( kursID, personID ){
loc = "/mediathek/KursDescriptionWindow.jsp?kursID=" + kursID + "&personID=" + personID;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+800+",height="+600+",left="+59+",top="+10);
newwin.top.focus();
}

function launchMPSession(param, agName){
//alert( "launchMPSession" );
//alert( "launchMPSession param: " + param + ", agName: " + agName );
loc = "/mp/sessionIndex.jsp?session=" + param + "&agName=" + agName;
//alert( "launchMPSession: url: " + loc );
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+714+",left="+39+",top="+50);
newwin.top.focus();
//parent.window.close();
}


function launchMP(param){
loc = "/mp/preindex.jsp?agid="+param;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+714+",left="+39+",top="+10);
newwin.top.focus();
}

function launchKonferenzSession(param){
loc = "/konferenz/sessionIndex.jsp?session="+param;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+678+",left="+39+",top="+50);
newwin.top.focus();
//parent.window.close();
}

function launchBLounge(param){
loc = "/bLounge/preindex.jsp?agid="+param;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+678+",left="+39+",top="+25);
newwin.top.focus();
}


function launchBriefCaseWB(ownerId){
        loc = "/wb/index.jsp?type=byOwner";
        w=945;
        h=688;
        newwin=open(loc,"briefwb","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
        newwin.top.focus();
}


function launchBriefCaseWBA4( ownerId ){
        loc = "/wb/index.jsp?type=byOwner&videoboardType=SmartboardA4";
//		height = 690; width = 849;
w=849;
h=690;
        newwin=open(loc,"briefwb","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
        newwin.top.focus();
}

function launchWB(agid, sessionName){
w=945;
h=688;
loc = "/wb/index.jsp?agid="+agid;
xtr = "";
if (sessionName){
        loc+="&sessionName="+sessionName;
        xtr = "sess";
}
if (agid<0)
        xtr += "_" + (-agid);
else
        xtr += "p" + agid;

newwin=open(loc,"wb" + xtr,"statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

function launchWBAufzeichnung(agid, sessionName, thema, gruppe){
w=945;
h=688;
loc = "/wb/index.jsp?agid="+agid;
xtr = "";
if (sessionName){
        loc+="&sessionName="+sessionName;
        xtr = "sess";
}
if (agid<0)
        xtr += "_" + (-agid);
else
        xtr += "p" + agid;

loc += "&aufThema=" + thema;
loc += "&aufGruppe=" + gruppe;

newwin=open(loc,"wb" + xtr,"statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

function launchWBA4(agid, sessionName){
//		height = 690; width = 849;
w=849;
h=690;
//loc = "/wb/videopreindex.jsp?agid="+agid+"&videoboardType=smartboardA4";
loc = "/wb/index.jsp?agid="+agid+"&videoboardType=smartboardA4";
xtr = "";
if (sessionName){
        loc+="&sessionName="+sessionName;
        xtr = "sess";
}
if (agid<0)
        xtr += "_" + (-agid);
else
        xtr += "p" + agid;

newwin=open(loc,"wb" + xtr,"statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

function launchWBA4Aufzeichnung(agid, sessionName, thema, gruppe){
//		height = 690; width = 849;
w=849;
h=690;
//loc = "/wb/videopreindex.jsp?agid="+agid+"&videoboardType=smartboardA4";
loc = "/wb/index.jsp?agid="+agid+"&videoboardType=smartboardA4";
xtr = "";
if (sessionName){
        loc+="&sessionName="+sessionName;
        xtr = "sess";
}
if (agid<0)
        xtr += "_" + (-agid);
else
        xtr += "p" + agid;

loc += "&aufThema=" + thema;
loc += "&aufGruppe=" + gruppe;

newwin=open(loc,"wb" + xtr,"statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

/**
The commObjectID is sent as the agid.
*/
function launchVideoWB( commObjectID, arbeitsgruppeID ){
w=945;
h=688;
loc = "/wb/videopreindex.jsp?agid="+commObjectID + "&arbeitsgruppeID=" + arbeitsgruppeID;
newwin = open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

function launchVideoWBA4( commObjectID, arbeitsgruppeID ){
//alert( "launchVideoWBA4" );
//		height = 690; width = 849;
w=849;
h=690;
loc = "/wb/videopreindex.jsp?agid=" + commObjectID + "&videoboardType=smartboardA4&arbeitsgruppeID=" + arbeitsgruppeID;
//alert( "mainUtils launchVideoWBA4, loc: " + loc );
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+30+",top="+20);
newwin.top.focus();
}

function showPM(){
  w=1000;
  h=600;
  l=10;
  t=30;
  newwin=open("/project/index.jsp?navigationModule=TopNavigation&fzModule=Navigation&toDo=ShowProjektmanagement&bottomPageArgs=navigationModule%3dProjektmanagement%26fzModule%3dProjektmanagement%26toDo%3dProjekteVerwalten","_blank","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+l+",top="+t);
  newwin.top.focus();

}

function launchStatisticHinweis(){
  //alert('Bitte warten!');
  var sWindow = "";
  sWindow = launchWindow( "/statistic/Hinweis.jsp", "Statistik", 310, 503,
          'left=330,top=340,status=no,toolbar=no,menubar=no,directories=no,scrollbars=no');
  sWindow.focus();
}

function kursStart(loc, height, width, x, y){
        //alert(loc);
        if( isEmpty(height) ) height = 400;
        if( isEmpty(width) ) width = 600;
        if( isEmpty(x) ) width = 189;
        if( isEmpty(y) ) width = 200;                
        
        var strArgs = "statusbar=yes,scrollbars=no,resizable=no,width="+width+",height="+height+",left="+x+",top="+y;
        
        //alert( loc );
        //alert( strArgs );
        
        newwin=open(loc,"kurs",strArgs);
        newwin.top.focus();
}



function launchVP(param){
loc = "/konferenz/preindex.jsp?objectid="+param;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+678+",left="+39+",top="+25);
newwin.top.focus();
}

function launchVPList(){
loc = "/comm/commUserOpenList.do?typeId=3&arbeitsgruppeid=-1";
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+906+",height="+678+",left="+39+",top="+25);
newwin.top.focus();
}

function launchVC(agid){
loc = "/vc/preindex.jsp?objectid="+agid;
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+945+",height="+658+",left="+29+",top="+50);
newwin.top.focus();
}

/** 
launch VC for an arbeitsgruppe, this way we will know
whether to show the Thema or not, check the number of users etc.
*/
function launchAgVC(agid){
loc = "/vc/preindex.jsp?objectid="+agid+"&forArbeitsgruppe=yes";
newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+945+",height="+658+",left="+29+",top="+50);
newwin.top.focus();
}

function launchVCList(){
loc = "/comm/commUserOpenList.do?typeId=1&arbeitsgruppeid=-1";
newwin=open(loc,"_blank","statusbar=yes,scrollbars=auto,resizable=no,width="+945+",height="+658+",left="+29+",top="+50);
newwin.top.focus();
}



function openWin(hLoc,w,h,l,t){
  loc = '/hilfe/hLoader.jsp?noHeader=yes&hLocation='+escape(hLoc)+'&width='+w;
  newwin=open(loc,"_blank","statusbar=yes,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+l+",top="+t);
  newwin.top.focus();
}

function showWaitNotice(){
  //alert('Bitte warten!');
  var bearbeitungWindow = "";
  bearbeitungWindow = launchWindow( "/mediathek/waitNotice.jsp", "Bearbeitung", 233, 417,
          'left=330,top=340,status=no,toolbar=no,menubar=no,directories=no,scrollbars=no');
  bearbeitungWindow.focus();
}

// useful constants
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
var ie6 = (document.getElementById && document.all) ? true : false;

//getting the OS of the client system.
var os="*";
if(navigator.appVersion.indexOf("Win")!=-1) os="win";
if(navigator.appVersion.indexOf("Mac")!=-1) os="mac";
if(navigator.appVersion.indexOf("X11")!=-1)os="unx";
if(navigator.appVersion.indexOf("Linux")!=-1) os="lnx";

function getOs(){
  var os1="*";
  if(navigator.appVersion.indexOf("Win")!=-1) os1="win";
  if(navigator.appVersion.indexOf("Mac")!=-1) os1="mac";
  if(navigator.appVersion.indexOf("X11")!=-1)os1="unx";
  if(navigator.appVersion.indexOf("Linux")!=-1) os1="lnx";

  return os1;
}
function getBrowser(){
  var browser="*";
  if( document.all ){
    browser="ie4";
  }
  if( document.layers ){
    browser="ns4";
  } 

  if( document.getElementById && !document.all ){
    browser="ns6";
  }

  if( document.getElementById && document.all ){
    browser="ie6";
  }
  var agt=navigator.userAgent.toLowerCase();
  if(agt.indexOf("opera") != -1){
    browser="opera";
  }
 return browser;
}


var isNav4, isIE4, isNS6, isOpera;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
agt=navigator.userAgent.toLowerCase();
mac = (agt.indexOf("mac")!=-1) ? 1 : 0;
isNS6=false;
isOpera=0;
isOpera = (agt.indexOf("opera") != -1);
isNS6 = (navigator.userAgent.indexOf("Netscape6") != -1) ? 1 : 0;
}

/*
 * general function for submitting a form and setting some fields before (where type of field="input||hidden")
 * params:
 *      first is the name of the form
 *      next two are the name of the field and the value
 *      next two are the name of the field and the value
 *      and so on.....
 */

function submitFormWithParams() {
  args=submitFormWithParams.arguments;
  for (i=1; i<args.length-1 ;i+=2){
    fieldObj = MM_findObj(args[i]);
    fieldObj.value = args[i+1];
  }

  formObj = MM_findObj(args[0]);
  formObj.submit();
}


// general function for submitting a form

function submitForm(formName) {
  formObj = MM_findObj(formName);
  formObj.submit();
}

/*
 * general function for resetting a form
 */

function resetForm(formName) {
        formObj = MM_findObj(formName);
        formObj.reset();
}

function goDThread(link){
        newwin=open(link,"dThread","statusbar=yes,scrollbars=no,resizable=no,width=654,height=478,left=150,top=200");
        newwin.top.focus();
}

function goNotizen(link){
        newwin=open(link,"notizen","statusbar=yes,scrollbars=no,resizable=no,width=654,height=478,left=150,top=200");
        newwin.top.focus();
}


/*
 * functions for opening a file into a new window ****Material ZONE*****
 */
function goMZOpen(file) {
   isNav4 =(navigator.appName.indexOf("Netscape") !=-1) ? true : false;
   isNav4 =(navigator.appVersion.indexOf("4") !=-1) && isNav4;


 newwin=open(file,"Material","statusbar=yes,scrollbars=no,resizable=no,width=550,height=502,left=150,top=220");
 newwin.top.focus();
}

/*
 * second window in mat Zone
 */

function goMZOpen2(file) {
   isNav4 =(navigator.appName.indexOf("Netscape") !=-1) ? true : false;
   isNav4 =(navigator.appVersion.indexOf("4") !=-1) && isNav4;


 newwin=open(file,"Material2","statusbar=yes,scrollbars=no,resizable=yes,width=550,height=465,left=420,top=200");
 newwin.top.focus();
}

/*
 * third window in mat Zone
 */

function goMZOpen3(file) {
   isNav4 =(navigator.appName.indexOf("Netscape") !=-1) ? true : false;
   isNav4 =(navigator.appVersion.indexOf("4") !=-1) && isNav4;


 newwin=open(file,"Material3","statusbar=yes,scrollbars=no,resizable=yes,width=550,height=465,left=420,top=200");
 newwin.top.focus();
}

/*
 * open da glossar
 */
function goGlossar(file) {
 newwin=open(file,"Glossar","statusbar=yes,scrollbars=yes,width=770,height=510,left=150,top=200");
 newwin.top.focus();
}

/*
 * opens should be used to open the forum from the search
 */
  function openForumFromSearch( url )
  {
    w = window.open( url, "forumAll", "width=775,height=488,left=160,top=160" );
    w.focus();
  }

/*
 * general function for opening a file into a new window at a specified position
 */

function goOpen(file) {
 newwin=open(file,"_blank","statusbar=yes,scrollbars=yes,width=654,height=465,left=150,top=240");
 newwin.top.focus();
}


/*
 * for netscape4 - groovy implementation of a:hover
 * have two layers named ["low"+param] and ["high"+param] we
 * switch the visible property of them
 * called on mouse over
 */
function goHigh(param){
        MM_showHideLayers('low'+param, '', 'hide');
        MM_showHideLayers('high'+param, '', 'show');
}

/*
 * for netscape4 - groovy implementation of a:hover
 * have two layers named ["high"+param] and ["low"+param] we
 * switch the visible property of them
 * called on mouse out
 */
function goLow(param){
        MM_showHideLayers('high'+param, '', 'hide');
        MM_showHideLayers('low'+param, '', 'show');
}



/*
 * used for changing the source for one picture object
 */
function changePic(name,newsrc){
  //java.lang.System.out.println("name: " +name + " src: " + newsrc);
   imgObj =MM_findObj(name);
   //alert('imgObj.src='+imgObj.src);
   imgObj.src =newsrc;

}
function showMenue(name,newsrc){
  //java.lang.System.out.println("name: " +name + " src: " + newsrc);
   imgObj =MM_findObj(name);
   //alert('imgObj.src='+imgObj.src);
   imgObj.src =newsrc;

}
function hideMenue(name,newsrc){
  //java.lang.System.out.println("name: " +name + " src: " + newsrc);
   alert('Show Manager and Coach Menue');
   imgObj =MM_findObj(name);
   //alert('imgObj.src='+imgObj.src);
   imgObj.src =newsrc;

}

/*
 * used for switching the visible property for certain objects
 */
function MM_showHideLayers() { //v3.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;
  }
}



/*
 * used for finding on object in the page by specifying the name of that object
 */
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 to trim white spaces from left of the string. 
 */
function ltrim( s )
{
        //alert('ltrim called.');
        return s.replace( /^\s*/, "" );
}

/**** 
 *  function to trim white spaces from right of the string. 
 */
function rtrim( s )
{
        //alert('rtrim called.');
        return s.replace( /\s*$/, "" );
}

/**** 
 *  function to trim white spaces from left and right of the string. 
 */
function trim( s )
{
        //alert('trim called.');
        return rtrim(ltrim(s));
}

/** 
  special function for opening a window with the adjusted height for
  different browsers and operating systems.
  Takes into account the width of the scroll bar etc.
 */
 function launchWindow( whichPage, windowName, windowHeight, windowWidth, otherParameters ){
   var fenster;
   var bro=getBrowser();
   var os=getOs();
   /*if( (bro=="ie4" && os!="mac")
   {
       //add 26 pixels for the right scroll bar
       windowWidth += 16;
       //windowHeight += 2;
   }
   */
   if(os=="win"){
      if(bro.substr(0,2)=="ie"){
      }
      if(bro=="ns4"){
      }
      if(bro=="ns6"){
      }
   }
   if( bro=="ie4" && os=="mac")
   {
       windowWidth -= 16;
       windowHeight -= 20;
   }
   //alert(" Browser: " + bro );
   if( bro=="ie4" || bro=="ns6")
      strWindow = "width=" + windowWidth + ",height=" + windowHeight;
   else
      strWindow = "innerWidth=" + windowWidth + ",innerHeight=" + windowHeight;

   //alert(bro.substring(0,2));
   if(bro.substring(0,2)=="ie"){
        strWindow = "width=" + windowWidth + ",height=" + windowHeight;
   }
   strWindow =  strWindow + "," + otherParameters;
   //alert( "window string: " + strWindow );
   fenster = window.open( whichPage, windowName, strWindow );
   return fenster;
 }
/** 
  special function for opening a window with the adjusted height for
  different browsers and operating systems.
  Takes into account the width of the scroll bar etc.
 */
 function launchWindow1( whichPage, windowName, windowHeight, windowWidth, otherParameters ){
   var fenster;
   var bro=getBrowser();
   var os=getOs();

   if(os=="win"){
      if(bro.substr(0,2)=="ie"){
          windowWidth  += 16;
          windowHeight -= 14;
      }
      if(bro=="ns4"){
          windowHeight += 1;
      }
      if(bro=="ns6"){
          //windowWidth  += 16;
          windowHeight -= 21;
      }
   }
   strWindow = "innerWidth=" + windowWidth + ",innerHeight=" + windowHeight;
   //alert('height : '+windowHeight+'\n width : '+windowWidth);
   if(bro.substring(0,2)=="ie" || bro=="ns6"){
        strWindow = "width=" + windowWidth + ",height=" + windowHeight;
   }
   strWindow =  strWindow + "," + otherParameters;
   //alert( "window string: " + strWindow );
   fenster = window.open( whichPage, windowName, strWindow );
   return fenster;
 }

function launchKursInFrame(url, h, w) {
        var winn = launchWindow(url, 'Kurs', h, w, 'status=yes');
        winn.top.focus();
}


function isNull(val){
  if(val==null) 
      return true;
  else
      return false;  
}

/** function sets the value in a form by given objID for (hidden) field and value to set to */

function setHiddenValue(fieldObj, valueObj) {
        obj = MM_findObj(fieldObj);
        obj.value=valueObj;
//      alert (obj);
}
/*
  This function takes in a string and checks weather its empty or not.
  returns true if the string is empty.
  returns false if the string is not empty.
*/
function isEmpty(str){
   if( str.length > 0){
      if(trim(str).length > 0 ) return false;
   }
   return true;
}
/** chat specific function - do not modify! */

function saveColor(fieldObj, userColor, previewObj) {
        setHiddenValue(fieldObj, userColor);
        temp = MM_findObj(previewObj);
        if (temp.style) {
                temp = temp.style;
                temp.backgroundColor= userColor;
        } else  temp.bgColor = userColor;
}


/**
* Function to check if the given emailID is valid,
* Dont send empty or null strings!, if you give me garbage i will
* give it back!
*/
function checkEmailID(str){
 return pCheckEmailID( str, "Bitte geben sie ein richtige EmailID" );
}

function pCheckEmailID( str, errMessage )
{
 var at="@";
 var dot=".";
 var lat=str.indexOf( at );
 var lstr=str.length;
 var ldot=str.indexOf( dot );

 if (str.indexOf(at)==-1){
   alert( errMessage );
   return false;
 }

 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   alert( errMessage );
   return false;
 }

 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
   alert( errMessage );
   return false;
 }

 if (str.indexOf(at,(lat+1))!=-1){
   alert( errMessage );
   return false;
 }

 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
   alert( errMessage );
   return false;
 }

 if (str.indexOf(dot,(lat+2))==-1){
   alert( errMessage );
   return false
 }
                
 if (str.indexOf(" ")!=-1){
   alert( errMessage );
   return false
 }

 return true                                        
}


/**
* Function to check if the given login name is ok
* Should contain only valid English alphabets or numbers
*/
function checkLogin( c )
{
  var msg = "Verwenden Sie bitte an dieser Stelle keine Umlaute, Sonderzeichen(.,-,*,\") und Leerzeichen.\n Wählen Sie als erstes Zeichen bitte keine Ziffer.";
  return checkSpecialCharacters( c, msg );
}

function checkSpecialCharacters( c, msg ){
 // check if the login has only digits and alphabets
 for(i=0; i<c.length; i++)
 { 
    if( (c.charAt(i)<"a" || c.charAt(i)>"z") && (c.charAt(i) <"0" || c.charAt(i)>"9") 
       && (c.charAt(i)<"A" || c.charAt(i)>"Z") )
    {  
      alert( msg );
      return false;
    }

    if( c.charAt(0) >= "0" && c.charAt(0) <= "9" )
    {  
      alert( msg );
      return false;
    }
 }
 return true;
}

/*
Allows spaces,umlauts and - in addition to alphabets and numbers
*/


function checkSonderzeichnen( c , allowedSpecialCharacters, allowUmlauts)
{
  var msg = "Entfernen Sie bitte eventuelle Sonderzeichnen (.,',*  usw.)!";

  if( !allowedSpecialCharacters ) allowedSpecialCharacters = "";
  if( !allowUmlauts ) allowUmlauts = "";

 //alert( " allowedSpecialCharacters : " + allowedSpecialCharacters );

 for(i=0; i<c.length; i++)
 {
    //alert( " c.charAt(i): " + c.charAt(i) + " allow umlauts: " + allowUmlauts 
    //  + " allowedSpecialCharacters.indexOf( c ): " + allowedSpecialCharacters.indexOf( c.charAt(i) ) );

    if( (c.charAt(i)<"a" || c.charAt(i)>"z") && (c.charAt(i) <"0" || c.charAt(i)>"9") 
        && (c.charAt(i)<"A" || c.charAt(i)>"Z") 
        && ( allowedSpecialCharacters.indexOf( c.charAt(i) ) == -1 ) 
      )
    { 
       // is it an umlaut?
      if( allowUmlauts != "yes" ){
        alert( msg );
        return false;
      }
      else if(  !( c.charAt(i) == 'ä' || c.charAt(i) == 'Ä' 
              || c.charAt(i) == 'ü' || c.charAt(i) == 'Ü' 
	      || c.charAt(i) == 'ß' || c.charAt(i) == 'ö' || c.charAt(i) == 'Ö' ) 
        )
       {
        alert( msg );
        return false;
       }
    }
 }
 return true;
}

/**
Function to submit a form when enter is pressed. Works only with
Internet explorer and Netscape 6.0. 
*/
function submitenter(myfield,e)
{
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else{
    //alert("unknown!");
    return true;
  }

  //alert( "keycode: " + keycode);

  if (keycode == 13)
  {
    myfield.form.submit();
    return false;
  }
  else
   return true;
}

function specialEscape( s ) {
  s = escape( s );
  s = s.replace(/\+/g, '%2B');
  return s;
}


