// JavaScript Document
function FRML(p_id,p_ipcl,p_isfocus,p_nxtbtins,p_clrbtins,p_caller){
	var thisobj=this;
	thisobj.form=document.getElementById(p_id);
	thisobj.idipcl=p_ipcl;
	thisobj.nxtbtins=p_nxtbtins;
	thisobj.clrbtins=p_clrbtins;
	thisobj.caller=p_caller;
	thisobj.fids=new Array();
	thisobj.txtareas=new Array();
	thisobj.otherobj=new Array();
	thisobj.nxtbt;
	thisobj.clrbt;
	thisobj.clrbtactv=false;
	thisobj.nxt=function(){	
		if(thisobj.clrbtactv==false){
			if(thisobj.nxtbt.id=="nxt"){			
				var chked=true;
				thisobj.res=new Array();
				for(var i=0;i<thisobj.fids.length;i++){
					if(!thisobj.chkv(thisobj.fids[i])){
						chked=false;
						break;
					}
				}
				if(chked==true){
					thisobj.nxtbt.id="snd";
					var tmp=thisobj.nxtbt.value;
					thisobj.nxtbt.value=thisobj.nxtbtins;
					thisobj.nxtbtins=tmp;
					thisobj.clrbt.id="bck";
					tmp=thisobj.clrbt.value;
					thisobj.clrbt.value=thisobj.clrbtins;
					thisobj.clrbtins=tmp;
					thisobj.shcnf();
				}
			}else if(thisobj.nxtbt.id=="snd"){
				thisobj.nxtbt.id="nxt";
				var tmp=thisobj.nxtbt.value;
				thisobj.nxtbt.value=thisobj.nxtbtins;
				thisobj.nxtbtins=tmp;
				thisobj.clrbt.id="clr";
				tmp=thisobj.clrbt.value;
				thisobj.clrbt.value=thisobj.clrbtins;
				thisobj.clrbtins=tmp;
				if(thisobj.caller!=null){
					thisobj.caller.nxtFRML(thisobj);	
				}
			}
		}
	};
	thisobj.clr=function(){
		if(thisobj.clrbtactv==false){
			thisobj.clrbtactv=true;
			if(thisobj.clrbt.id=="clr"){
				if(thisobj.caller!=null){
					thisobj.caller.clrFRML(thisobj);
				}
			}else if(thisobj.clrbt.id=="bck"){
				thisobj.nxtbt.id="nxt";
				var tmp=thisobj.nxtbt.value;
				thisobj.nxtbt.value=thisobj.nxtbtins;
				thisobj.nxtbtins=tmp;
				thisobj.clrbt.id="clr";
				tmp=thisobj.clrbt.value;
				thisobj.clrbt.value=thisobj.clrbtins;
				thisobj.clrbtins=tmp;
				thisobj.unshcnf();
			}
			window.setTimeout(thisobj.inactive,500);
		}
	};
	thisobj.inactive=function(){
		thisobj.clrbtactv=false;	
	};
	thisobj.idsort=function(p_a,p_b){
		return Number(p_a.id.substring(p_a.id.lastIndexOf("_")+1))-Number(p_b.id.substring(p_b.id.lastIndexOf("_")+1));
	};
	thisobj.sign=function(p_ip,p_fc){
		p_ip.className=thisobj.idipcl+"ipsgn";
		if(p_fc==true){
			p_ip.focus();
		}
		p_ip.onblur=function(){
			if(p_ip.className==thisobj.idipcl+"ipsgn"){
				p_ip.className=thisobj.idipcl+"ip";
			}
		};
	};
	thisobj.chkv=function(p_id){
		if(p_id.childNodes[0]!=null){
			if(p_id.childNodes[0].nodeValue!=null){
				var tmpip=document.getElementById(p_id.id.substring(0,p_id.id.lastIndexOf("_")+1)+"i");				
				if(p_id.childNodes[0].nodeValue.substr(0,1)=="*"){
					if(tmpip!=null){
						if(tmpip.tagName.toLowerCase()=="input"){
							if(tmpip.type=="text"){
								if(tmpip.value==""){
									thisobj.sign(tmpip,true);
									return false;
								}
							}else if(tmpip.type=="checkbox"){
								if(tmpip.checked==false){
									thisobj.sign(tmpip,true);
									return false;
								}
							}
						}else if(tmpip.tagName.toLowerCase()=="textarea"){
							if(tmpip.value==""){
								thisobj.sign(tmpip,true);
								return false;
							}
						}
					}
				}
				if(p_id.id.substr(p_id.id.indexOf("_")+1,2)=="em"){
					if(tmpip.value.indexOf("@")==-1){
						thisobj.sign(tmpip,true);
						return false;
					}
					if(tmpip.value.substring(tmpip.value.indexOf("@")).indexOf(".")==-1){
						thisobj.sign(tmpip,true);
						return false;
					}
					if(thisobj.caller!=null){
						thisobj.caller.feml=tmpip.value;
					}
				}
				if(p_id.id.substr(p_id.id.lastIndexOf("_")-2,2)=="_w"){
					var tmpid=p_id.id.substring(0,p_id.id.lastIndexOf("_")-2);
					for(var i=0;i<thisobj.res.length;i++){
						if(String(thisobj.res[i][2]).substring(0,tmpid.length)==tmpid){
							if(tmpip.value!=String(thisobj.res[i][1])){
								tmpip.value="";
								thisobj.sign(tmpip,false);
								thisobj.sign(document.getElementById(String(thisobj.res[i][2]).substring(0,String(thisobj.res[i][2]).lastIndexOf("_")+1)+"i"),true);
								return false;
							}
						}
						thisobj.otherobj.push(p_id);
						thisobj.otherobj.push(tmpip);
					}
				}else{
					if(tmpip.type=="text"){
						thisobj.res.push(new Array(p_id.childNodes[0].nodeValue,tmpip.value,p_id.id,tmpip));
					}else if(tmpip.tagName.toLowerCase()=="textarea"){
						thisobj.res.push(new Array(p_id.childNodes[0].nodeValue,tmpip.value,p_id.id,tmpip));
					}else if(tmpip.type=="checkbox"){
						if(tmpip.checked==true){
							thisobj.res.push(new Array(p_id.childNodes[0].nodeValue,"ja",p_id.id,tmpip));
						}else{
							thisobj.res.push(new Array(p_id.childNodes[0].nodeValue,"nein",p_id.id,tmpip));
						}
					}
				}
			}
		}
		return true;
	};
	thisobj.getdata=function(){
		return thisobj.res;
	};
	thisobj.getVAt=function(p_id){
		if(p_id!=""){
			for(var i=0;i<thisobj.res.length;i++){
				if(String(thisobj.res[i][2]).indexOf("_"+p_id+"_")>-1){
					return (thisobj.res[i][1]);	
				}
			}
		}
		return "";
	};
	thisobj.getVls=function(p_ids){
		if(p_ids!=""){
			var spc="-";
			var rtrn="_";
			var res="";
			var tmp="";
			for(var i=0;i<p_ids.length;i++){
				if(p_ids.substr(i,1)==spc){
					if(getDateFormated(tmp)!=null){
						res=res+getDateFormated(tmp)+" ";
					}else{
						res=res+thisobj.getVAt(tmp)+" ";
					}
					tmp="";
				}else if(p_ids.substr(i,1)==rtrn){
					if(getDateFormated(tmp)!=null){
						res=res+getDateFormated(tmp)+"\n";
					}else{
						res=res+thisobj.getVAt(tmp)+"\n";
					}
					tmp="";
				}else{
					tmp=tmp+p_ids.substr(i,1);
					if(i==p_ids.length-1){
						if(getDateFormated(tmp)!=null){
							res=res+getDateFormated(tmp);
						}else{
							res=res+thisobj.getVAt(tmp);
						}						
					}
				}
			}
			return res;
		}
	};
	thisobj.shcnf=function(){
		for(var i=0;i<thisobj.otherobj.length;i++){
			thisobj.otherobj[i].style.visibility="hidden";
		}
		for(var i=0;i<thisobj.fids.length;i++){
			thisobj.fids[i].className=thisobj.idipcl+"idcnf";
		}
		for(var i=0;i<thisobj.res.length;i++){
			if(thisobj.res[i][3].tagName.toLowerCase()=="input"){
				if(thisobj.res[i][3].type=="text"){
					thisobj.res[i][3].className=thisobj.idipcl+"ipcnf";
					thisobj.res[i][3].readOnly=true;
				}else if(thisobj.res[i][3].type=="checkbox"){
					thisobj.res[i][3].disabled=true;
					if(thisobj.res[i][3].checked==true){
						document.getElementById(String(thisobj.res[i][2])).className=thisobj.idipcl+"ipcnf";
					}
				}
			}else if(thisobj.res[i][3].tagName.toLowerCase()=="textarea"){
				thisobj.res[i][3].className=thisobj.idipcl+"ipcnf";
				thisobj.res[i][3].readOnly=true;
			}
		}
		thisobj.nxtbt.focus();
	};
	thisobj.unshcnf=function(){
		if(thisobj.res!=null){
			for(var i=0;i<thisobj.res.length;i++){
				if(thisobj.res[i][3].tagName.toLowerCase()=="input"){
					if(thisobj.res[i][3].type=="text"){
						thisobj.res[i][3].className=thisobj.idipcl+"ip";
						thisobj.res[i][3].readOnly=false;
					}else if(thisobj.res[i][3].type=="checkbox"){
						thisobj.res[i][3].disabled=false;
					}
				}else if(thisobj.res[i][3].tagName.toLowerCase()=="textarea"){
					thisobj.res[i][3].className=thisobj.idipcl+"ip";
					thisobj.res[i][3].readOnly=false;
				}
			}
		}
		for(var i=0;i<thisobj.otherobj.length;i++){
			thisobj.otherobj[i].style.visibility="visible";
		}
		for(var i=0;i<thisobj.fids.length;i++){
			thisobj.fids[i].className=thisobj.idipcl+"id";
		}
	};
	thisobj.reset=function(){
		thisobj.unshcnf();
		thisobj.form.reset();
		for(var i=0;i<thisobj.txtareas.length;i++){
			thisobj.txtareas[i][0].value=String(thisobj.txtareas[i][1]);	
		}
	};
	thisobj.getFrml=function(){
			return thisobj.form;
	};
	if(document.getElementById(thisobj.form.id+"cont").tagName.toLowerCase()=="table"){
		var cont=document.getElementsByTagName("td");
		for(var i=0;i<cont.length;i++){
			if((cont[i].className==thisobj.idipcl+"id")&&(cont[i].id!="")){
				thisobj.fids.push(cont[i]);
			}else if(cont[i].childNodes.length>0){
				if(cont[i].childNodes[0].tagName){
					if(cont[i].childNodes[0].tagName.toLowerCase()=="input"){
						if(cont[i].childNodes[0].type=="button"){
							if(cont[i].childNodes[0].id=="nxt"){
								thisobj.nxtbt=cont[i].childNodes[0];
								thisobj.nxtbt.onmouseup=function(){
									thisobj.nxt();
								};
								thisobj.nxtbt.onkeyup=function(p_event){
									if(!p_event){
										p_event=window.event;	
									}
									if(p_event.which){
										if(p_event.which==13){
											thisobj.nxt();
										}
									}else if(p_event.keyCode){
										if(p_event.keyCode==13){
											thisobj.nxt();
										}
									}
								};
							}else if(cont[i].childNodes[0].id=="clr"){
								thisobj.clrbt=cont[i].childNodes[0];							
								thisobj.clrbt.onmouseup=function(){
									thisobj.clr();
								};
								thisobj.clrbt.onkeyup=function(p_event){
									if(!p_event){
										p_event=window.event;	
									}
									if(p_event.which){
										if(p_event.which==13){
											thisobj.clr();
										}
									}else if(p_event.keyCode){
										if(p_event.keyCode==13){
											thisobj.clr();
										}
									}
								};	
							}
						}else{
							cont[i].childNodes[0].onkeyup=function(p_event){		
								if(!p_event){
									p_event=window.event;	
								}
								if(p_event.which){
									if(p_event.which==13){
										thisobj.nxt();
									}
								}else if(p_event.keyCode){
									if(p_event.keyCode==13){
										thisobj.nxt();
									}
								}
							};
						}
					}else if(cont[i].childNodes[0].tagName.toLowerCase()=="textarea"){
						thisobj.txtareas.push(new Array(cont[i].childNodes[0],cont[i].childNodes[0].value));
					}else{
						thisobj.otherobj.push(cont[i]);
					}
				}else{
					thisobj.otherobj.push(cont[i]);
				}
			}
		}	
	}
	thisobj.fids.sort(thisobj.idsort);
	thisobj.setFocus=function(){
		document.getElementById(thisobj.fids[0].id.substring(0,thisobj.fids[0].id.lastIndexOf("_")+1)+"i").focus();
	};
	if(p_isfocus==true){		
		thisobj.setFocus();
	}
}