/* used for displaying share links */

function shareUrl(url,imageSrc,title){
	this.url = url;
	this.imageSrc = imageSrc;
	this.title = title;
}

function writeShareLinks(contatinerId,shareLinks){
	var html = "<ul>";
	for ( var i = 0; i < shareLinks.length; i++) {
		var shareUrl = shareLinks[i];
		html += '<li><a href="'+shareUrl.url+'" target=\"_blank\"> <img height=\"30\" width=\"30\"\
			src=\"/images/'+shareUrl.imageSrc+'\" title=\"'+shareUrl.title+'\"\
			alt=\"'+shareUrl.title+'\" /> </a></li>';
		
	}
	html += "</ul>";
	
	var shareContainer = document.getElementById(contatinerId);	
	shareContainer.innerHTML = html;	
	
}

function share(url,title,containerId){
	var documentUrl=url;
 	var documentTitle = title;
 	 
	var faceBookShare = "http://www.facebook.com/sharer.php?u="+documentUrl+"&t="+documentTitle;
	var twitterShare =  "http://twitter.com/home/?status="+documentTitle+"%20"+documentUrl ; 
	var diggShare = "http://digg.com/submit?phase=2&url="+documentUrl+"&title="+documentTitle ; 
	var deliciousShare = "http://del.icio.us/post?url="+documentUrl+"&title="+documentTitle;	
	
	var shareLinks = new Array();
	shareLinks.push(new shareUrl(faceBookShare,'logo_facebook.png','Share on facebook'));
	shareLinks.push(new shareUrl(twitterShare,'logo_twitter.png','Share on Twitter'));
	shareLinks.push(new shareUrl(diggShare,'logo_digg.png','Share on Digg'));
	shareLinks.push(new shareUrl(deliciousShare,'logo_del.png','Share on Delicious'));
	writeShareLinks(containerId,shareLinks);
}
