function cnvToUpper(nomvar,dato) {
   var datostr=new String(dato)
   eval("document." + nomvar + ".value=datostr.toUpperCase()")
   ferror=0
   return ferror
}
function CODCLI_onBlur(){
	if (document.forms[0].CODUSR.value == "" ||  document.forms[0].CODUSR.value ==  " ")
  		document.forms[0].CODUSR.value=document.forms[0].CODCLI.value;
	
}

function AGENTE_onBlur(){
//	if (document.forms[0].CODCLI.value == "" ||  document.forms[0].CODCLI.value ==  " ")
//  		document.forms[0].CODCLI.value=document.forms[0].AGENTE.value;
	
}
function onClick_boton()  {
	document.forms[0].CLAVE.value=document.forms[0].CLAVE2.value
	if (document.forms[0].CLAVE.value ==  "" ||  document.forms[0].CLAVE.value ==  " " ) {
   		alert("Debe indicar su clave")
	}else {
	 	if (document.forms[0].TIWUSR.value == "2" ){
   			if (document.forms[0].AGENTE.value == "" ||  document.forms[0].AGENTE.value ==  " ")    {
     			alert("Debe indicar el código de empresa")

    		}else {
   				if (document.forms[0].CODCLI.value == "" ||  document.forms[0].CODCLI.value ==  " ")    {
     				alert("Debe indicar su Código de Utilizador")
        		}
    		}
		}

	}
	document.forms[0].target="agenteoculto";
	document.forms[0].OASPGM.value="com.koolsite.appls.contabilidad.utils.Login"
	if (document.forms[0].OASAMB.value=="ER"){
		document.forms[0].action="http://www.koolsite.es/asc-es/OASJHTM"
	}else 
	if (document.forms[0].OASAMB.value=="EP"){
		document.forms[0].action="http://www.koolsite.es/asc-es/OASJHTM"
	}else 
	if (document.forms[0].OASAMB.value=="RE"){
		document.forms[0].action="http://www.koolsite.es/kscontabre/OASJHTM"
	}else 
	if (document.forms[0].OASAMB.value=="SE"){
		document.forms[0].action="http://www.koolsite.es/kscontabre/OASJHTM"
	}else 
	if (document.forms[0].OASAMB.value=="PR"){
		document.forms[0].action="http://www.koolsite.es/kscontabpr/OASJHTM"
	}else{
		document.forms[0].action="http://localhost:8080/koolservlet/OASJHTM"
	}
   	document.forms[0].submit()
 
   	document.forms[0].CLAVE2.value=""
}
var hayapplet=false
function onClick_boton2()  {
	if (document.forms[0].BALCON.value ==  "" ||  document.forms[0].BALCON.value ==  " " ) {
   		alert("Deve indicar o balcão")
	}else {
   		if (document.forms[0].CODCLI.value == "" ||  document.forms[0].CODCLI.value ==  " ")    {
     		alert("Deve indicar o seu codigo de utilizador")

    	}else {
			verificarLogin();
			if (hayapplet)
				return
	 		document.forms[0].target="agenteoculto";
			document.forms[0].OASPGM.value="com.koolsite.internet.utils.Login"
            document.forms[0].submit()
    	}
	}
}

function onClick_boton3()  {
	
//	var frameset = parent.document.getElementById("gennew1");
//	var frameset2 = parent.document.getElementById("gennew");
//	var frameset3 = parent.document.getElementById("gennew2");
		
//    frameset.rows = "0,0,75,0,0";
//    frameset2.rows = "75,85%";
//    frameset3.cols = "5%,95%";
//	alert ("top.FRAMECT.cols:" +top.FRAMECT.cols);
//	alert ("top.FRAMECT.document.cols:" +top.FRAMECT.document.cols);
	alert ("top.FRAMECT.document.body.cols:" +top.FRAMECT.document.body.cols);
//	alert ("top.FRAMECT.body.cols:" +top.FRAMECT.body.cols);
//	alert ("top.FRAMECT.cols:" +top.FRAMECT.cols);
//	top.FRAMECT.document.body.cols="150,0,*";
//	return;
	document.forms[0].OASPGM.value="com.koolsite.internet.utils.Login"
	document.forms[0].TIWUSR.value="0"
    document.forms[0].submit()
}


function onClick_boton4()  {
	document.forms[0].CLAVE.value=document.forms[0].CLAVE2.value
	if (document.forms[0].CLAVE.value ==  "" ||  document.forms[0].CLAVE.value ==  " " ) {
   		alert("Deve indicar a sua password")
	}
	if (document.forms[0].CODCLI.value == "" ||  document.forms[0].CODCLI.value ==  " ")    {
     			alert("Deve indicar o seu Nº de Cliente")

    		}else {
   				if (document.forms[0].CODUSR.value == "" ||  document.forms[0].CODUSR.value ==  " ")    {
     				alert("Deve indicar o seu Código de Utilizador")
 				}
	}
	
	document.forms[0].target="agenteoculto";
	document.forms[0].OASPGM.value="com.koolsite.internet.utils.Login"
	document.forms[0].action="http://localhost:8080/koolservlet/OASJHTM"
   	document.forms[0].submit()
 
}

function verificarLogin(){
	hayapplet=false
	var balcon=document.forms[0].BALCON.value
	var codcli= document.forms[0].CODCLI.value
	try {
		if (top.agenteoculto!=null&&top.agenteoculto!=undefined&&top.agenteoculto.document.CHAT!=null&&top.agenteoculto.document.CHAT!=undefined){
//			alert("hay applet")
//			alert("parametros="+balcon+"@@@"+codcli);
			top.agenteoculto.document.CHAT.verificarLogin(balcon+"@@@"+codcli);
			hayapplet=true
		}
	}catch(e){
		hayapplet=false
//		alert("error con el applet");
	} 
}
function CLAVE_onBlur_func() {
	errcampo=cnvToUpper("forms[0].CLAVE2",document.forms[0].CLAVE2.value)
}

