// JavaScript Document

function renderPrimaryNav() {
document.write('<ul id="primary-nav">');
document.write('<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>');
document.write('<li id="jaNav"><a href="http://world.att.com/languages.html?lang=ja&id=' + state + '">JAPANESE/&#26085;&#26412;&#35486;</a></li>');
document.write('<li id="koNav"><a href="http://world.att.com/languages.html?lang=ko&id=' + state + '">KOREAN/&#54620;&#44397;&#50612;</a></li>');
document.write('<li id="zhNav" class="current"><a href="http://world.att.com/languages.html?lang=zh&id=' + state + '">CHINESE/&#20013;&#25991;</a></li>');
document.write('<li id="viNav"><a href="http://world.att.com/languages.html?lang=vi&id=' + state + '">VIETNAMESE/Ti&#7871;ng Vi&#7879;t</a></li>');
document.write('<li id="tlNav"><a href="http://world.att.com/languages.html?lang=tl&id=' + state + '">TAGALOG</a></li>');
document.write('</ul>');
}


//

// accordion.js v2.0
//
// Copyright (c) 2007 stickmanlabs
// Author: Kevin P Miller | http://www.stickmanlabs.com
// 
// Accordion is freely distributable under the terms of an MIT-style license.
//
// I don't care what you think about the file size...
//   Be a pro: 
//	    http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
//

/*-----------------------------------------------------------------------------------------------*/

var state = GetState();

if (typeof Effect == 'undefined') 
	throw("accordion.js requires including script.aculo.us' effects.js library!");

var accordion = Class.create();
accordion.prototype = {

	//
	//  Setup the Variables
	//
	showAccordion : null,
	currentAccordion : null,
	duration : null,
	effects : [],
	animating : false,
	
	//  
	//  Initialize the accordions
	//
	initialize: function(container, options) {
	  if (!$(container)) {
	    throw(container+" doesn't exist!");
	    return false;
	  }
	  
		this.options = Object.extend({
			resizeSpeed : 10,
			classNames : {
				toggle : 'accordion_toggle',
				toggleActive : 'accordion_toggle_active',
				content : 'accordion_content'
			},
			defaultSize : {
				height : null,
				width : null
			},
			direction : 'vertical',
			onEvent : 'click'
		}, options || {});
		
		this.duration = ((11-this.options.resizeSpeed)*0.9);

		var accordions = $$('#'+container+' .'+this.options.classNames.toggle);
		accordions.each(function(accordion) {
			Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false);
			if (this.options.onEvent == 'click') {
			  accordion.onclick = function() {return false;};
			}
			
			if (this.options.direction == 'horizontal') {
				var options = $H({width: '0px'});
			} else {
				var options = $H({height: '0px'});			
			}
			options.merge({display: 'none'});			
			
			this.currentAccordion = $(accordion.next(0)).setStyle(options);			
		}.bind(this));
	},
	
	//
	//  Activate an accordion
	//
	activate : function(accordion) {
		if (this.animating) {
			return false;
		}
		
		this.effects = [];
	
		this.currentAccordion = $(accordion.next(0));
		this.currentAccordion.setStyle({
			display: 'block'
		});		
		
		this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);

		if (this.options.direction == 'horizontal') {
			this.scaling = $H({
				scaleX: true,
				scaleY: false
			});
		} else {
			this.scaling = $H({
				scaleX: false,
				scaleY: true
			});			
		}
			
		if (this.currentAccordion == this.showAccordion) {
		  this.deactivate();
		} else {
		  this._handleAccordion();
		}
	},
	// 
	// Deactivate an active accordion
	//
	deactivate : function() {
		var options = $H({
		  duration: this.duration,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal,
			queue: {
				position: 'end', 
				scope: 'accordionAnimation'
			},
			scaleMode: { 
				originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
				originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
			},
			afterFinish: function() {
				this.showAccordion.setStyle({
          height: 'auto',
					display: 'block'
				});				
				this.showAccordion = null;
				this.animating = false;
			}.bind(this)
		});    
    options.merge(this.scaling);

    this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
    
		new Effect.Scale(this.showAccordion, 0, options);
	},

  //
  // Handle the open/close actions of the accordion
  //
	_handleAccordion : function() {
		var options = $H({
			sync: true,
			scaleFrom: 0,
			scaleContent: false,
			transition: Effect.Transitions.sinoidal,
			scaleMode: { 
				originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
				originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
			}
		});
		options.merge(this.scaling);
		
		this.effects.push(
			new Effect.Scale(this.currentAccordion, 100, options)
		);

		if (this.showAccordion) {
			this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
			
			options = $H({
				sync: true,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal
			});
			options.merge(this.scaling);
			
			this.effects.push(
				new Effect.Scale(this.showAccordion, 0, options)
			);				
		}
		
    new Effect.Parallel(this.effects, {
			duration: this.duration, 
			queue: {
				position: 'end', 
				scope: 'accordionAnimation'
			},
			beforeStart: function() {
				this.animating = true;
			}.bind(this),
			afterFinish: function() {
				if (this.showAccordion) {
					this.showAccordion.setStyle({
						display: 'none'
					});				
				}
				$(this.currentAccordion).setStyle({
				  height: 'auto'
				});
				this.showAccordion = this.currentAccordion;
				this.animating = false;
			}.bind(this)
		});
	}
}
	
	
    var id = GetQueryStringValue("id");
    var extension = GetQueryStringValue("ext");
    var anchor = GetQueryStringValue("anc");
		//  In my case I want to load them onload, this is how you do it!
		// 
		Event.observe(window, 'load', loadAccordions, false);
	
		//
		//	Set up all accordions
		//
		function loadAccordions() {
//			var topAccordion = new accordion('horizontal_container', {
//				classNames : {
//					toggle : 'horizontal_accordion_toggle',
//					toggleActive : 'horizontal_accordion_toggle_active',
//					content : 'horizontal_accordion_content'
//				},
//				defaultSize : {
//					width : 525
//				},
//				direction : 'horizontal'
//			});
//			
			//var bottomAccordion = new accordion('vertical_container');
			
			var bottomAccordion = new accordion('vertical_container', {
			  classNames : {
					toggle : 'accordion_toggle',
					toggleActive : 'accordion_toggle_active',
					content : 'accordion_content'
				}
			});
			
			// Open first one
			//
			
			var myString = window.location;
var location = myString.toString();
var urlparts = location.split('/');
 var showNav = urlparts[4];
 var showPage = urlparts[5];
 position = showPage.indexOf("_");
 showPage = showPage.substring(0,position);
 
if (state == "california") {
	
	if (showNav == 'justcall' || showNav == 'att_total_connections' || showNav == 'unity' || showNav == "voice" || showNav == "local_phone") {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[0]);
			}
			
 			//if (showNav == 'wireless') {
//bottomAccordion.activate($$('#vertical_container .accordion_toggle')[1]);
//			}
			
 			if (showNav == 'sat' || showNav == 'uverse' || showNav == 'DVR' || showPage == 'digitv') {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[1]);
			}
			
 			if (showNav == 'att_dsl' || showNav == 'att_dial' || showNav == 'wifi') {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[2]);
			}
			
	
}
else
 			if (showNav == 'justcall' || showNav == 'att_total_connections' || showNav == 'unity' || showNav == "voice" || showNav == "local_phone") {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[0]);
			}
			
 			if (showNav == 'wireless') {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[1]);
			}
			
 			if (showNav == 'sat' || showNav == 'uverse' || showNav == 'DVR' || showPage == 'digitv') {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[2]);
			}
			
 			if (showNav == 'att_dsl' || showNav == 'att_dial' || showNav == 'wifi') {
bottomAccordion.activate($$('#vertical_container .accordion_toggle')[3]);
			}
			}
//
	// You can hide the accordions on page load like this, it maintains accessibility
	//
	// Special thanks go out to Will Shaver @ http://primedigit.com/
	//
	var verticalAccordions = $$('.accordion_toggle');
	verticalAccordions.each(function(accordion) {
		$(accordion.next(0)).setStyle({
		  height: '0px'
		});
	});
	
function renderHome() {
document.write('<p><a href="http://world.att.com/languages.html?lang=zh&id=' + state + '">Home</a></p>');
}
	

function renderLeftNav() {
	

var myString = window.location;
var location = myString.toString();
var urlparts = location.split('/');
var showNav = urlparts[4] ;
var showSub= urlparts[5] ;
var showSub = showSub.split('?');
var showSub = showSub[0]
var showSub = showSub.split('.');
var showSub = showSub[0];
 
 
document.write('<div id="left-nav" style="margin-left: 10px !important;margin-right: 0px !important;">');
document.write('<div id="vertical_container" >');
document.write('<h1 class="accordion_toggle" title="Home Phone">Home Phone</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
if (showNav == "local_phone") {
document.write('<li><a href="/residential_customers/local_phone/anystate.html?id=' + GetState(true) +'" class="current">Local Phone</a></li>');
} else document.write('<li><a href="/residential_customers/local_phone/anystate.html?id=' + GetState(true) +'">Local Phone</a></li>');
if (showNav == "att_total_connections") {
document.write('<li><a href="/residential_customers/att_total_connections/anystate.html?id=' + GetState(false) +'" class="current">Nationwide Long Distance</a></li>');
} else document.write('<li><a href="/residential_customers/att_total_connections/anystate.html?id=' + GetState(false) +'">Nationwide Long Distance</a></li>');
if (showNav == "justcall") {
document.write('<li><a href="/residential_customers/justcall/anystate_worldwide_2.html?id=' + GetState(false) +'" class="current">International Long Distance</a></li>');
} else document.write('<li><a href="/residential_customers/justcall/anystate_worldwide_2.html?id=' + GetState(false) +'" >International Long Distance</a></li>');
if (showNav == "unity") {
document.write('<li><a href="/residential_customers/unity/promo.html?id=' + GetState(false) +'" class="current">AT&amp;T Unity</a></li>');
} else document.write('<li><a href="/residential_customers/unity/promo.html?id=' + GetState(false) +'">AT&amp;T Unity</a></li>');
if (showNav == "voice") {
document.write('<li><a href="/residential_customers/voice/index.html?id=' + GetState(false) +'" class="current">U-verse Voice</a></li>');
} else document.write('<li><a href="/residential_customers/voice/index.html?id=' + GetState(false) +'">U-verse Voice</a></li>');
document.write('</ul>');
document.write('</div>');
if (state == "california"){
}
else {
document.write('<h1 class="accordion_toggle" title="Wireless">Wireless</h1>');
document.write('<div class="accordion_content">');
document.write('<ul style="list-style-type: none !important;">');
if (showNav == "wireless") {
document.write('<li style="list-style-type: none !important;"><a href="/residential_customers/wireless/anystate.html?id=' + GetState(false) +'" class="current">Wireless</a></li>');
} else document.write('<li style="list-style-type: none !important;"><a href="/residential_customers/wireless/anystate.html?id=' + GetState(false) +'">Wireless</a></li>');
document.write('</ul>');
document.write('</div>');
}
document.write('<h1 class="accordion_toggle" title="Advanced TV">Advanced TV</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
if (showNav == "sat" && showSub == 'anystate' ){
document.write('<li><a href="/residential_customers/sat/anystate.html?id=' + GetState(false) +'" class="current">AT&amp;T&nbsp;|&nbsp;DIRECTV</a>');
} else document.write('<li><a href="/residential_customers/sat/anystate.html?id=' + GetState(false) +'">AT&amp;T&nbsp;|&nbsp;DIRECTV</a>');
if (showNav == "sat" && showSub == "international") {
document.write('<ul><li class="sub-nav" ><a href="/residential_customers/sat/international.html?id=' + GetState(false) +'" class="current">International Programming</a></li></ul>');
} else document.write('<ul><li class="sub-nav" ><a href="/residential_customers/sat/international.html?id=' + GetState(false) +'">International Programming</a></li></ul>');
document.write('</li>');
if (showNav == "uverse" && showSub == "index") {
document.write('<li><a href="/residential_customers/uverse/index.html?id=' + GetState(false) +'" class="current">AT&amp;T U-verse</a>');
} else document.write('<li><a href="/residential_customers/uverse/index.html?id=' + GetState(false) +'">AT&amp;T U-verse</a>');
if (showNav == "uverse" && showSub == "international") {
document.write('<ul><li class="sub-nav" ><a href="/residential_customers/uverse/international.html?id=' + GetState(false) +'" class="current">International Programming</a></li></ul>');
} else document.write('<ul><li class="sub-nav" ><a href="/residential_customers/uverse/international.html?id=' + GetState(false) +'">International Programming</a></li></ul>');

if (showNav == "DVR") {
document.write('<ul><li class="sub-nav"><a href="/residential_customers/DVR/index.html?id=' + GetState(false) +'" class="current">Total Home DVR</a></li></ul>');
} else document.write('<ul><li class="sub-nav"><a href="/residential_customers/DVR/index.html?id=' + GetState(false) +'">Total Home DVR</a></li></ul>');
document.write('</li></ul>');
document.write('</div>');
document.write('<h1 class="accordion_toggle" title="Internet">Internet</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
if (showNav == "att_dsl" && showSub == "anystate") {
document.write('<li><a href="/residential_customers/att_dsl/anystate.html?id=' + GetState(true) +'" class="current">AT&amp;T High Speed Internet</a></li>');
} else document.write('<li><a href="/residential_customers/att_dsl/anystate.html?id=' + GetState(true) +'">AT&amp;T High Speed Internet</a></li>');
if (showNav == "att_dsl" && showSub == "dsl_direct") {
document.write('<li><a href="/residential_customers/att_dsl/dsl_direct.html?id=' + GetState(true) +'" class="current">AT&amp;T DSL Direct</a></li>');
} else document.write('<li><a href="/residential_customers/att_dsl/dsl_direct.html?id=' + GetState(true) +'">AT&amp;T DSL Direct</a></li>');
if (showNav == "att_dial") {
document.write('<li><a href="/residential_customers/att_dial/anystate.html?id=' + GetState(true) +'" class="current">AT&amp;T Dial</a></li>');
} else document.write('<li><a href="/residential_customers/att_dial/anystate.html?id=' + GetState(true) +'">AT&amp;T Dial</a></li>');
if (showNav == "wifi") {
document.write('<li><a href="/residential_customers/wifi/anystate.html?id=' + GetState(true) +'" class="current">AT&amp;T WiFi</a></li>');
} else document.write('<li><a href="/residential_customers/wifi/anystate.html?id=' + GetState(true) +'">AT&amp;T WiFi</a></li>');
document.write('</ul>');
document.write('</div>');
document.write('</div>');
document.write('<div class="clear"></div>');
document.write('</div> ');

document.write('<div class="section nb"> ');
document.write('<p class="header">Consumer Information</p>  ');
document.write('<p><a href="/residential_customers/rewards_for_referral.html?id=' + GetState(false) + '">Rewards for Referrals</a></p>');
if(state == 'california') {}
else {document.write('<p><a href="/residential_customers/consumer_tips.html?id=' + GetState(false) + '">Consumer Safety Tips</a></p>');}
if (showSub == 'digitv_transition') {
document.write('<p><a href="/corporate_information/media_kits/digitv_transition.html?id=' + GetState(false) + '" class="current">DTV Switch</a></p>');
} else {
document.write('<p><a href="/corporate_information/media_kits/digitv_transition.html?id=' + GetState(false) + '">DTV Switch</a></p>');
document.write('<p><a href="/corporate_information/contact.html?id=' + GetState(false) + '">Contact Us</a></p>');
document.write('</div> ');
document.write('</div> ');
document.write('<div class="section nb"> ');
document.write('<p class="header">Corporate Information</p>  ');
document.write('<p><a href="/corporate_information/index.html?id=' + GetState(false) + '">Media Newsroom</a></p>');
if (showNav == "uverse") {
document.write('<div id="triplepack-menu-btn"><p><a href="/residential_customers/order_product.html?prod=uverse&id=' + GetState(false) + '">&#20170;&#22825;&#23601;&#21152;&#20837; <img src="/mlcomm/images/INDC/white_btn_forward.gif" alt=""/></a><br/>\n<a href="#triple" onclick="open(\'/residential_customers/triplepack_terms.html\',\'\',\'width=550,height=340,scrollbars=0,menubar=0\')">&#29554;&#21462;&#26356;&#22810;&#36039;&#35338; <img src="/mlcomm/images/INDC/white_btn_forward.gif" alt=""/></a></p></div>');
	}
document.write('</div> ');	
}

}
			

function renderLeftNavOrderform() {
	


	

var myString = window.location;
var location = myString.toString();
var urlparts = location.split('/');
var showNav = urlparts[4] ;
var showNav = showNav.split('?');
var showNav = showNav[0]
var showNav = showNav.split('.');
var showNav = showNav[0];

 

document.write('<div id="left-nav" style="margin-left: 10px !important;margin-right: 0px !important;">');
document.write('<div id="vertical_container" >');
document.write('<h1 class="accordion_toggle" title="Home Phone">Home Phone</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
document.write('<li><a href="/residential_customers/local_phone/anystate.html?id=' + GetState(true) +'">Local Phone</a></li>');
document.write('<li><a href="/residential_customers/att_total_connections/anystate.html?id=' + GetState(false) +'">Nationwide Long Distance</a></li>');
document.write('<li><a href="/residential_customers/justcall/anystate_worldwide_2.html?id=' + GetState(false) +'" >International Long Distance</a></li>');
document.write('<li><a href="/residential_customers/unity/promo.html?id=' + GetState(false) +'">AT&amp;T Unity</a></li>');
document.write('<li><a href="/residential_customers/voice/index.html?id=' + GetState(false) +'">U-verse Voice</a></li>');
document.write('</ul>');
document.write('</div>');
if (state == "california"){
}
else {
document.write('<h1 class="accordion_toggle" title="Wireless">Wireless</h1>');
document.write('<div class="accordion_content">');
document.write('<ul style="list-style-type: none !important;">');
 document.write('<li style="list-style-type: none !important;"><a href="/residential_customers/wireless/anystate.html?id=' + GetState(false) +'">Wireless</a></li>');
document.write('</ul>');
document.write('</div>');
}
document.write('<h1 class="accordion_toggle" title="Advanced TV">Advanced TV</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
document.write('<li><a href="/residential_customers/sat/anystate.html?id=' + GetState(false) +'">AT&amp;T&nbsp;|&nbsp;DIRECTV</a>');
document.write('<ul><li class="sub-nav" ><a href="/residential_customers/sat/international.html?id=' + GetState(false) +'">International Programming</a></li></ul>');
document.write('</li>');
document.write('<li><a href="/residential_customers/uverse/index.html?id=' + GetState(false) +'">AT&amp;T U-verse</a>');
document.write('<ul><li class="sub-nav"><a href="/residential_customers/DVR/index.html?id=' + GetState(false) +'">Total Home DVR</a></li></ul>');
document.write('</li></ul>');
document.write('</div>');
document.write('<h1 class="accordion_toggle" title="Internet">Internet</h1>');
document.write('<div class="accordion_content">');
document.write('<ul>');
document.write('<li><a href="/residential_customers/att_dsl/anystate.html?id=' + GetState(false) +'">AT&amp;T High Speed Internet</a></li>');
document.write('<li><a href="/residential_customers/att_dsl/dsl_direct.html?id=' + GetState(false) +'">AT&amp;T DSL Direct</a></li>');
 document.write('<li><a href="/residential_customers/att_dial/anystate.html?id=' + GetState(false) +'">AT&amp;T Dial</a></li>');
document.write('<li><a href="/residential_customers/wifi/anystate.html?id=' + GetState(false) +'">AT&amp;T WiFi</a></li>');
document.write('</ul>');
document.write('</div>');
document.write('</div>');
document.write('<div class="clear"></div>');
document.write('</div> ');	
	

document.write('<div class="section"> ');
document.write('<p class="header">Consumer Information</p>  ');
if(showNav == "rewards_for_referral") {
document.write('<p><a href="/residential_customers/rewards_for_referral.html?id=' + GetState(false) + '" class="current">Rewards for Referrals</a></p>');
} else document.write('<p><a href="/residential_customers/rewards_for_referral.html?id=' + GetState(false) + '">Rewards for Referrals</a></p>');
 
if(showNav == "consumer_tips" || showNav == "game_eng" || showNav == "game_zh") {
document.write('<p><a href="/residential_customers/consumer_tips.html?id=' + GetState(false) + '" class="current">Consumer Safety Tips</a></p>');
} else document.write('<p><a href="/residential_customers/consumer_tips.html?id=' + GetState(false) + '">Consumer Safety Tips</a></p>');
 
if (showNav == 'media_kits') {
document.write('<p><a href="/corporate_information/media_kits/digitv_transition.html?id=' + GetState(false) + '" class="current">DTV Switch</a></p>');
} else document.write('<p><a href="/corporate_information/media_kits/digitv_transition.html?id=' + GetState(false) + '">DTV Switch</a></p>');
document.write('<p><a href="/corporate_information/contact.html?id=' + GetState(false) + '">Contact Us</a></p>');
document.write('</div> ');	
document.write('<div class="section nb"> ');
document.write('<p class="header">Corporate Information</p>  ');
document.write('<p><a href="/corporate_information/index.html?id=' + GetState(false) + '">Media Newsroom</a></p>');
document.write('</div> '); 
}			




function showContactMap(region) {
	 
	document.getElementById('contactMap').style.display = 'none';
	
	allregions = new Array('california','west','southCentral','midwest','northeast','southeast');
	
	for(m=0;m<allregions.length;m++) {
	
	if(region == allregions[m]) {
		document.getElementById(region).style.display = 'block'
	}
	else document.getElementById(allregions[m]).style.display = 'none'
	
	}
}






