/***
*  Header functions
**/
    function searchType(st)
	{
	 	var showRow = (navigator.appName.indexOf("Internet Explorer") != -1) ? "block" :"table-row";
	 	if(st == 'site')
	 	{
			document.getElementById("websearch").style.display = "none" ;
			document.getElementById("googleImage").style.display = "none" ;
		 	document.getElementById("searchImage_web").style.display = "none" ;
		 	document.getElementById("sitesearch").style.display = showRow ;
		 	document.getElementById("searchImage_site").style.display = showRow ;
		 	document.header_search._pageLabel.value = 'vzc_Site_Search';
		 	document.header_search.sc.value = 'site';
	 	}
	 	else
	 	{
		 	document.getElementById("websearch").style.display = showRow ;
		 	document.getElementById("sitesearch").style.display = "none" ;
		 	document.getElementById("searchImage_site").style.display = "none" ;
		 	document.getElementById("searchImage_web").style.display = showRow ;
			document.getElementById("googleImage").style.display = showRow ;
		 	document.header_search._pageLabel.value = 'google_results';
		 	document.header_search.sc.value = 'web';
	 	}
	}

function showTutorialCustomContents( flashvars, player, width, height, bgcolor ) {
	popUpWindow( width, height, 'FlashTutorial', 'https://www.verizon.net/central/portlets/help/flash/flash.jsp?player='+escape(player)+'&width='+width+'&height='+height+'&bgcolor='+bgcolor+'&flashvars='+escape(flashvars), 0, 0 );
}

function showTutorialContents( title, movie ) {
	popUpWindow(570,408,'FlashTutorial','https://www.verizon.net/central/portlets/help/flash/flash.jsp?title='+title+'&player=http://onlinehelp.verizon.net/consumer/bin/flash/FlashTutorials/VOLHelp_Player.swf&flashvars='+escape('SubMovieURL='+movie+'&SubMovieName='+title)+'&width=550&height=380&bgcolor=E2EBF1',0,0);
}

/***
*  MAT Left Nav functions
**/
	function showHideLinks(link)
	{
		var showRow = (navigator.appName.indexOf("Internet Explorer") != -1) ? "block" :"table-row";
		var id = "";
		if (link == "My Account") {
			if (document.getElementById("billing") != null)
				document.getElementById("billing").style.display = "none";
			if (document.getElementById("myServices") != null)
				document.getElementById("myServices").style.display = "none";
			if (document.getElementById("MATsupport") != null)
				document.getElementById("MATsupport").style.display = "none";	
			id = "accountSettings";
		} else if (link == "My Bill") {
			if (document.getElementById("accountSettings") != null)
				document.getElementById("accountSettings").style.display = "none";
			if (document.getElementById("myServices") != null)
				document.getElementById("myServices").style.display = "none";
			if (document.getElementById("MATsupport") != null)
				document.getElementById("MATsupport").style.display = "none";
			id = "billing";	
		} else if (link == "My Services") {
			if (document.getElementById("accountSettings") != null)
				document.getElementById("accountSettings").style.display = "none";
			if (document.getElementById("billing") != null)
				document.getElementById("billing").style.display = "none";
			if (document.getElementById("MATsupport") != null)
				document.getElementById("MATsupport").style.display = "none";
			id = "myServices";
		} else if (link == "Support") {
			if (document.getElementById("accountSettings") != null)
				document.getElementById("accountSettings").style.display = "none";
			if (document.getElementById("billing") != null)
				document.getElementById("billing").style.display = "none";
			if (document.getElementById("myServices") != null)
			document.getElementById("myServices").style.display = "none";
			id = "MATsupport";
		}	
		
		if (document.getElementById(id).style.display == showRow) {			
			document.getElementById(id).style.display = "none";		
		} else if (document.getElementById(id).style.display == "none") {			
			document.getElementById(id).style.display = showRow;
		}
	}

/***
*  ScotTrade functions
**/
		function getBlank (form, stdValue) {
			if (form.value == stdValue){
				form.value = '';
			}
			return true;
		}
		function submitScotForm(scotUrl){
			document.scot.action=scotUrl+document.scot.Symbol.value;
			return true;
		}
		
/***********
* Help pop up windows
*********/
function contextHelp(theLink){

  var mat = false;
  if(theLink.indexOf("http")<0 && theLink.indexOf("bookmark")<0) {
  	mat = true;
  	theLink = "http://www.verizon.net/central/portlets/help/popUpContent/popUpContent.jsp?helppopup&case=" + theLink;
  }
  popupWin=window.open(theLink, "Context", "width=560,height=320,toolbar=0,scrollbars=1,resizable=0");
  // when this function is called, wait 150 milliseconds before putting focus on the window.
  setTimeout("popupWin.focus()",150);

  if(mat)
  	return false;
 }
 
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}
 
function LinkToeRepair()
{
      //window.open ("/portal/help/popup_repair.jsp", "_blank","location=0,status=1,scrollbars=1,width=400,height=350");
      document.location.href = "https://www22.verizon.com/foryourhome/fttprepair/nr/common/MainMenu.aspx?FIOSSupport";
}

function popUpWindow (window_width, window_height, window_name, window_url, _resizeable, _scrollbars )
{
	return popUpWindow (window_width, window_height, window_name, window_url, _resizeable, _scrollbars, false);
}

//General Purpose popUp Script
//usage: (#, #, 'name', 'url', 1/0, 1/0) where the last 2 parameters must be a 1 or 0.
function popUpWindow(window_width, window_height, window_name, window_url, _resizeable, _scrollbars, center )
{
	var options="resizable="+_resizeable+",scrollbars="+_scrollbars+",width="+window_width+",height="+window_height+"";
	if (center)
	{
	    var yScrolltop;
	    var xScrollleft;
	    var de = document.documentElement;
	    var pageWidth = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	    var pageHeight = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight

	    if (self.pageYOffset || self.pageXOffset) {
		    yScrolltop = self.pageYOffset;
		    xScrollleft = self.pageXOffset;
	    } else if (de && de.scrollTop || de.scrollLeft ){	 // Explorer 6 Strict
		    yScrolltop = de.scrollTop;
		    xScrollleft = de.scrollLeft;
	    } else if (document.body) {// all other Explorers
		    yScrolltop = document.body.scrollTop;
		    xScrollleft = document.body.scrollLeft;
	    }
	    
	    options += ",left=" + (xScrollleft + (pageWidth - window_width)/2) + ",top=" + (yScrolltop + (pageHeight-window_height)/2) + "";
	}
	popupWin=window.open(window_url, window_name, options);
	return false;
}
/***********
* Cookie Read/Write/Delete Functions
*********/
function setCookie(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=/; domain=.verizon.net;";
	document.cookie = name+"="+value+expires+"; path=/;";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
			return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function deleteCookie( name, path, domain ) 
{
	if ( readCookie( name ) ) 
		document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1957 00:00:01 GMT";
}

function cookiesEnabled()
{
	var enabled = false;
	setCookie('test', 'none', '');
	if ( readCookie('test') )
	{
	     enabled = true;
	     deleteCookie('test', 'none', '');
	}
	return enabled;
}