function StatusAnzeigenNavi(Status, Level) {
   var Gesamt = Status;

   if(document.all) {
      if (Level == 0)
         parent.frames.edit_status.document.all.StatusIE.innerHTML = Gesamt;

      if(document.Menue.MenueDesc.value != "" && Level != 0)
         parent.frames.edit_status.document.all.StatusIE.innerHTML = "von " + document.Menue.MenueDesc.value + " nach " + Gesamt;
      else
         parent.frames.edit_status.document.all.StatusIE.innerHTML = Gesamt;
   }
   else if(document.layers) {
      parent.frames.edit_status.document.StatusNS.document.open();
      parent.frames.edit_status.document.StatusNS.document.write('<p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: white; text-decoration: none; font-weight: bold;")>' + Status + '</p>');
      parent.frames.edit_status.document.StatusNS.document.close();
   }
}

function StatusAnzeigen(Status) {
   var Gesamt = Status;

   if(document.all)
      parent.frames.edit_status.document.all.StatusIE.innerHTML = Gesamt;
   else if(document.layers) {
      parent.frames.edit_status.document.StatusNS.document.open();
      parent.frames.edit_status.document.StatusNS.document.write('<p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: white; text-decoration: none; font-weight: bold;")>' + Status + '</p>');
      parent.frames.edit_status.document.StatusNS.document.close();
   }
}

// Navigationsaufruf aus der Menüleiste
function MenueLink(Content) {
   parent.document.location.href = parent.document.location.pathname + '?ContentID=' + Content + '&PageID=0';

}

// Anzeigedatum in Menüleiste übernehmen
function showdate( year, month, date ) {
   document.Ampel.viewdate.value = "" + date + "." + month + "." + year;
   hideCalendar('calendar');
   document.Ampel.reload.value = "yes"; 
   document.Ampel.submit();
}

// Fenster für Suche öffnen
function openSuche() {
	web4biz_search = window.open('../content/index_search.html','web4biz_search','width=900,height=650,locationbar=no,hotkeys=no,menubar=no,status=yes,resizable=yes');
	web4biz_search.focus();
}

// Fenster für Fehler öffnen
function openFehler(strErrorFile, strProgressErr) {
	web4biz_error = window.open('index_view_error.html?ErrorFile=' + strErrorFile + '&ProgressErr=' + strProgressErr ,'web4biz_error','width=600,height=300,locationbar=no,hotkeys=no,menubar=no,status=yes');
	web4biz_error.focus();
}

// Fenster für Ueber web4biz öffnen
function openUeber() {
	web4biz_ueber = window.open('/web4files/ueber_web4biz.html','web4biz_ueber','width=400,height=400,locationbar=no,hotkeys=no,menubar=no,status=no');
	web4biz_ueber.focus();
}

// Fenster für Veröffentlichung öffnen
function openPublish() {
	Publish = window.open('../content/index_publish.html','Publish','width=800,height=600,locationbar=no,hotkeys=no,menubar=no,status=yes');
	Publish.focus();
}

// Fenster für Versionsauflistung öffnen
function openCorsaXMLImport( ) {
   web4biz_version = window.open('../content/index_corsaXML.html','Publish','width=800,height=600,locationbar=no,hotkeys=no,menubar=no,status=yes');
}

// Fenster für Versionsauflistung öffnen
function openVersion( ContentID ) {
   web4biz_version = window.open('../content/index_version.html?ContentID=' + ContentID,'web4biz_version','width=790,height=590,locationbar=no,hotkeys=no,menubar=no,resizable=no,status=yes');
   web4biz_version.focus();
}

// Anzeig der Template-Sourcen
function openTemplate( Template ) {
   web4biz_template = window.open(Template,'web4biz_template','width=800,height=600,locationbar=no,hotkeys=no,menubar=no,status=yes');
   web4biz_template.focus();
}

// Vorschaufenster der Objecte
function OpenVorschau(Image, Breite, Hoehe) {
   Vorschau = window.open(Image,'Vorschau','status=yes,resizable=yes,width=' + Breite + ',height=' + Hoehe + ',scrollbars=no,dependent,menuebar=no');
   Vorschau.focus();
}

// Upload von Objekten
function OpenUpload(FieldName, Directory, StateInfo) {
   Upload = window.open('../content/index_upload.html?DirStart=' + Directory + '&StateInfo=' + StateInfo +  '&Directory=' + Directory + '&FieldName=' + FieldName  ,'Upload','width=790,height=590,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
   Upload.focus();
}

// Navigationsstruktur anzeigen
function OpenLinkTree(FieldName) {
   LinkTree = window.open('index_link.html?FieldName=' + FieldName,'LinkTree','width=250,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
   LinkTree.focus();
} 

// Fenster für Report öffnen
function openReport() {
	web4biz_report = window.open('../reports/index_report.html','web4biz_report','width=850,height=600,locationbar=no,hotkeys=no,menubar=no,status=yes,resizable=yes');
	web4biz_report.focus();
}

// Navi-Baum Auswahl
// Navigationsstruktur anzeigen
function OpenLinkNaviBaum() {
   NaviBaum1 = window.open('../content/index_navi-baum.html','NaviBaum1','width=310,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
   NaviBaum1.focus();
}
function OpenNaviBaum(FieldName, Caller,callerhref) {
   //alert(Caller + callerhref);
   if (Caller =="edit_subcontentfields") { 
      //alert("navi2");
      LinkTree  = window.open('../content/index_navi-baum.html?FieldName=' + FieldName + '&callerhref=' + callerhref,'NaviBaum2','width=310,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
      LinkTree.focus();
   }
   else {
   NaviBaum1  = window.open('../content/index_navi-baum.html?FieldName=' + FieldName + '&callerhref=' + callerhref,'NaviBaum1','width=310,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
   NaviBaum1.focus();
   }
}
function OpenFolderBaum(FieldName,FolderID,callerhref) {
      //alert("navi2");
      LinkTree  = window.open('../content/index_folder-baum.html?FieldName=' + FieldName + '&callerhref=' + callerhref,'FolderBaum','width=390,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
      LinkTree.focus();

}
function OpenDocBaum(FieldName,callerhref) {
      //alert("navi2");
      LinkTree  = window.open('../content/index_doc-baum.html?FieldName=' + FieldName + '&callerhref=' + callerhref,'DocBaum','width=310,height=560,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes');
      LinkTree.focus();

}

function isEmpty(){
   if (document.Eingabe == null){
	   FFieldList = parent.edit_subcontentfields.document.Eingabe.FormatFields.value;
   } else {
	   FFieldList = document.Eingabe.FormatFields.value;
   }
   if(FFieldList != "") {
      FFields = FFieldList.split(",");
      for (x = 0; x<=FFields.length - 2; x++) {
	     werte = FFields[x];
	     Feldname = werte.substring( 0, werte.indexOf("|"));
		   if (document.Eingabe == null){
			   Feldwert = parent.edit_subcontentfields.document.Eingabe.elements[Feldname].value;
		   } else {
			   Feldwert = document.Eingabe.elements[Feldname].value;
		   }
		 Feldtyp = werte.substring( werte.indexOf("|") + 1, werte.length );
		 intMask = 1;
		 if (Feldwert != ""){
		    intMask = mask(Feldwert, Feldtyp);}
		    if (intMask == 0) {
		          switch(Feldtyp) {
		           case "d":
		              strFormat = "Ungueltiges Datumsformat (TT.MM.JJJJ) ";
		              break;
		           case "n":
		              strFormat = "Nur numerische Werte sind erlaubt";
		              break;
		           case "t":
		              strFormat = "Ungueltiges Zeitformat (HH:MM)";
		              break;		 
		           case "f":
		              strFormat = "Nur Fließkommazahlen erlaubt";
		              break;		 
			       }
				   alert(strFormat);
				   if (document.Eingabe == null){
					   parent.edit_subcontentfields.document.Eingabe.elements[Feldname].focus();
				   } else {
					   document.Eingabe.elements[Feldname].focus();
				   }
		           return false;
		      }
	      }
       } 
	
   if(parent.edit_subcontentfields.document.Eingabe.ReqFields != null) {
      if (parent.edit_subcontentfields.document.Eingabe.ChangedSel.value != "") {
         if(parent.edit_subcontentfields.document.Eingabe.OriginalSel.value != parent.edit_subcontentfields.document.Eingabe.ChangedSel.value) 
            {return true; }
      }
      cFieldList    = parent.edit_subcontentfields.document.Eingabe.ReqFields.value;
      cFieldListBez = parent.edit_subcontentfields.document.Eingabe.ReqFieldsBez.value;
      if(cFieldList != "") {
	      cFields    = cFieldList.split(",");
	      cFieldsBez = cFieldListBez.split(",");
         for (i=0; i < parent.edit_subcontentfields.document.Eingabe.length; i++) {
            for(y=0; y<=cFields.length; y++) {
               if(cFields[y] == parent.edit_subcontentfields.document.Eingabe.elements[i].name) {
                  if(parent.edit_subcontentfields.document.Eingabe.elements[i].value == "") {
                     alert("Feld " + cFieldsBez[y] + " ist ein Pflichtfeld");
                     parent.edit_subcontentfields.document.Eingabe.elements[i].focus();
                     return false;	  
                  }
               }
            }   
         }
      }
   } 
   return true;
}

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_findObj(n, d) { //v3.0
   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);
   return x;
}

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_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_nbGroup(event, grpName) { //v3.0
   var i,img,nbArr,args=MM_nbGroup.arguments;
   if (event == "init" && args.length > 2) {
      if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
         img.MM_init = true; 
         img.MM_up = args[3]; 
         img.MM_dn = img.src;
         if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
            nbArr[nbArr.length] = img;
         for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
            if (!img.MM_up) 
               img.MM_up = img.src;
            img.src = img.MM_dn = args[i+1];
           nbArr[nbArr.length] = img;
         }
      }
   } 
   else if (event == "over") {
      document.MM_nbOver = nbArr = new Array();
      for (i=1; i < args.length-1; i+=3) 
         if ((img = MM_findObj(args[i])) != null) {
            if (!img.MM_up) 
               img.MM_up = img.src;
            img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
            nbArr[nbArr.length] = img;
         }
   }
   else if (event == "out" ) {
      for (i=0; i < document.MM_nbOver.length; i++) {
         img = document.MM_nbOver[i]; 
         img.src = (img.MM_dn) ? img.MM_dn : img.MM_up;
      }
   }
   else if (event == "down") {
      if ((nbArr = document[grpName]) != null)
         for (i=0; i < nbArr.length; i++) {
            img=nbArr[i]; 
            img.src = img.MM_up; 
            img.MM_dn = 0;
         }
      document[grpName] = nbArr = new Array();
      for (i=2; i < args.length-1; i+=2) 
         if ((img = MM_findObj(args[i])) != null) {
            if (!img.MM_up) 
               img.MM_up = img.src;
            img.src = img.MM_dn = args[i+1];
            nbArr[nbArr.length] = img;
         }
   }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
   var newWin = window.open(theURL,winName,features);
   newWin.erzeuger = self;
}

function showMsg(text) {
   parent.frames.edit_status.picform.message.value = text;
}

function getCategory() {
   var cList="";
   for(var x=0;x<parent.edit_category.document.Eingabe.elements.length;x++) {
      var myElement=parent.edit_category.document.Eingabe.elements[x];
      if(myElement.type=="checkbox" && myElement.checked) {
         cList = cList + "," + myElement.value;
      }
   }	
   return cList;
}

function resetFields() {
   parent.edit_content.document.Eingabe.reset();
   parent.edit_subcontentfields.document.Eingabe.reset();
   parent.edit_category.document.Eingabe.reset();
}

function newSubcontent() {
	parent.edit_subcontentfields.document.Eingabe.Speichern.value = "neu";
	parent.edit_subcontentfields.document.Eingabe.submit();
}

function  setDefaultValues(picContDesc, picVerzeichnis) {
   if(document.Eingabe.ContDescription.value == "")
      document.Eingabe.ContDescription.value = picContDesc;
   if(document.Eingabe.ContDirectory.value == "") {
      document.Eingabe.ContDirectory.value = picVerzeichnis + "/" + picContDesc;
   	low = document.Eingabe.ContDirectory.value.toLowerCase();
   	document.Eingabe.ContDirectory.value = low;
   }
	if(document.Eingabe.ContFileName.value == "")
      document.Eingabe.ContFileName.value = "index.htm";
}

function mask (InString, Mask) {
   if(Mask=="d")
      if(!isDate(InString))
         return(0);
	if(Mask=="t"){
      for (Count=0; Count<=InString.length - 1; Count++) {
         StrChar = InString.substring(Count, Count+1); 
            if(!isTimeNumber(StrChar))
               return(0);
      }
      if(!isTime(InString))
        	return(0);
	}
	if(Mask=="n") {
      for (Count=0; Count<=InString.length - 1; Count++) {
         StrChar = InString.substring(Count, Count+1); 
            if(!isNumberChar(StrChar))
              return(0);
      }
   }
   if(Mask=="f") {
      for (Count=0; Count<=InString.length - 1; Count++) {
         StrChar = InString.substring(Count, Count+1); 
            if(!isNumberCommChar(StrChar))
               return(0);
      }
   }
   return (1); 
} 
 
function isNumberChar (InString) { 
   if(InString.length!=1)  
      return (false); 
   RefString="1234567890"; 
   if (RefString.indexOf (InString, 0)==-1)  
      return (false);
   else
      return (true);
} 

function isNumberCommChar (InString) { 
   if(InString.length!=1)  
      return (false); 
   RefString="1234567890,"; 
   if (RefString.indexOf (InString, 0)==-1)  
      return (false);
   else
      return (true);
} 

function isTimeNumber (InString) { 
   if(InString.length!=1)  
      return (false); 
   RefString="1234567890:"; 
   if (RefString.indexOf (InString, 0)==-1)  
      return (false);
   else
      return (true);
} 

function isTime(picTime){
  arrTeile = picTime.split(":");
  if (arrTeile[0] > 24)
   return(false);
  if (arrTeile[1] > 59)
   return(false);
  if (arrTeile[2] != "<undefined>")
    if (arrTeile[2] > 59)
      return(false);
  return(true);    
} 

function isDate(picDate) {
  var re =
  /^((29(-|\.)0?2(-|\.)(19(0[48]|[2468][048]|[13579][26])|2000))|(((3[01]|[12][0-9]|0?[1-9])(-|\.)(0?[13578]|1[02]))|((30|[12][0-9]|0?[1-9])(-|\.)(0?[469]|11))|(([12][0-8]|19|0?[1-9])(-|\.)(0?2)))(-|\.)(19\d{2}|20\d{2}))$/ 

  if(!re.test(picDate))
      return (false);
  else
 	  return (true);
}
 
function checkFormat (InFormat) {
   OutFormat = ""; 
   if(InFormat.length < 1) 
      return (OutFormat);
   InFormat=InFormat.toLowerCase(); 
   RefString="dfnt"; /* valid format characters */ 
   FirstChar = InFormat.charAt(0); 
   if (RefString.indexOf(FirstChar) == -1) 
      return (false); 
   else
      return (true);
}		

function TextVerify(field, field_format){ 
   var strFormat;
   // a null string is OK, we do not do mandatory field checking (yet)
   if (field.value == null || field.value == "" || field.value == "<undefined>") 
      return;
   switch(field_format) {
      case "d":
         strFormat = "Ungueltiges Datumsformat (TT.MM.JJJJ)";
         break;
      case "n":
         strFormat = "Nur numerische Werte sind erlaubt";
         break;
      case "t":
         strFormat = "Ungueltiges Zeitformat (HH:MM)";
         break;		 
      case "f":
         strFormat = "Nur Fließkommazahlen erlaubt";
         break;		 
	}
   if(checkFormat(field_format))
      if (mask(field.value, field_format) == 0) { 
         alert(field.value + " ist ein ungueltiges Format! \n" + strFormat); 
         field.focus(); 
      }
}


function fillLink(picInhalt, picFeld) {
   for (i=0; i < opener.document.Eingabe.length; i++) {
      if(picFeld == opener.document.Eingabe.elements[i].name)
		    opener.document.Eingabe.elements[i].value == picInhalt;
   }
}

function DisableSubContentVariableField(field_key){

   if (field_key == "CHECKBOX" || field_key == "DATE" || field_key == "MULTSEL" || field_key == "MULTCHECK" || field_key == "COMBO" || field_key == "RADIO" || field_key == "TIME" || field_key == "WebEdit" ) {
	   document.FormDet.Len.disabled = true;
   } else {
	   document.FormDet.Len.disabled = 0;
   }

   if (field_key == "OBJECT" || field_key ==  "PICT" || field_key == "CHECKBOX" || field_key == "DATE" || field_key == "LINK" || field_key == "MULTCHECK" || field_key == "COMBO" || field_key == "RADIO" || field_key == "TEXT" || field_key == "TIME" || field_key == "WebEdit" || field_key == "DECIMAL" || field_key == "INTEGER" || field_key == "INCLUDE" ) {
	  document.FormDet.Height.disabled = true;
	} else {
	  document.FormDet.Height.disabled = 0;
	}

   if (field_key == "OBJECT" || field_key == "PICT" || field_key == "CHECKBOX" || field_key == "DATE" || field_key == "LINK" || field_key == "CONTENT" || field_key == "CONTENTHTML" || field_key == "TEXT" || field_key == "TIME" || field_key == "WebEdit" || field_key == "DECIMAL" || field_key == "INTEGER" ) {
	  document.FormDet.PropID.disabled = true;
	} else {
	  document.FormDet.PropID.disabled = 0;
	}

   if (field_key == "CHECKBOX" || field_key == "DATE" || field_key == "LINK" || field_key == "MULTSEL" || field_key == "MULTCHECK" || field_key == "CONTENT" || field_key == "CONTENTHTML" || field_key == "COMBO" || field_key == "RADIO" || field_key == "TEXT" || field_key == "TIME" || field_key == "WebEdit" || field_key == "DECIMAL" || field_key == "INTEGER" ) {
	  document.FormDet.Directory.disabled = true;
	} else  {
	  document.FormDet.Directory.disabled = 0;
	}

   return true;
}
