if ( (navigator.appName == "Netscape") ) 
	{
	  document.write(
	   '<style type="text/css">' + 
	   'ul {margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: -28px;list-style-position: outside;list-style-image: url(http://www.ecsusa.com/images/blackDot.gif)}' + 
	   'li {padding:0xp}' +
	   '</style>');
	}
	else if ( (navigator.appName == "Microsoft Internet Explorer") )
	{
	  document.write(
	   '<style type="text/css">' + 
	   'ul {margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 15px;list-style-position: outside;list-style-image: url(http://www.ecsusa.com/images/blackDot.gif)}' + 
	   'li {padding:1xp}' +
	   '</style>');
	}
    else 
	{
	  document.write(
	   '<style type="text/css">' + 
	   'ul {margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 15px; list-style-position: outside;list-style-image: url(http://www.ecsusa.com/images/blackDot.gisf)}' + 
	   'li {padding:1xp}' +
	   '</style>');
}
function rollout(category) 
	{
	  if (document.getElementById) {
	     thisMenu = document.getElementById(category).style
		 if (thisMenu.display == "block") 
		 {
		    thisMenu.display = "none"
			//document.images[category+"1"].src = "images/lef_marc.gif";
		 } else { 
		    thisMenu.display = "block"
			//document.images[category+"1"].src = "images/lef_marc_1.gif";
		 }
		 return false
	  } else {
	     return true
	   }	 	 	
	}

function openBrWindow(URL,winName,features) { //v2.0
  var ws = window.open(URL,winName,features);
  ws.focus();
}

function openPage(URL) {
  window.location = URL;
}
function alertaOK() {
	alert('Para navegar no site voce precisa escolher o modelo do seu aparelho!');
}

function CheckSend(ChannelID, TargetURL, Type, Resource)
{
		
	if( Form1.chkCompromise.checked )	
	{
		if( ChannelID == 46 )
		{
			if ( Form1.txtDDD.value != "" && Form1.txtPhoneNumber.value != "" && Form1.txtPassWord.value != "" )
			{
				return true;
			}
			else
			{
				alert('Voce precisa preencher todos os campos antes de comprar.');
				return false;
			}
		}
		if( ChannelID == 82 || ChannelID == 87 )
		{
			if ( Form1.txtDDD.value != "" && Form1.txtPhoneNumber.value != "" )
			{
				return true;
			}
			else
			{
				alert('Voce precisa preencher todos os campos antes de comprar.');
				return false;
			}
		}
		if( ChannelID == 9 || ChannelID == 77  )
		{
			openBrWindow('http://minas.vivo.com.br/login/default.aspx?tiporedir=1&Target='+TargetURL,'login','width=300,height=300')
			return false;
		}
		if( ChannelID == 21 || ChannelID == 89 )
		{
			openBrWindow('http://www.amazoniacelular.com.br/login/default.aspx?tiporedir=1&recurso='+Resource+'&tiporecurso='+Type+'&Target='+TargetURL,'login','width=300,height=300')
			return false;
		}
		if( ChannelID == 0 )
		{
		  return true;
		}
		
	}
	else
	{
		alert('Voce precisa concordar com o termo de compromisso antes de comprar.');
		return false;
	}
}

function getPersonalText(ItemTypeId, ItemId, ItemFormatId, Element)
{
	document.Form1.imgItem.src = 'http://previews.ringring.com.br/Default.aspx?s=100&idt='+ItemTypeId+'&id='+ItemId+'&idf='+ItemFormatId+'&ext=gif&t='+document.Form1.txtImageChef.value; 
	return false;
}

// Script Tab automatico para formularios//
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++; 
		return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
		return true;
}

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_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_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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function  getElementHeight(Elem){
	var ns4 = document.layers;
	var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) 
		||(navigator.userAgent.indexOf("Opera/5")!=-1);
	var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) 
		||(navigator.userAgent.indexOf("Opera/6")!=-1);
	var agt=navigator.userAgent.toLowerCase();
	var mac = (agt.indexOf("mac")!=-1);
	var ie = (agt.indexOf("msie") != -1); 
	var mac_ie = mac && ie;
	
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) { 
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	} 
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i>x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function MudarTamanho()
{
	top.document.getElementById("bottom").height = getElementHeight('TblPrincipal');
	OcultarImagem();
	
}

function OcultarImagem()
{
	
	try
	{
		var categorias = ",793,794,795,796,797,798,";
	
		if( categorias.indexOf(','+CATEGORIA+',') >= 0 )
		{
			if( showMessage() )
			{
				TamanhoDivAviso();
				MM_showHideLayers('layeraviso','','show');
				MM_showHideLayers('flashtitle','','hide');
				
				
			}
			MM_showHideLayers('flashtitle','','show');
			top.document.getElementById("logoTelcel").src = "images/pixel.gif";
		}
		else
		{
			MM_showHideLayers('flashtitle','','show');
			top.document.getElementById("logoTelcel").src = "images/operadoras/63.gif";
		}
	}
	catch(ex)
	{
		try
		{
			top.document.getElementById("logoTelcel").src = "images/operadoras/63.gif";
		}
		catch(ex)
		{}
	}
}

function getQueryVariable(variable) 
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");

  for (var i=0;i<vars.length;i++)
  {
    var pair = vars[i].split("=");
  
    if (pair[0] == variable) 
    {
      return pair[1];
    }
  } 
  
  return '';
}


// Begin COOKIE
var expMinutes = 1; // number of days the cookie should last

function GetCookie(name)
{  
	var arg  = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i    = 0;  
	
	while (i < clen)
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0)
			break;   
	}  
	return null;
}

function SetCookie (name, value)
{  
	var argv    = SetCookie.arguments;  
	var argc    = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path    = (argc > 3) ? argv[3] : null;  
	var domain  = (argc > 4) ? argv[4] : null;  
	var secure  = (argc > 5) ? argv[5] : false;  

	document.cookie = name + "=" + escape (value) + 
					((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
					((path    == null) ? "" : ("; path=" + path)) +  
					((domain  == null) ? "" : ("; domain=" + domain)) +    
					((secure  == true) ? "; secure" : "");
}

function DeleteCookie (name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date(); 
exp.setTime(exp.getTime() + (expMinutes*60*1000));

function amt(){
	var count = GetCookie('adulto')
	if(count == null) 
	{
		SetCookie('adulto','1')
		return 1
	}
	else 
	{
		var newcount = parseInt(count) + 1;
		DeleteCookie('adulto')
		SetCookie('adulto',newcount,exp)
		return count
   }
}

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}


function showMessage()
{
	var count = GetCookie('adulto');
	
	if (count == null || count == 0)
	{
		return true;
	}
	
	return false;
}

function TamanhoDivAviso()
{
	document.getElementById('aviso').height = getElementHeight('TblPrincipal') - (181); 
}
//  End COOKIE

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
    }

//-->