// Mail to
var email ='';
var mail_subject = '';
var mail_body = ''

function Forward()
{
	location.href = 'mailto:'+email+'?subject='+(encodeURIComponent(mail_subject))+'&body='+(encodeURIComponent(mail_body));
}

// 社群網站分享用
var title = "";
var href = "";

function Share(a_type,a_title,a_url)
{
	if(a_title == undefined)
	{
		title = encodeURIComponent(title);
	}
	else
	{
		title = encodeURIComponent(a_title);
	}
	if(a_url==undefined)
	{
		share_link = GetURL();
	}
	else
	{
		share_link = encodeURIComponent(a_url);
	}
	
	switch(a_type)
	{
		case 'facebook':
			window.open('http://www.facebook.com/sharer.php?u=' + share_link + '&t=' + title,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		break;
		
		case 'googleplus':
			window.open('https://m.google.com/app/plus/x/?v=compose&content=' + title + ' - ' + share_link,'sharer','toolbar=0,status=0,width=626,height=436');
			return false;
		break;
		
		case 'delicious':
			var url = 'http://del.icio.us/post?url='+share_link+'&title='+title;
			window.open(url);
			return false;
		break;
		
		case 'digg':
			var url = 'http://digg.com/submit?phase=2&url='+share_link;
			window.open(url);
			return false;
		break;
		
		case 'reddit':
			var url = 'http://reddit.com/submit?url='+share_link+'&title'+title; 
			window.open(url);
			return false;
		break;
		
		case 'twitter':
			window.open('http://twitter.com/home/?status=' + title + ' ' + share_link);
			return false;
		break;
		
		case 'plurk':
			window.open('http://www.plurk.com/?qualifier=shares&status=' + share_link + ' ( ' + title + ' ) ');
			return false;
		break;
		
		case 'funp':
			window.open('http://funp.com/push/submit/add.php?via=tools');
			return false;
		break;
		
		case 'hd':
		 	window.open('http://www.hemidemi.com/user_bookmark/new?title='+title+'&url='+share_link);
  			return false;
		break;
	}
}

function GetURL()
{
	return encodeURIComponent(href);
}

// 加到書籤
function AddToFavorite()
{
	if (document.all)
	{
		window.external.AddFavorite(href, document.title);	// For IE
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(document.title, href, "");	// For Firefox
	}
}

// For Flash OpenNewWindow
function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
