/*
 ***************************************
 * Numeric Analytics tagging framework
 * v.3 alpha June 9th 2008
 * October 16, 2008
 ***************************************
*/
try{
var _numeric_ = new Object;
_numeric_.omni = new Object;
// ******************   CONFIG *********************************
_numeric_.config = new Object;
_numeric_.config.openScrpt = '<scr' + 'ipt language="JavaScript" type="text/javascript" src="';
_numeric_.config.closeScrpt = '"></scr' + 'ipt>';

if ((location.href.indexOf("https") == -1))
	{
		_numeric_.config.baseUrl ="http://ldsp.convio.net/numeric/";
	} else {
		_numeric_.config.baseUrl ="https://secure3.convio.net/ldsp/numeric/";
	}

_numeric_.s = new Object;
_numeric_.loops = 0;

if(! _numeric_.config.pnPrefix) 
	_numeric_.config.pnPrefix = "";
	
// usesJS_PageName_Override is used to toggle the Javascript PageName
// generator which looks to page h1 tags to assemble the PageName.

// if changed to false the only PageName manipulation preformed 
// will be toLowercase()
_numeric_.config.usesJS_PageName_Override = true; 
// ******************   END CONFIG *********************************

// ******************   UTILS *********************************
_numeric_.utils = new Object;
_numeric_.utils.loadScriptLibrary = function(src, targetElement) { 
	try{
		if (_numeric_.scriptElement == null) {
			_numeric_.scriptElement = document.createElement('script');
			_numeric_.scriptElement.type = 'text/javascript'; 
		}
		if (targetElement == null){
			if (_numeric_.headElement == null)
				_numeric_.headElement = document.getElementsByTagName('body')[0];
			targetElement = _numeric_.headElement;
		}
		var library = _numeric_.scriptElement.cloneNode(true);
		library.src = src;
		targetElement.appendChild(library);
	}catch(e){}
}

_numeric_.utils.getEventTarget = function(e)
	{
		try {
			var targ = null;
			if (!e) {
				var e = window.event;
			}
			if (e.target) {
				targ = e.target;
			} 
			else if (e.srcElement) {
				targ = e.srcElement;
			}
			if (targ.nodeType == 3) {
				targ = targ.parentNode;
			}
			return targ;
		} catch(e) {}
	}
	
_numeric_.utils.getEventTargetName = function(e)
	{
		try {
			var targ;
			if (!e) {
				var e = window.event;
			}

			if (e.target) {
				targ = e.target;
			} 
			else if (e.srcElement) {
				targ = e.srcElement;
			}

			if (targ.nodeType == 3) {
				targ = targ.parentNode;
			}
			return targ.tagName;
		} catch(e) {}
	}
	
_numeric_.utils.addOnloadEvent = function(func, El){
		try{
			if(typeof El == "undefined"){
				El = window;
			}
			if(El.attachEvent){
					El.attachEvent("onload",func);
			}
			if(El.addEventListener){
				El.addEventListener("load",func,false);
			}
			return this;
		}catch(e){}
	}
	
_numeric_.utils.addOnClickEvent = function(func, El){
		try{
			if(El.attachEvent){
				El.attachEvent("onclick",func);
			}
			if(El.addEventListener){
				El.addEventListener("click",func,false);
			}
			return this;
		}catch(e){}
	}
	
_numeric_.utils.addOnSubmitEvent = function(func, El){
		try{
			if(El.attachEvent){
				El.attachEvent("onsubmit",func);
			}
			if(El.addEventListener){
				El.addEventListener("submit",func,false);
			}
			return this;
		}catch(e){}
	}
	
_numeric_.utils.queryStringToHash = function(str){
		try{
			var qs = [];
			var a = str.indexOf("?")>-1 ? str.split("?")[1].split("&") : str.split("&");
			for(var x = 0; x<a.length; x++ ){
				var b = a[x].split("=");
				qs[b[0]] = b[1];
			}
			return qs;
		}catch(e){}
	}
_numeric_.utils.readCookie = function(name){
		try{
			var name = name+"=";
			var ca = document.cookie.split(';');
			for(var i = 0; i < ca.length; i++ ){
				var c = ca[i];
				while(c.charAt(0)==' '){
					c = c.substring(1,c.length);
				}
				if(c.indexOf(name)==0){
					return c.substring(name.length,c.length);
				}
			}
			return null;
		}catch(e){}
	}
_numeric_.utils.setCookie = function(name,value){
		try{
			document.cookie = name+"="+value+"; path=/";
		}catch(e){}
	}
	
String.prototype.toProperCase = function(){
     return this.toLowerCase().replace(/\w+/g,function(s){
          return s.charAt(0).toUpperCase() + s.substr(1);
     })
}
	
	
_numeric_.utils.decode = function( $str ){
	try{
		var $entities = [ ['%f8','%20'], ['%a0', '%20'],  ['%3e','%20'], ['%3c','%20'],  ['%26','%20'],  ['%22','%20'] ];
		var $ii = 0;
		var $estr = escape( $str );
		$estr = $estr.toLowerCase();
			while ($ii < $entities.length){
				$estr = $estr.replace(new RegExp($entities[$ii][0], "g"), $entities[$ii][1] );
				$ii++;
			}
		return unescape($estr);
	}catch(e){return $str;}
}

_numeric_.utils.getText = function(nodeOrig){
	try{
	 var rtn =  "";
	 var t = 0;
	 var fcn = function(node){
	 	if(t < 100){
		 	for(var c = 0; c<node.childNodes.length; c++ ){
				var childnode = node.childNodes[c];
				switch(childnode.nodeType){
					case 3: 
						rtn += _numeric_.utils.decode( childnode.nodeValue );
						break;
					case 1:
						t++;
						fcn(childnode);
						break;
					};
				}
	 		}
		 }
		 fcn(nodeOrig);
	return rtn;
	}catch(e){return "";}
}

_numeric_.utils.getDownloadType = function( fileExtensions ){
	try {
		var mimesArray = document.getElementsByTagName( 'a' );    // an array of objects
		var extArray = fileExtensions.split(',');
		for( mm  = 0;mm <  mimesArray.length;mm++ ){
			for( tt = 0; tt < extArray.length; tt++ ){
				if (mimesArray[mm].innerHTML.indexOf(extArray[tt]) != -1 ){
					break;
				}	
			}
		}
	}catch(e) {}
}

_numeric_.isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);

if (!  _numeric_.isIE ) {
  HTMLElement.prototype.__defineGetter__("innerText", 
              function () { return(this.textContent); });
  HTMLElement.prototype.__defineSetter__("innerText", 
              function (txt) { this.textContent = txt; });
}
/*
 * July 25, 08 rfd
 * The sendEvent was stolen from PM.  It may get used, but substitued and ALERT call
 * in its place.
 */
 
_numeric_.utils.sendEvent = function(el,event, vars, vals, type){
		try{
			s=s_gi(s_account);
			var tmp = new Array;
			if(typeof vars == "undefined"){
				s.linkTrackVars ="events";
				s.linkTrackEvents =event;
				s.events=event;
			}else{
				s.linkTrackVars =vars;
				s.linkTrackEvents =event;
				if(event != "None"){
					s.events=event;
				}
				tmp = vars.split(',');
				var tmp1 = vals.split(',');
				for(i=0;i<tmp.length;i++){
					s[tmp[i]]= tmp1[i]; 
				}				
			}
			if(typeof type == "undefined"){
				s.tl(el, 'o');
			}else{
				s.tl(el, type);
			}
			for(i=0;i<tmp.length;i++){
					s[tmp[i]]= ""; 
				}
			s.linkTrackVars ="None"
			s.linkTrackEvents ="None";
			
		}catch(e){}
	}	
// ******************   UTILS *********************************

_numeric_.waToLoad = new Array;
//Call vender code
//Omniture
_numeric_.utils.loadScriptLibrary(_numeric_.config.baseUrl + "s_code.js",  document.getElementsByTagName('head')[0]);
_numeric_.waToLoad.push("omni");
_numeric_.omni.call = true;
_numeric_.timer;

//Google Analytics
//_numeric_.config.gaJsHost = "https:" == document.location.protocol ? "https://ssl." : "http://www.";
//_numeric_.utils.loadScriptLibrary(_numeric_.config.gaJsHost  +"ga.js",  document.getElementsByTagName('head')[0]);
//_numeric_.waToLoad.push("ga");


_numeric_.analyticsCallBack = function() {
	try{
	if(_numeric_.loops < 10 ) {
		if(typeof s != "undefined" && _numeric_.waToLoad.length > 0){
			for(i=0; i < _numeric_.waToLoad.length; i++ ) {
				if(_numeric_.waToLoad[i]=="omni"){
				_numeric_.utils.loadScriptLibrary(_numeric_.config.baseUrl +"omniWidget.js",  document.getElementsByTagName('head')[0]);
					_numeric_.waToLoad.splice(i,1);
					break;
				}
			}
		}
   /*
	*		if(typeof _gat != "undefined" && _numeric_.waToLoad.length > 0){	
	*			for(i=0; i < _numeric_.waToLoad.length; i++ ){
	*			if(_numeric_.waToLoad[i]=="ga"){
	*			_numeric_.utils.loadScriptLibrary(_numeric_.config.baseUrl + "gaWidget.js",  document.getElementsByTagName('head')[0]);
	*				_numeric_.waToLoad.splice(i,1);
	*				break;
	*			}
	*		}
	*	}
	*/
		if(_numeric_.waToLoad.length > 0){
			_numeric_.timer = setTimeout("_numeric_.analyticsCallBack()", 1000 );
			_numeric_.loops++;
		}else{
			clearTimeout(_numeric_.timer);
		}
	}else{
		clearTimeout(_numeric_.timer);
	}
	
	}catch(e){};
}
}catch(e){}