// ******************************
// INICIO FUNCIONES WAPPUSH
// ******************************

var indiceInicialWapPush = 0;
function nlimpiaInput(wp)
{
	eval("if (document.wappush_"+wp+") document.wappush_"+wp+".lt_msisdn.value = ''");
}

// esta ya existia para otras páginas
function getParametersWapPush() {
  var s = document.location + "";
  s = s.substring(s.indexOf("?")+1);
  var p = s.split(/&/);
  if (p.length < 1)
      p = s.split(/\?/);
   
  var pht={};
  if (typeof p!="undefined") {
    for(var i=0;i<p.length;i++) {
      var av=p[i].split(/=/);     
      if (typeof av!="undefined") {		  
        pht[av[0]]=(av[1]) ? av[1].split(/\?/)[0] : av[0];
      }
    }
  }
  return pht;
}


function nverWapPush( id )
{
	if (document.getElementById('fotoWapPush_'+id)) document.getElementById('fotoWapPush_'+id).style.display = 'none';
	if (document.getElementById('contenidoWapPush_'+id)) document.getElementById('contenidoWapPush_'+id).style.display = 'block';
}

// Comprobacion telefono
function telefonoWapPush(opcional,formulario, campoForm, mensaje)
{
		var errores = "";
		var tel = eval('formulario' + '.' + campoForm + '.value');
		
		if(!opcional && tel == '') return errores;
		else
		{
			var mensajeCampo = (mensaje)? mensaje : 'Teléfono de contacto'
			if(tel == '') errores += "- El campo " + mensajeCampo + " esta vacío \n";	
			else if( tel.length != 9  || isNaN(tel) || tel.substring(0,1) != '6' ) errores += "- El " + mensajeCampo + " no es válido \n";		
		}
	
	return errores;
}

function nenviar_wappush( wp )
{
	var form = eval("if (document.wappush_"+wp+") document.wappush_"+wp);
	form.urlPag.value = (form.urlPag) ? (form.urlPag.value.indexOf("?")>=0) ? form.urlPag.value.substring(0,form.urlPag.value.indexOf("?")) : form.urlPag.value : '';
	var errores = telefonoWapPush(true,form,'lt_msisdn','Número de Teléfono');
	
	if(errores == '')
	{ 
		if ( c_ck_get('pill_wp') == null )
		{
			document.cookie = 'pill_wp='+wp+';'+document.cookie;
		}
		else
		{
			setCookie('pill_wp', wp);
		}
			
		setCookie('hb', '');		
		eval("document.wappush_"+wp+".submit();");
	}
	else alert(errores);
}

function ncambioCapa( wp ) // V2
{
	eval ("document.getElementById('CambioCapa_"+wp+"').style.display = 'block'");
}

function nmostrarLongtail( wp ) // V2
{
	eval("document.getElementById('CambioCapa_"+wp+"').style.display = 'none'");
}




function checkLongtail()
{
	var actual = (c_ck_get('boxpaginada') || null);
	if (actual)
	{
		cambiaWappush(parseInt(actual), 5);			
	}
}
