function Omniture()
{
	window[ this._self = "$Omniture" ] = this;
	this.__loadMeta();
	this.loadClickouts();
}
Omniture.prototype.loadClickouts = function()
{
	var aLink = document.getElementsByTagName( "A" );
	for( var i = 0; i < aLink.length; i++ )
	{
		if( ( aLink[ i ].className.match( "( |^)popup( |$)" ) || aLink[i].href.indexOf( document.domain ) == -1 ) && ( aLink[ i ].href != "" && aLink[ i ].href != "undefined" ) )
		{
			this.setOnclick( aLink[i] );
		}
		if( ( aLink[ i ].className.match( "( |^)omnitureevent( |$)" ) ) )
			this.setEvent( aLink[ i ] );
		
	}
	
}
Omniture.prototype.getHostnameFromUrl = function(url)
{
	aMatch = url.match(/:\/\/(.[^/]+)/);
	return aMatch ? aMatch[ 1 ] : null ;
}
Omniture.prototype.setOnclick = function( obj )
{
	obj._parent = this;
	obj.onclick = function()
	{				
		if( s )
		{
			var aPageName = s.pageName.split( ":" );
			s.linkTrackVars = "eVar13";
			s.linkTrackEvents = "None";
			s.tl( this, "e", s.pageName + ":" + this._parent.getHostnameFromUrl( this.href ) );
			window.open( this.href );
			return false;
		}
	}
}
Omniture.prototype.setEvent = function( oElm )
{
	oElm.onclick = function()
	{
		window.$Omniture.event( "None", "None", false, null, null, null, this.id );
		window.open( this.href );
		return false;
	}
}

Omniture.prototype.__loadMeta = function()
{
	var aMeta = document.getElementsByTagName( "META" );
	for( var i = 0; i < aMeta.length; i++ )
	{
		switch( aMeta[ i ].name )
		{
			case "PHILIPS.METRICS.DIVISION":
				this.division = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.COUNTRY":
				this.country = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.LANGUAGE":
				this.language = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.SECTION":
				this.section = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.PAGENAME":
				this.pagename = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.EVENTS":
				this.events = aMeta[ i ].content;
				break;
			case "PHILIPS.METRICS.REPSUITEADD":
				this.repsuiteadd = aMeta[ i ].content;
				break;
			default:
				break;
		}
	}
}
Omniture.prototype.logout = function()
{
	var aPageName = omniture.pagename.split( ":" );
	s.linkTrackVars = "eVar14,eVar13";
	s.eVar13 = "LI:asx:" + aPageName[ 0 ] + ":not_logged_in";
	s.tl(true, "o", omniture.division + ":" + omniture.section + ":" + aPageName[ 0 ] + ":logout");
}
Omniture.prototype.event = function( sLinkTrackVars, sLinkTrackEvents, mEvents, oEVar, bTl, sTl, sPageAddition )
{
	if( !s )
		return;
	s.linkTrackVars   = sLinkTrackVars;
	s.linkTrackEvents = sLinkTrackEvents;
	if( mEvents )
		s.events          = mEvents;
	for( i in oEVar )
		s[ i ] = oEVar[ i ];
	s.tl( ( typeof bTl == "boolean" ? bTl : true ), ( typeof sTl  != "undefined" && sTl != null ? sTl : "o" ), s.pageName+":"+(  typeof sPageAddition  != "undefined" && sPageAddition != null ? sPageAddition : "page" ) );
}
Omniture.prototype.perform = function( sEvent )
{
	switch( sEvent )
	{
		case "addthis":
			this.event( "events,eVar3", "event14,event15", "event14,event15", null, null, null, "share" );
			break;
		case "b2b_emailme":
			this.event( "events,eVar3", "event20", "event20", {eVar3: s.pageName}, null, null, "emailme" );
			break;
		case "b2b_callme":
			this.event( "events,eVar3", "event20", "event20", {eVar3: s.pageName}, null, null, "callme" );
			break;
		case "b2b_survey_button_flash":
			this.event( "None", "None", false, null, null, null, "topbanner_start_the_test" );
			break;
		case "b2b_audit_2":
			this.event( "None", "None", false, null, null, null, "question1" );
			break;
		case "b2b_audit_3":
			this.event( "None", "None", false, null, null, null, "question2" );
			break;
		case "b2b_audit_4":
			this.event( "None", "None", false, null, null, null, "question3" );
			break;
		case "b2b_audit_5":
			this.event( "None", "None", false, null, null, null, "conclusion" );
			break;
		case "b2b_audit_start":
			this.event( "None", "None", false, null, null, null, "5questions_start_the_test" );
			break;
		case "poll":
			this.event( "None", "None", false, null, null, null, "poll" )
			break;
		case "fblogin":
			this.event( "events", "event36", "event36", null, null, null, "facebook_login" );
			break;
		case "scan":
			this.event( "events,eVar25", "event46", "event46", { eVar25 : "LI:asx:b2c:do_the_scan_now" }, null, null, "do_the_scan_now" );
			break;
		default:
			break;
	}
}
