(function($){
	intel.YOT.appendOverlayJS = function() {
		var OverlayScript = $('<script src="' + intel.YOT.gbl.OVERLAY_SCRIPT_URI + '"></script>');
		$('body').append(OverlayScript);
	};

	intel.YOT.loadLibraries = function () {
		if (!intel.yotOverlay) {
			var FacebookScript = $('<script src="' + intel.YOT.gbl.FACEBOOK_SCRIPT_URI + '"></script>');
			$('body').append(FacebookScript);
			setTimeout("intel.YOT.appendOverlayJS()",6000);
		} else {
			intel.yotOverlay.open();
		}
	};

	intel.YOT.share = function(shareURL, app){
		var shareURL = encodeURIComponent(shareURL);
		var appURL;

	switch(app){
		case 'email':
			appURL = 'http://www.intel.com/sites/sitewide/zh_CN/emailfriend.htm?param=' + decodeURIComponent(shareURL);
		break;
		case 'emailcar':
			appURL = 'http://www.intel.com/sites/sitewide/zh_CN/emailfriend.htm?site=sot&param=' + decodeURIComponent(shareURL);
		break;
		case 'facebook':
			appURL = 'http://facebook.com/sharer.php?u=' + shareURL;
		break;
		case 'delicious':
			appURL = 'http://delicious.com/post?url=' + shareURL;
		break;
		case 'twitter':
			appURL = 'http://twitter.com/home?status=' + shareURL;
		break;
		//case 'stumble_upon':
		case 'stumble':
			appURL = 'http://www.stumbleupon.com/submit?url=' + shareURL;
		break;
		case 'digg':
			appURL = 'http://digg.com/submit?url=' + shareURL;
		break;
		case 'newsvine':
			appURL = 'http://www.newsvine.com/_tools/seed&amp;save?u=' + shareURL;
		break;
	}
		if((app=="email")||(app=="emailcar"))
		{
			window.open(appURL, 'Share', 'width=492,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
		}
		else
		{
			window.open(appURL, 'Share');
		}
	};

	intel.YOT.shareSite = function(app){
		intel.YOT.share('http://www.intel.com/zh_CN/tomorrow', app);
	};

	intel.YOT.sharePage = function(app,pageDL){
		var sharestr = window.location.protocol + "//" + window.location.host + window.location.pathname + "#" + pageDL;
		if(app == 'email')
		{
			//intel mail freaks out if query-string contains a dash.  Replace dashes with "_ndash_".  In the Flash, swap it back again.
			sharestr = window.location.protocol + "//" + window.location.host + window.location.pathname + "#" + pageDL.replace(/-/g,"_ndash_");
			if(pageDL.indexOf("future_config") >= 0)
			{
				app = 'emailcar';
			}
		}
		intel.YOT.share(sharestr, app);
	};
})(jQuery);
