﻿
var AR=AR||{};
AR.Sharing={};
AR.Sharing=function(url,title,description,embedcode) {	
	return {
		Providers:{
			email:function(){addthis_sendto('email');},
			facebook:{url:'http://www.facebook.com/sharer.php?u={0}&t={1}',height:440, width:620},
			twitter:{url:'http:\/\/twitter.com\/home?status={1}%20{0}',height:650, width:1024},
			myspace:{url:'http:\/\/www.myspace.com\/Modules\/PostTo\/Pages\/?t={1}&c={3}&u={0}&l=1',height:650, width:1024},
			orkut:{url:'http:\/\/www.orkut.com\/FavoriteVideos.aspx?u={0}',height:650, width:1024},
			hi5:{url:'http:\/\/www.hi5.com\/friend\/checkViewedVideo.do?t={1}&url={0}',height:475, width:800},
			blogger:{url:'http:\/\/www.blogger.com\/blog-this.g?n={1}&source=BNJ.TV&b={3}&eurl={0}',height:468, width:768},
			spaces:{url:'http:\/\/spaces.live.com\/BlogIt.aspx?Title={1}&description={3}',height:650, width:1024},
			bebo:{url:'http:\/\/www.bebo.com\/c\/share?Url={0}&TUUID=c583051f-6b2d-41ec-8dd0-a3a0ee1656c1&MID=8348657161',height:436, width:626},
			buzz:{url:'http:\/\/www.google.com\/buzz\/post?url={0}',height:650, width:1024},
			stumbleupon:{url:'http:\/\/www.stumbleupon.com\/submit?url={0}&title={1}',height:650, width:1024}
		},
		OpenPopup:function(p)
		{
			var w=window.open(p.url,"sharer","status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=1,height="+p.height+",width="+p.width);
		},
		FormatUrl:function(format)
		{
			var args = Array.prototype.slice.call(arguments, 1);
			return format.replace(/\{(\d+)\}/g, function(m, i) {
				return args[i];
			});
		},
		ShareOn:function(t)
		{
			var p=this.Providers[t.toLowerCase()];
			if(typeof(p)=="function") {
				return p();
			}
			else {
				this.OpenPopup({url:this.FormatUrl(p.url,url,title,description,embedcode),height:p.height,width:p.width});
			}
		}
	};
};

AR.Tracking=function(cfg)
{
	return {
		ObjectID:cfg.ObjectID,
		Category:cfg.Category,
		Providers:{
			'local':function(category,action,label,value,id){

			var url="http://"+cfg.Domain+"/"+id+"."+action+"?ht="+(Math.random()*100000);

			setTimeout("var i=new Image();i.src=\""+url+"\";",0);
			}
,			'GA':function(category,action,label,value,id){pageTracker._trackEvent(category,action,label,value);}
			
		},
		TrackPlayerEvent:function(action,label,value,id)
		{			
			if(typeof(id)=="undefined") {
				id=this.ObjectID;
			}
			for(var p in this.Providers) {
				this.Providers[p](this.Category,action,label,value,id);
			}
		}
	};
};
