// JavaScript Document

$j('.shareHeader').live('click',function(){
	$j(this).next().slideToggle('fast');
});
$j('.share_close_button').live('click',function(){
	$j('.shareBlock').slideUp('fast');
});

function showETAF(){
	$j('#email_to_a_friend_overlay').css('z-index','3000');
	showMask();
	$j('#email_to_a_friend_overlay').fadeIn('fast');
}

function hideETAF(){
	hideMask();
	$j('#email_to_a_friend_overlay').fadeOut('fast');
}

function validateEmail(){
	if ($j('#etaf_to').val() == "") return;
	if ($j('#etaf_from').val() == "") return;
	if ($j('#etaf_title').val() == "") return;
	sendEmail();
}

function sendEmail(){
	// functions go here...
}

$j('.shareLink').live('click',function(){
	var selected = $j(this).attr('rel');
	var u = location.href;
	var t = document.title;
	var msg = 'Browsing the Milken Archive : ' + u;
	switch(selected){
		case "email":
			emailBody = 'Browsing the ' + t + ' @ ' + u;
			// use the overlay
			//showETAF();
			//$j('#etaf_title').val(t);
			//$j('#etaf_body').html(emailBody);
			// use mailto
			win = window.open('mailto:?subject='+encodeURIComponent(t)+'&body='+encodeURIComponent(emailBody),'emailWindow');
			win.close();
			break;
		case "facebook":
			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
			break;
		case "myspace":
			window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(u),'ptm','height=450,width=440').focus();
			break;
		case "twitter":
			window.open('http://twitter.com/home?status=Browsing the Milken Archive : ' + encodeURIComponent(u),'tweet','height=450,width=800').focus();
			break;
		case "google":
			window.open('http://www.google.com/buzz/post?url=' + encodeURIComponent(u) + '&message=Browsing the ' + encodeURIComponent(t));
			break;
	}
	$j('.shareBlock').slideToggle('fast');
	return false;
});
