// JavaScript Document

//-----------------------------------------------------------------------------------

/*Creacion del Objeto AJAX GENERICO para utilizar en la Aplicacion. */
function nuevoAjax() {
  //Se define la  variable xmlhttp de forma global, para que se pueda usar desde cualquier parte el objeto.
  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 trim(string){
return string.replace(/(^\s*)|(\s*$)/g,'');
}

function OpenWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(window.screen)if(isCenter)if(isCenter=="true"){
var myLeft = (screen.width-myWidth)/2;
var myTop = (screen.height-myHeight)/2;
features+=(features!='')?',':'';
features+=',left='+myLeft+',top='+myTop;
}
window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}



function isEmailAddress2() {
var s = document.newsteller.Saludemail.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return true;
if (filter.test(s))
	return true;	
else {
		alert("Ingrese un Email verdadero!");
		return false;
	};
}

function Inscribir() {
var email = document.newsteller.Saludemail.value;
var nombre = document.newsteller.Saludnombre.value;

	if (isEmailAddress2(email)){
		ajax = nuevoAjax();
		ajax.open("GET","a_nuevonewsteller.php?email="+email+"&nombre="+nombre,true);
		ajax.onreadystatechange = function(){
			if (ajax.readyState==4){
				enviado = ajax.responseText;
				alert(enviado);
			}; 
		 };
		 ajax.send(null);
	};
}

function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

function Solicite(){
	OpenWindow('popsolicite.php','Test','','400','200','true');
}
function SoliciteContacto(){
	OpenWindow('popcontactanos.php','Test','','400','200','true');
}

function PopUp($Img){
  alert($Img);
  OpenWindow('popup.php','Test','','400','200','true');
}





