// JavaScript Document
var p=0;
var gal_exit=false;
function recarga(){
	var izquierdo =document.getElementById('banners_izq');
	var derecho =document.getElementById('banners_der');
	var ajax=creaAjax();
	ajax.open ('GET', '/JPVajax.php?pag=1', true);
	ajax.onreadystatechange = function() { 
				 if (ajax.readyState==4){
                         if(ajax.status==200){ 
						 					if (ajax.responseText=="")
											{
												izquierdo.innerHTML='<div align="center" class="error" style="margin-top:40; width:100%;">error</div>' ;
												
											}
											else {mensaje=ajax.responseText;
												posicion = mensaje.split('*');
											    izquierdo.innerHTML=posicion[0];
												derecho.innerHTML=posicion[1];
											   }
	  						    
							}
		               }
	}
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send( null);
}
function trim(cad)
{
	return cad.replace(/^(\s|\&nbsp;)*|(\s|\&nbsp;)*$/g,"");
}

function ValidaCampos() {
    var er_nombre = /^([a-zA-ZÑñáÁÉéÍíÓóÚú\.\s])+$/
	var er_tlfono = /^([0-9\s\-])+$/
	var er_mail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.([a-zA-Z]{2,4})$/
	
	
	msj="";
    tmp=trim(document.fcontacto.nombre.value);
	
	if (tmp.length<6){ msj="El nombre debe tener por lo menos 6 caracteres.<br>"} 
	else if(!er_nombre.test(tmp)) {msj="El nombre s&oacute;lo permite: A-Z,a-z,espacios,puntos.<br>"}
	
	
	tmp=trim(document.fcontacto.tel.value);
	
	if (tmp.length<6){ msj=msj+"El tel&eacute;fono debe tener por lo menos 7 caracteres.<br>"} 
	else if(!er_tlfono.test(tmp)) {msj=msj+"El tel&eacute;fono  s&oacute;lo permite: 0-9,espacios,guion medio (-).<br>"}

   
	tmp=trim(document.fcontacto.correo.value);
	if (tmp.length<10){ msj=msj+"El E-mail debe tener por lo menos 10 caracteres.<br>"} 
	else if(!er_mail.test(tmp)) {msj=msj+"El e-mail no es un formato valido.<br>"}
	
	tmp=trim(document.fcontacto.comentario.value);
	if (tmp.length==0){ msj=msj+"Es obligatorio el mensaje."} 
	


	if(msj.length==0){
		document.getElementById('msj_form').style.display="none";
		return true;}
	else {
		
		document.getElementById('error_form').innerHTML=msj;  
		document.getElementById('msj_form').style.display="block";
		return false}
		
} 



function rpvWIN(Windowpage,WinWidth,WinHeight,sScroll){winleft=(screen.width-WinWidth)/2;wintop=(screen.height-WinHeight)/2;
	string="toolbar=0,scrollbars="+sScroll+",location=0,statusbar=0,menubar=0,resizable=no,width="+WinWidth+",height="+WinHeight+",left="+winleft+",top="+wintop+"";
	winend=window.open(Windowpage,"_blank",string);
}
function rpvJUMP(uri){
		if(uri!=''&&uri!='#')
		{ if (uri.indexOf("http")<0) {window.location=uri;}
		  else {window.open(uri, '_blank');}
		}
}
function rpvIMG(rP){if(rP!=''){rpvWIN("/rpvdo.php?s=image&i="+rP,660,480,0);}}
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }
         return objetoAjax;
}
     

 	setInterval('recarga()',60000);

