

/* detect.js */
var url1 = "http://espanol.verizon.com/enes/sdsearch/";
var agt=navigator.userAgent.toLowerCase();
var appVer=navigator.appVersion.toLowerCase();
var is_minor=parseFloat(appVer);
var is_major=parseInt(is_minor);
var iePos=appVer.indexOf('msie');
if (iePos!=-1){
	is_minor=parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
	is_major=parseInt(is_minor);}
var is_opera=(agt.indexOf("opera")!=-1);
var is_konq=false;
var kqPos=agt.indexOf('konqueror');
if(kqPos!=-1){
	is_konq=true;}
var is_safari=((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var is_khtml=(is_safari||is_konq);
var is_moz=((agt.indexOf('mozilla/5')!=-1)&&(agt.indexOf('spoofer')==-1)&&
		(agt.indexOf('compatible')==-1)&&(agt.indexOf('opera')==-1)&&
		(agt.indexOf('webtv')==-1)&&(agt.indexOf('hotjava')==-1)&&
		((navigator.vendor=="")||(navigator.vendor=="Mozilla")));
var is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)
		&&(agt.indexOf('compatible')==-1)&&(agt.indexOf('opera')==-1)
		&&(agt.indexOf('webtv')==-1)&&(agt.indexOf('hotjava')==-1)
		&&(!is_khtml)&&(!(is_moz)));
var is_nav5up=(is_nav&&is_minor>=5);
var is_ie=((iePos!=-1)&&(!is_opera)&&(!is_khtml));
var is_ie4=(is_ie&&is_major==4);
var is_ie4up=(is_ie&&is_minor>=4);
var is_ie5up=(is_ie&&is_minor>=5);
var is_ie5_5up=(is_ie&&is_minor>=5.5);
var is_ie6=(is_ie&&is_major==6);
var is_ie6up=(is_ie&&is_minor>=6);
var is_ie7up=(is_ie&&is_minor>=7);
var is_win=((agt.indexOf("win")!=-1)||(agt.indexOf("16bit")!=-1));
var is_mac=(agt.indexOf("mac")!=-1);
if(is_mac){is_win=!is_mac;}
var is_Flash=false;
var is_FlashVersion=0;
if((is_nav||is_opera||is_moz)||is_safari||(is_mac&&is_ie5up)){
var plugin=(navigator.mimeTypes&&
	navigator.mimeTypes["application/x-shockwave-flash"]&&
	navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)?
	navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
if(plugin){
	is_Flash=true;
	is_FlashVersion=parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));}}
if(is_win&&is_ie4up){
	document.write(
		'<scr'+'ipt language=VBScript>'+'\n'+
		'Dim hasPlayer,playerversion'+'\n'+
		'hasPlayer=false'+'\n'+
		'playerversion=10'+'\n'+
		'Do While playerversion>0'+'\n'+
		'On Error Resume Next'+'\n'+
		'hasPlayer=(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash."&playerversion)))'+'\n'+
		'If hasPlayer=true Then Exit Do'+'\n'+
		'playerversion=playerversion-1'+'\n'+
		'Loop'+'\n'+
		'is_FlashVersion=playerversion'+'\n'+
		'is_Flash=hasPlayer'+'\n'+
		'<\/sc'+'ript>'
	);
}
var isBestClient=false;
if(is_ie5_5up&&(is_FlashVersion>=6)){
	isBestClient=true;
}

var isBestClientFlash=false;
if(is_FlashVersion>=6){
	isBestClientFlash=true;
}

/* headerlogin.js */

/* ***** GLOBALS ***** */

var DIVOff=-250;
var ZIPOn=3;

var dly=50;
var out=2;

var hideZIPTimer=0;
var doGetLoc=0;

/* ***** LOCATION DIV ***** */

function mvDIVzip(o,p){
	var d=0;
	if(o!=null){
		window.mvDIVzipAg=function(){
			var cp=parseInt(o.style.top);
			if(p>0){
				d=Math.floor((p-cp)/2);
				o.style.top=cp+d+"px";
				if(d!=0){
					setTimeout("mvDIVzipAg()",dly);
				}
			}else{
				if(cp>p){
					if(d==0)d=-1;
					d=d*out;
					o.style.top=cp+d+"px";
					if(d>p&&cp>DIVOff){
						setTimeout("mvDIVzipAg()",dly);
					}
				}
			}
		}
		mvDIVzipAg();
	}
}
function sldLzip(){
	var obj,args=arguments;
	if((obj=fObj(args[0]))!=null){
		mvDIVzip(obj,args[1]);
	}
}
function hideZIP(){
	dispLayer("ghzipdiv","none");
}
function toggleZIP(){
	var objDIVzip=fObj("ghzip");
	if(objDIVzip!=null){
		if(parseInt(objDIVzip.style.top)<ZIPOn-1){
			ZIPin();
		}else{
			ZIPout();
		}
	}
}
function ZIPin(){
	window.clearTimeout(hideZIPTimer);
	dispLayer("ghzipdiv","block");
	sldLzip("ghzip",ZIPOn);
}
function ZIPout(){
	window.clearTimeout(hideZIPTimer);
	sldLzip("ghzip",DIVOff);
	hideZIPTimer=window.setTimeout("hideZIP()",200);
}
/*
function validateZIP(frm,zipiframe){
	if(frm.zipcode.value==""||frm.zipcode.value=="Enter your ZIP code"||(frm.zipcode.value).length<5){
		alert("Please enter a valid ZIP code.");
		frm.zipcode.focus();
		return false;
	}else{
		var objZIPiframe = fObj(zipiframe);
		if(objZIPiframe != null){
			var strURL="https://development.verizon.com/includes/getlocation/?zipcode="+frm.zipcode.value;
			objZIPiframe.src=strURL;
			doGetLoc=window.setTimeout("window.location.reload()",2000);
			return false;
		}
	}
	return false;
}
*/
function resetLocation(){
	var expireDate=new Date();
	expireDate.setTime(expireDate.getTime()-(1000*60*60*24*365));
	fnSetFullCookie('vzapps','NPA=&NXX=&LAST=&STATE=;',expireDate,'/','.verizon.com');
	window.location.reload();
}
function checkZIP(p,e){
	var s=p.value;
	var ev=e?e:window.event;
	if(!ev){return false;}
	var targ=ev.target?ev.target:ev.srcElement;
	var which=-1;
	if(ev.which){which=ev.which;}
	else if(ev.keyCode){which=ev.keyCode;}
	if(which==8||which==9||which==13||which==35||which==36||which==37||which==39||which==45||which==46){ 
		return true;
	}else if((which>47&&which<58)&&s.length<5){
		return true;
	}else{
		return false;
	}
	return false;
}
function getLocInfo(){
	window.clearTimeout(doGetLoc);
	var stCity=null;
	var stState=null;
	var stZIP=null;
	var stACity=null;
	var stAState=null;
	var stAZIP=null;

	stCity=fnGetFullCookie("vzapps","CITY");
	if(stCity==null && stACity!=""){stCity=stACity;}
	if(stCity!=null){stCity=stCity.replace(/%5f/gi," ");}

	stState=fnGetFullCookie("vzapps","STATE");
	if(stState==null && stAState!=""){stState=stAState;}
	if(stState!=null){stState=stState.replace(/%5f/gi," ");}

	stZIP=fnGetFullCookie("vzapps","ZIPCODE");
	if(stZIP==null && stAZIP!=""){stZIP=stAZIP;}
	if(stZIP!=null){stZIP=stZIP.replace(/%5f/gi," ");}

	stACity="";stAState="";stAZIP="";

	if(stState!=null&&(stState=="V1"||stState=="V2")){stState="VA";}
	if(stState!=null&&(stState=="P1"||stState=="P2")){stState="PA";}
	var gLoc = "";if(stCity != null && stState != null && stZIP != null)gLoc += stCity+", "+stState+" "+stZIP;
	else if(stState != null){for(var z=0;z<arrStateAbbrev.length;z++){if(stState==arrStateAbbrev[z]){stState=arrStateFullCAPS[z];break;}}gLoc = stState;}
	if(gLoc != ""){
		rewriteHTML("loclinklabel","Location:&nbsp;<!--mp_trans-->");
		rewriteHTML("loclinktext","");
		rewriteHTML("ghziploc",gLoc);
		ZIPout();
		//if(document.locationfrm.zipcode){document.locationfrm.zipcode.value="";}
	}
}

/* global.js */

function getCookie (name) {
	var dcookie = document.cookie;
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	while (cbegin < clen) {
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname) {
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
			return unescape(dcookie.substring(vbegin, vend));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0) break;
	}
	return null;
}

function LTrim(str){
	str = str.replace(/^\s+/, "");
	return str;
}

function RTrim(str){
	str = str.replace(/\s+$/, "");
	return str;
}

function fnGetFullCookie(name,subname){
	var strRetval=null;
	if(!name)name="";
	if(!subname)subname="";
	var dcookie = document.cookie;
	var arrCookie = new Array();
	arrCookie = dcookie.split(";");
	for(var i=0;i<arrCookie.length;i++){
		var thisCookieName = "";
		thisCookieName = LTrim(RTrim(arrCookie[i].substring(0,arrCookie[i].indexOf("="))));
		if(thisCookieName.toLowerCase() == name.toLowerCase()){
			if(subname == ""){
				strRetval=LTrim(RTrim(arrCookie[i].substring(arrCookie[i].indexOf("=")+1)));
				break;
			}else{
				var arrSubCookie = new Array();
				arrSubCookie = LTrim(RTrim(arrCookie[i].substring(arrCookie[i].indexOf("=")+1))).split("&");
				for(var j=0;j<arrSubCookie.length;j++){
					var thisSubCookieName = "";
					thisSubCookieName = LTrim(RTrim(arrSubCookie[j].substring(0,arrSubCookie[j].indexOf("="))));
					if(thisSubCookieName.toLowerCase() == subname.toLowerCase()){
						strRetval=LTrim(RTrim(arrSubCookie[j].substring(arrSubCookie[j].indexOf("=")+1)));
					}
				}
			}
		}
	}
	if(strRetval==""){
		return null;
	}else{
		return strRetval;
	}
}

function fnSetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function fnSetFullCookie(name,value,expires,path,domain,secure){
	document.cookie = name + "=" + value +
		( (expires) ? ";expires=" + expires.toGMTString() : "") +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
		( (secure) ? ";secure" : "");
}

function fObj(n, d){
	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=fObj(n,d.layers[i].document);
	if(!x&&d.getElementById)x=d.getElementById(n);return x;
}

function swLayer(){
	var i,p,v,obj,args=arguments;
	for(i=0;i<(args.length-1);i+=2){
	if((obj=fObj(args[i]))!=null){
	v=args[i+1];if(obj.style){
	obj=obj.style;v=(v=='show')?'visible':(v='hide')?'hidden':v;}
	obj.visibility=v;}}
}

function dispLayer(){
	var i,p,v,obj,args=arguments;
	for(i=0;i<(args.length-1);i+=2){
	if((obj=fObj(args[i]))!=null){
	v=args[i+1];if(obj.style){
	obj=obj.style;v=(v=='block')?'block':'none';}
	obj.display=v;}}
}

function rewriteHTML(id,s){
try{
	var x;
	if(document.layers){
		x=document.layers[id].document;
		s2='<p>'+s+'</p>';
		x.document.open();
		x.document.write(s2);
		x.document.close();
	}else if(document.getElementById){
		x=document.getElementById(id);
		x.innerHTML='';
		x.innerHTML=s;
	}else if(document.all){
		x=document.all[id];
		x.innerHTML=s;
	}
}
catch(e)
{}
}

var arrStateAbbrev = new Array("AL","AK","AZ","AR","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MS","MO","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY");
var arrStateFull = new Array("Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","District of Columbia","Delaware","Florida","Georgia","Hawaii","Iowa","Idaho","Illinois","Indiana","Kansas","Kentucky","Louisiana","Massachusetts","Maryland","Maine","Michigan","Minnesota","Mississippi","Missouri","Montana","North Carolina","North Dakota","Nebraska","New Hampshire","New Jersey","New Mexico","Nevada","New York","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Virginia","Vermont","Washington","Wisconsin","West Virginia","Wyoming");
var arrStateFullCAPS = new Array("ALABAMA","ALASKA","ARIZONA","ARKANSAS","CALIFORNIA","COLORADO","CONNECTICUT","DISTRICT OF COLUMBIA","DELAWARE","FLORIDA","GEORGIA","HAWAII","IOWA","IDAHO","ILLINOIS","INDIANA","KANSAS","KENTUCKY","LOUISIANA","MASSACHUSETTS","MARYLAND","MAINE","MICHIGAN","MINNESOTA","MISSISSIPPI","MISSOURI","MONTANA","NORTH CAROLINA","NORTH DAKOTA","NEBRASKA","NEW HAMPSHIRE","NEW JERSEY","NEW MEXICO","NEVADA","NEW YORK","OHIO","OKLAHOMA","OREGON","PENNSYLVANIA","RHODE ISLAND","SOUTH CAROLINA","SOUTH DAKOTA","TENNESSEE","TEXAS","UTAH","VIRGINIA","VERMONT","WASHINGTON","WISCONSIN","WEST VIRGINIA","WYOMING");

function trim(str){return str.replace(/^\s+|\s+$/g,'');}
/*
function ghsearch(frm){
frm.q.value=trim(frm.q.value);
var strTerm=trim(frm.q.value);
if(strTerm==""||strTerm=='Enter a search term'){alert("Please enter a search phrase or keyword.");frm.q.focus();return false;}
return true;}
*/
/* functions.js */

function load(){
	var imgs=load.arguments;
	if(document.images){
		if(document.preload==null)document.preload=new Array();
		var i=document.preload.length;
		for(var j=0;j<imgs.length;j++){
			document.preload[i]=new Image();
			document.preload[i++].src=imgs[j];
		}
	}
}

function restore(){
	var i,x,a=document.swaps;
	if(a)for(i=0;i<a.length;i++)
		if(a[i].oldSrc)a[i].src=a[i].oldSrc;
}

function swap(){
	var i,j=0,a=arguments;
	document.swaps=new Array;
	for(i=0;i<(a.length-1);i+=2){
		document.swaps[j++]=a[i];
		if(!a[i].oldSrc)a[i].oldSrc=a[i].src;
		a[i].src=a[i + 1];
	}
}

function openW(url,name,w,h){
	var windowprops="width=" + w + ",height=" + h;
	popup=window.open(url,name,windowprops);
	setTimeout('popup.focus();',250);
}

/* checkempty.js */

function checkemptymyvz(frm,uid,pass){
	var strUID=uid.value;
	var strPass=pass.value;
	if(strUID.length!=0&&strPass.length!=0){
		var objRememberMe=fObj("rememberme");
		if(objRememberMe!=null){
			if(!objRememberMe.checked){
				var expireDate=new Date();
				expireDate.setTime(expireDate.getTime() + (1000*60*60*24*-1));
				fnSetFullCookie("MyVzCom","remopt=N",expireDate,"/",".verizon.com");
				frm.target.value=frm.targetorig.value;
			}else if(objRememberMe.checked){
				frm.target.value=frm.targetorig.value+"&remopt=Y";
			}
		}
		signinloop(' ');
		return false;
	}else{
		alert('Ingresa tu identificaci\363n de usuario y tu contrase\361a.');
		if(strUID.length==0)
			uid.focus();
		else if(strPass.length==0)
			pass.focus();
		return false;
	}
	return false;
}

/* header.js (mdb) */

var hideTimer=0;
function toggleTip(state){
	var tipObj=fObj("num800");
	if(tipObj){
		if(is_ie&&!is_ie7up){
			tipObj.style.background="url(https://development.verizon.com/images/headerfooter/bubblesolidwhite.gif) no-repeat";
		}
		var intPos=parseInt(tipObj.style.left);
		if(state==2){
			window.clearTimeout(hideTimer);
			show800(tipObj);
		}else if(state==1){
			hideTimer=window.setTimeout("hide800()", 200);
		}
	}
}
function hide800(){
	var tipObj=fObj("num800");
	tipObj.style.left="-1500px";
}
function show800(){
	var tipObj=fObj("num800");
	tipObj.style.left="128px";
}


function ghsearch(){

if(document.getElementById('GlobalHeader_selectCombo') != undefined)
{
	document.getElementById('GlobalHeader_rv').value = document.getElementById('GlobalHeader_selectCombo').value;
}
var ques = document.getElementById('GlobalHeader_q').value;

var tp_val = document.getElementById('GlobalHeader_tp').value;
var rv_val = document.getElementById('GlobalHeader_rv').value;


	ques=trim(ques);
	var strTerm=trim(ques);

	if(strTerm.toLowerCase()=="type a question or keyword")
	{
		//alert("Please enter a search phrase or keyword.");
		alert("Escribe una pregunta o palabra clave.");
		return;
	}

	if(strTerm==""){
		//alert("Please enter a search phrase or keyword.");
		alert("Escribe una pregunta o palabra clave.");
		document.getElementById('GlobalHeader_q').focus();
		return true;
	}
	//document.getElementById('q').value=ques;
	//document.getElementById('tp').value=tp_val;
	//document.getElementById('rv').value=rv_val;
	url1 = "http://espanol.verizon.com/enes/sdsearch/";
	url1 = url1 + "?tp=" + tp_val +"&rv=" + rv_val + "&q=" + ques;
	//_hbLink("gh_search");
	setTimeout("gotosearchurl()",50);

}
function gotosearchurl()
{
		window.location.href = url1;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function CaptureEnterKeyZip(e)
{

	var strZipCode = 'zipcode';
	var varZip = document.getElementById(strZipCode);
	if (!isNumericZip(e))
	    return false;
	
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : event.keyCode; 
	if(keyCode == 13)
	{	
		validateZipCode();
		return false;
		          
	}
	else
		return true;
} 


function CaptureEnterKeySearch(e)
{
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : event.keyCode; 
	if(keyCode == 13 )
	{	
	    if(document.getElementById("GlobalHeader_q").value != "")		
		setTimeout("ghsearch()",100);

	    else
		{
		//alert("Please enter a search phrase or keyword");
		alert("Escribe una pregunta o palabra clave.");
		return false;
		}
	    return false;         
	}
	return true;
} 



function showZipCodeWindow(clientId) 
{	

	var ZipCodeCtl = 'zipcode';
	var SetHomeCtl = 'sethome';
	var zipInput = document.getElementById(ZipCodeCtl);
	//var resChkBox = document.getElementById(SetHomeCtl);
	var varZipFrame = document.getElementById("zipCodeframe");

	try{			
	
		document.forms[0].action=__CMS_CurrentUrl;
	}
	catch(e){}
		
		
		document.getElementById(masterClientID+"GlobalHeader_btnGetZipcode").click();	
		
		//varZipFrame.src='/content/consumerdsl/Includes/Header/ZipCodeModule.aspx?zipInput=' + zipInput.value ;
		//VDSI Code Chage End

	
}


function validateZipCode()
{
	//_hbLink('ZipGO');		 
	var error_count = 0;
	var errorMessage = 'Please enter a valid zip code';
	var strZipCode = 'zipcode';
	var varZip = document.getElementById(strZipCode);
	if ((varZip.value == '') || (varZip.value.length != 5))
		{error_count++;}
	if (error_count > 0)
	{	
		alert (errorMessage);	
		return false;
	}
	else
	{
		setTimeout("showZipCodeWindow()",50);
		return true;
	}
}

	
function trim(str){
	return str.replace(/^\s+|\s+$/g, '') ;
}

function isNumericZip(e)
{
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	
	if (isNN)
	{
		if (keyCode == 0)
			return true;
	}
	if((keyCode>47&&keyCode<58)||(keyCode==8)||(keyCode==9) || (keyCode == 13)) 
	{
			return true;
	}
	else
	{
		if (e.returnValue) 
			{
                e.returnValue = false;
                return false;
            } 
            else if (e.preventDefault) 
            {
                e.preventDefault();
                return false;
            }
            this.event.returnValue = false;
            return false; 
	}
}
