//Test Deploy 07/12/09 for consumer
// function for building location dependent URLs

var fullpath = location.pathname;
var URL = window.location.href;
var isadded = (URL.indexOf('added') > -1);
var isADL = (URL.indexOf('additional_lines.html') > -1);
var isEquip = (URL.indexOf('src=equip') > -1);
var noTop = (URL.indexOf('productSelection') > -1);
var lastSlash = fullpath.lastIndexOf("/");
var thepath = fullpath.substring(0,lastSlash);
var nextSlash = thepath.lastIndexOf("/");
var lastActiveTab = null;
var directory = thepath.substring(nextSlash+1,thepath.length);

if (isEquip) {
	var currentHtmlFile = 'equipment/equip_cordless.html';
} else {
var currentHtmlFile=fullpath.substring(lastSlash+1,fullpath.length);
}//bob 3/24/06
//alert(currentHtmlFile)
//defining image path to lnav images
var lnav_img_path = "/consumer/scripts/";     

//preloading active tab images into browser cache
if (document.images)
{
  img_answers_service = new Image(130, 24);
  img_answers_service.src = lnav_img_path+"ln_answers_service2.gif";
  
  img_local_service = new Image(130, 24);
  img_local_service.src = lnav_img_path+"ln_local_service2.gif";

  img_long_distance = new Image(130, 24);
  img_long_distance.src = lnav_img_path+"ln_long_distance2.gif";
  
  img_internet_services = new Image(130, 24);
  img_internet_services.src = lnav_img_path+"ln_internet_services2.gif";
  
  img_wireless = new Image(130, 24);
  img_wireless.src = lnav_img_path+"ln_wireless2.gif";

  img_customer_service = new Image(130, 24);
  img_customer_service.src = lnav_img_path+"ln_customer_service2.gif";

  
  img_none = new Image(1, 1);
  img_none.src = "/images/spacer.gif";
} 

//paths
if (protocolString == "https:") {
	var RELpath = "http://www.bellsouth.com/consumer/";
}
else {
	var RELpath = "/consumer/";
}
var ORDERpath = "/orderservice/";
var APPpath = "https://www.bellsouth.com/apps/";
var URLpath = "http://www.bellsouth.com";
var CONTACTpath = 'https://emailus.sbc.com';
var HELPpath = "/residential/";
  
//hypertext and link array for each tab	

var local_serviceArray = [
	["Local Calling Plans",RELpath+"local/index.html?src=lftnav"],
	["Voice Mail",RELpath+"voicemail.html?src=lftnav"],
	["Phones and Accessories","http://telephones.att.com/telephones_ui/index.cfm"],
	/*["Maintenance Plans",RELpath+"maintenance/maint_compare.html?src=lftnav"],*/
	["Additional Lines",ORDERpath+"additional_lines.html?src=adl"],
	["Local Service Help",RELpath+"local/localhelp.html?src=lftnav"]]
				   
var long_distanceArray = [
	["International Plans",RELpath+"ld/ld_int_compare.html?scr=lftnav"],
	["Calling Cards",RELpath+"ld/ld_global_cc.html?src=lftnav"],
	["Long Distance Help",RELpath+"ld/longdistancehelp.html?src=lftnav"]]
					  
var internet_servicesArray = [
	["DSL without a phone line",RELpath+"inetsrvcs/promo_unreal.html?src=lftnav"],
	["Special Offers",RELpath+"inetsrvcs/inetsrvcs_special_offers.html?src=lftnav"],
	["Compare Plans",RELpath+"inetsrvcs/inetsrvcs_compare.html?src=lftnav"],
	["HomeNetworking",RELpath+"inetsrvcs/inetsrvcs_fa_homenet.html?src=lftnav"],
	["Dial Internet Service",RELpath+"inetsrvcs/inetsrvcs_dial.html?src=lftnav"],
	//["Internet Security",RELpath+"inetsrvcs/inetsrvcs_fa_security.html?src=lftnav"],
	["Static IP",RELpath+"inetsrvcs/inetsrvcs_fa_static_ip.html?src=lftnav"],
	["AT&amp;T Broadband via Satellite","http://www.att.com/gen/general?pid=9212"],
	["Internet Services Help","http://support.att.com"],
	["FAQ","http://www.att.com/esupport/main.jsp?cv=801"]]
					  
var wirelessArray = []
			  
var digital_tvArray = []

var answers_serviceArray = []

var noneArray = []

var customer_serviceArray = [
	["Help & Support",HELPpath+"helpcenter.html?src=lftnav"],
	["Billing Help","http://support.att.com"],
	["Troubleshoot & Repair","http://www.att.com/repair"],
	["Travel Support","http://www.att.com/gen/general?pid=12809"],
	["Glossary",HELPpath+"glossary.html?src=lftnav"],
	["Order Status",APPpath+"resorderstatus/OrderStatusCnt.jpf?src=lftnav"],
	["Getting Started",URLpath+"/ewelcome"],
	["Contact Us",CONTACTpath+"/ermsfp/emailus?service=external/Home"]]

if (document.getElementById)
{ 
	document.write('<style type="text/css">\n')
	document.write('.submenucont{display: block;}\n')
	document.write('</style>\n')
}

function displayNav(navID,matchCurrentHtml)
{
var activeImg = eval("document.img_"+navID);
	if(document.getElementById)
	{
		var el = document.getElementById(navID);
		var ar = document.getElementById("leftMenu").getElementsByTagName("div"); 
		if(el.style.display != "block")
		{
			for (var i=0; i<ar.length; i++)
			{
				if (ar[i].className=="submenucont")
				{
					ar[i].style.display = "none";
					activeImg.src = lnav_img_path+'ln_'+navID+'.gif';
				}
			}
			activeImg.src = lnav_img_path+'ln_'+navID+'2.gif';
			
			//reverts last active tab image to an inactive state, if last active tab exists 
			//and is not the same as the current open tab.
			if(lastActiveTab != null && lastActiveTab != navID){
			  var lastActiveImg = eval("document.img_"+lastActiveTab);
				lastActiveImg.src = lnav_img_path+'ln_'+lastActiveTab+'.gif'; 
			}			
			//sets value of lastActiveTab to the value of this iterations active tab
			lastActiveTab = navID;
						
			var navContent = genNav(navID,matchCurrentHtml);
			el.innerHTML=navContent;
			el.style.display = "block";			
		}
		else
		{
			activeImg.src = lnav_img_path+'ln_'+navID+'.gif';
			el.style.display = "none";	
		}
	}
}

//Called by displayNav is the innerHTML is blank  
re=/.+\/(.+\.html)/;  //should satisfy xyz.html and xyz.html?src=lftnav as file name  bob 3/24/06

function genNav(navID)
{
	if(window.leftnavtitle)
	{
			currentHtmlFile = window.leftnavtitle;
	}
    //bob 3/24/06 changes throughout function
    var activeArray = eval(navID+'Array');
    var navStr = '<table width="130" border="0" cellspacing="0" cellpadding="2">\n';
    for(var i=0; i < activeArray.length; i++)
    {
	    var suppressLink=false;  
	    if (re.test(activeArray[i][1]))    
            {
		var testFile=RegExp.$1;
		if (testFile==currentHtmlFile)
		{
			suppressLink=true;
//		        window.alert(testFile+"="+currentHtmlFile);
		}
//	        window.alert(testFile+"="+currentHtmlFile);
            }

	navStr+='<tr>\n';	    //bob 3/24/06
	navStr+='<td width="15" valign="top" align="center" class="blue">&raquo;</td>\n';
	navStr+='<td width="115">';
	if (suppressLink)
	{
	    navStr+='<span class="grey">'+activeArray[i][0]+'</span>';
	}
	else
	{
	    navStr+='<a href="'+activeArray[i][1]+'" class="submenu">'+activeArray[i][0]+'</a>';
	}
	navStr+='</td>\n';
	navStr+='</tr>\n';	    
    }
    navStr+='</table>\n'; 
    return navStr;
}

function initializeLNav(navID)
{
	var tStr='';
	if (!noTop) {
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="'+RELpath+'local/index.html"><img src="'+lnav_img_path+'ln_establish_service2.gif" alt="Establish Service" name="img_establish_service2" width="130" height="24" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="https://ordering.bellsouth.com/apps/supern/MoveOrderStartAction.form"><img src="'+lnav_img_path+'ln_moving.gif" alt="Moving?" name="img_moving" width="130" height="24" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="menubutt2"><a onclick="deactivateDropOffAds();" href="'+ORDERpath+'index.html?custType=c&src=lftnav"><img src="'+lnav_img_path+'ln_modify_service.gif" alt="Modify Service" name="img_modify_service" width="130" height="24" border="0" class="imgBlock" /></a></div>\n';
	}
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="'+RELpath+'answers/index.html"><img src="'+lnav_img_path+'ln_answers_service';
	if (directory == "answers")
	{
	tStr+='2.gif" ';
	}
	else
	{
	tStr+='.gif" ';
	}
	tStr+=' alt="AT&T Bundles" name="img_answers_service" width="130" height="24" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="answers_service"></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="'+RELpath+'local/index.html"><img src="'+lnav_img_path+'ln_local_service.gif" alt="Local Services" name="img_local_service" width="130" height="24" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="local_service"></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="'+RELpath+'ld/index.html"><img src="'+lnav_img_path+'ln_long_distance.gif" height="24" width="130" alt="Long Distance" name="img_long_distance" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="long_distance"></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="http://www.att.com/shop/internet/"><img src="'+lnav_img_path+'ln_internet_services.gif" height="24" width="130" alt="Internet Services" name="img_internet_services" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="internet_services"></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="http://www.att.com/shop/wireless/"><img src="'+lnav_img_path+'ln_wireless.gif" height="24" width="130" alt="Wireless Services" name="img_wireless" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="wireless"></div>\n';
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="http://www.att.com/shop/tv/"><img src="'+lnav_img_path+'ln_digital_tv';
	if (directory == "advancedtv")
	{
	tStr+='2a.gif" ';
	}
	else
	{
	tStr+='a.gif" ';
	}
	tStr+='height="24" width="130" alt="Digital TV" name="img_digital_tv" border="0" class="imgBlock" /></a></div>\n';
	tStr+='<div class="submenucont" id="digital_tv"></div>\n';
	
	
	tStr+='<div class="menubutt"><a onclick="deactivateDropOffAds();" href="http://www.att.com/esupport/"><img src="'+lnav_img_path+'ln_customer_service.gif" height="24" width="130" alt="Customer Service" name="img_customer_service" border="0" /></a></div>\n';
	tStr+='<div class="submenucont" id="customer_service"></div>\n';	
	tStr+='<div class="menubutt"><img src="/images/spacer.gif" height="1" width="1" alt="none" name="img_none" border="0" /></div>\n';
		
//var dslPages = ((currURL.indexOf("/inetsrvcs/indexA") != -1) || (currURL.indexOf("fa_homenet") != -1) || (currURL.indexOf("fa_security") != -1) || (currURL.indexOf("fa_static_ip") != -1) || (currURL.indexOf("inetsrvcs_order") != -1)  || (currURL.indexOf("inetsrvcs_compare") != -1));
//var leftNavorOn = ((currURL.indexOf("/triplechoice") != -1) || (currURL.indexOf("/move") != -1) || (currURL.indexOf("/residentialservice") != -1) || (currURL.indexOf("/view_selections") != -1) || (currURL.indexOf("help") != -1) || (currURL.indexOf("ewelcome") != -1) || (currURL.indexOf("maint_") != -1) || (currURL.indexOf("orderservice") != -1) || (currURL.indexOf("equipment") != -1) || (currURL.indexOf("voicemail") != -1) || (currURL.indexOf("ld_global_cc.html") != -1) || (currURL.indexOf("global/promos") != -1) || (currURL.indexOf("residential") != -1) || (currURL.indexOf("prepare") != -1) || (currURL.indexOf("media") != -1) || (currURL.indexOf("productSelection") != -1) || (currURL.indexOf("unreal") != -1));

	//if (!current_new && dslPages){
	//tStr+='<div id="inqC2CImgContainer"></div>';
	//} else if (!current_new || leftNavorOn) {
	//tStr+=''
	//} else if (current_new) {
	//tStr+='<div id="inqC2CImgContainer"></div>';
	//}

//Live Person Tagging
var leftNavorOn = ((currURL.indexOf("/ld/index") != -1)|| (currURL.indexOf("/ld/ld_int_compare") != -1));

	if ((leftNavorOn) && (current_new == 'newCustomer')){
	tStr+='<div id="lpbutton-DIV-short"></div>';
	} else {
	tStr+=''
	}

document.writeln(tStr);
	  
	if(navID == null)  // if a specific tab needs to be expanded onload depending on the directory - this if statement makes that happen using the navID variable
	{
		if (directory == "local" || "maintenance" || "equipment" || "consumer") displayNav('local_service');
		if (directory == "ld") displayNav('long_distance');
		if (directory == "answers") displayNav('answers_service');
		if (directory == "inetsrvcs") displayNav('internet_services');
		if (directory == "wireless") displayNav('wireless');
		if (directory == "advancedtv") displayNav('digital_tv');
		if (directory == "residential") displayNav('customer_service');
	}
}
