
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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' Es Necesario.\n'; }
  } 
   nombre = MM_findObj(args[i]);
 	if ( nombre.length < 3 ) errors += '- '+nm+' Debe contener ms de 3 caracteres.\n';
  
  if (errors) alert('Ocurrio el siguiente error:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function WriteSwf2(img,wsize,hsize){	
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+wsize+"\" height=\""+hsize+"\"  id=\"MyFlash2\" > ");
    document.write("<param name=\"movie\" value=\""+img+"\">");
    document.write("<param name=\"quality\" value=\"high\">");
    document.write("<param name=wmode value=transparent>");
    document.write("<embed src=\""+img+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+wsize+"\" height=\""+hsize+"\" id=\"MyFlash2\"></embed>");
   document.write("</object>");
}

function WriteSwf(img,wsize,hsize,mode){	
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 	");
	document.write("	codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" ");
	document.write("	width=\""+wsize+"\" height=\""+hsize+"\"  				");
	document.write("	id=\"MyFlash\" >										");
    document.write("<param name=\"movie\" value=\""+img+"\">					");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />	");
    document.write("<param name=\"quality\" value=\"high\">						");
	document.write("<param name=\"FlashVars\" value=\"mod="+ mode +"\">			");
    document.write("<param name=wmode value=transparent>						");
    document.write("<embed wmode=transparent 									");
	document.write("	FlashVars=\"mod="+ mode +"\"  							");
	document.write("	src=\""+img+"\" 										");
	document.write("	quality=\"high\" 										");
	document.write("	pluginspage=\"http://www.macromedia.com/go/getflashplayer\"		");
	document.write("	type=\"application/x-shockwave-flash\" 						 	");
	document.write("	width=\""+wsize+"\" height=\""+hsize+"\" 						");
	document.write("	name=\"MyFlash\"												");
	document.write(" 	swLiveConnect=\"true\">											");
	document.write("</embed> ");								
   document.write("</object>");
}

//function para abrir el popup de NetMeeting
function Abraventana() { //v2.0
	pagina="/hogares/asesor/net_pop.htm";
	var sx=screen.availWidth/2-290/2;
	var sy=screen.availHeight/2-200/2;	
 	window.open(pagina,'asesor','width=280,height=220,top='+sy+',left='+sx);
}

function mostrarDivServicio(prod)
{	
	if(document.getElementById('solicitar'))
	{
		if(document.getElementById('servicio').style.display == 'block')
			{	
				document.getElementById('Info').style.display = 'none';
				document.getElementById('servicio').style.display = 'none';
			}
			else
			{	
				document.getElementById('Info').style.display = 'none';
				document.getElementById('servicio').innerHTML = document.getElementById('solicitar').innerHTML;
				document.getElementById('servicio').style.display = 'block'
			}
	}
	else
	{	if(prod == "322" || prod == "294" || prod == "5" || prod == "12" || prod == "16" || prod == "294" || prod == "458" || prod == "27")
			{prod = "37"}
			
		if(prod == "72" || prod == "73")
			{prod = "272"}
		
		if(prod == "258")
		{ 
		document.location.href = 'https://www.etb.com.co/formularios/juegos.asp?pro_id='+prod+'&for_tipo=1';
		}
		else
		{		
		document.location.href = 'https://www.etb.com.co/formularios/?pro_id='+prod+'&for_tipo=1';
		}
	}
	
}

function mostrarDivServicioEmpresas(prod)
{	
	if(document.getElementById('solicitar'))
	{
		if(document.getElementById('servicio').style.display == 'block')
			{	
				document.getElementById('Info').style.display = 'none';
				document.getElementById('servicio').style.display = 'none';
			}
			else
			{	
				document.getElementById('Info').style.display = 'none';
				document.getElementById('servicio').innerHTML = document.getElementById('solicitar').innerHTML;
				document.getElementById('servicio').style.display = 'block'
			}
	}
	else
	{	
            if(prod == "191" || prod == "42" || prod == "234"  || prod == "235")
        	{
        		prod = "71"
        	}	
			if(prod == "111"){prod = "161"}
			if(prod == "151"){prod = "62"}
			if(prod == "419"){prod = "53"}
			
		document.location.href = 'https://www.etb.com.co/formularios/form_corp.asp?pro_id='+prod+'&for_tipo=1';
	}
	
}

function mostrarDiv(id)
{	
	if(document.getElementById(""+id+""))
	{
		if(document.getElementById(""+id+"").style.display == 'block')
			{	
				document.getElementById(""+id+"").style.display = 'none';
			}
			else
			{
				document.getElementById(""+id+"").style.display = 'block'
			}
	}
	
}

function mostrarInfoTarjeta(id)
{	
		if(id == "ny")
		{
			if(document.getElementById("ny").style.display == 'none')
				{	
					document.getElementById("ny").style.display = 'block';
					document.getElementById("otro").style.display == 'none';
				}
			else
				{
					document.getElementById("ny").style.display = 'none';					
				}
			
		}
		else if(id == "otro")
		{
			if(document.getElementById("otro").style.display == 'none')
				{	
					document.getElementById("otro").style.display = 'block';
					document.getElementById("ny").style.display = 'none';
				}
			else
				{
					document.getElementById("otro").style.display = 'none';
				}				
			
		}
}

var i_nav=0;
function mostrar(id,url)
{	
	var url = url;
	if(url != '')
	{			 
			//document.location.href = url+'&id='+id;
			abrir_seccion(url+'&id='+id,'contentarea');
			//cargar(url+'&id='+id);
	}
	else
	{		
		mostrarDiv(id)
	}
}

function cargar (url)
{	
	var pagActual = url;//document.location.href;
	var IdPrev	=  getURLParam(url,'id');
	var id1 = getURLParam(url,'id1');
	
	if(id1)
	{
		mostrarDiv(id1)
	}

	if(IdPrev)
	{
		mostrarDiv(IdPrev)		
	}
}

function mostrarInfo()
{	
	if(document.getElementById('Info').innerHTML.indexOf("ETB HP") >= 0)
	document.getElementById('Info').style.display = 'none';
	else if(document.getElementById('Info').innerHTML != '<A name=Info></A><BR>')
	{
			if(document.getElementById('Info'))
				{
				if(document.getElementById('Info').style.display == 'block')
				{	
					document.getElementById('Info').style.display = 'none';
				}
				else
				{
					document.getElementById('Info').style.display = 'block'
				}
			}
	
	}
}

function mostrarInfoEmpresas()
{	
			if(document.getElementById('Info'))
				{
				if(document.getElementById('Info').style.display == 'block')
				{	
					document.getElementById('Info').style.display = 'none';
				}
				else
				{
					document.getElementById('Info').style.display = 'block'
				}
			}
}

function mostrar_list(id)
{	
	var div = eval("document.getElementById('"+id+"');");

	if(div.style.display == 'block')
		div.style.display = 'none';
	else
		div.style.display = 'block';	
}

function info(id)
{		
	var divContenido 	= eval("document.getElementById('divCon');");
	divContenido.style.display = "block";
	
	var datos 	= eval("document.getElementById('"+id+"');");
	var info 	= eval("document.getElementById('info');");
	var titulo	= eval("document.getElementById('tit');");
	info.innerHTML = datos.innerHTML;
	
	if(id == 'info1')
		{titulo.innerHTML = "018000 112 170&nbsp;&nbsp;";}
	else if(id == 'info2')
		{titulo.innerHTML = "114&nbsp;&nbsp;";}
	else if(id == 'info3')
		{titulo.innerHTML = "170&nbsp;&nbsp;";}
	else if(id == 'info4')
		{titulo.innerHTML = "171&nbsp;&nbsp;";}
	else if(id == 'info5')
		{titulo.innerHTML = "177&nbsp;&nbsp;";}
	else if(id == 'info6')
		{titulo.innerHTML = "018000 111 178&nbsp;&nbsp;";}
	else if(id == 'info7')
		{titulo.innerHTML = "179&nbsp;&nbsp;";}
	else if(id == 'info8')
		{titulo.innerHTML = "182&nbsp;&nbsp;";}
	else if(id == 'info9')
		{titulo.innerHTML = "183&nbsp;&nbsp;";}
	else if(id == 'info10')
		{titulo.innerHTML = "178&nbsp;&nbsp;";}
}

function changeLayer(id){
	n = eval("document.getElementById('"+id+"');");
	if(n.style.display == "none")
		n.style.display = "block";
	else
		n.style.display = "none";
}

/***************** Inicio Ajax menu ******************/
function abrir_seccion(url, containerid)
{	
	var detect = navigator.userAgent.toLowerCase();
	if(detect.indexOf("msie")>-1)
		IE = true;
	else
		IE = false;
	
	var param_cab="?cab=1&is=1";

	if(url.indexOf('?')>-1)
		param_cab="&cab=1&is=1";	
		
	if(IE)
	{
		document.getElementById("ajaxnav").setAttribute('src', '/includes/ajaxnav.asp?hash='+url+param_cab);
	}
	else
	{
		if(document.location.href.indexOf('#')>-1)
		{
			document.location.href=document.location.href.substring(0,document.location.href.indexOf('#'))+"#"+url+param_cab;
		}
		else
		{
			document.location.href=document.location.href+"#"+url+param_cab;
		}
	}
}

function abrir(url, containerid)
{
	var bustcachevar = true;
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject)
	{ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e)
		{
			try
			{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	
	page_request.onreadystatechange=function()
	{		
		loadpage(url,page_request, containerid)
	}
	if (bustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

//Funcion para cambiar dinamicamente el menu principal
function ChangeMainMenu(cat)
{	
	if(cat == "hogares")
	{	//alert(cat)
		document.getElementById("1").href = "javascript:mostrar('linea1','/hogares/telocal/?prod=31&id1=Planes');";
		document.getElementById("2").href = "javascript:mostrar('ip1','/hogares/telip/?prod=72&id1=planes1');";
		document.getElementById("3").href = "javascript:mostrar('planes','/hogares/ldistancia/?prod=64');";
		document.getElementById("4").href = "javascript:mostrar('inter1','/hogares/internet/?prod=27&id1=planes1');";
		document.getElementById("5").href = "javascript:abrir_seccion('/hogares/tarjeta/?prod=198','contentarea');";
		document.getElementById("7").href = "javascript:mostrar('lardis3','/hogares/ldistancia/?prod=326')";		
	}
	else if(cat == "empresaspymes")
	{	//alert(cat)		
		document.getElementById("1").href = "javascript:mostrar('lardis1','/empresaspymes/telocal/default.asp?prod=62&id1=planes1');";
		document.getElementById("2").href = "javascript:mostrar('ip3','/empresaspymes/telip/?prod=211')";
		document.getElementById("3").href = "javascript:mostrar('lardis1','/empresaspymes/ldistancia/?prod=377&id1=planes');";
		document.getElementById("4").href = "javascript:mostrar('inter1','/empresaspymes/internet/?prod=127');";
		document.getElementById("5").href = "javascript:mostrar('tar1','/empresaspymes/tarjeta/?prod=123');";
		document.getElementById("6").href = "javascript:mostrar('tar1','/empresaspymes/conectividad/?prod=136');";
		document.getElementById("7").href = "javascript:mostrar('lardis3','/empresaspymes/ldistancia/?prod=472')";				
	}
	else if(cat == "empresas")	
	{	//alert(cat)
		document.getElementById("1").href = "javascript:mostrar('lardis1','/empresas/telocal/default.asp?prod=137&id1=planes1');";
		document.getElementById("2").href = "javascript:mostrar('ip33','/empresas/telip/?prod=211');";
		document.getElementById("3").href = "javascript:mostrar('lardis1','/empresas/ldistancia/?prod=377&id1=planes');";
		document.getElementById("4").href = "javascript:mostrar('inter1','/empresas/internet/default12.asp?prod=240');";
		document.getElementById("5").href = "javascript:mostrar('tar1','/empresas/tarjeta/?prod=163');";
		document.getElementById("6").href = "javascript:mostrar('tar1','/empresas/conectividad/?prod=157');";
		document.getElementById("7").href = "javascript:mostrar('lardis3','/empresas/ldistancia/?prod=339')";		
	}
	else 
	{	//alert(cat)
		document.getElementById("1").href = "/segmentos/telocal/";
		document.getElementById("2").href = "/segmentos/telip/";
		document.getElementById("3").href = "/segmentos/ldistancia/";
		document.getElementById("4").href = "/segmentos/internet/";
		document.getElementById("5").href = "/segmentos/tarjetas/";
		document.getElementById("6").href = "/segmentos/conectividad/";
		document.getElementById("7").href = "javascript:mostrar('lardis3','/hogares/ldistancia/?prod=326')";		
	}

}

function loadpage(url,page_request, containerid)
{		
	if (page_request.readyState == 4 )//&& page_request.status == 200)
	{	
		document.getElementById(containerid).innerHTML=page_request.responseText;
		cargar(url);
		var mod;
		
		if(url.indexOf('pymes')>-1)
		{		ChangeMainMenu('empresaspymes')
				mod = 5
		}	
		else if(url.indexOf('empresaspymes')>-1)
		{		
				ChangeMainMenu('empresaspymes')
				mod = 5
		}		
		else if(url.indexOf('sac')>-1)
		{
				mod = 3
		}	
		else if(url.indexOf('empresas')>-1)
		{		
				ChangeMainMenu('empresas')
				mod = 2
		}
		else if(url.indexOf('hogares')>-1)
		{
				ChangeMainMenu('hogares')
				mod = 1
		}
		else if(url.indexOf('tienda_virtual')>-1)
		{
				mod = 4
		}
		else if(url.indexOf('tu_casa')>-1)
		{
				ChangeMainMenu('hogares')
				mod = 1
		}
		else
		{
			mod = 6
		}
		
		if(window.document["MyFlash"])
		{
			
			//alert(mod);
			window.document["MyFlash"].SetVariable("mod", mod);
		}
		

		if(eval("document.getElementById('contacto');")){			
		display_contactenosEmpresas(getURLParam(url,"prod"));
		}		
		
		//Hogares
		if(eval("document.getElementById('solServ');"))
		{	
			display_prod(getURLParam(url,"prod"))
		}
		else if(eval("document.getElementById('solServEmpr');"))
		{	
			//Empresas
			display_prodEmpresas(getURLParam(url,"prod"))
		}
	}
}



/************** Fin Ajax Menu **************/

/***************Validacion Formulario consulta tu Factura ****************/
function ValidaForm(formulario)
{
    var retorno = true;
    var msg = "";
	if(formulario.tb_usuario.value.length < 4)
	{
		msg = msg + "\nDigite su usuario";
	}
	if(formulario.tb_pwd.value.length < 4)
	{
		msg = msg + "\nDigite su contraseña";
	}
    
    if (msg.length > 0)
	{
		alert(msg);
		return false;
	}
    return retorno;
}

function display_prod(produc) 
{  
	/// Array de productos que no requieren servicios
	var miArray = new Array(237, 216, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 284, 224, 222, 223, 220, 221, 226,225,290,240,120,42,234,235,177,109,158,120,109,257,268,113,33,100,34,182,199,30,130) ;

	
	
	for (i=0;i<miArray.length;i++){ 
			if(produc == miArray[i])
			{
						eval("document.getElementById('solServ').style.display = 'none';");
			}
	} 
}

function display_prodEmpresas(produc) 
{  
	/// Array de productos que requieren servicios
	var miArray1 = new Array(0,41,42,58,62,119,151,161,168,177,191,234,235,270);
	
	for (i=0;i<miArray1.length;i++){ 
	
			if(produc == miArray1[i])
			{				
				eval("document.getElementById('solServEmpr').style.display = 'block';");
			}
	} 
}


function display_contactenosEmpresas(produc) 
{  

			if(produc > 420)
			{
				eval("document.getElementById('contacto').style.display = 'none';");				
			}
	/// Array de productos que no requieren contactenos
	var miArray1 = new Array(0,288,326,328,329,289,300,302,357,358,359,360,361,362,363,413,290,304,306,389,308,348,413,414,415,312,314,419) ;
	
	for (i=0;i<miArray1.length;i++){ 
	
			if(produc == miArray1[i])
			{
				eval("document.getElementById('contacto').style.display = 'none';");				
			}
	} 
	
			if(produc == 426 || produc == 427 || produc == 428 || produc == 437 || produc == 481 || produc == 482 || produc == 483 || produc == 484 || produc == 446 || produc == 452)
			{
				eval("document.getElementById('contacto').style.display = 'block';");				
			}


}


function getURLParam(url,strParamName){
		
  var strReturn = "";
  var strHref = url;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }

  return strReturn;
}


