// JavaScript Document
function objetus() {
   var xmlhttp=false;
	try {
   		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {

                   try {
                           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                   } catch (E) {
                           xmlhttp = false;
                   }
           }
           if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                   xmlhttp = new XMLHttpRequest();
           }
           return xmlhttp
   }
   
   
  function validaCaptcha(){
           _objetus=objetus()
           _target=document.getElementById('loader')
		   if (document.formm.code.value.length != 4){
			   alert("El codigo de verificaion es incorrecto")
		   		return false
		   }
           _values_send="funcion=ejemplo5&opcion=valCaptcha&code="+document.formm.code.value
           _URL_="../js/captcha/validaCapcha.php?"
           _objetus.open("GET",_URL_+"&"+_values_send,true);
           _objetus.onreadystatechange=function() {
                   if(_objetus.readyState==4)
                   {
                           if(_objetus.status==200)
                           {
                                   _target.innerHTML = _objetus.responseText;
								   if (document.formm.resp.value=='false'){
										   cargaCaptcha()
										   alert("Inrese el codigo de validacion nuevamente")
										   document.formm.code.value.focus();
										   return false
								   }else {
									   //document.formm.submit()
								   		return true
								   }
                           }
                   }
  
           }
           _objetus.send(null);
   }  
   //carga imagen del captcha
   function cargaCaptcha(){
           _objetus=objetus()
           _target=document.getElementById('captcha')		   
		   _values_send="funcion=ejemplo5&opcion=cargaCaptcha"
           _URL_="../js/captcha/validaCapcha.php?"
           //_loader.style.display='<img src="images/loader.gif">'
           _objetus.open("GET",_URL_+"&"+_values_send,true);
           _objetus.onreadystatechange=function() {
                   if(_objetus.readyState==4)
                   {
                           if(_objetus.status==200)
                           {
                                   _target.innerHTML = _objetus.responseText;
                           }
                   }
  
           }
           _objetus.send(null);
   }