// JavaScript Document
/* Pavan Agrawal - april 10, 2010 */

function share(a,b,sharing,type,pre_text){
if(sharing=='facebook'){	
	var popup = window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(a)+"&t="+encodeURIComponent(b)+"&rand=63461232","Facebook_Sharer","toolbar=0,status=0,width=626,height=436");
}else
 if(sharing=='twitter'){
	
var popup = window.open("http://twitter.com/home?status="+encodeURIComponent(pre_text+" "+ a),"Twitter_Sharer","toolbar=0,status=0,width=800,height=520");
		
var jsonRequest = new Request.JSON({
onSuccess: function(data) 
{
	for (var r in data.results) {
	result = data.results[r];
	result['longUrl'] = r;
	break;
	}
	if(result['shortUrl']!==''){
		popup = window.open("http://twitter.com/home?status="+encodeURIComponent(pre_text+" "+ result['shortUrl'])+"&rand=63461232","Twitter_Sharer","toolbar=0,status=0,width=800,height=520");
	}
					
	},	
	onFailure: function() { }
			   
});
		
}else if(sharing=='orkut'){
	
	var popup = window.open("http://promote.orkut.com/preview?nt=orkut.com&du="+encodeURIComponent(a)+"&tt="+encodeURIComponent(b)+"&tn="+encodeURIComponent(pre_text)+"&rand=63461232","Orkut_Sharer","toolbar=0,status=0,width=660,height=520");
	
}
	popup.focus();
	return false;
}
