<!--
// mailFormCheck - v1.2

// hl dr 020514
// dr 021022 (erweiterung)

// in form tack has to be:  onsubmit="return autoCheckFormular( this )"

// orders forms with input-prefixes "optional_" or "required_" (smail)
// textarea forms with input-prefixes "optional_" or "required_" (smail)
// checks forms with input-prefixes "required_" (smail)
// alerts the empty "required_"'s

function startsWith( prefix ){	
	return (this.indexOf(prefix) == 0)
}
function trimString(){
	var val = this; var a = 0; var e = val.length; while( val.charAt(a) == " " && a < e ){ a++; }
	if ( a >= e ) return ""; while( val.charAt(e-1) == " " ){ e--; }; return val.substring(a, e);
}
String.prototype.startsWith = startsWith
String.prototype.trim = trimString

function orderFormular( f ){
	var elementArray = new Array()
	var stringOrderBy =""; 
	for(i=0; i< f.elements.length ; ++i){
		var fieldname = f.elements[i].name
		if (( fieldname.startsWith("optional_") || fieldname.startsWith("required_") ) && !elementArray[fieldname]){
			elementArray[fieldname] = "1"
			stringOrderBy += fieldname + "|"
    	}
	}
	return stringOrderBy.substring(0,(stringOrderBy.lastIndexOf("|")));
}
function checkFieldCHECKBOX( obj ){
	return (!obj.checked)	
}
function checkFieldSELECTONE( obj ){
	return ( obj[obj.selectedIndex].value == "" )	
}
function checkFieldTEXT( obj ){
	var value = obj.value
	return ( value.trim() == "" )	
}

function checkFieldRADIO( formular, fieldname ){
	var obj = formular.elements[fieldname]
	var isOneChecked = false
	for(var radioI=0; radioI< obj.length ; ++radioI){
	if (obj[radioI].checked)
			isOneChecked = true	
	}
	return (!isOneChecked)
}
var textareaFields=new String()
function checkformular( f ) {
	var isError = false;
	for(i=0; i< f.elements.length ; ++i){
	 	var obj=f.elements[i]
		var fieldname = obj.name
		if (!fieldname.startsWith("required_")) continue
		switch( obj.type ){			
				case "checkbox":
					isError = checkFieldCHECKBOX(obj)	
				break;
				case "select-one":
					isError = checkFieldSELECTONE( obj )
				break;
				case "textarea": 
					textareaFields += "|"+obj.name
				case "text": 
					isError = checkFieldTEXT( obj )
				break;
				case "radio": 
					isError = checkFieldRADIO( f, obj.name )
				break;
		}
		if (isError){
			var field = obj.name;
			field = field.substring((field.lastIndexOf("_")+1),field.length);
			alert("Bitte füllen sie das Feld "+field+" aus. ")
			obj.focus();
			return false
		}
	}
	return true
}
function autoCheckFormular( f ){
	if (typeof f.smail_order != "undefined") f.smail_order.value = orderFormular( f )
	if (typeof f.smail_textarea != "undefined") f.smail_textarea.value = textareaFields
	return checkformular( f )
}


/*
function openStartPopup(){
	if (oldInit) oldInit()
	openPopupWithoutScrollbarsAtCenter('/startpopup.jsp',466,241,'')
}
window.onload=openStartPopup
function openSWFPopup(){
	if (oldInit) oldInit()
	openPopupWithoutScrollbarsAtCenter('/swfpopup.jsp',577,450,'')
}
var oldInit=window.onload
window.onload=openSWFPopup
*/
// SPECIAL
//021106(rm)Diese Methode wird aus einer Pressemitteilung aufgerufen. Da bei der formularbasierten
// Eingabe " in &quot; umgewandelt wird und somit nur ' zur Verfügung steht, darf dieser
// Aufruf keine (String-)Parameter enthalten
function openPopupDKM(){
	openPopupNoScrollbars("/unternehmen/popup_dkm.jsp",577, 454)
}
function openPopup( url, width, height ){	
	if (!width) width = 640
	if (!height) height = 540
	LIBopenWindow(url,'popupCL1',width,height,null,null,"scrollbars, resizable").focus()
}
function openPopupWithoutScrollbarsAtCenter( url, width, height ){	
	if (!width) width = 640
	if (!height) height = 540
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	LIBopenWindow(url,'popupCL2',width,height,left,top,"").focus()
}
function openPopup640_400( url, width, height ){	
	if (!width) width = 647
	if (!height) height = 400
	LIBopenWindow(url,'popupCL3',width,height,null,null,"scrollbars").focus()
}
function openPopup_540( url, width, height ){	
	if (!width) width = 556
	if (!height) height = 540
	LIBopenWindow(url,'popupCL4',width,height,null,null,"scrollbars").focus()
}
function openPopupProduktAbstract(url, h){
	var width = 482
	var height = 540
	if(h>0)
		height = h
	if(height>550)
		height = 550
	LIBopenWindow(url,'popupCL4_'+height,width,height,null,null,"scrollbars").focus()
}
//<a href="javascript:openPopupNoScrollbars('popup_direktversicherung.jsp',300,300)">LINK</a>
function openPopupNoScrollbars( url, width, height ){	
	LIBopenWindow(url,'popupCL5',width,height,null,null,"").focus()
}

//reloads the window if Nav4 resized
function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//reloads the window if Nav4 resize
function checkKey(keyevent){ // erzwingt beim IE Absendevehalten 
	if(keyevent.keyCode == "13") document.loginformular.submit();
}
///////////////////////////////////
/*
var message="copyright by Canada Life";
function clickIE4(){ if (event.button==2){ alert(message); return false; } }
function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){ alert(message); return false; }
}	}

if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
*/
//-->
