function popup(url,name,width,height,resize,scroll) {
var dialogWin = new Object();
dialogWin.width = width;
dialogWin.height = height;
now = new Date();
var millis=now.getTime();
var mstr=""+millis;
if (navigator.appName == "Netscape") {
dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
} else if (document.all) {
dialogWin.left = (screen.width - dialogWin.width) / 2;
dialogWin.top = (screen.height - dialogWin.height) / 2;
var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
}
tienesp=false;
for (i=0; i<url.length; i++)
if (url.charAt(i)=='?')
tienesp=true;
if (tienesp)
nocach='&nocache='+mstr;
else
nocach='?nocache='+mstr;
window.open(url + nocach ,name,attr);
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

var is_regexp = (window.RegExp) ? true : false;

function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}



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 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 colexp(objid,action)
{
	obj = fetch_object(objid);
	cel = fetch_object(objid);
	img = fetch_object(objid);
	
	
	switch (action)
	{
		case 'expand':
			obj.style.display = '';
			break;
			
		case 'colapse':
			obj.style.display = 'none';
			break;
		
		case '':
			if (obj.style.display == 'none')
			{
				
				obj.style.display = '';
			}
			else
			{
				obj.style.display = 'none';
			}		
			break;
		
	}
	return false;
}

function validarSitio(){ 
   var enviar;

   window.document.step_2.onsubmit = function ( ) {  { return false;} }
  if (window.document.step_2.Sitio_web.value=="" ||  window.document.step_2.Sitio_web.value=="www.misitioweb.com.ar"){
	alert("Por favor ingrese un sitio web");
	 window.document.step_2.Sitio_web.focus();
	return false;
  }else{
      
     //    var re=/^w+(\.\w+)*\.\w{2,3}$/; 
      //   var re2=/^http:\/\/\w+(\.\w+)*\.\w{2,3}$/; 
        
     //    if (re.test(window.document.step_2.Sitio_web.value) || re2.test(window.document.step_2.Sitio_web.value )) {
		    //alert('SITIO OK');
    //     }else{		
	 //	    alert('Por favor ingrese una dirección válida de su sitio web');
	 //	    window.document.step_2.Sitio_web.focus();
	 //	    return false;
	 //    }
      
      
      
       var block = document.getElementById("blockUI");
       block.style.display = 'block';
       window.document.getElementById('layer').style.visibility="visible"; 
       xmlhttpPost(window.document.step_2.Sitio_web.value);
        window.document.step_2.onsubmit = function ( ) {  { return false;} }
  }
} 


function xmlhttpPost(strURL) {
    var strASP = "ajaxValidarUrl.asp?sURL=" + escape(strURL) ;
 //  alert(strASP);
    var xmlHttpReq = false;
  //  var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open("GET", strASP, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            updatepage(xmlHttpReq.responseText);
         // window.alert(xmlHttpReq.responseText);
        }
    }
    xmlHttpReq.send(null);
}



function updatepage(str){
 //  alert(str);
    var enviar;
  if (str== -1){
     window.document.getElementById('layer').style.visibility="hidden";
     var block = document.getElementById("blockUI");
     block.style.display = 'none'; 
     window.document.getElementById('msgerror').innerHTML="La dirección ingresada es inválida. Por favor verifíquela.<br/><br/>"; 
     window.document.step_2.onsubmit = function ( ) {  { return false;} }
  }else{
     window.document.step_2.submit();
    }
    window.document.step_2.onsubmit = function ( ) {  { return false;} }
}



    
    


function validarPais()
{
var marcado = "no";
with (document.step_3)
{
for ( var i = 0; i < ID_Pais.length; i++ ) 
{
    if ( ID_Pais[i].checked ) 
    {
     var marcado = "si";
     document.step_3.submit();
    }
}
if ( marcado == "no" )
{
window.alert("Por favor ingrese al menos un país" ) ;
	return false;
}
}
}


function versal(cadena) {
  var er = /[A-Z,Ñ].*$/ ;
  return er.test(cadena)
}



function charMay(cadena) {
  var contadorMay = 0;
  var flagMay = false;
    for (x = 0; x < cadena.length; x++) {
     //   alert(cadena.charAt(x));
        flagMay = versal(cadena.charAt(x));
     //   alert(flagMay);
        if (flagMay){
           contadorMay++;
        //    alert(contadorMay);
        }else{
            contadorMay = 0;
        }
     }
   //  alert(contadorMay);
   return contadorMay;
}


function validarAnuncio()
{

//alert(versal(document.step_4.titulo.value));

//alert(document.step_4.titulo.value.length);
//alert(document.step_4.titulo.value.charAt(3));



//document.step_4.titulo.value = document.step_4.titulo.value.toLowerCase();
	if (document.step_4.titulo.value=="") {
		alert("Por favor, ingrese el título del anuncio.");
		document.step_4.titulo.focus();
		return false;
	}else{
	
	      var cantMay = charMay(document.step_4.titulo.value);
	      var tituloUpPer = document.step_4.titulo.value.toUpperCase();
	      
	      if (cantMay > 4 || document.step_4.titulo.value== tituloUpPer){
	        alert("No está permitido el uso excesivo de Mayúsculas en el texto de los anuncios. Por favor corrija el texto e intente nuevamente.");
		    document.step_4.titulo.focus();
		    return false;
	      }
	}
	if (document.step_4.linea1.value=="") {
		alert("Por favor, ingrese la primera línea del anuncio.");
		document.step_4.linea1.focus();
		return false;
    }else{
      
      var cantMay = charMay(document.step_4.linea1.value);
      var linea1UpPer = document.step_4.linea1.value.toUpperCase();
      
      if (cantMay > 4 || document.step_4.linea1.value== linea1UpPer){
        alert("No está permitido el uso excesivo de Mayúsculas en el texto de los anuncios. Por favor corrija el texto e intente nuevamente.");
	    document.step_4.linea1.focus();
	    return false;
      }
	}    
	if (document.step_4.linea2.value=="") {
		alert("Por favor, ingrese la segunda línea del anuncio.");
		document.step_4.linea2.focus();
		return false;
	
	}else{
	
	  var cantMay = charMay(document.step_4.linea2.value);
	  var linea2UpPer = document.step_4.linea2.value.toUpperCase();
	    
      if (cantMay > 4 || document.step_4.linea2.value== linea2UpPer){
        alert("No está permitido el uso excesivo de Mayúsculas en el texto de los anuncios. Por favor corrija el texto e intente nuevamente.");
	    document.step_4.linea2.focus();
	    return false;
      }
	
	
    }	   
    var block = document.getElementById("blockUI");
    block.style.display = 'block'; 
    window.document.getElementById('layer').style.visibility="visible"; 
    var strASP = "ajaxValidarAnuncio.asp?titulo=" + document.step_4.titulo.value + "&linea1=" + document.step_4.linea1.value + "&linea2=" +  document.step_4.linea2.value + "&Sitio_web=" + document.step_4.Sitio_web.value;
 //   alert(strASP);
    var xmlHttpReq = false;
  //  var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open("GET", strASP, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            updatepageAnuncio(xmlHttpReq.responseText);
        // window.alert(xmlHttpReq.responseText);
        }
    }
    xmlHttpReq.send(null);
//	document.step_4.submit();
}

function updatepageAnuncio(str){
 // alert(str);
  var enviar;
 
  
  if (str== -1 || str== -2){
     window.document.getElementById('layer').style.visibility="hidden"; 
     var block = document.getElementById("blockUI");
     block.style.display = 'none'; 
     if (str== -1){     
          window.document.getElementById('msgerror').innerHTML="El anuncio no condice con las <a href=\"javascript:popup('popup-politicas.asp','popup',550,500,'no','no');\" class=\"anu_tit\">políticas editoriales.</a> Por favor lea las mismas y corrija el anuncio.</br>"; 
     }else{
          window.document.getElementById('msgerror').innerHTML="El anuncio que está intentando publicar, contiene una marca registrada cuyo propietario ha restringido su uso.</br> Si usted posee autorización escrita del mismo, por favor <a href=\"javascript:popup('contacto.asp','popup',800,1024,'no','yes');\" class=\"anu_tit\">contáctese con nosotros</a>, muchas gracias.</br>";      
     }
     window.document.step_4.onsubmit = function ( ) {  { return false;} }
  }else{
      if (str== 1){
          enviar  = 1 ;
      }else{
          enviar  = 0 ;
      }
  //    alert(enviar);
      document.step_4.flagException.value = enviar;
      window.document.step_4.submit();
  }
  window.document.step_4.onsubmit = function ( ) {  { return false;} }
}



function validarKeywords()
{
	haytexto=0;
	for (i=0;i<document.step_5.keyword.length;i++) {
		if (document.step_5.keyword[i].value!="") haytexto=1;
	}
	if (haytexto==0) {
		alert("Debe ingresar al menos una palabra clave para su campaña.");
	    return false;
	} 
	document.step_5.submit();
}


function validardatos()
{
	



	if (document.step_6_3.RazonSocial.value=="") {
		alert("Por favor, ingrese su nombre o razón social.");
		document.step_6_3.RazonSocial.focus();
		return false;
	}
	
		if (document.step_6_3.Telefono.value=="") {
		alert("Por favor, ingrese su teléfono.");
		document.step_6_3.Telefono.focus();
		return false;
	}
	
	
		if (document.step_6_3.Contacto.value=="") {
		alert("Por favor, ingrese su contacto.");
		document.step_6_3.Contacto.focus();
		return false;
	}
	

	
	if (document.step_6_3.DomicilioLegal.value=="") {
		alert("Por favor, ingrese su domicilio legal.");
		document.step_6_3.DomicilioLegal.focus();
		return false;
	}
	
	strErr = "";

      if ( !strErr.length && !document.step_6_3.Email.value.length ){
        strErr = "Por favor, ingrese un E-Mail.";
      }

      if ( !strErr.length && ( document.step_6_3.Email.value.indexOf("@") == -1 || document.step_6_3.Email.value.indexOf(".") == -1 ) ){
        strErr = "Por favor, ingrese un E-Mail valido.";
      }

      if ( strErr.length ){
        alert(strErr);
        document.step_6_3.Email.focus();
       return false;
     
      }
	
    if (document.step_6_3.Password.value=="") {
		alert("Por favor, ingrese una contraseña.");
		document.step_6_3.Password.focus();
		 return false;
	}
	
	
    if (document.step_6_3.Password2.value=="") {
		alert("Por favor, ingrese la confirmación de la contraseña.");
		document.step_6_3.Password2.focus();
		 return false;
	}
	
	if (document.step_6_3.Password.value != document.step_6_3.Password2.value) {
		alert("Las contraseñas no coinciden, por favor ingreselas nuevamente.");
		document.step_6_3.Password.focus();
	   return false;
	}
	
	if (document.step_6_3.terms.checked==false) {
		alert("Para continuar, debe leer y aceptar los Términos y Condiciones del servicio.")
	   return false;
	}
//	alert('ATENCION: A continuación, usted será direccionado a DineroMail, donde podrá realizar su pago con su tarjeta de crédito. Al finalizar, regresará automáticamente a este sitio.');
	document.step_6_3.submit();
}



function validardatosLogin()
{
	
	if (document.step_6_1.RazonSocial.value=="") {
		alert("Por favor, ingrese su nombre o razón social.");
		document.step_6_1.RazonSocial.focus();
		return false;
	}
	
		if (document.step_6_1.Telefono.value=="") {
		alert("Por favor, ingrese su teléfono.");
		document.step_6_1.Telefono.focus();
		return false;
	}
	
	
		if (document.step_6_1.Contacto.value=="") {
		alert("Por favor, ingrese su contacto.");
		document.step_6_1.Contacto.focus();
		return false;
	}
	
	
	if (document.step_6_1.DomicilioLegal.value=="") {
		alert("Por favor, ingrese su domicilio legal.");
		document.step_6_1.DomicilioLegal.focus();
		return false;
	}

	

	if (document.step_6_1.terms.checked==false) {
		alert("Para continuar, debe leer y aceptar los Términos y Condiciones del servicio.")
	    return false;
	}
//	alert('ATENCION: A continuación, usted será direccionado a DineroMail, donde podrá realizar su pago con su tarjeta de crédito. Al finalizar, regresará automáticamente a este sitio.');
	document.step_6_1.submit();
}



function ValidarLoginUser(){
   
   
   
	strErr = "";

      if ( !strErr.length && !document.step_6_2.User.value.length ){
        strErr = "Por favor, ingrese un E-Mail.";
      }

      if ( !strErr.length && ( document.step_6_2.User.value.indexOf("@") == -1 || document.step_6_2.User.value.indexOf(".") == -1 ) ){
        strErr = "Por favor, ingrese un E-Mail valido.";
      }

      if ( strErr.length ){
        alert(strErr);
        document.step_6_2.User.focus();
      }else{
      
         if (document.step_6_2.Pass.value=="") {
		    alert("Por favor, ingrese una contraseña.");
		    document.step_6_2.Pass.focus();
		 }else{  
		    location.href='step_6.asp?User=' + document.step_6_2.User.value + '&Pass=' + document.step_6_2.Pass.value + '&ID_Partner=' + document.step_6_2.ID_Partner.value + '&ID_Paquete=' + document.step_6_2.ID_Paquete.value + '&ID_Campana=' + document.step_6_2.ID_Campana.value +'&Keywords='+ document.step_6_2.Keywords.value  + '&Keyword=' + document.step_6_2.Keyword.value  + '&Paises=' + document.step_6_2.Paises.value +'&Titulo=' + document.step_6_2.Titulo.value +'&Linea1='+ document.step_6_2.Linea1.value +'&Linea2='+ document.step_6_2.Linea2.value +'&chk='+ document.step_6_2.chk.value  +'&ID_Pais='+ document.step_6_2.ID_Pais.value +'&ID_Lenguaje=' + document.step_6_2.ID_Lenguaje.value +'&Sitio_web=' + document.step_6_2.Sitio_web.value +'&Paquete=' + document.step_6_2.Paquete.value +'&flagException=' + document.step_6_2.flagException.value ;
	     }
     
      }
   

}


function ValidarLoginUserCampanas(){
   
   
   
	strErr = "";

      if ( !strErr.length && !document.step_6_2.User.value.length ){
        strErr = "Por favor, ingrese un E-Mail.";
      }

      if ( !strErr.length && ( document.step_6_2.User.value.indexOf("@") == -1 || document.step_6_2.User.value.indexOf(".") == -1 ) ){
        strErr = "Por favor, ingrese un E-Mail valido.";
      }

      if ( strErr.length ){
        alert(strErr);
        document.step_6_2.User.focus();
        return false;
      }else{
      
         if (document.step_6_2.Pass.value=="") {
		    alert("Por favor, ingrese una contraseña.");
		    document.step_6_2.Pass.focus();
		    return false;
		 }     
      }
 //  return true;
document.step_6_2.submit();
}
