var jsHTML = window.jsHTML || {};

/*
 * This function builds the share more dialog 
 * 
 * articleTitle - The title of the page to be shared, encoded for inclusion in a URL 
 * productionUrl - the url of the page to be shared, It should always point to a production URL so that the feature can be tested (as digg et al can't resolve no-production URLs)
 */
jsHTML.shareMore = function(_this, articleTitle, productionUrl) {
	$("body").createAppend('div', {id:'shareMore', className: 'popupBox', style: 'left: ' + ($(_this).offset().left - 400) + 'px; top: ' + ($(_this).offset().top + 15) + 'px; display: none;'}, [
		'div', {className:'title'}, 'Share TVNZ stories on some of the most-popular social networking and content sites on the internet.',
		'a', {href: '#', className:'close'}, 'CLOSE',
		'div', {className:'content'}, [
			'a', {href: 'http://del.icio.us/post?url=' + productionUrl + '%3Fref=delicious&title=' + articleTitle, title: 'Bookmark on Delicious', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxDelicious.gif', alt:'Delicious'}],
			'a', {href: 'http://digg.com/submit?url=' + productionUrl + '%3Fref=digg&title=' + articleTitle, title: 'Share on Digg', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxDigg.gif', alt:'Digg'}],
			'a', {href: 'http://www.facebook.com/sharer.php?u=' + productionUrl + '%3Fref=facebook&t=' + articleTitle, title: 'Share on Facebook', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxFacebook.gif', alt:'Facebook'}],
			'a', {href: 'http://reddit.com/submit?url=' + productionUrl + '%3Fref=reddit&title=' + articleTitle, title: 'Share on Reddit', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxReddit.gif', alt:'Reddit'}],
			'a', {href: 'http://technorati.com/faves?add=' + productionUrl+'%3Fref=technorati', title: 'Share on Technorati', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxTechnorati.gif', alt:'Technorati'}],
			'a', {href: 'http://www.newsvine.com/_wine/save?popoff=0&u=' + productionUrl + '%3Fref=newsvine&h=' + articleTitle, title: 'Share on Newsvine', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxNewsvine.gif', alt:'Newsvine'}],
			'a', {href: 'http://www.stumbleupon.com/submit?url=' + productionUrl + '%3Fref=stumble&title=' + articleTitle, title: 'Share on Stumbleupon', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxStumbleupon.gif', alt:'Stumbleupon'}],
			'a', {href: 'http://www.myspace.com/Modules/PostTo/Pages/?u=' + productionUrl + '%3Fref=myspace&t=' + articleTitle, title: 'Share on MySpace', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxMyspace.gif', alt:'MySpace'}],
			'a', {href: 'http://www.bebo.com/c/share?Url=' + productionUrl + '%3Fref=bebo&Title=' + articleTitle, title: 'Share on Bebo', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBebo2.gif', alt:'Bebo'}],
			'a', {href: '#', title: 'Share on Twitter', target: '_blank', id: 'twitterBtn'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxTwitter.gif', alt:'Twitter'}],
		],
		'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/makeHPArrow.gif', height:'9', width:'17', className:'arrow', alt:'Make TVNZ my Homepage'}
	]);
	$(document).ready(function(){
		$("#twitterBtn").click(function(event){
			www.tweet(productionUrl, urlEncodedArticleTitle);
			event.preventDefault();
		});
	});
	
}

