function Sharing()
{
	var _me = this;
	this._zeroClipboard = null;

	Sharing.prototype.init = function()
	{
		$(".thisURL").focus(_me.thisURL_onFocus);
		$(".sharePanel_emailButton").click(function(event)
		{
			_me.openEmailPanel();
			trackClick('openEmailPanelClick');
			return false;
		});
		$(".sharePanel_friendsEmail").keypress(_me.sharePanel_friendsEmail_onKeyPress);
		$(".smartbar_admin").click(function(event)
		{
			_me.openAdminPanel();
			trackClick('openAdminPanelClick');
			return false;
		});
		$(".smartbar_close").click(function(event)
		{
			_me.closeEmailPanel();
			trackClick('closeEmailPanelClick');
			return false;
		});



		this._zeroClipboard = new ZeroClipboard.Client();
		ZeroClipboard.setMoviePath( '../../scripts/skins/skinA/components/ZeroClipboard.swf' );
		this._zeroClipboard.setHandCursor(true);
		this._zeroClipboard.addEventListener('complete', this.my_complete);
		this._zeroClipboard.setText(window.location.href);
		this._zeroClipboard.glue( 'sharePanel_copyURLButton' );
		this.onResize();
	}

	Sharing.prototype.my_complete = function(client, text)
	{
		//alert("Copied text to clipboard: " + text);
		trackClick('copyUrlClick');
	}

	Sharing.prototype.onResize = function()
	{
		this._zeroClipboard.reposition();
	}

	Sharing.prototype.thisURL_onFocus = function(event)
	{
		var clip = $(".thisURL")[0];
		clip.select();
	}

	Sharing.prototype.sharePanel_friendsEmail_onKeyPress = function(e)
	{
		if(e.keyCode == 13){
			_me.openEmailPanel();
			return false;
		}
	}

	Sharing.prototype.openEmailPanel = function()
	{
		$(".smartbar_expanded.emailPanel").css("display", "block");
		var entryField = $(".sharePanel_friendsEmail")[0];
		var entryField2 = $("#recipients")[0];
		if(entryField2){
			if(entryField.value != entryField.defaultValue) entryField2.value = entryField.value;
		}
	}

	Sharing.prototype.closeEmailPanel = function()
	{
		$(".smartbar_expanded.emailPanel").css("display", "none");
		var entryField = $(".sharePanel_friendsEmail")[0];
		entryField.value = entryField.defaultValue;
		var entryField2 = $("#recipients")[0];
		if(entryField2){
			entryField2.value = entryField2.defaultValue;
		}
	}

	Sharing.prototype.openAdminPanel = function()
	{
		var $adminPanel = $(".smartbar_expanded.adminPanel");
		if($adminPanel.css("display") == "block"){
			$adminPanel.css("display", "none");
		}else{
			$adminPanel.css("display", "block");
		}
	}

	Sharing.prototype.clearField = function(clip)
	{
		if(clip.value == clip.defaultValue) clip.value = "";
	}

	Sharing.prototype.resetField = function(clip)
	{
		if(clip.value == "") clip.value = clip.defaultValue;
	}

	this.init();
}



