function selectTab(sel_name) {
	// make all tabs unselected and hide all tab blocks
        var sel_tab = 'false';
	for (var i = 0; i < tabs.length; i++) {
		tab_name = tabs[i].href.split('#')[1];
		document.getElementById(tab_name).style.display = "none";
		tabs[i].className = "tab";
	 
		if (tab_name == sel_name) { sel_tab = tabs[i]; }
	}

        if (sel_tab!='false') {
	sel_tab.className += " active";
	document.getElementById(sel_name).style.display = "block";
        }
	
}
function newTestInit() {
	// go through subtabs and add to array
	tabs = []
	var loc = window.location.toString();
	var links = document.getElementsByTagName("a");
	// take care of the currently selected node
	for (var i = 0; i < links.length; i++) { 
		// if it is a tab class, we add it to the tab array
		if (links[i].className.indexOf("tab") != -1) {
			tabs.push(links[i]);
			links[i].onclick = function () {
				selectTab(this.href.split('#')[1]);
				return false;
			}
			
		// if this is a link to a tab on this page, we attach the onclick
		} else if (links[i].href.indexOf(loc) != -1 && links[i].href.indexOf('#tab') != -1) {
			links[i].onclick = function () {
				selectTab(this.href.split('#')[1]);
				window.location.hash = "#content";
				return false;
			}
		}
	}
	// select the current anchor or the default first tab
	var sel_name = loc.split('#')[1]
     
	if (sel_name=='ipad' || sel_name=='podcast') {	
		$("#win_an_ipad").colorbox({iframe:true, innerWidth:600, innerHeight:555,open:true});
                 
		try {
			var pageTracker = _gat._getTracker("UA-18134361-1");
			pageTracker._trackPageview('/virtual/'+sel_name+"/email");
		}
		catch(e) {
		}
		sel_name = "tab1"
		  
		selectTab("tab1");
	 } else {
		if (sel_name == null) { sel_name = "tab1" }
		selectTab(sel_name);
	}
}
// attach the init to the load event based on browser
if (window.addEventListener)
	window.addEventListener("load", newTestInit, false);
else if (window.attachEvent)
	window.attachEvent("onload", newTestInit);

