/**
 *  Global Calls
 */
(function()
{
    /**
     *  Fix IE background image flicker
     *  http://www.mister-pixel.com/
     */
    try
    {
	    document.execCommand('BackgroundImageCache', false, true);
    }
    catch(e) {}
    
    linkExternal = function(obj, linkName)
    {
        omnitureTag(obj, 'e', linkName);
    };

    linkCustom = function(obj, linkName)
    {
        omnitureTag(obj, 'o', linkName);
    }

    linkDownload = function(obj, linkName)
    {
        omnitureTag(obj, 'd', linkName);
    }
    
    omnitureTag = function(obj, type, linkName)
    {
        var s = s_gi(s_account);
        s.linkTrackVars = 'None';
        s.linkTrackEvents = 'None';
        var lt = (obj.href != null) ? s.lt(obj.href) : '';
        if (lt == '') s.tl(obj, type, linkName);
    };
})();

var CSSRules = function() {
	
	var headElement = document.getElementsByTagName("head")[0], styleElement = document.createElement("style");
	styleElement.type = "text/css";
	headElement.appendChild(styleElement);
	
	var add = function() {
		// IE doesn't allow you to append text nodes to <style> elements
		if (styleElement.styleSheet) {
			return function(selector, rule) {
				if (styleElement.styleSheet.cssText == '') {
					styleElement.styleSheet.cssText = '';
				}
				styleElement.styleSheet.cssText += selector + " { " + rule + " }";
			}
		} else {
			return function(selector, rule) {
				styleElement.appendChild(document.createTextNode(selector + " { " + rule + " }"));
			}
		}
	}();
	return {
		add : add
	}
}();

var isMac = false;
if((navigator.userAgent.indexOf('Mac') != -1) || (navigator.userAgent.indexOf('iPhone') != -1)){
	isMac = true;	
};
if (isMac) {
	CSSRules.add('h2.longheader', 'letter-spacing:-1px');
}
		

function clearField(field, defaultMsg)
{
    if (field.value != defaultMsg) return;
    field.value = '';
}

function defaultField(field, defaultMsg)
{
    if (field.value != '') return;
    field.value = defaultMsg;
}

function windowPop(url, name, width, height, scrollboolean)
{
	var params = (scrollboolean != '') ? 'scrollbars='+scrollboolean : 'scrollbars=0';
	params = params + ",location=0,menubar=0,status=1,toolbar=1,resizable=1,top=40,left=40,width=" + width + ",height=" + height; 
	window.open(url, name, params).focus();
	
	return false;
}

var trapID = "SearchBox_goSearch";

holdOrigID = trapID;

function trapEnter(evt)
{
	var e = (evt) ? evt : event;
	var objItemToSubmit = document.getElementById(trapID);
	
	if (objItemToSubmit == null || e.keyCode != 13) return;
    
    e.returnValue = false;
	e.cancel = true;

	// Check the type of the trapID.  You should either have an input or anchor tag.
	if (objItemToSubmit.click)
	{
		objItemToSubmit.click();
	}
	else
	{
		window.location.href = objItemToSubmit.href;
	}
}

function setTrapID(id)
{
	trapID = id;
}

// This replaces sage_ev
function clickTag(n, v)
{
	sage_ev(n, v);
}

document.onkeypress = trapEnter;