function Clean(t) {
    if(t.value == 'Busque médico o especialidad')
        t.value="";
}

function CleanNewsletter(t) {
    if(t.value == 'Introduce tu e-mail')
        t.value="";
}

function ValidarNewsletter(f) {
    var t = f.email;
    if(t.value == 'Introduce tu e-mail') {
       alert("Debe introducir su email")
    } else {
       f.submit();
    }
}

function MM_showHideLayers() { //v6.0
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
        obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function isValidEmail(emailForm) {
    var idx_at = emailForm.value.indexOf('@');
    if (idx_at == -1 || idx_at == 0) return false;
    var idx_dot = emailForm.value.indexOf('.', (idx_at + 2));
    if (idx_dot == -1 ) return false;
    return true;
}

function isEmptyField(campo) {
    if (campo.value.length==0 || campo.value==null) return true;
    else return false;
}

function showMenu(idShow, total) {
    for (i=0;i<total;i++) {
        var hide = document.getElementById("zona"+i);
        if (i != idShow) {
            hide.style.display = 'none';
        } else {
            hide.style.display = 'block';
        }
    }
}

function searchService(f, action) {
    if((f.query.value == 'Búsque médico o especialidad') || (f.query.value == '')) {
        alert('Introduzca un médico o especialidad');
        return false;
    } else {
        f.action = action;
        return true;
    }
}

function validarFormulario(f) {
    
    if(f.conditions.checked == false)  {
        alert('Debe aceptar las condiciones de política y privacidad');
    } 
    else {
        f.submit();
    }
}

function validarContactenos(f) {
    if((f.email != null) &&  (!isValidEmail(f.email))) {
        alert('Debe introducir un email válido');
    }
    else if (f.conditions.checked == false) {
        alert ('Debe aceptar las condiciones de política y privacidad')
    }
    else {
        f.submit();
    }
}


function changeMovility(f) {
    if (f.movility[f.movility.selectedIndex].value == '1') {
        f.cityMovility.disabled = false;
    } else {
        f.cityMovility.disabled = true;
    }
}

function changeWork(f) {

    if (f.workCapio[f.workCapio.selectedIndex].value == '1') {
        f.centerWorkCapio.disabled = false;
        f.monthIniWork.disabled = false;
        f.monthEndWork.disabled = false;
        f.yearIniWork.disabled = false;
        f.yearEndWork.disabled = false;
    } else {
        f.centerWorkCapio.disabled = true;
        f.monthIniWork.disabled = true;
        f.monthEndWork.disabled = true;
        f.yearIniWork.disabled = true;
        f.yearEndWork.disabled = true;
    }
}

function controlarCurriculum() {
	var workCapio = document.getElementById("workCapio");
	var centerWorkCapio = document.getElementById("centerWorkCapio");
	var monthIniWork = document.getElementById("monthIniWork");
	var monthEndWork = document.getElementById("monthEndWork");
	var yearIniWork = document.getElementById("yearIniWork");
	var yearEndWork = document.getElementById("yearEndWork");
	var movility = document.getElementById("movility");
	var cityMovility = document.getElementById("cityMovility");
	
	if (workCapio[workCapio.selectedIndex].value == '1') {
    	centerWorkCapio.disabled = false;
        monthIniWork.disabled = false;
        monthEndWork.disabled = false;
        yearIniWork.disabled = false;
        yearEndWork.disabled = false;
    } else {
    	centerWorkCapio.disabled = true;
        monthIniWork.disabled = true;
        monthEndWork.disabled = true;
        yearIniWork.disabled = true;
        yearEndWork.disabled = true;
    }

    if (movility[movility.selectedIndex].value == '1') {
        cityMovility.disabled = false;
    } else {
        cityMovility.disabled = true;
    }
}

function isBadFormat(s){
    if(s!= null && s.value!=null) {
        if(s.value == "") {
            return true;
        }
        if(!isNaN(s.value)) {
            return false;
        }
    }
    return true;
}

function asignarFuncionesDesplegables () {
    var h2s = document.getElementById('content').getElementsByTagName('H2');
    for (i = 0; i < h2s.length; i++) {
        h2s[i].onclick = function () { deployUndeploy(this); };
        h2s[i].style.cursor = "pointer";
    }

    var divs = document.getElementById('content').getElementsByTagName('DIV');
    for (i = 0; i < divs.length; i++) {
        if (divs[i].getAttribute("id")!='descargaDocumentos' && divs[i].className !='rightColumn') divs[i].style.display = 'none';
    }
}

function deployUndeploy (objectThis) {

    var i;
    var brother = objectThis.nextSibling;

    while (brother.nodeName != 'DIV')
    {
        brother = brother.nextSibling;
    }
    if (brother.nodeName == 'DIV') {
        if (brother.style.display == 'none') {
            // brother.class= "";
            brother.style.display = 'block';
        } else {
            // brother.class= "";
            brother.style.display = 'none';
        }
    }
}

function showMenuNoServices(idShow) {
    var show = document.getElementById(idShow);
    if(show.style.display == 'none') {
        show.style.display = 'block';
    } else {
        show.style.display = 'none';
    }
}

function changeTypeContact(f) {
    var v = f.typeContact.options[f.typeContact.selectedIndex].value;
    var sug = document.getElementById("tr_sugerencia");
    var inf = document.getElementById("tr_information");
    var env = document.getElementById("tr_enviar");
    if (v == '0') {
        sug.style.display = 'block';
        env.style.display = 'block';
        inf.style.display = 'none';
    } else if (v == '1') {
        sug.style.display = 'none';
        env.style.display = 'block';
        inf.style.display = 'block';
    } else {
        sug.style.display = 'none';
        env.style.display = 'none';
        inf.style.display = 'none';
    }
}

function isInteger(value){
    if (value.indexOf('.') >= 0) {
        return false;
    }
    if (isNaN(value)) {
        return false;
    }else{
        return true;
    }
}