function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function validate(emailad) {
var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;
	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
{
 return true
  }
 else  return false
}

function verifydigit(texto)
{
  largo = texto.length;
  for (i=0; i < largo ; i++ )
    {
   if ( texto.charAt(i) != "0" && 
        texto.charAt(i) != "1" && texto.charAt(i) != "2" && 
        texto.charAt(i) != "3" && texto.charAt(i) != "4" && 
        texto.charAt(i)!= "5" && texto.charAt(i) != "6" && 
        texto.charAt(i) != "7" && texto.charAt(i)!= "8" && 
        texto.charAt(i) != "9" && texto.charAt(i)!= "-")
        {
          return false;
        }
    }
    return true;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
var submitcount=0;

function conta() {
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else 
      {
      alert("Los datos del formulario se est&aiacute;n procesando..");
      return false;
      }
   }
function anyCheck(form)
{
	var total = 0;
	var max = form.idtema.length;
	for (var idx = 0; idx < max; idx++)
	{
	if (eval("document.form1.idtema[" + idx + "].checked") == true)
		{
			total += 1;
		}	
	}	
	if(total > 0)
	{
		document.form1.com_chec.value = 1
	}
	else
	{
		document.form1.com_chec.value = 0
	}
}
function verifica_captcha(){
	var t1;
	
	t1 = document.getElementById('texto_ingresado').value;
	if(t1 !="")
	{
		
	ajax=nuevoAjax();
	ajax.open("GET","verifica_captcha.php?texto_ingresado="+t1,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
		document.getElementById('texto_ingresado').value = "Verificando..."
//		document.getElementById('save').disabled = true;
		document.contacto.save.disabled = true; 
	 	}
		else if (ajax.readyState==4) {
			if(ajax.responseText == 0)
			{
			alert("El c&oacute;digo ingresado es incorrecto")
//			document.form1.texto_ingresado.value == ""
			document.getElementById('texto_ingresado').value = ""
			document.getElementById('texto_ingresado').focus()
//			document.getElementById('save').disabled = false;
			document.contacto.save.disabled = false;
			}
			else
			{
			document.getElementById('texto_ingresado').value = ajax.responseText
//			ddocument.getElementById('save').disabled = false;
			document.contacto.save.disabled = false;
			}		
	 	}
	}
	ajax.send(null)	
		
	}
}
function verifica_captcha_ing(){
	var t1;
	
	t1 = document.getElementById('texto_ingresado').value;
	if(t1 !="")
	{
		
	ajax=nuevoAjax();
	ajax.open("GET","verifica_captcha.php?texto_ingresado="+t1,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1) {
		document.getElementById('texto_ingresado').value = "Verificando..."
//		document.getElementById('save').disabled = true;
		document.contacto.save.disabled = true; 
	 	}
		else if (ajax.readyState==4) {
			if(ajax.responseText == 0)
			{
			alert("El c&oacute;digo ingresado es incorrecto")
//			document.form1.texto_ingresado.value == ""
			document.getElementById('texto_ingresado').value = ""
			document.getElementById('texto_ingresado').focus()
//			document.getElementById('save').disabled = false;
			document.contacto.save.disabled = false;
			}
			else
			{
			document.getElementById('texto_ingresado').value = ajax.responseText
//			ddocument.getElementById('save').disabled = false;
			document.contacto.save.disabled = false;
			}		
	 	}
	}
	ajax.send(null)	
		
	}
}
function chequea_esp(forma)
{
		
	if(forma.nombre.value=="")
	{
	alert("Ingrese su nombre")
	forma.nombre.focus()
	return false
	}
	if(forma.apellido.value=="")
	{
	alert("Ingrese su apellido")
	forma.apellido.focus()
	return false
	}
	if(forma.compania.value=="")
	{
	alert("Ingrese nombre de la compañía")
	forma.compania.focus()
	return false
	}
	if(forma.direccion.value=="")
	{
	alert("Ingrese dirección")
	forma.direccion.focus()
	return false
	}
	if(forma.ciudad.value=="")
	{
	alert("Ingrese ciudad")
	forma.ciudad.focus()
	return false
	}
	if(forma.pais.options[forma.pais.selectedIndex].value == "0" )
	{
	alert("Seleccione país")
	forma.pais.focus()
	return false
	}
	if(forma.fono.value =="")
	{
	alert("Ingrese número de teléfono")
	forma.fono.focus()
	return false
	}
	if(!verifydigit(forma.fono.value))
	{
	alert("Ingrese solo números")
	forma.fono.focus()
	return false
	}
	/*if(forma.fax.value =="")
	{
	alert("Ingrese número de fax")
	forma.fax.focus()
	return false
	}*/
	if(!verifydigit(forma.fax.value))
	{
	alert("Ingrese solo números")
	forma.fax.focus()
	return false
	}
	if(forma.email.value=="")
	{
	alert("Ingrese direcci&oacute;n de correo electr&oacute;nico")
	forma.email.focus()
	return false
	}
	if(validate(forma.email.value))
	{
    alert("Debe contener email valido.")
	forma.email.focus();
    return false
  	}
	if(forma.nombre_sitio.value=="")
	{
	alert("Ingrese nombre del sitio")
	forma.nombre_sitio.focus()
	return false
	}
	if(forma.url_sitio.value=="")
	{
	alert("Ingrese URL del sitio")
	forma.url_sitio.focus()
	return false
	}
	if(forma.categoria1.options[forma.categoria1.selectedIndex].value == "0" )
	{
	alert("Seleccione categoria 1")
	forma.categoria1.focus()
	return false
	}
	if(forma.categoria2.options[forma.categoria2.selectedIndex].value == "0" )
	{
	alert("Seleccione categoria 2")
	forma.categoria2.focus()
	return false
	}	
	if(forma.tamano1.checked == false && forma.tamano2.checked == false && forma.tamano3.checked == false && forma.tamano4.checked == false && forma.tamano5.checked == false && forma.tamano6.checked == false)
	{
	alert("Seleccione tamaño de los banners que acepta su sitio")
	return false
	}	
	if(forma.pago.checked == false && forma.pago3.checked == false)
	{
	alert("Seleccione la via de pago")
	return false
	}
	if(forma.pago.checked == true && forma.email_envio.value == "")
	{
	alert("Escriba el mail de envío")
	forma.email_envio.focus()
	return false
	}
	if(forma.pago.checked == true && forma.email_envio.value != "")
	{
		if(validate(forma.email_envio.value))
		{
    	alert("Ingrese email valido.")
		forma.email_envio.focus();
    	return false
  		}
	}
	if(forma.pago2.checked == true && forma.cuenta.value == "")
	{
	alert("Escriba la informacion de la cuenta")
	forma.cuenta.focus()
	return false
	}
	if(forma.pago3.checked == true && forma.dir_envio.value == "")
	{
	alert("Escriba la dirección del envío")
	forma.dir_envio.focus()
	return false
	}
	if(forma.texto_ingresado.value=="")
	{
	alert("Ingrese codigo de seguridad")
	forma.texto_ingresado.focus()
	return false	
	}
	if(forma.condiciones.checked==false)
	{
	alert("Debe aceptar las condiciones de registro")
	return false	
	}
return conta();
return true
}
function chequea_esp2(forma)
{
		
	/*if(forma.Company.value=="")
	{
	alert("Ingrese compañia")
	forma.Company.focus()
	return false
	}*/
	if(forma.FirstName.value=="")
	{
	alert("Ingrese nombre")
	forma.FirstName.focus()
	return false
	}
	if(forma.LastName.value=="")
	{
	alert("Ingrese apellido")
	forma.LastName.focus()
	return false
	}
	if(forma.Email.value=="")
	{
	alert("Ingrese direcci&oacute;n de correo electr&oacute;nico")
	forma.Email.focus()
	return false
	}
	if(validate(forma.Email.value))
	{
    alert("Debe contener email valido.")
	forma.Email.focus();
    return false
  	}
	/*if(forma.Phone.value =="")
	{
	alert("Ingrese número de teléfono")
	forma.Phone.focus()
	return false
	}
	if(!verifydigit(forma.Phone.value))
	{
	alert("Ingrese solo numeros")
	forma.Phone.focus()
	return false
	}
	if(forma.Street.value=="")
	{
	alert("Ingrese dirección")
	forma.Street.focus()
	return false
	}
	if(forma.City.value=="")
	{
	alert("Ingrese ciudad")
	forma.City.focus()
	return false
	}
	if(forma.State.value=="")
	{
	alert("Ingrese estado")
	forma.State.focus()
	return false
	}
	
	if(forma.ZipCode.value=="")
	{
	alert("Ingrese Codigo Postal (ZIP)")
	forma.ZipCode.focus()
	return false
	}
	if(forma.Country.value=="")
	{
	alert("Ingrese país")
	forma.Country.focus()
	return false
	}
	if(forma.Description.value=="")
	{
	alert("Ingrese Comentario")
	forma.Description.focus()
	return false
	}*/
	if(forma.texto_ingresado.value=="")
	{
	alert("Ingrese codigo de seguridad")
	forma.texto_ingresado.focus()
	return false	
	}
return conta();
return true
}
function chequea_ing(forma)
{
		
	if(forma.first_name.value=="")
	{
	alert("Enter your first name")
	forma.first_name.focus()
	return false
	}
	if(forma.last_name.value=="")
	{
	alert("Enter your last name")
	forma.last_name.focus()
	return false
	}
	if(forma.company_name.value=="")
	{
	alert("Enter company name")
	forma.company_name.focus()
	return false
	}
	if(forma.address.value=="")
	{
	alert("Enter Address")
	forma.address.focus()
	return false
	}
	if(forma.city.value=="")
	{
	alert("Enter city")
	forma.city.focus()
	return false
	}
	if(forma.country.options[forma.country.selectedIndex].value == "0" )
	{
	alert("Select a country")
	forma.country.focus()
	return false
	}
	if(forma.phone.value =="")
	{
	alert("Enter phone number")
	forma.phone.focus()
	return false
	}
	if(!verifydigit(forma.phone.value))
	{
	alert("Enter only numbers")
	forma.phone.focus()
	return false
	}
	/*if(forma.fax.value =="")
	{
	alert("Enter fax number")
	forma.fax.focus()
	return false
	}*/
	if(!verifydigit(forma.fax.value))
	{
	alert("Enter only numbers")
	forma.fax.focus()
	return false
	}
	if(forma.email.value=="")
	{
	alert("Enter Email Address")
	forma.email.focus()
	return false
	}
	if(validate(forma.email.value))
	{
    alert("Enter valid email.")
	forma.email.focus();
    return false
  	}
	if(forma.site_name.value=="")
	{
	alert("Enter site name")
	forma.site_name.focus()
	return false
	}
	if(forma.url_site.value=="")
	{
	alert("Enter site url")
	forma.url_site.focus()
	return false
	}
	if(forma.category1.options[forma.category1.selectedIndex].value == "0" )
	{
	alert("Select category 1")
	forma.category1.focus()
	return false
	}
	if(forma.category2.options[forma.category2.selectedIndex].value == "0" )
	{
	alert("Select category 2")
	forma.category2.focus()
	return false
	}	
	if(forma.size1.checked == false && forma.size2.checked == false && forma.size3.checked == false && forma.size4.checked == false && forma.size5.checked == false && forma.size6.checked == false)
	{
	alert("Select banner sizes your site accepts")
	return false
	}	
	if(forma.pay.checked == false && forma.pay3.checked == false)
	{
	alert("Select payment via")
	return false
	}
	if(forma.pay.checked == true && forma.email_sended.value == "")
	{
	alert("Enter Email")
	forma.email_sended.focus()
	return false
	}
	if(forma.pay.checked == true && forma.email_sended.value != "")
	{
		if(validate(forma.email_sended.value))
		{
    	alert("Enter valid email.")
		forma.email_sended.focus();
    	return false
  		}
	}
	
	if(forma.pay2.checked == true && forma.account.value == "")
	{
	alert("Enter account info")
	forma.account.focus()
	return false
	}
	if(forma.pay3.checked == true && forma.dir_sended.value == "")
	{
	alert("Enter address")
	forma.dir_sended.focus()
	return false
	}
	if(forma.texto_ingresado.value=="")
	{
	alert("Enter security code")
	forma.texto_ingresado.focus()
	return false	
	}
	if(forma.condiciones.checked==false)
	{
	alert("You must accept terms")
	return false	
	}
return conta();
return true
}
function chequea_ing2(forma)
{
		
	/*if(forma.Company.value=="")
	{
	alert("Enter Company")
	forma.Company.focus()
	return false
	}*/
	if(forma.FirstName.value=="")
	{
	alert("Enter First Name")
	forma.FirstName.focus()
	return false
	}
	if(forma.LastName.value=="")
	{
	alert("Enter Last Name")
	forma.LastName.focus()
	return false
	}
	if(forma.Email.value=="")
	{
	alert("Enter email")
	forma.Email.focus()
	return false
	}
	if(validate(forma.Email.value))
	{
    alert("Enter valid email")
	forma.Email.focus();
    return false
  	}
	/*if(forma.Phone.value =="")
	{
	alert("Enter phone number")
	forma.Phone.focus()
	return false
	}
	if(!verifydigit(forma.Phone.value))
	{
	alert("Enter only numbers")
	forma.Phone.focus()
	return false
	}
	if(forma.Street.value=="")
	{
	alert("Enter Street")
	forma.Street.focus()
	return false
	}
	if(forma.City.value=="")
	{
	alert("Enter City")
	forma.City.focus()
	return false
	}
	if(forma.State.value=="")
	{
	alert("Enter State")
	forma.State.focus()
	return false
	}
	
	if(forma.ZipCode.value=="")
	{
	alert("Enter Zip Code")
	forma.ZipCode.focus()
	return false
	}
	if(forma.Country.value=="")
	{
	alert("Enter Country")
	forma.Country.focus()
	return false
	}
	if(forma.Description.value=="")
	{
	alert("Enter Description")
	forma.Description.focus()
	return false
	}*/
	if(forma.texto_ingresado.value=="")
	{
	alert("Enter security code")
	forma.texto_ingresado.focus()
	return false	
	}
return conta();
return true
}
function nuevoAjax(){
	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;
}