//if (parent.frames.length)
//parent.location.href= self.location;

function comprobarFormularioContacto(){

    a=comprobarFormularioContacto.arguments;
    formu=a[0];
    for(i=1; i<a.length-2; i=i+3){
        radioB=false;
        checkB=false;
        for (var j=0;j<formu.elements.length;j++) {
            var e = formu.elements[j];
            if (e.name.indexOf(a[i])>=0){
                if ((a[i+1].indexOf("Formato")>=0)&&(a[i+2]!=0)){
                    nombre=a[i+1].substring(8,a[i+1].length);
                    if (a[i+2]==1){
                        if (!(parseInt(eval("formu."+a[i]+".value")))){alert(a[a.length-1]+": "+nombre);return false;};
                    }
                    if (a[i+2]==2){
                        if (!(checkEmail(eval("formu."+a[i]+".value")))){alert(a[a.length-1]+": "+nombre);return false;};
                    }
                    if (a[i+2]==3){
                        if (!(checkPhone(eval("formu."+a[i]+".value")))){alert(a[a.length-1]+": "+nombre);return false;};
                    }
                }
                if ((a[i+1]=="Text input")||(a[i+1]=="Text area")){
                    if (eval("formu."+a[i]+".value==''")) {
                        alert(a[a.length-2]+": "+a[i+2]);
                        return false;
                    }
                }
                if (a[i+1]=="SELECT menu"){
                    if (e.selectedIndex<0)
                        alert(a[a.length-2]+": "+a[i+2]);
                }
                if (a[i+1]=="Radio buttons"){
                    if (e.checked) {radioB=true;}
                }
                if (a[i+1]=="Checkbox(es)"){
                    if (e.checked) {checkB=true;}
                }
            }
        }
        if ((a[i+1]=="Radio buttons")&&(!radioB)){alert(a[a.length-2]+": "+a[i+2]); return false;}
        if ((a[i+1]=="Checkbox(es)")&&(!checkB)){alert(a[a.length-2]+": "+a[i+2]); return false;}
    }
    return true;
}

function checkPhone(text) {
    if (/[0-9]{9}/.test(text)){
        return (true);
    }
    else if (text==""){
        return (true)
    }
    return (false);
}
function checkEmail(text) {
    //if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(text)){
    //    return (true);
    //}
    if (text.indexOf("@") > 0){
        return (true);
    }
    else if (text==""){
        return (true);
    }
    return (false);
}