// JavaScript Document
function nuevoAjax()
{ 
var xmlhttp = false;
if(window.XMLHttpRequest){
	 xmlhttp = new XMLHttpRequest();
	}else {
		if(ActiveXObject){
			var vectorVersiones=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHTTP"];
			for(var i=0;i<vectorVersiones.length;i++){
				try{
					xmlhttp=new ActiveXObject(vectorVersiones[i]);
					return xmlhttp;
				   }catch(e){}
				}
			}
	}
return xmlhttp;
/*var xmlhttp = false;
try{
	//comprobamos si es IE
	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 getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function cerrar()
{
 document.getElementById('box_reg_agencia').style.display="none";
 document.getElementById('lienzo').style.display="none";
}
function isValidUsername(sText){
	var letras=/^[a-zA-Z0-9]+$/;
	return letras.test(sText);
}
function isValidDirec(sText){
	var letras=/^[a-zA-Z0-9- ]+$/;
	return letras.test(sText);
}
function isValidEmail(sEmail) {
	var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
	return reEmail.test(sEmail);
}
function isValidPassword(sPasw,rPasw)
{
 if(sPasw==rPasw) return true;
  else return false;
}
function isValidWebsite(url)
{
 var dir_url=/^w{3}(\.\w+)*\.\w{2,3}$/; 
 return dir_url.test(url);
}
function isValidLetters(sText){
	var letras=/^[a-zA-Z- ]+$/;
	return letras.test(sText);
}
function isValidcodigoP(cod)
{
 var cdigo=/^[a-zA-Z0-9- ]+$/;
 return cdigo.test(cod);
}
function isValidRoom(cod)
{
 var cdigo=/^[a-zA-Z0-9- ]+$/;
 return cdigo.test(cod);
}
function isValidTel(tel)
{
 var tel_ext=/^\d{3}-\d{3}-\d{4}\+\(\d{3,4}\)$/;
 return tel_ext.test(tel);
}
function isValidExt(ext)
{
 var text=/^\d{3,4}$/;
 return text.test(ext);
}
function isValidPais(op)
{
 if( op == null || op == 0 )
 {
  return false;
 }
 return op;
}
function isValidFecha(sdate)
{
	var fecha=/[0-9]{4}-[0-9]{2}-[0-9]{2}/;
	return fecha.test(sdate);
}
function isValidHora(hora)
{
hora_chek=/^\d{1,2}:\d{1,2}:\d{1,2}$/;
if(hora_chek.test(hora))
  {
	time=hora.split(':');
	hour = time[0];
    minute = time[1];
    second = time[2];
	
	 if (hour < 0  || hour > 12)
	 {
      return false;
	 }
     if (minute<0 || minute > 59)
	 {
	  return false;
	 }
     if (second != null && (second < 0 || second > 59))
	 {
	  return false;
	 }
   return true;
  }
  else return false;
}
/*****************Lee y Escribe Los mensajes de ERROR**********************************/
function escribe(campo,mensaje){
	document.getElementById(campo).innerHTML=mensaje;
}
function lee(campo){
	return document.getElementById(campo).innerHTML;
}
/*****************Actualizar el captcha**********************************/
var reloadCaptcha = function()
{
 var img_captcha=document.getElementById("captchaImg");
 var rimg_captcha="captcha.php?r"+Math.random();
 img_captcha.setAttribute("src", rimg_captcha);
}
function refresh_captcha()
{
 reloadCaptcha();
}

