if (securityMode)
{
    /*DESHABILITAMOS EL BOTON DERECHO DEL RATÓN*/
    /*document.oncontextmenu = function(){return false};*/

    /*DESHABILITAMOS LA SELECCIÓN DE TEXTO*/
    /*function disableselect(e){ return false; }

    function reEnable(){ return true; }

    document.onselectstart=new Function ("return false")

    if (window.sidebar)
    {
       document.onmousedown=disableselect;
       document.onclick=reEnable;
    }*/


    /*SCRIPT QUE DESHABILITA:
    - Ctrl + cualquier tecla
    - Botón Print Screen
    - Archivo -> Imprimir...
    - Botón derecho del Mouse*/

    hp_ok = true;

    function hp_d00(s)
    {
      if(!hp_ok) return;
      document.write(s)
    }

    function hp_ne() { return true }

    onerror = hp_ne;

    function hp_dn(a) { return false }

    function hp_cm() { return false }

    function hp_de(e)
    {
        return(e.target.tagName != null && e.target.tagName.search('^(INPUT|TEXTAREA|BUTTON|SELECT)$') != -1)
    }

    function hp_md(e)
    {
        mac = navigator.userAgent.indexOf('Mac') != -1;

        if(document.all)
        {
            if(event.button == 2 || (mac && (event.ctrlKey || event.keyCode == 91))) { return(false) }
        }
        else
        {
            if(e.which == 3 || (mac && (e.modifiers == 2 || e.ctrlKey)))
            {
                return false
            }
            else if(e.which == 1)
            {
                window.captureEvents(Event.MOUSEMOVE);
                window.onmousemove = hp_dn
            }
            else if (e.ctrlKey)
            {
                return false
            }
        }
    }

    function hp_mu(e)
    {
        if(e.which == 1)
        {
            window.releaseEvents(Event.MOUSEMOVE);
            window.onmousemove = null
        }
    }

    if(navigator.appName.indexOf('Internet Explorer') == -1 || (navigator.userAgent.indexOf('MSIE') != -1 && document.all.length != 0))
    {
        if(document.all)
        {
            mac=navigator.userAgent.indexOf('Mac') != -1;
            version = parseFloat('0'+navigator.userAgent.substr(navigator.userAgent.indexOf('MSIE')+5),10);

            if(!mac && version > 4)
            {
                document.oncontextmenu = hp_cm
            }
            else
            {
                document.onmousedown=hp_md;
                document.onkeydown=hp_md;
            }

            document.onselectstart = hp_dn
        }
        else if(document.layers)
        {
            window.captureEvents(Event.MOUSEDOWN|Event.modifiers|Event.KEYDOWN|Event.MOUSEUP);
            window.onmousedown = hp_md;
            window.onkeydown = hp_md;
            window.onmouseup = hp_mu;
        }
        else if(document.getElementById && !document.all)
        {
            document.onkeydown=hp_md;

            document.oncontextmenu = hp_cm;
            document.onmousedown = hp_de
        }
    }

    function hp_dp1()
    {
        for(i=0; i<document.all.length; i++)
        {
            if(document.all[i].style.visibility != "hidden") { document.all[i].style.visibility = "hidden"; document.all[i].id = "hp_id"; }
        }
    }

    function hp_dp2()
    {
        for(i=0;i<document.all.length;i++)
        {
            if(document.all[i].id == "hp_id") document.all[i].style.visibility = ""
        }
    }

    window.onbeforeprint=hp_dp1;
    window.onafterprint=hp_dp2;
    document.write('<style type="text/css" media="print"><!--body{display:none}--></style>');

    function hp_dc()
    {
        hp_ta.createTextRange().execCommand("Copy");
        setTimeout("hp_dc()",300)
    }

    if(navigator.appName.indexOf('Internet Explorer') == -1 || (navigator.userAgent.indexOf('MSIE') != -1 && document.all.length != 0))
    {
        if(document.all && navigator.userAgent.indexOf('Opera') == -1)
        {
            document.write('<div style="position:absolute;left:-1000px;top:-1000px"><input type="textarea" name="hp_ta" value=" " style="visibility:hidden"></div>');
            hp_dc()
        }
    }

    function hp_ndd() { return false }

    document.ondragstart = hp_ndd;
}


function xmlhttpPost_login()
{
    document.getElementById('errorValidate').innerHTML = "&nbsp;";
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) { // Mozilla & Safar
        self.xmlHttpReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', 'examen_ajax.php', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
    {
        if (self.xmlHttpReq.readyState == 4)
        {
            textReturn = unescape(self.xmlHttpReq.responseText);
            if (textReturn == 1) {
                document.formulario.nif.value = "";
                document.formulario.pass.value = "";
                window.open('examen.php', '', 'width='+screen.width+',height='+screen.height+',menubar=no,location=no,resizable=no,scrollbars=yes,status=no');
            } else if(textReturn == 2) {
                document.getElementById('errorValidate').innerHTML = "<div class='error'><b>* ERRORES</b><ul><li>Lo sentimos, pero ha caducado el periodo del que disponia para realizar las pruebas. (2)</li></ul></div>";
            } else if(textReturn == 3) {
                document.getElementById('errorValidate').innerHTML = "<div class='error'><b>* ERRORES</b><ul><li>Lo sentimos, pero ha caducado el periodo del que disponia para realizar las pruebas. (3)</li></ul></div>";
            } else {
                document.getElementById('errorValidate').innerHTML = "<div class='error'><b>* ERRORES</b><ul><li>Nif / Password incorrectos</li></ul></div>";
            }
        }
    }
    self.xmlHttpReq.send('nif='+document.formulario.nif.value+'&pass='+document.formulario.pass.value+'&op=login');
}
