// JavaScript Document

//////////////////////////////////////////////////////////////////////////////////////////////////////
// The header_footer.js script is leveraged by most of the BellSouth.com sites. Because updates are // 
// distributed to a number of third parties outside of the BellSouth network certain parts of this  //
// should be removed before distributing to avoid javascript errors for these groups.               //
// All code snippets that should be removed are notated as 'BellSouth.com exclusive content'        //
//                                                                                                  //
// IMPORTANT: the writeFooter() function contains calls to these BellSouth exclusive functions.     //
// These function calls also need to be removed before distribution.                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


var debug = {
	debug : true,
	alert:function(message) {
		if (debug.debug) alert(message);
	}
}

// creates a variable from the current URL that is leveraged in a number of the functions below.
var currURL = unescape(window.location.href);
var currREF = unescape(document.referrer); //Added 12-15-05 
var thisDay = new Date();
var fullYear = thisDay.getFullYear();

function getProtocol()
{	
	// function for building location dependent URLs 
	var defaultName = "http:";
	
	if(location.protocol)
	{
		return location.protocol;
	}
	else
	{
		return defaultName;
	}
}

var protocolString = getProtocol();

if ( (currURL.indexOf('iocecstgwww') > -1) || (currURL.indexOf('macpreprod') > -1)  || (currURL.indexOf('ordering-preprod') > -1)  || (currURL.indexOf('mactest') > -1)  || (currURL.indexOf('krabby') > -1)  || (currURL.indexOf('preprodconnect') > -1) || (currURL.indexOf('localhost') > -1) ) {
var searchDomain = 'http://ask.att.com/esh/main/chainAction.do?';
var searchFormDomain = 'http://www.att.com/global-search/search.jsp';
//var searchDomain = 'http://ask.stage.att.com/esh/main/chainAction.do?';
//var searchFormDomain = 'http://ask.stage.att.com/esh/main/chainAction.do';
var searchPop = 'http://ask.stage.att.com/esh/chc/chainAction.do?';
var relDomain = '';
} else {
var searchDomain = 'http://ask.att.com/esh/main/chainAction.do?';
var searchFormDomain = 'http://www.att.com/global-search/search.jsp';
//var searchDomain = 'http://ask.att.com/esh/main/chainAction.do?';
//var searchFormDomain = 'http://ask.att.com/esh/main/chainAction.do';
var searchPop = 'http://ask.att.com/esh/chc/chainAction.do?';
var relDomain = protocolString + '//www.bellsouth.com';
}

var util = {
	writeJS:function(src)  {
		document.write('<SCR' + 'IPT LANGUAGE="JavaScript" SRC="' + src);
		document.write('"></SCR' + 'IPT>');		
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// Begin BellSouth.com exclusive content                                                          //
// The following functions create a cookie that is used for tracking reports and to determine     //
// customer type. This code should be removed before distribution to third party vendors outside  //
// of the BellSouth.com network.                                                                  //
////////////////////////////////////////////////////////////////////////////////////////////////////

util.writeJS(relDomain + '/global/promos/day1.js');

//Favicon
document.write('<link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />');

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments\cf1

function setCookie(name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

 // name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist\cf1
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

//returns a random value from 1 to 10 million
function getRand()
{
var n =10000000; //uper perameter from 0 to 10 mill
var val = Math.round(Math.random() * n);
return val.toString(); 
}

//writes a cookie 
function writeCookie()
{
var delimeter='&'; var yearLen=3;
var cookieName="bs_metriccookie"; var val = "metricValue="+getRand()+delimeter;

var domainValue=document.domain;

if((domainValue=="")||(domainValue==" "))domainValue="bellsouth.com";

var today = new Date(); var expDate = new Date (today.getFullYear()+yearLen,today.getMonth(),today.getDay());
 //expDate is set for 3 years  from whatever date

val+=" expDate="+expDate+delimeter;
if(!getCookie(cookieName))  setCookie(cookieName,val,expDate,"/",domainValue);
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds\cf1
function deleteCookie(name, path, domain)
{
  if (getCookie(name))
  {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

//cookie stuff
var expires = "";
var path ="/";
var domain = "bellsouth.com";
var secure = "";

cookiestuff = ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
	  
var branch_string = "";
function branch_place(branch, url)
{
branch_string = branch_string + "xxx" + branch;
document.cookie = "branch=" + escape(branch_string) + cookiestuff;
window.location = url;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// End BellSouth.com exclusive content for writing cookies                                          //
//////////////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Begin Global Headers and Footer functions ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

// Logic to determine customer type - leveraged in writeGlobalNav()

// These arrays contain the URLs that determine which tab navigation image to display. 
// There is not an array for residential as it is the default in the event that the current URL does not match
// any of the strings in these arrays.
var custID_smlBiz = new Array ('smallbusiness.bellsouth.com','contact.bellsouth.com/smallbusiness','/bapco/','/apps/adsl/','smallbusiness','=sbs','http://www.bellsouth.com/apps/orderstatus/jsp/checkordstatus.jsp','busUnit=SBS','at_your_business')
var custID_lrgBiz = new Array ('largebusiness.bellsouth.com','bellsouthlargebusiness.com','interconnection.bellsouth.com/notifications/network/','/apps/bsldto/','/bsldto/','/ebs/')
var custID_aboutUs = new Array ('/employment/','bellsouthcorp.com','/investor/','/community/','corporate_governance','/suppliers/','ethics.bellsouth.com','/federal/','contact.bellsouth.com/bipman/','aboutus','aboutus/index.html','/tariffs','mediaroom.com','legal.html','privacydoc.html','termsofuse.html','noticeofcopyright.html')
//wr6025 5/4/06 bh: added 'legal.html','privacydoc.html','termsofuse.html','noticeofcopyright.html' to aboutUs arry

var custID_none = new Array ('/mastercard','/myAcct','apps/cpr/home/login','/apps/nlss','/eshkana','/esh/main','/ermsfp/emailus','att.com/search/bls')

// wr 6470
var tabRESIDENTIAL = "null";
var tabSMALLBUSINESS = "smlBiz";
var tabLARGEBUSINESS = "lrgBiz";
var tabABOUTUS = "aboutUs";
var tabNONE = "none";

var customerTypeID = tabRESIDENTIAL;
function getCustomerTypeID()
{
    var urlMatch= -1;
    //initial custerTypeID search - checks for match in URL string for small Business
    var arrayLen = custID_smlBiz.length;
    for(var i=0; i < arrayLen; i++){
	urlMatch = currURL.indexOf (custID_smlBiz[i]);
	if(urlMatch != -1){
	    customerTypeID = tabSMALLBUSINESS; 
	    break;   
	}  
    }
    //if a match was not found above check for match in URL string for large business
    if(customerTypeID == "null"){
    //search for match in custID_smlBiz
	var arrayLen = custID_lrgBiz.length;
	for(var i=0; i < arrayLen; i++){
	    urlMatch = currURL.indexOf (custID_lrgBiz[i]);
	    if(urlMatch != -1){
		customerTypeID = tabLARGEBUSINESS;
		break;   
	    }  
	}
    }
    //if a match was not found above check for match in URL string for About Us
    if(customerTypeID == "null"){
    //search for match in custID_smlBiz
	var arrayLen = custID_aboutUs.length;
	for(var i=0; i < arrayLen; i++){
	    urlMatch = currURL.indexOf (custID_aboutUs[i]);
	    if(urlMatch != -1){
		customerTypeID = tabABOUTUS; 
		break;   
	    }  
	}
    }
    if(customerTypeID == "null"){
    //search for match in custID_none
	var arrayLen = custID_none.length;
	for(var i=0; i < arrayLen; i++){
	    urlMatch = currURL.indexOf (custID_none[i]);
	    if(urlMatch != -1){
		customerTypeID = tabNONE; 
		break;   
	    }   
	}
    }
    // if a match is not found above the script assumes the user is a residential customer
} // efunc  //e wr 6470
// use this on every page for the nav back
function writeNavBack()
{
	var tStr='<div id="globalNavBack">';
	tStr+='<table cellpadding="0" cellspacing="0" border="0" background=" ' + relDomain + '/images/navback.jpg">\n';
	tStr+='<tr>\n';
	tStr+='<td><img src="' + relDomain + '/images/spacer.gif" width="780" height="79" border="0"></td>\n';
	tStr+='</tr>\n';
	tStr+='</table>\n';
	tStr+='</div>';
	document.writeln(tStr);
}

// use this on every page to write the BellSouth Logo 
function writeLogo()
{
	document.write(day1logo);
}

function writeServiceLinks()
{
 var tStr='<div id="globalServiceLinks" class="whtlink"><a href="http://www.yellowpages.com/" class="whtlink" name="&lid=Yellowpage+Link&lpos=Homepage+Header+Links">YELLOWPAGES.COM&trade;</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.bellsouth.com/specialneeds/index.html" class="whtlink" name="&lid=Special+Needs+Link&lpos=Homepage+Header+Links">Accessible Equipment</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.bellsouth.com/spanish/index.html" class="whtlink" name="&lid=Spanish+Link&lpos=Homepage+Header+Links">En Espa&ntilde;ol</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://interconnection.bellsouth.com/" class="whtlink" name="&lid=Wholesale+Link&lpos=Homepage+Header+Links">Wholesale</a>&nbsp;&nbsp;';
if ((officialNameInd==null) || (officialNameInd!="on")) //pre day 1
{
tStr+='|&nbsp;&nbsp;<a href="http://www.att.jobs" class="whtlink" name="&lid=Careers+Link&lpos=Homepage+Header+Links">Careers</a>&nbsp;&nbsp;';
}
tStr+='|&nbsp;&nbsp;<a href="https://emailus.sbc.com/ermsfp/emailus?service=external/Home" class="whtlink" name="&lid=Contact+Us+Link&lpos=Homepage+Header+Links">Contact Us</a></div>';
 
tStr+='<div id="globalServiceLinks2">YELLOWPAGES.COM&trade;&nbsp;&nbsp;|&nbsp;&nbsp;Accessible Equipment&nbsp;&nbsp;|&nbsp;&nbsp;En Espa&ntilde;ol&nbsp;&nbsp;|&nbsp;&nbsp;Wholesale&nbsp;&nbsp;';
if ((officialNameInd==null) || (officialNameInd!="on")) //pre day 1
{
tStr+='|&nbsp;&nbsp;Careers&nbsp;&nbsp;';
}
tStr+='|&nbsp;&nbsp;Contact Us</div>';
 document.writeln(tStr);
 bumpServiceLinks();
}

function bumpServiceLinks()
{
//  // bump service links over to right if day 1
  if ((officialNameInd!=null) && (officialNameInd=="on")) //post day 1
  {
    if ( (document.getElementById("globalServiceLinks")!=null) && (document.getElementById("globalServiceLinks2")!=null) )
    {
	var tObj=document.getElementById("globalServiceLinks");
	var tObj2=document.getElementById("globalServiceLinks2");
//	tObj.style.visibility="hidden";
//	tObj2.style.visibility="hidden";
	tObj.style.left="285px";
    	tObj2.style.left="287px";
//	tObj.style.visibility="visible";
//	tObj2.style.visibility="visible";
    }
  }
}


// use this on pages that need the quick links
function writeGlobalSearch()
{
    var tStr='<div id="globalSearch">';
    //Old Search
	/*tStr+='<form onsubmit="return submitQuestion();" method="POST" action="' + searchFormDomain + '" name="question_form">\n';
	tStr+='<input type="hidden" name="ui_mode" value="question"><input type="hidden" name="charset" value="UTF-8"><input type="hidden" name="language" value="en-US"><input type="hidden" name="Ask" value="Ask"><input name="qsource" value="gn" type="hidden"><input name="context" value="new" type="hidden">\n';
	//tStr+='<div id="ask1">Ask a Question</div>\n';
	//tStr+='<div id="ask2">Ask a Question</div>\n';
	tStr+='<div id="ask1">Search</div>\n';
	tStr+='<div id="ask2">Search</div>\n';
	tStr+='<div id="searchField"><input name="search" type="text" value="" maxlength="150" onFocus="clearSearchBox()" class="smallFont" style="border-right: 1px solid #CCC; border-left: 1px solid #000; border-top: 1px solid #000; border-bottom: 1px solid #CCC; height:18px; width:150px; padding:2px;">\n';
	tStr+='<input type="image" title="Click here to ask a question" value="ASK" name="ACTION" src="' + relDomain + '/images/buttons/gh_search2.gif" width="22" height="20" alt="Click here to ask a question" border="0" style="vertical-align:middle;"></div>\n';*/
	
	//New Search Form
	tStr+='<form method="GET" action="' + searchFormDomain + '" id="question_form" name="question_form">\n';
	tStr+='<div id="ask1">Search</div>\n';
	tStr+='<div id="ask2">Search</div>\n';
	tStr+='<div id="searchField"><input name="q" type="text" value="" maxlength="150" class="smallFont" style="border-right: 1px solid #CCC; border-left: 1px solid #000; border-top: 1px solid #000; border-bottom: 1px solid #CCC; height:18px; width:150px; padding:2px;"><input type="hidden" name="tab" value="Res" /><input type="hidden" name="App_ID" value="BLS" />\n';
	tStr+='<input type="image" src="' + relDomain + '/images/buttons/gh_search2.gif" value="Go" alt="Submit search" class="btnGo" id="searchSubmit" style="vertical-align:middle;"></div>\n';
	tStr+='</form>\n';
	tStr+='</div>';
	document.writeln(tStr);
}

function writeGlobalNav()
{
	if(customerTypeID == tabSMALLBUSINESS){
          var tStr='<div id="globalTabSmallBusiness">';
          tStr+='<img src="' + relDomain + '/images/buttons/gh_nav_small_business.gif" width="505" height="24" border="0" usemap="#cust_smallbiz">\n';
          tStr+='<map name="cust_smallbiz">';
	  tStr+='<area shape="poly" coords="5,20,16,8,86,9,96,16,87,20" href="javascript: branch_place(&#39;residential&#39;, &#39;http://www.bellsouth.com/index.html&#39;)" alt="Residential">';
	  tStr+='<area shape="poly" coords="92,21,108,2,294,2,312,21" href="javascript: branch_place(&#39;smallbiz&#39;, &#39;http://smallbusiness.bellsouth.com/&#39;)" alt="Small Business">';
	  tStr+='<area shape="poly" coords="424,21,410,7,316,8,309,16,316,21" href="javascript: branch_place(&#39;largebiz&#39;, &#39;http://www.att.com/gen/landing-pages?pid=9214&#39;)" alt="Enterprise">';
	  tStr+='<area shape="poly" coords="428,21,418,16,426,9,487,8,500,22" href="javascript: branch_place(&#39;aboutus&#39;, &#39;http://www.bellsouth.com/aboutus/index.html&#39;)" alt="About Us">';
	  tStr+='</map>';
	  tStr+='</div>';
	  document.writeln(tStr);
	  if (hbx)
	  { 
		hbx.acct="DM5606085BDM;DM551012D0VA";
	  }
       }
       else if(customerTypeID == tabLARGEBUSINESS){
          var tStr='<div id="globalTabLargeBusiness">';
          tStr+='<img src="' + relDomain + '/images/buttons/gh_nav_lrg_business.gif" width="506" height="24" border="0" usemap="#cust_lrgbiz">\n';
          tStr+='<map name="cust_lrgbiz">';
	  tStr+='<area shape="poly" coords="99,22,2,21,17,8,87,8" href="javascript: branch_place(&#39;residential&#39;, &#39;http://www.bellsouth.com/index.html&#39;)" alt="Residential">';
	  tStr+='<area shape="poly" coords="101,22,94,15,102,9,198,8,211,17,202,22" href="javascript: branch_place(&#39;smallbiz&#39;, &#39;http://smallbusiness.bellsouth.com/&#39;)" alt="Small Business">';
	  tStr+='<area shape="poly" coords="423,23,404,2,222,3,203,22" href="javascript: branch_place(&#39;largebiz&#39;, &#39;http://www.att.com/gen/landing-pages?pid=9214&#39;)" alt="Enterprise">';
	  tStr+='<area shape="poly" coords="426,23,419,17,429,8,491,9,502,22" href="javascript: branch_place(&#39;aboutus&#39;, &#39;http://www.bellsouth.com/aboutus/index.html&#39;)" alt="About Us">';
	  tStr+='</map>';
	  tStr+='</div>';
	  document.writeln(tStr);
	}
	else if(customerTypeID == tabABOUTUS){
          var tStr='<div id="globalTabAboutUs">';
          tStr+='<img src="' + relDomain + '/images/buttons/gh_nav_about_us.gif" width="478" height="24" border="0" usemap="#cust_aboutus">\n';
          tStr+='<map name="cust_aboutus">';
	  tStr+='<area shape="poly" coords="101,22,88,9,17,8,2,21" href="javascript: branch_place(&#39;residential&#39;, &#39;http://www.bellsouth.com/index.html&#39;)" alt="Residential">';
	  tStr+='<area shape="poly" coords="214,26,200,8,102,9,95,16,106,24" href="javascript: branch_place(&#39;smallbiz&#39;, &#39;http://smallbusiness.bellsouth.com/&#39;)" alt="Small Business">';
	  tStr+='<area shape="poly" coords="311,22,318,15,310,8,212,9,208,16,212,22" href="javascript: branch_place(&#39;largebiz&#39;, &#39;http://www.att.com/gen/landing-pages?pid=9214&#39;)" alt="Enterprise">';
	  tStr+='<area shape="poly" coords="314,21,335,-1,454,1,476,22" href="javascript: branch_place(&#39;aboutus&#39;, &#39;http://www.bellsouth.com/aboutus/index.html&#39;)" alt="About Us">';
	  tStr+='</map>';
	  tStr+='</div>';
	  document.writeln(tStr);
	}
	else if(customerTypeID == tabNONE){
          var tStr='<div id="globalTabAboutUs">';
           tStr+='<img src="' + relDomain + '/images/buttons/gh_nav_null.gif" width="478" height="24" border="0" usemap="#cust_none">\n';
          tStr+='<map name="cust_none">';
	  tStr+='<area shape="poly" coords="5,20,16,8,86,9,96,16,87,20" href="javascript: branch_place(&#39;residential&#39;, &#39;http://www.bellsouth.com/index.html&#39;)" alt="Residential">';
	  tStr+='<area shape="poly" coords="101,22,94,15,102,9,198,8,211,17,202,22" href="javascript: branch_place(&#39;smallbiz&#39;, &#39;http://smallbusiness.bellsouth.com/&#39;)" alt="Small Business">';
	  tStr+='<area shape="poly" coords="311,22,318,15,310,8,212,9,208,16,212,22" href="javascript: branch_place(&#39;largebiz&#39;, &#39;http://www.att.com/gen/landing-pages?pid=9214&#39;)" alt="Enterprise">';
	  tStr+='<area shape="poly" coords="314,24,320,15,327,8,389,8,402,24" href="javascript: branch_place(&#39;aboutus&#39;, &#39;http://www.bellsouth.com/aboutus/index.html&#39;)" alt="About Us">';
	  tStr+='</map>';
	  tStr+='</div>';
	  document.writeln(tStr);
	}
	else{ //if residential or no customerTypeID is defined
          var tStr='<div id="globalTabResidential">';
          tStr+='<img src="' + relDomain + '/images/buttons/gh_nav_residential.gif" width="488" height="24" border="0" usemap="#cust_res">\n';
          tStr+='<map name="cust_res" id="cust_res">';
	  tStr+='<area shape="poly" coords="186,24,3,23,23,2,164,2" href="javascript: branch_place(&#39;residential&#39;, &#39;http://www.bellsouth.com/index.html&#39;)" alt="Residential">';
	  tStr+='<area shape="poly" coords="296,22,187,23,181,15,189,8,282,9" href="javascript: branch_place(&#39;smallbiz&#39;, &#39;http://smallbusiness.bellsouth.com/&#39;)" alt="Small Business">';
	  tStr+='<area shape="poly" coords="408,23,294,22,292,15,303,8,393,8" href="javascript: branch_place(&#39;largebiz&#39;, &#39;http://www.att.com/gen/landing-pages?pid=9214&#39;)" alt="Enterprise">';
	  tStr+='<area shape="poly" coords="407,21,402,15,409,9,471,8,484,22" href="javascript: branch_place(&#39;aboutus&#39;, &#39;http://www.bellsouth.com/aboutus/index.html&#39;)" alt="About Us">';
	  tStr+='</map>';
	  tStr+='</div>';
	  document.writeln(tStr);
	}
}

// Global variables for global header variations
var adShowTabsShowSearch = 0;
var adHideTabsHideSearch = 1;
var adShowTabsHideSearch = 2;
var adHideTabsShowSearch = 3;


	//wr 6769
	//reference script that sets the HBX variables (it uses customerTypeID to segregate traffic)
	util.writeJS('/scripts/hbx2.js');

//main function to write bellsouth.com header
function writeCompleteHeader(globalNav,languageFlag) {
    var languageVar = languageFlag;
    //wr6470
    var tabSelection="";
    if (arguments.length>2)
    {
	tabSelection=arguments[2];
    }
    if ((tabSelection != null) && (tabSelection != ""))
    {
	customerTypeID = tabSelection;
    }
    else 
    {
        getCustomerTypeID();
    }

    // e wr6470
	if(globalNav == adHideTabsHideSearch || globalNav == adHideTabsShowSearch){
	   var hasNav = "false";	   
	}else{
	   var hasNav = "true";
	}
	
	if(globalNav == adHideTabsHideSearch || globalNav == adShowTabsHideSearch){
	   var hasSearch = "false";	   
	}else{
	   var hasSearch = "true";
	}
	
	// don't show the search on the following directories because of javascript conflicts
	if(currURL.indexOf("/apps/ebppwe/paymentflows/PaymentArrangements/") != -1 || currURL.indexOf("/apps/nlss") != -1)
	{ 
	   var hasSearch = "false";
	}
	//if( (currURL.indexOf("/apps/ebpp/") != -1 ) && (currURL.indexOf("billview") != -1 ) )  // 6/27/06 bh
        if( (currURL.indexOf("/apps/ebpp/") != -1 ) && ( (currURL.indexOf("billview") != -1 ) || (currURL.indexOf("billsection") != -1 ) ) )  
	{ 
	   var hasSearch = "false";
	}
	
	//currently written in all cases regardless of passed arguments - writes background and logo
	writeNavBack();
	writeLogo();
		
		
	//currently the default header for spanish is: no tabs, no service links and no search
	if(languageVar == "spanish"){ 
	   if(hasNav == "true"){ //placeholder for future dev
	   
	   }else{

	   }
	}else{
	   if(hasNav == "true"){ //if hasNav is true write tabs and servicelinks
	      writeServiceLinks();
	      writeGlobalNav(languageVar);
		  if(hasSearch == "true"){ //if hasSearch is true write search
		    writeGlobalSearch();
		  }	      	   
	   }else{ //if not DHTML write only back to bellsouth portion
		  if(hasSearch == "true"){
		    writeGlobalSearch();
		  }	   
	   }	
	}
	//hpp.pollSurvey(); // if there is a survey for this page, this will trigger the logic
}

//Cookie based personalizationb script added 06/10/06 by EF. 
//Updated WR6606-- 8/16/06 BH. Code provided by razorfish
//Updated WRXXXX-- 12/06/07 JL. Passing cookie info.


var toHex = {
	// call this function with an ascii String as a parameter
	// it returns a hex string
	 transform:function(s){
		var hex='';
		var i;
		for (i=0; i<s.length; i++) {
	
			// for debugging:
			// alert('Hex values are:' + hexfromdec( s.charCodeAt(i) ));
			// break;
				
			hex += toHex.hexfromdec( s.charCodeAt(i) );
		}
		return hex;
	},

	// the below two functions actually do the convert
	// from decimal ascii to hexidecimal ascii code
	 hexfromdec:function(num) {
			if (num > 65535) { return ("err!") }
			first = Math.round(num/4096 - .5);
			temp1 = num - first * 4096;
			second = Math.round(temp1/256 -.5);
			temp2 = temp1 - second * 256;
			third = Math.round(temp2/16 - .5);
			fourth = temp2 - third * 16;
			return (""+toHex.getletter(third)+toHex.getletter(fourth));
	},
	
	// this functions handles converting values > 9
	// to their hex equivalent: A, B, C, etc.
	 getletter:function(num) {
		if (num < 10) {
			return num;
		} else {
			if (num == 10) { return "A"; }
			if (num == 11) { return "B"; }
			if (num == 12) { return "C"; }
			if (num == 13) { return "D"; }
			if (num == 14) { return "E"; }
			if (num == 15) { return "F"; }
		}
	}
}

var hpp = {
		currentTag : null,
		currentSurvey : null,
		needBillInvite: 'no',
		isPotentialSbsPage:'no',
		TagBase : '//switch.atdmt.com/action/',
		Account : {
			Tag : 'BLS_13char_AID_Capture/v3/aid.',
			Cookie : 'MACSession'
		},
		taglist : [ // [ url string, hpp tag string, exact match, survey type]
	["/apps/ebpp/home/enrollbillsuppression?busUnit=CSR","", true,1],
	["/apps/ebpp/home/resonetimeecheckpayment?busUnit=CSR","", true,1],
	["/apps/ebppwe/paymentflows/PaymentArrangements/newAction1.do","",true,1],
	["/apps/ebppwe/paymentflows/PaymentHistory/PaymentHistoryController.jpf","",true,1],
	["/apps/ebppwe/paymentflows/PaymentHistory/begin.do","", true,1],
	["/apps/ebpp/home/recurringecheckenroll?busUnit=CSR", "",true,1],
	["/apps/ebppwe/billingflows/dispute/SubmitDispute.do", "",true,1],
	["/apps/ebppwe/billingflows/eBFDispute/SubmitDispute.do", "", true,1],
	["/consumer/residentialservice/", "", true, 0],
	["/consumer/residentialservice/index.html", "", false, 0],
	["/consumer/voicemail.html","", false, 0],
	["/consumer/equipment/equip_cordless.html", "", false, 0],
	["/consumer/advancedtv/index.html", "", false, 0],
	["/consumer/advancedtv/", "", true, 0],
	["/orderservice/change_existing_service.html", "", true, 0],
	["/apps/mac/MyAccount/Controller.jpf","BLS_HPP_CPR_Login_Residential",true,1], //Account Management	
	["/apps/mac/MyAccount/","BLS_HPP_CPR_Login_Residential",true,0], //Account Management
	["/apps/cpr/home/login/residentialLanding","BLS_HPP_CPR_Login_Residential",false,-1], //Account Management
	["/consumer/inetsrvcs/index.html","BLS_HPP_Marketing_Pages_FastAccess_DSL",false,1], //Marketing - DSL
	["/consumer/inetsrvcs/","BLS_HPP_Marketing_Pages_FastAccess_DSL",true,1], //Marketing - DSL 
	["/consumer/local/local_just_added.html","BLS_HPP_Ordering_AddedLocal",false,0], //Shopping Cart - Added Local
	["/consumer/local/index.html","BLS_HPP_Marketing_Pages_Local",false,1], //Marketing - Local
	["/consumer/local/","BLS_HPP_Marketing_Pages_Local",true,1], //Marketing - Local
	["/consumer/inetsrvcs/inetsrvcs_order.html","BLS_HPP_Marketing_Pages_Order_DSL_Now",false,-1], //Marketing - DSL Order Now
	["/consumer/new_customer.html","BLS_HPP_Marketing_Pages_NewCustomersPage",false,-1], //Marketing - New Customer
	["/consumer/wireless/wireless_familytalk.html","BLS_HPP_Marketing_Pages_WirelessFamilyMarkPage",false,-1], //Marketing - Wireless Family Talk
	["/consumer/wireless/wireless_media.html","BLS_HPP_Marketing_Pages_WirelessMediaPlanMarkPage",false,-1], //Marketing - Wireless Media
	["/consumer/wireless/wireless_just_added.html","BLS_HPP_Ordering_AddedWireless",false,-1], //Shopping Cart - Added Wireless
	["/consumer/wireless/","BLS_HPP_Marketing_Pages_CingularMarketingPage",true,0], //Marketing - Wireless
	["/consumer/wireless/index.html","BLS_HPP_Marketing_Pages_CingularMarketingPage",false,0], //Marketing - Wireless
	["/consumer/directv/index.html","BLS_HPP_Marketing_Pages_DIRECTV",false,-1], //Marketing - DTV
	["/consumer/directv/","BLS_HPP_Marketing_Pages_DIRECTV",true,-1], //Marketing - DTV
	["/consumer/ld/ld_just_added.html","BLS_HPP_Ordering_AddedLD",false,-1], //Shopping Cart - Added LD
	["/consumer/ld/index.html","BLS_HPP_Marketing_Pages_Long_Distance",false,0], //Marketing - LD
	["/consumer/ld/","BLS_HPP_Marketing_Pages_Long_Distance",true, 0], //Marketing - LD
	["/torder/move.jsp","BLS_HPP_Marketing_Pages_MovingMarketingPage",false,-1], //Marketing - Moving
	["/consumer/answers/answerspromo.html","BLS_HPP_Marketing_Pages_Answers_Promo_Page",false,-1], //Marketing - Answers Promo
	["/apps/rnr/ordering/torder/controller.jsp?action=launch","BLS_HPP_Marketing_Pages_MoveExistingPhone",false,-1], // Marketing - Move Existing Phone
	["/consumer/answers/index.html","BLS_HPP_Marketing_Pages_Answers_Marketing_Page",false,1], //Marketing - Answers
	["/consumer/answers/","BLS_HPP_Marketing_Pages_Answers_Marketing_Page",true,1], //Marketing - Answers
	["/consumer/inetsrvcs/inetsrvcs_compare.html","BLS_HPP_Marketing_Pages_Compare_Us",false,-1], //Marketing - DSL Compare
	["/consumer/inetsrvcs/inetsrvcs_fa_homenet.html","BLS_HPP_Marketing_Pages_Home_Networking",false,-1], //Marketing - DSL Home Networking
	["/consumer/controller.jsp?action=entry&amp;src=rql","BLS_HPP_Marketing_SwitchPhoneService",false,-1], //Switch Service
	["/consumer/inetsrvcs/inetsrvcs_fa_security.html","BLS_HPP_Marketing_Pages_Internet_Security",false,-1], //Marketing - DSL Internet Security
	["/orderservice/additional_lines.html","BLS_HPP_Marketing_Pages_Additional_Lines",false,-1], //Marketing - Additional Lines
	["/consumer/local/local_cc.html","BLS_HPP_Marketing_Pages_Complete_Choice",false,-1], //Marketing - Local Complete Choice
	["/apps/rnr/ordering/adl/controller.jsp?action=entry","BLS_HPP_AdditionalLines",false,-1], //Ordering - Additional Line
	["/apps/rnr/ordering/adl/controller.jsp?action=orderConfirm&rr=complete","BLS_HPP_Ordering_CPE_AddLine",false,-1], //Ordering - Additional Line
	["/apps/ebppwe/billingflows/presentation/DisplayBillSummary.do","BLS_HPP_View_Bill",false,1], //View Bill
	["/apps/ebppwe/billingflows/eBFPresentation/DisplayBillSummary.do","BLS_HPP_View_Bill",true,1], //View Bill (post-EBF
	["/apps/ebpp/home/resonetimeecheckterms","BLS_HPP_PayBill_OnetimeecheckConsumer",false,-1], //One time echeck - Consumer
	["/apps/ebpp/home/resonetimeccterms","BLS_HPP_PayBill_OnetimecreditConsumer",false,-1], //One time credit - Consumer
	["/apps/ebppwe/paymentflows/PaymentArrangements/authAction.do","BLS_HPP_EPPWE_PayArrangementAndSchedulePay",false,-1], //EPPWE Payment arrangement & EBPPWE Schedule payments
	["/apps/ebppwe/paymentflows/PaymentArrangements/confirmation.do","BLS_HPP_EPPWE_PayArrangementAndSchedulePay",false,-1], //EPPWE Payment arrangement & EBPPWE Schedule payments
	["/apps/cpr/home/reg/displayRegThankYouPage","BLS_HPP_eBill_CPR",false,-1], //e-Bill Confirmation pages CPR
	["/apps/ebpp/home/executebillsuppression?busUnit=CSR&executeAction=A","BLS_HPP_eBill_EBPP",false,-1], //e-Bill Confirmation pages EBPP
	["/apps/ebpp/home/recurringechecktermssubmit","BLS_HPP_AutoPayEnrollmentConfirmation",false,-1], //Autopay eCheck
	["/apps/ebpp/home/recurringCCtermssubmit","BLS_HPP_AutoPayEnrollmentConf_Card",false,-1], //Autopay Credit Card
	["/apps/resorderstatus/OrderStatusCnt.jpf","BLS_HPP_OrderStatus",false,-1], //Order Status
	["/apps/rnr/ordering/ldprovider/controller.jsp?action=orderConfirm&rr=complete","BLS_HPP_Ordering_CPE_ChangePic",false,-1], //Ordering - Change PIC/LPIC
	["/apps/rnr/ordering/cpe/controller.jsp?action=thankyou&rr=complete","BLS_HPP_Ordering_CPE",false,-1], //Ordering - CPE
	["/apps/rnr/ordering/cpeemployee/controller.jsp?action=thankyou","BLS_HPP_Ordering_CPE_Employee",false,-1], //Ordering - CPE Employee
	["/apps/rnr/ordering/ecard/controller.jsp?action=step3","BLS_HPP_Ordering_Ecard",false,-1], //Ordering - Ecard
	["/apps/rnr/ordering/dtvexternal/controller.jsp?action=step3&rr=complete","BLS_HPP_Ordering_DTV",false,-1], //Ordering - DTV
	["/apps/rnr/ordering/torder/controller.jsp?action=orderConfirm&rr=complete","BLS_HPP_Ordering_Torder",false,0], //Ordering - T Order
	["/apps/rnr/ordering/answers/controller.jsp?action=orderconfirm&rr=complete","BLS_HPP_Ordering_Norder",false,-1], //Ordering - N Order
	["/apps/rnr/ordering/consumer/controller.jsp?action=step9&rr=complete","BLS_HPP_Ordering_Consumer_Reacquisition",false,-1], //Ordering - Reacq
	["/apps/rnr/ordering/vendor_redesign/controller.jsp?action=thankyou","BLS_HPP_Ordering_VendorReacquisition",false,-1], //Ordering - Vendor Reacq
	["/apps/rnr/ordering/d2d/controller.jsp?action=thankyou","BLS_HPP_DoortoDoor",false,-1], //Ordering - Door To Door
	["/apps/rnr/ordering/spanish_ld/controller.jsp?action=thankyou","BLS_HPP_Spanish",false,-1], //Ordering - Spanish
	["/apps/rnr/ordering/susprest/controller.jsp?action=orderConfirm&rr=complete","BLS_HPP_Suspend_Restore",false,-1], //Ordering - Suspend Restore
	["/apps/rnr/ordering/isafa/controller.jsp?action=confirm&rr=complete","BLS_HPP_iSAFANOrder",false,-1], //Ordering - ISAFA
	["/apps/corder/COrderReqDispatcher/submitOrderEvent","BLS_HPP_Corder",false,-1], //Ordering - C Order
	["/apps/corder/COrderReqDispatcher/CorderHomeEvent","BLS_HPP_ChangeService",false,-1], //Ordering - Change Service (quick login)
	["/apps/rnr/ordering/cpe/controller.jsp?action=billingInfo","BLS_HPP_Phones_Accessories",false,-1], //Ordering - Phones & Accessories (quick login)
	["/apps/rnr/ordering/susprest/controller.jsp?action=schedule","BLS_HPP_Suspend_RestoreService",false,-1], //Ordering - Suspend/Restore Service (quick login)
	["/apt","BLS_HPP_Marketing_Pages_Reacquisition_2_welcome",false,-1], //Reacq Phase II 
	["newmover","BLS_HPP_Marketing_Pages_Reacquisition_2_Connect",false,-1], //Reacq Phase II
	["pulte.html","BLS_HPP_Marketing_Pages_Reacquisition_2_hookup",false,-1], //Reacq Phase II
	["/consumer/inetsrvcs/inetsrvcs_just_added.html","BLS_HPP_Ordering_AddedInternetService",false,-1], //Shopping Cart - DSL Added
	["/consumer/directv/dtv_just_added.html","BLS_HPP_Ordering_AddedDTV",false,-1], //Shopping Cart - Added DTV
	["/consumer/view_selections.html","BLS_HPP_Ordering_ViewSelections",false,-1], //Shopping Cart - View Selections
	["/ebill/eCheckindex.html","BLS_HPP_Billing_eCheckLandingpage",false,-1], //Billing - eCheck
	["/ebill/","BLS_HPP_Billing_eBillLandingPage", true, 0], //Billing - eBill
	["/ebill/index.html","BLS_HPP_Billing_eBillLandingPage", false, 0], //Billing - eBill
	["/register/","BLS_HPP_Billing_CPRLandingPage",false,-1], //Billing - CPR
	["/apps/ebpp/home/main?bcid=pay","BLS_HPP_Billing_BillPayPage",false,-1], //Billing - Bill Pay
	["/consumer/autopay.html","BLS_HPP_Billing_AutoPayLandingPage",false,-1], //Billing - Autopay
	["/esh/main/chainAction.do","",false,0], //FAQ
	["/search?site=SE_res&client=b&output=xml_no_dtd&proxystylesheet=b","",false,0] //Search
		],
		checkInqId:function() {
			if(typeof(inqCustomerID) != "undefined" && typeof(inqCustomerID) != null && typeof(hbx) != "undefined" && typeof(hbx) != null) {
				if (inqCustomerID == 0) hbx.seg = -12;
				else hbx.seg = 12;

			}
		},
		writeImage:function(tag) {
			if (tag != "") {
				var hppImg = new Image(1,1);
				hppImg.src = protocolString + hpp.TagBase + tag;
			}
		},
		findTag:function() {
			var i = 0;
			var currURL = document.location.href;
			var domain = document.domain;
			currURL = currURL.replace(/(http(s)*:\/\/.+?)(?=\/)/,"");
			//window.alert("Current URL: "+currURL);
			for (var i=0; i < hpp.taglist.length; i++) {				
				if(hpp.taglist[i][2])  // if true, check if url and string are equal; otherwise, check if url contains the string
				{
					//window.alert("currURL: "+currURL+"\nTagList: "+hpp.taglist[i][0]);
					if (currURL==hpp.taglist[i][0]) {
						//window.alert("Equal: "+currURL);
						hpp.setCurrent(i);
						if (currURL.indexOf("/SubmitDispute.do")!=-1)
						{
						    hpp.needBillInvite='yes';
						}
						if (currURL.indexOf("/DisplayBillSummary.do")!=-1)  //suppress survey if Bill View SBS
						{
						    hpp.isPotentialSbsPage='yes';
						}
						return true;
					}
				}
				else
				if (currURL.indexOf(hpp.taglist[i][0]) > -1) { 
					hpp.setCurrent(i);
					return true;
				}
			}
			return false;
		},
		getCookie:function() {
			var cookieVal = getCookie(hpp.Account.Cookie);
			if (cookieVal != null) {
				hpp.writeImage(hpp.Account.Tag + toHex.transform(cookieVal));
			}
			else return "";
		},
		setPageTags:function() {
			var found = hpp.findTag();
			if (found) {
				hpp.writeImage(hpp.currentTag);
				hpp.getCookie();
				hpp.writeSurvey(hpp.currentSurvey);
			}
		},
		setCurrent:function(index) {
			hpp.currentTag = hpp.taglist[index][1];
			hpp.currentSurvey = hpp.taglist[index][3];
		},
		writeSurvey:function(survey) {
			if (survey == 0) {
				if (hpp.needBillInvite=='yes')
				{
				    util.writeJS('/scripts/triggerParamsBill.js');
				}
				else
				{
				    if ((currURL.indexOf("/esh/main/chainAction.do?")!=-1) || (currURL.indexOf("/search?site=SE_res&client=b&output=xml_no_dtd&proxystylesheet=b")!=-1))
					{
					util.writeJS(protocolString + '//www.bellsouth.com/scripts/triggerParams.js');
					} else {
					util.writeJS('/scripts/triggerParams.js');
					}
				}
				if ((currURL.indexOf("/esh/main/chainAction.do?")!=-1) || (currURL.indexOf("/search?site=SE_res&client=b&output=xml_no_dtd&proxystylesheet=b")!=-1))
				{
				util.writeJS(protocolString + '//www.bellsouth.com/scripts/stdLauncher.js');
				} else {
				util.writeJS('/scripts/stdLauncher.js');
				}
			}
			if (survey == 1) {
				util.writeJS('/scripts/foresee/foresee-trigger.js');
			}
			
			
		},
		pollSurvey:function() {
		    if (navigator.userAgent.indexOf("MSIE")!=-1)   //IE browser
		    {
	    		if ((document.title.indexOf("Please Wait")==-1) && (document.title.indexOf("Error")==-1))
			{
			    if (typeof(Poll) != 'undefined' && typeof(Poll) != null) 
			    {
				if (hpp.isPotentialSbsPage=="yes")  //skip if Sbs Bill View
				{
				    if (customerTypeID == tabSMALLBUSINESS)
				    {
				    	return;
				    }
				}
				//window.alert("Poll");
				Poll();				
			    }
			}
		    }
		}
}
hpp.setPageTags();
//End Cookie Personalization

//Begin functions for Global Navigation Search
function submitQuestion(){
  var searchVal = document.question_form.search.value;
  if(isEmpty(searchVal) || searchVal == ""){
	document.question_form.search.value = "";
	document.question_form.submit();
	return false;
  }else{
	document.question_form.submit();
	return false;				
  }			
}
		
function isEmpty(str){
  if (str == null){
	return false;
  }
  for (var intLoop = 0; intLoop < str.length; intLoop++){
	if (" " != str.charAt(intLoop)){
	  return false;		    
	}
  }
  return true;
}

// Clears initial value from search box onFocus
function clearSearchBox(){
  var searchVal = document.question_form.search.value;
  if(searchVal == ""){
	document.question_form.search.value = "";
  }
}
//End functions for Global Navigation Search

// This function writes the legal footer, logic determines the content layer
function writeFooter(languageVar)
{
    var language = languageVar;
	var tStr="";
	var catchLayer;
	var ie_ver = 0;
	
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// begin BellSouth.com exclusive content//////////////////////////
///This portion of code should be removed before distribution to third party vendors///
    


	//Added util.writeJS() on 06-12-08 by JL
	hpp.checkInqId();
	util.writeJS('/scripts/hbx.js');  //Calls the tracking codes scripts
	util.writeJS('//www.wireless.att.com/webtrends/scripts/dcs_tag.js') //Webtrends tracking script
	
	util.writeJS('/scripts/baynote.js');  //Baynote Script
	util.writeJS('/scripts/baynote-observer.js');  //Baynote Observer

	hpp.pollSurvey(); // if there is a survey for this page, this will trigger the logic
	writeCookie(); //writes a persistent cookie for tracking reports and customer type

	
////////////////////////end BellSouth.com exclusive content//////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
	
	//checking ie for [real] browser version
	if (is_ie ) {
		var split_agt = agt.split('msie');
		ie_ver = parseInt(split_agt[1]);
	}

	//if (!(is_nav && (is_minor >= 4.7) || (is_ie && (ie_ver >= 5.0)))) {
	if (!(is_nav && (is_major >= 5) || (is_ie && (ie_ver >= 5.0)))) {
		tStr += '<p align="center" class="grey">This site is optimized for '
		tStr += '<a href="http://www.microsoft.com/windows/ie/default.asp" class="bread" target="_blank">Microsoft<sup class="bread">&reg;</sup> Internet Explorer</a>'
		tStr += ' versions 5.5 or higher ';
		tStr += 'and <a href="http://www.netscape.com" class="bread" target="_blank">Netscape Communicator</a> versions 6.2 or higher.'
	}

	if(language == "spanish"){ //spanish language variable
	  tStr+='<p align="center" class="grey">&copy;' + fullYear + ' AT&amp;T Intellectual Property.<br />Todos los derechos reservados. AT&amp;T, el logotipo de AT&amp;T y todas las otras marcas de AT&amp;T <br />contenidas aquí son marcas comerciales de AT&amp;T Intellectual Property y/o compañías afiliadas a AT&amp;T.<br />\n';
	  tStr+=' <a href="http://www.bellsouth.com/spanish/legal.html" class="bread">Notificaciones legales</a> y <a href="http://www.bellsouth.com/spanish/privacydoc.html" class="bread">Normas de privacidad</a>\n';	
	}else{
	  tStr+='<p align="center" class="grey">&copy;' + fullYear + ' AT&amp;T Intellectual Property.<br />All rights reserved. AT&amp;T, AT&amp;T logo and all other marks contained herein<br />are trademarks of AT&amp;T Intellectual Property and/or AT&amp;T affiliated companies.<br />\n';
	  tStr+=' <a href="http://www.bellsouth.com/legal.html?ft=legal" class="bread" target="_blank">Legal Notices</a> | <a href="http://www.att.com/privacy" class="bread" target="_blank">Privacy Policy</a> | <a href="http://www.att.jobs" class="bread" name="&lid=Careers+Link&lpos=Homepage+Footer+Links">Careers</a>';

//Olympic Logo & Link
tStr+='<br /><br /><a href="http://att.net/teamusa" target="_blank"><img src="' + relDomain + '/global/promos/images/usa.gif" width="226" height="26" border="0"></a>';

	} //e if lang
	tStr+='</p>\n';
	tStr+='<br>\n';

	if (is_nav4)  //
	{
		for (eachLayer in document.layers) {
		  if ((eachLayer.indexOf('content') != -1) || (eachLayer.indexOf('legal') != -1)) catchLayer = eachLayer;
		}
		eval('document.' + catchLayer + '.document.writeln(tStr);');
	}
	else // ie or ns6
	{
		document.writeln(tStr);
	}
}

// This function writes the header for BellSouth popup windows
function writePopupHeader()
{
	var tStr='<div id="popupHeader">';
	tStr+='<table cellpadding="0" cellspacing="0" border="0" width="205" height="50">\n';
	tStr+='<tr>\n';
	tStr+='<td width="5">&nbsp;</td>\n';
	tStr+='<td><img src="' + relDomain + '/images/att_popup_logo.gif" height="40" width="87" alt="AT&amp;T"></td>\n';
	tStr+='</tr>\n';
	tStr+='</table>\n';
	tStr+='</div>';
	document.writeln(tStr);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// End Global Headers and Footer functions ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
