
// tool tip popups //
	if(window.attachEvent)
		window.attachEvent("onload",hoverTextInit);
	else
		window.addEventListener("load", hoverTextInit, false);
	var hoverdiv, iid;
	function hoverTextInit(){
	    hoverdiv = document.createElement("div");
	    hoverdiv.id = "hovertext";
	    hoverdiv.innerHTML = "<div id=\"top\"></div><p></p><div id=\"bot\"></div>";
		document.getElementById("content").appendChild(hoverdiv);
	}
	function setLableStatic(evt, lab){
		var elem = hoverdiv.getElementsByTagName("p")[0];
		elem.innerHTML = lab;
		if(document.all){
			xoff = document.documentElement.scrollLeft;
			yoff = document.documentElement.scrollTop;
			if(400 + evt.clientX > document.documentElement.offsetWidth)
				xoff -= 350;
		}
		else{
			xoff = window.pageXOffset;
			yoff = window.pageYOffset;
			if(400 + evt.clientX > document.width)
				xoff -= 350;
		}
		xpos = evt.clientX+xoff+5;
		ypos = evt.clientY+yoff+15;
		hoverdiv.style.left = xpos + "px";		
		hoverdiv.style.top = ypos + "px";
		showTooltip();
	}
	function fadeTooltip(start, change){
	var ie = (document.all) ? 1 : 0;
	var opacStyle = (ie) ? "filter" : "opacity";
		if(iid)
			clearInterval(iid);
		var time = 5;
		var opac = start;
		var opacS = (ie) ? "alpha(opacity="+opac+")" : opac/100;
		hoverdiv.style[opacStyle] = opacS;
		iid = setInterval(function(){
			if(time-- > 0){
				opac+=change;
				opacS = (ie) ? "alpha(opacity="+opac+")" : opac/100;
				hoverdiv.style[opacStyle] = opacS;
			}
			else{
				if(change < 0)
					hoverdiv.style.display = "none";
				clearInterval(iid);
				iid = null;
			}
		},20);
		
	}
	function showTooltip(){
		hoverdiv.style.display = "block";
		fadeTooltip(15,16);
	}
	function hide(){
		fadeTooltip(95,-16);
	}
	// end tool tip popups //
	// open popup window (calcs) //
	function openWin(href){
	    h = screen.availHeight+50;
	    arg = 'width=798,height='+h+'toolbar=no,location=no,menubar=no,status=no,scrollbars=yes';
		w = window.open(href,'_blank',arg);
		w.moveTo(150,0);
	}
	// end open popup window (calcs) //
	// ie input:focus fix //
	sfFocus = function() {
		dosfFocus("input");
		dosfFocus("textarea");
	}
	dosfFocus = function(tagName) {
		var sfEls = document.getElementsByTagName(tagName);
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onfocus=function() {
				this.className+=" sffocus";
			}
			sfEls[i].onblur=function() {
				this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfFocus);
	// end ie input:focus fix //
	
	// ie6 image flicker fix
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
	// end image flicker fix
	
	
	var calcTipHighlight = function(index){
	    var qs = document.getElementById("quickstats");
	    var elems = qs.getElementsByTagName("ul")[0].getElementsByTagName("li");
	    elems[index].className += " current";
	}
	var calcTipHighlightRemove = function(index){
	    var qs = document.getElementById("quickstats");
	    var elems = qs.getElementsByTagName("ul")[0].getElementsByTagName("li");
	    elems[index].className = elems[index].className.substring(0, elems[index].className.indexOf(" current"));
	}
	
	var tellAFriend = function(){
    if(!document.getElementById("tafiframe")){
        var iframe = document.createElement("iframe");
        iframe.id = "tafiframe";
        iframe.src = baseURL + "/tellafriend.aspx";
        var w;
		if(document.all){
			w = document.documentElement.offsetWidth;
		}
		else{
			w = document.width;
		}
        iframe.style.left = ((w - 504)/2) + "px";
        document.body.appendChild(iframe);
    }
}

// jQuery Code

// Creating custom :external selector
$.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname);
};

$(document).ready(function(){
    $('#smalltext').click(function() {
        _gaq.push(['_trackEvent', 'Text Size', 'Reduce']);
    });
    
    $('#medtext').click(function() {
        _gaq.push(['_trackEvent', 'Text Size', 'Enlarge']);
    });
});
