function tabMaker(tabList,startTab) {

	this.currentTab = (startTab ? startTab : tabList[0]);
	this.switchTab = function(anc) {
		switchTo = anc.tabID;
		
		if ( switchTo != this.currentTab) {
			$(this.currentTab+'Content').style.display = 'none';
			$(switchTo+'Content').style.display = 'block';
	
			setCls( $(this.currentTab+'Tab'), 'off');
			setCls( $(switchTo+'Tab'), 'on');
			
			this.currentTab = switchTo;
		}
	}

	// this function is really procedural here. "this" refers to
	// the anchor tag, which is passed thru from the event mgr
	function tabMakerSwitchTab() {this.tabMaker.switchTab( this);}
	
	for(i=0;i<tabList.length;++i) {
		anc = $(tabList[i]+'Tab');
		anc.tabMaker = this;
		anc.tabID = tabList[i];
		// attach an onclick event to the tab
		addEvent(anc,'click',tabMakerSwitchTab,true);
	}
}

/* ---------- MISC */



function isBlockTag( tag) {
	return tag == 'DIV' || tag == 'P' || tag == 'BLOCKQUOTE' || tag == 'TABLE';
}

// toggles visibility of all IDs you pass in. only works if the initial state is hidden!
function toggleVis() {
	for (var i=0, len=arguments.length; i<len; ++i) {
		var elt=$(arguments[i]),
			showStyle = isBlockTag( elt.tagName) ? 'block' : 'inline';
		elt.style.display = (elt.style.display == showStyle) ? 'none' : showStyle;
	}
}
// use when the object is showing
function hideBox() {
	for (var i=0, len=arguments.length; i<len; ++i) {
		var elt=$(arguments[i]),
			showStyle = isBlockTag( elt.tagName) ? 'block' : 'inline';
		elt.style.display = (elt.style.display == 'none') ? showStyle : 'none';
	}
}
function collapseElt(e) { e.style.display = 'none'; }
function expandElt(e,sty) { e.style.display = (sty||'block'); }


/* ---------- SITE LOCATION (these 2 functions require "site-specific.js") */

function runningLocally() {
	// ensure the URL is a valid RE search string
	var searchFor = siteURL().toLowerCase().replace( /\./g, "\\."),
		re = new RegExp( searchFor, "g"),
		isLoc = document.domain.toLowerCase().search(re) < 0;
	delete re;
	return isLoc;
}

function rootDir() {
	return runningLocally() ? '/' + siteVirtual() + '/' : '/';
}


/* ---------- CLASSES */

// returns the class name of an element
function getCls( elt) { return elt.className; }
function setCls( elt, newCls) { elt.className = newCls; }

// see if an element has a given class.
// (you can pass in either a DOM OBJECT or a CLASS string)
function classContains(X, lookFor) {
	var cls = (typeof(X) == "string" ? X : getCls(X));
	if ( cls ) {
		cls = ' '+cls+' ';
		return (cls.indexOf(' '+lookFor+' ') != -1);
	}
	return false;
}

// handles an element w/multiple classes
function replaceClass(elt, oldCls, newCls) {
	var fullCls = ' '+getCls(elt)+' ',
		re = new RegExp(' '+oldCls+' ','gi'),
		tmp = fullCls.replace(re,' '+newCls+' ');
	setCls(elt,tmp.substring(1,tmp.length-1));	// remove outer spaces
	delete re;
}

function toggleClass(elt,cls1, cls2) {
	if ( classContains(elt,cls1) )
		replaceClass(elt,cls1,cls2);
	else
		replaceClass(elt,cls2,cls1);
}

// this takes a partial classname.
// IOW, this implies "class*" (right-side wildcard). 
// so passing in "myclass" will match "myclass" or "myclass500", but not "xxx_myclass"
// (pass in either a DOM OBJECT or a CLASS string)
//
function classContainsPartial(X, lookFor) {
	var cls = (typeof(X) == "string" ? X : getCls(X));
	if ( cls ) {
		cls = ' '+cls;
		return (cls.indexOf(' '+lookFor) != -1);
	}
	return false;
}

// when using "classContainsPartial", then "indexOf", you need
// to strip off add'l classes (e.g., "ipv-xxx arrow")
function stripMultiCls( cls) {
	var sp = (cls + '').indexOf(' ');
	return (sp >= 0) ? cls.substring(0,sp) : cls;
}


/* --------- ONLOAD */

var onDomLoad = null;

// call this to add your function to the queue (FIFO) that
// gets executing when the DOM is ready.
addLoadEvent = function(func) {
	var oldonload = onDomLoad;
	if(!onDomLoad)
		onDomLoad = func;
	else {
		onDomLoad = function() {
			oldonload();
			func();
		}
	}
}
function runLoadEvents() {}		// legacy: do not use

// - - - we install a handler that runs as soon as the DOM is
//		loaded (like window.onload, but that waits for images)

// http://dean.edwards.name/weblog/2006/06/again/#comment5338
function DOMinit() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    if (_timer) clearInterval(_timer);

	if(onDomLoad)
		onDomLoad();
		
	// override this so that future "addLoadEvent" calls execute immediately.
	// useful for deferred JS loading; see extras.js/ensureScript()
	addLoadEvent = function(func) { func(); }
};

if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", DOMinit, false);

/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=//0><\/script>");
    var ieScr = $("__ie_onload");
    ieScr.onreadystatechange = function() {
        if (this.readyState == "complete") {
            DOMinit();
			this.onreadystatechange = "";
		}
    };
/*@end @*/

if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval( function() { if (/loaded|complete/.test(document.readyState)) DOMinit(); }, 10);
}

// for other browsers
window.onload = DOMinit;

/*---------------  AddEvent Mgr (c) 2005 Angus Turnbull http://www.twinhelix.com

	addEvent(obj,eventName,func,useLegacy)
		(we need to use the "legacy" flag to work in safari)
*/
if (typeof aeOL == 'undefined') {
	var aeOL = [];
	var addEvent = function(o, n, f, l) {
		var d = 'addEventListener', h = 'on' + n, t, a;
		if (o[d] && !l) return o[d](n, f, false);
		if (!o.aE) { o.aE = aeOL.length || 1; aeOL[o.aE] = { o:o } }
		t = aeOL[o.aE][n] || (aeOL[o.aE][n] = []);
		for (var i = 0; i < t.length; ++i)
			for (var j = 0; j < t[i].length; ++j)
				if (t[i][j] == f) return;
		if (o[h] && o[h]._ae) {
			a = t[t.length - 1];
			a[a.length] = f;
		}
		else {
			t[t.length] = o[h] ? [o[h], f] : [f];
			o[h] = new Function('e', 'var r = true, i = 0, o = aeOL[' + o.aE + '].o,' +
				'a = aeOL[' + o.aE + ']["' + n + '"][' + (t.length - 1) + '];' +
				'for (; i < a.length; i++) { ' +
				'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;' +
				'} return r');
			o[h]._ae = 1;
		}
	};

	var removeEvent = function(o, n, f, l) {
		var d = 'removeEventListener', t, a, i, j, s;
		if (o[d] && !l) return o[d](n, f, false);
		if (!o.aE || !aeOL[o.aE]) return;
		t = aeOL[o.aE][n];
		i = t.length;
		while (i--) {
			a = t[i];
			j = a.length;
			s = 0;
			while (j--) {
				if (a[j] == f) s = 1;
				if (s) a[j] = a[j + 1];
			}
			if (s) { a.length--; break }
		}
	};
}
// see basics-docs
function cancelEvent(e, c) {
	e.returnValue = false;
	if (e.preventDefault) e.preventDefault();
	try {
		if (c) {
			e.cancelBubble = true;
			if (e.stopPropagation) e.stopPropagation();
		}
	} catch(xx) {}
};

/* ---------- ANCHOR TAG SETUP */

// see basics-docs.txt

var anchorTypes = new Array();
function registerAnchorType( ancInfo ) {
	anchorTypes.push( ancInfo);
}

	// pass in an element
	function setupOneAnchor(a) {
		var j=0, aCls=''+getCls(a),
			typeCt=anchorTypes.length, href, ext;
			
		// scan thru the registered anchor types
		for (; j<typeCt; ++j) {
			ancType = anchorTypes[j];

			// exact class match
			if ( ancType.cls && classContains(aCls,ancType.cls))
				ancType.apply(a);

			// partial class match (i.e., "class*")
			else if ( ancType.clsPartial && classContainsPartial(aCls,ancType.clsPartial))
				ancType.apply(a);

			// href match
			else if ( ancType.hrefTestFunc) {
				href = a.href;
				ext = href.substring(-3).toLowerCase();	// last 3 chars
				if ( ancType.hrefTestFunc( href, ext))
					ancType.apply(a);
			}
		}
	}

// called at dom-ready
var anchorsHaveBeenSetup = false;
function setupAllAnchors() {
	if ( anchorTypes.length > 0 && !anchorsHaveBeenSetup) {
		var aTags=document.links,anc,i,ct=aTags.length;
		for ( i=0;i<ct;++i)
			setupOneAnchor(aTags[i]);
		anchorsHaveBeenSetup = true;
	}
}
addLoadEvent(setupAllAnchors);

// adds HTML.[browsername]
// see basics-docs
function classupHTML() {
	var ua = navigator.userAgent.toLowerCase(),
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		c = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ?
				((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1) :
			is('gecko/') ? 'gecko' :
			is('opera') ? 'opera' :
			is('applewebkit/') ? 'webkit safari' :
			is('mozilla/') ? 'gecko' : 0;
	if (c) h.className += h.className ? ' ' + c : c;
}
addLoadEvent(classupHTML);

function blankSearch() {
	var srch = $('searchText');
	if ( srch.value == "search")
		srch.value = '';
}
function blankEmail() {
	var eml = $('emailSignupEmail');
	if ( eml.value == "Enter email")
		eml.value = '';
}

function initHomePage() {
	var tbm = new tabMaker( ['ac','ee','ev']),
		eml = $('emailSignupEmail'),
		srch = $('searchText');
	if ( eml) {
		eml.value = "Enter email";
		addEvent(eml,'focus',blankEmail,true);
	}
	if ( srch) {
		srch.value = "search";
		addEvent(srch,'focus',blankSearch,true);
	}

}
addLoadEvent(initHomePage);

