﻿function makeUrl(type, title, longURL) {
	// API key와 provider 를 결정하여 Short Link를 생성한다.
	var url = "http://tiny-url.info/api/v1/create?format=json&apikey=" +
	"9D9009C3AA7E99DBD3CE" +
	"&provider=" + 
	"dok_do" + 
	"&url=" + encodeURIComponent(longURL) + "&callback=?";
	sendUrl = "";
	shortUrl = "";
	switch(type){
		case "tw":
		sendUrl = "http://twitter.com/share?text="+title+"&url="+location.href;
		break;

		case "me":
		sendUrl = "http://me2day.net/posts/new?new_post[body]="+ title+ " " +location.href;
		break; 

		case "fa":
		sendUrl ="http://www.facebook.com/sharer.php?u="+location.href+"&t="+title;
		break;
	}
	if( sendUrl != "" )
		window.open(encodeURI(sendUrl));
	/* Short URL 현재 사용하지 않아 Full URL 이동으로 변경
	jQuery.getJSON(url, function(data){ 
        // Make a good use of short URL 
		if( data.state == "ok" ) {
			shortUrl = data.shorturl;
			switch(type){
				case "tw":
				sendUrl = "http://twitter.com/home?status="+title+"+"+shortUrl;
				break;

				case "me":
				sendUrl = "http://me2day.net/posts/new?new_post[body]="+ title+ " " +shortUrl;
				break; 

				case "fa":
				sendUrl ="http://www.facebook.com/sharer.php?u="+shortUrl+"&t="+title;
				break;
			}
			if( sendUrl != "" )
				window.open(encodeURI(sendUrl));
		}
    });
	*/
};
