// JavaScript Document

function FDK_StripChars(theFilter,theString) {
        var strOut,i,curChar
        strOut = ""
        for (i=0;i < theString.length; i++) {           
                curChar = theString.charAt(i)
                if (theFilter.indexOf(curChar) < 0)     // if it's not in the filter, send it thru
                        strOut += curChar               
        }       
        return strOut
}

function FDK_Trim(theString) {
 var i,firstNonWhite
 if (FDK_StripChars(" \n\r\t",theString).length == 0 ) return ""
        i = -1
        while (1) {
                i++
                if (theString.charAt(i) != " ")
                        break   
        }
        firstNonWhite = i
        //Count the spaces at the end
        i = theString.length
        while (1) {
                i--
                if (theString.charAt(i) != " ")
                        break   
        }       
        return theString.substring(firstNonWhite,i + 1)
}

function validar(form){
    form.Nombre.value=FDK_Trim(form.Nombre.value)
    
    if(form.Sistema.value=='-'){alert('Por Favor indique el Sistema');form.Sistema.focus();return false;}
    if(form.TopicoContacto.value=='-'){alert('Por Favor indique Tópico de Contacto');form.TopicoContacto.focus();return false;}

    if(form.consultas.value.length==0){alert('Debe ingresar su consulta o descripción de problema');form.consultas.focus();return false;}

    if(form.Nombre.value.length==0){alert('Debe ingresar Nombre Contacto');form.Nombre.focus();return false;}

    if(form.correo.value.length==0){alert('Debe ingresar su email');form.correo.focus();return false;}

        //Checkear validez email
        var idx_at = form.correo.value.indexOf("@",0);
        var tstr = form.correo.value.toString();
        tstr = tstr.substring(idx_at+1);
        var idx_dot = tstr.indexOf(".",0);
        if(idx_at < 1 || idx_dot < 1 || idx_dot > tstr.length-3) {alert('Debe ingresar un email válido');form.correo.focus();return false;}

    if(form.MetodoContacto.value=='-'){alert('Por Favor indique Método de Contacto');form.MetodoContacto.focus();return false;}

    return true;
} 