var startpage = "http://www.vfke.org";

////// Browsertyp
var browser  = "w3c";
app_name = window.navigator.userAgent;
app_name = app_name.toLowerCase();;  
brs_name = window.navigator.appName; 
brs_name = brs_name.toLowerCase();
if ((brs_name.indexOf("explorer") >= 0) || (app_name.indexOf("explorer") >= 0)){ browser  = "ie" ;}
if ((brs_name.indexOf("opera") >= 0) || (app_name.indexOf("opera") >= 0)){ browser  = "opera" ;}
if ((brs_name.indexOf("x11") >= 0) || (app_name.indexOf("x11") >= 0)){ browser  = "x11" ;}

//onError = no_Error;
function no_Error(){ return true; }

function callFltr(im){

         im = document.images[im];
         var imgID = (im.id) ? "id=\"" + im.id + "\" " : ""
         var imgClass = (im.className) ? "class=\"" + im.className + "\" " : ""
         var imgTitle = "";
         var imgStyle = "display: inline-block; cursor: pointer " + im.style.cssText;
         var strNewHTML = "<span " + imgID + imgClass ///  + imgTitle
         strNewHTML += " style=\"margin: 0px; padding: 0px; " + imgStyle + "; " + "width:" + im.width + "px; height:" + im.height + "px; "
         strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         strNewHTML += "(src=\'" + im.src + "\', sizingMethod='scale');\"></span>" 
         im.outerHTML = strNewHTML
         //alert( "yes" );
	 
}


////// Fenstergroesse    
function windowSize(m){
	var window_s;  
	if(browser == "ie"){
		if(m == "w"){
			window_s = document.body.clientWidth;
		}
		else{
			window_s = document.body.clientHeight;
		}
	} 
	else{
		if(m == "w"){
			window_s = window.innerWidth;
		}
		else{
			window_s = window.innerHeight;
		}
	}
	return window_s;
}
    
var objectLayer;	//
var objectStyle;
var objectPos;

function getMethod(){
 if (document.all){
  objectLayer = 'document.all[\'';
  objectStyle = '\'].style';
  objectPos   = '\']'; 
 } 
 else{
   if(document.layers){
      objectLayer = 'document.layers[\''; 
      objectStyle = '\']'; } 
   else{ 
      if (document.getElementById){
        objectLayer = 'document.getElementById(\''; 
        objectStyle = '\').style';
        objectPos   = '\')';  
      } 
      else {}  
   } 
 }
}

function modLayer(nameLayer,actionLayer,toDo){ 
if (objectLayer) {
 layerString = objectLayer + nameLayer + objectStyle + actionLayer + toDo;
 //alert(layerString);
 layer = eval(layerString);
} 
}

function swapForms(c){
	if(c == 2){
		d_1 = 'f_login'; d_2 = 'f_anmeld';
	}
	else{
		d_2 = 'f_login'; d_1 = 'f_anmeld';
	}
	modLayer(d_1, '.visibility=', '\'hidden\'' ); modLayer(d_2, '.visibility=', '\'visible\'' );
}

function checkFields(){

	var stopptime = new Date(); stopptime = stopptime.getTime();
	var sekndsneed = stopptime - starttime;
	// immer Sekunden eintragen !
	document.anmld.inserttime.value = sekndsneed;
	if (sekndsneed < 8000){
		//alert('no robots');
		return (false);
	}
	
		pflicht = new Array();
		pflicht['name'] = 'Benutzername';
		pflicht['password'] 	= 'Passwort';
		pflicht['full'] = 'Name';
		pflicht['mail'] = 'E-Mail';
		pflicht['org'] 	= 'Unternehmen / Institution';
		pflicht['pos'] 	= 'Position';

	//alert(' ß  ü  Ü, ä, Ä, ö, Ö ');	
	var checkOK = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	var checkStr = document.anmld.name.value;
	var allValid = true;
	for (i = 0; i < checkStr.length; i++){
		ch = checkStr.charAt(i);
		if( checkOK.indexOf( ch ) < 0 ){
			allValid = false;
			break;
		}
	}
	if (allValid == false){
		alert('Der Benutzername darf keine Leer- und Sonderzeichen (._-/) enthalten !');
		document.anmld.name.focus()
		return (false);
	}
	for(h=0; h < document.anmld.elements.length; h++){
		if (document.anmld.elements[h].value.length == 0  ){
			tmp = document.anmld.elements[h].name ;
			if(tmp != 'comment' && tmp != 'submit'){
				iname = pflicht[ tmp ];
				alert ('Bitte füllen Sie das Feld "' + iname + '" aus !');
				document.anmld.name.focus();
				return (false);
			}
		}
	}
	if ( document.anmld.password.value.length < 6 ){
		alert('Der Passwort muss eine Mindestlänge von 6 Zeichen haben !');
		return (false);
	}   
	var is_dot = document.anmld.mail.value.indexOf(".");
	var is_at  = document.anmld.mail.value.indexOf("@");
	var is_pos = document.anmld.mail.value.length;
	if (( is_dot == -1) || ( is_at == -1) || is_pos < 7 ){alert("Bitte überprüfen Sie die angegebene E-Mail-Adresse !");
		return false;
	}
	//return false;
}      

function makeHistory(){
 history.back();
}

function printIt(){
  if(window.print){
     window.print();}
}

function setStyle(id){
  
  if (browser == "ie" && document.all && (app_name.indexOf("opera") == -1) == true ){       
			var elem = document.getElementById("s_" + id);
			if( elem.className == "color_normal" || elem.className == "color_hover" ){
				//alert(id.className);
				var stat; 
				if( elem.className == "color_hover" ){ stat = "color_normal"; }
				if( elem.className == "color_normal" ){ stat = "color_hover"; }
				codeStart = "document.all.";
				codeEnd = "";      
				toset = codeStart + "s_" + id +codeEnd + ".className = \"" + stat + "\";";
				eval(toset);
				//alert(todo);
			}
  }
  
}

function moveDiv(c){
    if(c == 0){
    	stat = "balken_n";
    	moving = 0;
    }
    if(c == 1){
    	stat = "balken_d";
    	moving = 1;
    }
    setStyle('balken',stat);
    
}


// Img swap (Mouseover)
function swapImg(id,nr){
  if(! document.layers){
   if(document.images){t = "document.images['" + id + "'].src= icons[" + nr + "]"}
   eval(t);
   //alert(t);
  }
}

function openWin(file,ww,hh,fname,sb){

if(file == 'login'){file = '../editor/login'; ww = 200; hh = 200; fname = 'editor'; sb = 'yes';}
toeval ="mwindow = window.open(\""+file+"\",\""+fname+"\",\"width="+ww+",height="+hh+",toolbar=no,dependent=yes,scrollbars="+sb+",resizable=yes,status=yes\")";
eval(toeval);
}

function checkMail(f){
var myvalue = document.forms[f].mail.value;
if((myvalue.indexOf("@") < 0) || (myvalue.indexOf(".") < 0) || (myvalue.indexOf(",") >= 0) || (myvalue.indexOf(":") >= 0) || (myvalue.indexOf(";") >= 0)  || (myvalue * 1 == 0)){
return 0;}
else{return 1;}
}

getMethod();
