sfHover = function() {
	
	// Main Navigation
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}

}

if (window.attachEvent) window.attachEvent("onload", sfHover);

openWin = function (file, w, h, scrl) {
	window.open(file, "KEYMILE", "width="+w+", height="+h+", left=0, top=0, scrollbars="+scrl+"");
}

openWinResize = function (file, w, h, scrl) {
	window.open(file, "MEDIA", "width="+w+", height="+h+", left=0, top=0, resizable=yes, scrollbars="+scrl+"");
}

openNamedWin = function (file, w, h, scrl, windowName) {
	window.open(file, windowName, "width="+w+", height="+h+", left=0, top=0, scrollbars="+scrl+"");
}

openHelpWin = function (file, w, h, scrl) {
	window.open(file, "Hilfe", "width="+w+", height="+h+", left=0, top=0, scrollbars="+scrl+"");
}

// custom image popup with variable size and dynamic close() onClick
openWin_img = function (file, b, h, info) {

	eigenschaften="left=100,top=100,screenX=100,screenY=100,width="+b+",height="+h+",menubar=no,toolbar=no,statusbar=0";
	test = window.open(file, "KEYMILE", eigenschaften);
	with (test) {
		document.write('<html><head>');
	  document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
	  document.write("function click() { window.close(); } ");
	  document.write("document.onmousedown=click ");
	  document.write('</scr' + 'ipt>');
	  document.write('<title>' + info + '</title></head>');
	  document.write('<' + 'body ');
	  document.write('marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">');
	  document.write('<center>');
	  document.write('<img src="'+ file +'"border="0">');
	  document.write('</center>');
	  document.write('</body></html>');
	}
}

// check registration form
reg_check = function () {
	
	var count = 0;
	// enter all mandatory fields here -->
	var reg_fields = new Array("km_name1", "km_pw01", "km_pw02", "company", "adress", "country", "firstname", "surname", "email", "phone");
	
	for (var i=0; i<reg_fields.length; i++) {
		
		var image = reg_fields[i]+"_img";
		
		if (document.getElementById(reg_fields[i]).value=="") {
			document.getElementById(image).src="img/icons/red_star.gif";
			count++;
		} else {
			document.getElementById(image).src="img/icons/empty_star.gif";
		}
				
	}
	
	// check email for correct format
	if (document.getElementById("email").value!="") {
		if (!checkMail(document.getElementById("email").value)) {
			document.getElementById("email_img").src="img/icons/red_star.gif";
			count++;
		}
	}
	
	// check username for correct length
	if ( document.getElementById("km_name1").value.length>30) {
		alert("Der Username darf max. 30 Zeichen haben!");
		count++;
	}
	
	// check pwd01 and pwd02
	if ( document.getElementById("km_pw01")!="" || document.getElementById("km_pw02")!="" ) {
		if (document.getElementById("km_pw01").value != document.getElementById("km_pw02").value) {
			alert("Die Passwörter müssen übereinstimmen!!");
			count++;
		}
		// check password for correct length (min 8 characters)
		if ( document.getElementById("km_pw01").value.length<8) {
			alert("Das Passwort muss mindestens 8 Zeichen haben!");
			count++;
		}
	}
	
	// go!
	if (count==0) {
		document.getElementById("testform").submit();
	}
	
}

function checkMail(str)	{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(str)) {
		return true;
	}
}