/* 
Share.js Version 1.5.3

EXAMPLE
1) set these
	share.url = "";
	share.title = "";
	share.description = "";
	share.tweet = "";
2) call them like this
	share.send("twitter");
	share.send("facebook");
	...
3) set custom setting for site
	share.digg.title = "";
*/

Share = function(){
	/*Private*/


	/*Public / Privileged*/
	return {
		// required
		url: null,
		title: null,
		tracking: false,
		tracking_link: null,
		
		// optional
		description: null,
		property: null,
		unique_tracking_id: '_button',
		
		// specific
		tweet: null,
		
		// custom settings
		delicious: {},
		digg: {},
		facebook: {},
		myspace: {},
		reddit: {},
		stumbleupon: {},
		twitter: {},
		yahoo: {},		
		tumblr: {},

		sony_facebook: {},
		sony_vkontakte: {},
		sony_twitter: {},
		sony_livejournal: {},
		sony_youtube: {},

		getLink: function(site){
			this.tracking_link = null;
			var link = null
			switch (site) {
				case 'delicious':
					link = 'http://livejournal.com/update.bml?event=%D0%9E%D0%B1%D0%B8%D1%82%D0%B5%D0%BB%D1%8C+%D0%B7%D0%BB%D0%B0:+%D0%B2%D0%BE%D0%B7%D0%BC%D0%B5%D0%B7%D0%B4%D0%B8%D0%B5+(3D)+-+%3Ca+href=%22http://obitelzla-film.ru%22%3E%D0%BE%D1%84%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D1%81%D0%B0%D0%B9%D1%82+%D1%84%D0%B8%D0%BB%D1%8C%D0%BC%D0%B0%3C/a%3E&subject=%D0%9E%D0%B1%D0%B8%D1%82%D0%B5%D0%BB%D1%8C+%D0%B7%D0%BB%D0%B0:+%D0%B2%D0%BE%D0%B7%D0%BC%D0%B5%D0%B7%D0%B4%D0%B8%D0%B5+(3D)';
					break;
				case 'digg':
					link = 'http://connect.mail.ru/share?share_url=http://obitelzla-film.ru';
					break;
				case 'facebook':
					link = 'http://facebook.com/sharer.php?u=http://obitelzla-film.ru/index.html';
					break;
				case 'myspace':
					link = 'http://vk.com/share.php?url=http://obitelzla-film.ru';
					break;
				case 'stumbleupon':
					link = 'http://odnoklassniki.ru/dk?st.cmd=addShare&st.s=1000&st._surl=http://obitelzla-film.ru';
					break;
				case 'twitter':
					link = 'http://twitter.com/share?text=%D0%9E%D0%B1%D0%B8%D1%82%D0%B5%D0%BB%D1%8C+%D0%B7%D0%BB%D0%B0:+%D0%B2%D0%BE%D0%B7%D0%BC%D0%B5%D0%B7%D0%B4%D0%B8%D0%B5+(3D).+http://www.obitelzla-film.ru';
					break;		

				case 'sony_facebook':
					link = 'http://facebook.com/SonyPicturesRU';
					break;
				case 'sony_vkontakte':
					link = 'http://vkontakte.ru/club14191354';
					break;
				case 'sony_twitter':
					link = 'http://twitter.com/SonyPicturesRU';
					break;
				case 'sony_livejournal':
					link = 'http://sonypicturesru.livejournal.com';
					break;
				case 'sony_youtube':
					link = 'http://youtube.com/SonyPicturesRU';
					break;

				}
			return link;
		},
		
		send: function (site)
		{

			var link = this.getLink(site);

			if (this.tracking && typeof s == "object" && this.tracking_link) {
				var property = this.property?this.property+'_':'';//s.prop4.substring(s.prop4.lastIndexOf(':') + 1);
				sCode.trackOutboundClick(this.tracking_link, property + 'share' + site + this.unique_tracking_id);
			}

			if (link) 
				if(!window.open(link))
					alert('Please disable your popup blocker and try again.');
		},
		setUrl: function(url){
			this.url = url;
		},
		setTweet: function(str){
			this.tweet = str;
		},
		setTitle: function(str){
			this.title = str;
		},
		setDescription: function(str){
			this.description = str;
		},
		debugVars: function(){
			if(console){
				console.log('url:'+this.url);
				console.log('title:'+this.title);
				console.log('tracking:'+this.tracking);
				console.log('tracking_link:'+this.tracking_link);
				console.log('description:'+this.description);
				console.log('property:'+this.property);
				console.log('unique_tracking_id:'+this.unique_tracking_id);
				console.log('tweet:'+this.tweet);
				console.log('delicious:');
				console.log(this.delicious);
				console.log('digg:');
				console.log(this.digg);
				console.log('facebook:');
				console.log(this.facebook);
				console.log('myspace:');
				console.log(this.myspace);
				console.log('reddit:');
				console.log(this.reddit);
				console.log('stumbleupon:');
				console.log(this.stumbleupon);
				console.log('twitter:');
				console.log(this.twitter);
			}
		}
	};

}

var share = new Share();
