
var Omniture = new function()
{

	this.newPageView = function(pagename)
	{
		s.pageName = pagename;
		s.t();
	};
	
	this.clearEvents = function()
	{
		s.linkTrackEvents = 'None';
	};

	this.trackOmioWidget = function(obj, product_id)
	{
		s.linkTrackVars = 'eVar33,events,products';
		
		if (product_id != undefined)
		{
			if (product_id == '')
			{
				s.products = product_id;
			}
			else
			{
				s.products = ';' + product_id;
			}
		}
		
		s.linkTrackEvents = 'event23';
		s.events = s.linkTrackEvents;
		s.eVar33 = 'omio widget';
		s.tl(obj, 'o', 'cnetcouk');
		
		this.clearEvents();
	};
	
	this.trackComment = function()
	{
	    s.linkTrackVars = 'events,products';
	    s.linkTrackEvents = 'event19';
	    s.events = s.linkTrackEvents;
	    s.tl($('comment-form'), 'o', 'cnetcouk');
	    this.clearEvents();
	};

	this.trackRegistration = function(obj)
	{
	    s.linkTrackVars = 'events';
	    s.linkTrackEvents = 'event29';
	    s.events = s.linkTrackEvents;
	    s.tl(obj, 'o', 'cnetcouk');
	    this.clearEvents();
	};

	this.trackReview = function(obj)
	{
	    s.linkTrackVars = 'events,products';
	    s.linkTrackEvents = 'event22';
	    s.events = s.linkTrackEvents;
	    s.tl(obj, 'o', 'cnetcouk');
	    this.clearEvents();
	};

	this.trackProductBuy = function(obj, products)
	{
		s.linkTrackVars = 'events,products';
		s.linkTrackEvents = 'event28';
		s.events = s.linkTrackEvents;
		if (products != undefined)
		{
			s.products = products;
		}
		s.tl(obj, 'o', 'cnetcouk');
		this.clearEvents();
	};

	this.trackSentiment = function(obj, type, minus_type)// here there will be an extra parameter: minus_type || type_minus
	{
		s.linkTrackVars = 'events,products,prop3';
		var events_list = 'None';
		if (type == 'own-it')
		{
			events_list = 'event24';
		}
		else if (type == 'want-it')
		{
			events_list = 'event25';
		}
		else if (type == 'not-for-me')
		{
			events_list = 'event26';
		}
		if (minus_type != undefined)
		{
			if (minus_type == 'own-it')
			{
				events_list += ',event48';
			}
			else if (minus_type == 'want-it')
			{
				events_list += ',event49';
			}
			else if (minus_type == 'not-for-me')
			{
				events_list += ',event50';
			}
		}

		if (events_list != 'None')
		{
			s.linkTrackEvents = events_list;
			s.events = s.linkTrackEvents;
			s.tl(obj, 'o', 'cnetcouk');
		}
		this.clearEvents();
	};

	this.trackGeneric = function(obj, name, value)
	{
		s.linkTrackVars = 'prop43';
		s.linkTrackEvents = 'None';
		s.prop43 = value;
		s.tl(obj, 'o', name);
		this.clearEvents();
	};
	
	this.trackStorySlider = function(obj, title, slot, url)
	{
		s.linkTrackVars = 'prop25,prop26,prop27';
		s.linkTrackEvents = 'None';
		s.prop25 = title;
		s.prop26 = slot;
		s.prop27 = url;
		s.tl(obj, 'o', 'cnetcouk');
		this.clearEvents();
	};
	
	this.trackAdaptiveSwitch = function(obj, adaptive_switch)
	{
		
		s.linkTrackVars = 'prop43';
		s.linkTrackEvents = 'None';
		
		if (adaptive_switch == 0) 
		{
			s.prop43 = 'standard site click';
		}
		else if (adaptive_switch == 1) 
		{
			s.prop43 = 'adaptive site click';
		}
		
		s.tl(obj, 'o', 'trackAdaptiveSwitch');
		this.clearEvents();
	};
		
	this.trackSearch = function(obj, text)
	{
		s.linkTrackVars = 'eVar8,events,products';
		s.linkTrackEvents = 'event33';
		s.products = ';sitesearch';
		s.events = s.linkTrackEvents;
		s.eVar8 = text.toLowerCase();
		s.tl(obj, 'o', 'cnetcouk');
		this.clearEvents();
	};
	
	this.trackCMU = function(obj, text)
	{
		s.linkTrackVars = 'eVar33,eVar35,events,products';
		s.linkTrackEvents = 'event39,event40';
		s.products = ';sitesearch';
		s.events = s.linkTrackEvents;
		s.eVar33 = text;
		s.eVar35 = 'merchandising rule';
		s.tl(obj, 'o', 'cnetcouk');
		this.clearEvents();
	};

	this.trackBroadbandSpeedTest = function()
	{
		s.linkTrackVars = 'events';
		s.linkTrackEvents = 'event17';
		s.events = s.linkTrackEvents;
		s.tl(this, 'o', 'trackBroadbandSpeedTest');
		this.clearEvents();
	};
	
	this.trackShareLink = function(share_name)
	{
		s.linkTrackVars = 'eVar21,events,products';
		s.linkTrackEvents = 'event21';
		s.products = ';';
		s.events = s.linkTrackEvents;
		s.eVar33 = share_name;
		s.tl(true, 'o', 'trackShare');
		this.clearEvents();
	};
		
	this.trackSearchResult = function(obj, endeca_id, position)
	{
		s.linkTrackVars = 'eVar29,eVar35,events,products';
		var posevent = null;
		if (position < 6)
		{
			switch (position)
			{
				case 1:
					posevent = 'event34';
					break;
				case 2:
					posevent = 'event71';
					break;
				case 3:
					posevent = 'event72';
					break;
				case 4:
					posevent = 'event73';
					break;
				case 5:
					posevent = 'event74';
					break;
			}
		}
		else if (position < 11)
		{
			posevent = 'event36';
		}
		else if (position < 21)
		{
			posevent = 'event37';
		}
		else
		{
			posevent = 'event38';
		}
		s.linkTrackEvents = 'event39,' + posevent;
		s.products = ';sitesearch';
		s.events = s.linkTrackEvents;
		s.eVar29 = endeca_id;
		s.eVar35 = position;
		s.tl(obj, 'o' , 'cnetcouk');
		this.clearEvents();
	};

	this.trackAdCampaign = function($campaigns)
	{	
		if ($campaigns.Tracking == true)
		{		
			s.linkTrackVars = 'eVar26,eVar27,eVar28,events';
			s.linkTrackEvents = 'event59';
			
			if (typeof($campaigns.Campaign_1) !== 'undefined')
			{
				s.eVar26 = $campaigns.Campaign_1;
			}
			
			if (typeof($campaigns.Campaign_2) !== 'undefined')
			{
				s.eVar27 = $campaigns.Campaign_2;
			}
			
			if (typeof($campaigns.Campaign_3) !== 'undefined')
			{
				s.eVar28 = $campaigns.Campaign_3;
			}
			
			s.events = s.linkTrackEvents;
			s.tl(true, 'o', 'trackAdCampaign');
			this.clearEvents();
		}
	};

       this.trackGooglePlusOne = function(product)
        {
                s.linkTrackVars = 'eVar21,events,products';
                s.linkTrackEvents = 'event80';
                s.events = s.linkTrackEvents;
                s.eVar21 = 'google plus button';
                s.products = product;
                s.tl(true, 'o', 'trackGooglePlusOne');
                this.clearEvents();
        };
	
	this.videoTracking = function(video_id, video_point)	
	{
		s.linkTrackVars = 'eVar30,events,products';
		
		switch (video_point)
		{
			case 1:
				// video started
				position_event = 'event6';
				break;
			case 2:
				// video at 25%
				position_event = 'event7';
				break;
			case 3:
				// video at 50%
				position_event = 'event8';
				break;
			case 4:
				// video at 75%
				position_event = 'event9';
				break;
			case 5:
				// video completely
				position_event = 'event10';
				break;
		}

		s.linkTrackEvents = position_event;
		s.products = ';';
		s.events = s.linkTrackEvents;
		s.eVar30 = video_id;
		s.tl(true, 'o', 'videoTracking');
		this.clearEvents();
	};

	
}



