//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: mototaxis_comm.js
// Created: 2016-08-12
// Updates: 2016-08-12
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
var xmlHttp1;
var xmlHttpStream1;
var OpenWindows = new Object();
var isIE      	= document.all?true:false;
var isNS		= document.layers?true:false;
//-------------------------------------------------------//
window.onload = function(){
    setTimeout("loadParameters()",1000);
}
//-------------------------------------------------------//
//LEVEL 1
function loadParameters() {
    lan		  = parent.list.document.linkl.lan.value;
    appid	  = parent.list.document.linkl.appid.value;
    clase     = parent.list.document.linkl.clase.value;
    component = parent.list.document.linkl.appid.value;
	id		  = parent.list.document.linkl.id.value;
}
function Go() {
    var len   = document.linkf.pago.length;
    for (var a=0;a<len;a++) {
            if (document.linkf.pago[a].checked) {
                value = document.linkf.pago[a].value
            }
    }    
    id_field = value;
    parent.list.document.linkl.id_field.value = id_field;
    id       = eval("document.linkf."+id_field+".value");
    if(id==""){
        alert("Favor Ingrese el ID de busqueda");
        return;
    }
    var frame = "this.location.href='commf.pl?lan="+lan+"&appid="+appid+"&clase="+clase+"&id_field="+id_field+"&id="+id+"'";
    eval(frame);
    parent.list.GetOptions();
    LoadFrame();
    getExpedienteObservaciones();
}
//-------------------------------------------------------//
//LEVEL 2
function onlyDigits(e,decReq) {
    var key = (isIE) ? window.event.keyCode : e.which;
    var obj = (isIE) ? event.srcElement : e.target;
    var isNum = (key > 47 && key < 58) ? true:false;
    var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
    window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
    e.which = (!isNum && !dotOK && isNS) ? 0:key;
    return (isNum || dotOK);
}
function LoadFrame(){
    if(document.linkf.i8_mototaxi_id.value!=""){
        parent.list.OpenFrame('VerRegistro','REPT,mototaxis');
    }
}
function getExpedienteObservaciones(){
    var URL     = "/cgi-bin/"+appid+"/pl/get_observaciones.pl?appid="+appid+"&lan="+lan+"&id="+id+"&clase="+clase;
    xmlHttp11	= GetXmlHttpObject(getExpedienteObservacionesSC);
    xmlHttp11.open("GET",URL,true) ;
    xmlHttp11.send(null);
}
function getExpedienteObservacionesSC(){
    if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
        xmlHttpStream11=xmlHttp11.responseText;
        if(xmlHttpStream11==""){return;}else{
            //alert(xmlHttpStream11);
			openExpedienteObservaciones();
        }
    } 
}
function openExpedienteObservaciones(){
    var winame 	= "ExpedienteObservaciones";
	if (!OpenWindows[winame] || OpenWindows[winame].closed){
		var win ="window.open('/cgi-bin/"+appid+"/pl/expediente.observaciones.rept.pl?lan="+lan+"&appid="+appid+"&clase=mototaxi&i8_expediente_id="+id+"','ExpedienteObservacionesRept','left=150,top=100,width=900,height=600,scrollbars=1,toolbar=0,menubar=0,resizable=1,location=0,status=0')";
		OpenWindows[winame]=eval(win);
	}else{OpenWindows[winame].focus()}
}
//-------------------------------------------------------//
//AUXILIAR
function GetXmlHttpObject(handler){
	var objXmlHttp=null;	
	if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 		
	}
	if(window.ActiveXObject){// code for IE6, IE5
		objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		objXmlHttp.onreadystatechange=handler 		
	}
	if(objXmlHttp==null){alert("Your Browser Does Not Suppport AJAX")}
	return objXmlHttp;
}