function nuevoAjax()
{ 
    /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
    lo que se puede copiar tal como esta aqui */
    var xmlhttp=false; 
    try 
    { 
        // Creacion del objeto AJAX para navegadores no IE
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch(e)
    { 
        try
        { 
            // Creacion del objet AJAX para IE 
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(E) { xmlhttp=false; }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

    return xmlhttp; 
}

 function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
if(email.length <= 0)
{
return true;
}
var splitted = email.match("^(.+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_user) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
if(splitted[2].match(regexp_domain) == null) 
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
if(splitted[2].match(regexp_ip) == null) return false;
}// if
return true;
}
return false;
}

function votar(id,valor){
    ajax=nuevoAjax();
    ajax.open("GET", "/ajax_votar.php?id="+id+"&valor="+valor+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
           document.getElementById("divvotar").innerHTML=ajax.responseText;
	
 	     } 
    }
    ajax.send(null);    
		   document.getElementById("divvotarok").style.display='block';
  			setTimeout("document.getElementById('divvotarok').style.display='none';",3000);
}



function valiar_anios() {
	if (document.frmbusfecha.anio_ini.value>document.frmbusfecha.anio_fin.value){
		alert("El año inicial debe ser menor al año final.");
		document.frmbusfecha.anio_ini.focus();  
	}
	else
	{  document.frmbusfecha.submit();
	}
}

function paginarel(valor,periodo,idgenero,idactor,listado_style){
    ajax=nuevoAjax();
    ajax.open("GET", "/ajax_pagina.php?valor="+valor+"&periodo="+periodo+"&idgenero="+idgenero+"&idactor="+idactor+"&listado_style="+listado_style+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
       if (ajax.readyState==1)
        { 
           document.getElementById("list").innerHTML="<div align='center' style='margin-top:100px;'><img src='/images/loading2.gif' width='100' height='50' /></div>";
	
 	     } 
	   if (ajax.readyState==4)
        { 
           document.getElementById("list").innerHTML=ajax.responseText;
			
 	     } 
    }
    ajax.send(null);    
 
}

function votarno(id,valor){
    document.getElementById('divvotarno').style.display='block';
  setTimeout("document.getElementById('divvotarno').style.display='none';",3000);
}



 
  function abuso(){    
var accs=1;
	if (document.formabuso.email.value=="" & accs!=0){
		alert("Debes ingresar Email.");
		document.formabuso.email.focus();  
		accs=0;
		}
	if(!validateEmailv2(document.formabuso.email.value) & accs!=0){
		alert("Debes ingresar Email correcto.");
		document.formabuso.email.focus();  
		accs=0;
	}  		
	if (document.formabuso.mensaje.value=="" & accs!=0){
		alert("Debes ingresar mensaje.");
		document.formabuso.mensaje.focus();  
		accs=0;
		}		
	if (document.formabuso.validacion.value=="" & accs!=0){
		alert("Debes ingresar Codigo de Validacion.");
		document.formabuso.validacion.focus();  
		accs=0;
		}	
 	if (document.formabuso.validacion.value!=document.formabuso.validacion.value & accs!=0){
		alert("Debes ingresar Codigo de Validacion.");
		document.formabuso.validacion.focus();  
		accs=0;
		}	
	 
	if (accs==1) { document.formabuso.submit();}
	}
function abusodiv(){   
 var el = document.getElementById("divabuso"); //se define la variable "el" igual a nuestro div
el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
}


	
function eliminar_act(act){
	if (act=="Escribe el nombre")
		{
			document.getElementById('act').value="";
		}
	
	}
	
function eliminar_actdos(act){
	if (act=="Escribe el nombre")
		{
			document.getElementById('actdos').value="";
		}
	
	}
	
function mostrarthumb(idpelicula){
    document.getElementById("divimagen"+idpelicula+"").style.display="block";
}

function ocultarthumb(idpelicula){
   document.getElementById("divimagen"+idpelicula+"").style.display="none";
}

 

 
function enterkeypress(e)
{
var key=(document.all) ? e.keyCode : e.which;
if (key==13) { process();}
}
function process()
{
var val=document.frmpel.palabra.value;
if (val !="Escribe título de película")
	{
	if (val.length>2)
		{
 		document.frmpel.submit(); 	
 		}
	} 
}
function selectsearch(code)
{
if (code=="0")
	{ document.getElementById('palabra').style.border="1px #333333  solid"; 	}
else
	{ document.getElementById('palabra').style.border="1px #"+code+" solid"; 	}	
}
function resettext(text)
{
if (text=="Escribe título de película")
	{ document.getElementById('palabra').value=""; }
}
 