﻿// JScript File

function validaCampos()
{
    var elemento;
    var e2;
    //campo codigo
//    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtCodigo');
//    if(elemento.value=='')
//        {
//            alert('El código del elemento afectado es obligatorio.');
//            return false;
//        }

    // campo nombre
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtNombre');
    e2=document.getElementById('ctl00_ContentPlaceHolder1_txtApellidos');
    if(elemento.value=='' || e2.value=='')
        {
            alert('Debe introducir su nombre y apellidos');
            return false;
        }

    // campo empresa
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbEmpresa');
    if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar una empresa.');
            return false;
        }

    // campo tipo
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbTipo');
     if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar un tipo.');
            return false;
        }
    
    // campo Subtipo
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbSubtipo');
        if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar un subtipo.');
            return false;
        }
    
    // campo tipo notificacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbtipoNotificacion');
        if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar un tipo de notificación.');
            return false;
        }
    
    // campo dir notificacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtDireccion');
        if(elemento.value=='')
        {
            alert('Debe indicar una dirección.');
            return false;
        }
        
    // campo numero
        elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtNumero');
        if(elemento.value=='')
        {
            alert('Debe indicar un número.');
            return false;
        }
        
    // campo poblacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbPoblacion');
        if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar una población.');
            return false;
        }
    
    // campo calle
    //elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtCalle');
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbCalle');
        if(elemento.value=='')
        {
            alert('Debe indicar una calle.');
            return false;
        }
        
    // campo problema
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbProblema');
        if(elemento.selectedIndex==0)
        {
            alert('Debe seleccionar un problema.');
            return false;
        }   
    return true;
}

function validaCamposBis()
{
    var elemento;
    var e2;
    //campo codigo
//    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtCodigo');
//    if(elemento.value=='')
//        {
//            alert('El código del elemento afectado es obligatorio.');
//            return false;
//        }

    // campo nombre
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtNombre');
    e2=document.getElementById('ctl00_ContentPlaceHolder1_txtApellidos');
    if(elemento.value=='' || e2.value=='')
        {
            return 1;
        }

    // campo empresa
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbEmpresa');
    if(elemento.selectedIndex==0)
        {
            return 2;
        }

    // campo tipo
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbTipo');
     if(elemento.selectedIndex==0)
        {
            return 3;
        }
    
    // campo Subtipo
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbSubtipo');
        if(elemento.selectedIndex==0)
        {
            return 4;
        }
    
    // campo tipo notificacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbtipoNotificacion');
        if(elemento.selectedIndex==0)
        {
            return 5;
        }
    
    // campo dir notificacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtDireccion');
        if(elemento.value=='')
        {
            return 6;
        }
        
    // campo poblacion
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbPoblacion');
        if(elemento.selectedIndex==0)
        {
            return 7;
        }
    
    // campo calle
    //elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtCalle');
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbCalle');
        if(elemento.value=='')
        {
            return 8;
        }
        
    // campo calle
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_txtNumero');
        if(elemento.value=='')
        {
            return 10;
        }
        
    // campo problema
//    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbProblema');
//        if(elemento.selectedIndex==0)
//        {
//            return 9;
//        }   
    return 0;
}

function validaCmbProblema()
{
    // campo problema
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbProblema');

    if(elemento.selectedIndex==0)
    {
        alert('Debe seleccionar un problema.');
        return false;
    }
    return true;
}

function validaCmbPoblacion()
{
    // campo problema
    elemento=document.getElementById('ctl00_ContentPlaceHolder1_cmbPoblacion');
    if(elemento.selectedIndex==0)
    {
        return false;
    }
    return true;
}

function compruebaTextoCalle(id)
    {
        if(validaCmbPoblacion())
            {
                var obj=document.getElementById(id);
                if(obj.value=='')
                    {
                        alert('Debe indicar algo de la calle.');
                        return false;
                    }
                return true;     
            }
        else
            {
                alert('Debe seleccionar una población.');
                return false;
            }
        
    }
    
function visualizaPopup()
{
    var txt=document.getElementById('ctl00_ContentPlaceHolder1_txtContadorProblemas');
    
    if(txt.value=='0')
        {
            alert('Introduzca algún problema');
            return false;
        }
    else
        {
            var resultado=validaCamposBis();
            switch(resultado)
                {
                    case 0: //Todo OK
                        var botonOculto=document.getElementById('ctl00_ContentPlaceHolder1_cmdHidden');
                        var extender = Sys.Application.findComponent('ctl00_ContentPlaceHolder1_mdp');
                        extender.show();
                        //botonOculto.click();
                        return false;
                        break;
                    case 1:
                        alert('Debe introducir su nombre y apellidos');
                        return false;
                        break;
                    case 2:
                        alert('Debe seleccionar un tipo.');
                        return false;
                        break;
                    case 3:
                        alert('Debe seleccionar un tipo.');
                        return false;
                        break;
                    case 4:
                        alert('Debe seleccionar un subtipo.');
                        return false;
                        break;
                    case 5:
                        alert('Debe seleccionar un tipo de notificación.');
                        return false;
                        break;           
                    case 6:
                        alert('Debe seleccionar una población.');
                        return false;
                        break;
                    case 7:
                        alert('Debe seleccionar una población.');
                        return false;
                        break;
                    case 8:
                        alert('Debe indicar una calle.');
                        return false;
                        break;
                    case 9:
                        alert('Debe seleccionar un problema.');
                        return false;
                        break;
                    case 10:
                        alert('Debe indicar un numero de calle');
                        return false;
                        break;
                }
        }
    //var extender = $find('ctl00_ContentPlaceHolder1_mdp');
    //extender.show();
    //alert(extender);
    //return validacampos();
}

function visualizaImagenes(ruta)
{
 //   validaSrcImagen();
    var x=document.getElementById('ctl00_ContentPlaceHolder1_img1');
    var urlBase=ruta;
    //x.src='';
    x.src=urlBase;
    var extender = Sys.Application.findComponent('ctl00_ContentPlaceHolder1_mpImagenes');
    extender.show();
//    if(x.width>400)
//        {
//            var nuevo_w=x.width;
//            x.width=nuevo_w/2;
//        }
//     if(x.height>200)
//        {
//            var nuevo_h=x.height;
//            x.height=nuevo_h/2;
//        }
//    alert(x.width + ' /\ ' +x.height);
    //x.src=ruta;
    return false;
}

function visualizaImagenesResponder(ruta)
{
    var x=document.getElementById('ctl00_ContentPlaceHolder1_img1Responder');
    var urlBase=ruta;    //x.src='';
    x.src=urlBase;
    var extender = Sys.Application.findComponent('ctl00_ContentPlaceHolder1_mpImagenesResponder');
    extender.show();
    return false;
}

function validaSrcImagen()
{
    var x=document.getElementById('ctl00_ContentPlaceHolder1_img1');
    var myString = new String(x.src);
    var cadena=myString.split('Temp');
}

function visualizaPnlResultadoBusqueda()
{
 
 var extender = Sys.Application.findComponent('ctl00_ContentPlaceHolder1_mdpBusqueda');   
 extender.show();
 return false;
}