var socialIntervalHandler;
var objSocialPopup;
var popupName="socialPopup";
var useBitlyApi=true;
if(typeof(kakaoJavascriptKey)!=="undefined"&&kakaoJavascriptKey!="") Kakao.init(kakaoJavascriptKey);
function sendSocialShare(platform,w,h,){
var option="width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,top=100,left=100,scrollbars=no,resizable=no";
shareData["url2"]=shareData["url"];
if(("http:"==document.location.protocol)&&useBitlyApi&&bitlyApiId!=""&&bitlyApiKey!=""){
useBitlyApi=false;
var param="login="+bitlyApiId+"&apiKey="+bitlyApiKey+"&longUrl="+encodeURIComponent(shareData["url"]);
jQuery.ajax({
url: "http://api.bit.ly/v3/shorten",
type: "POST",
data: param,
success:function(response,state){
if(response.status_code==200){
shareData["url"]=response.data.url;
}
openSocialSharePopup(platform,shareData,option);
},error:function(e){
openSocialSharePopup(platform,shareData,option);
},timeout: 15000,
cache: false,
dataType: "json"
});
}else{
openSocialSharePopup(platform,shareData,option);
}}
function sendSocialShare2(response){
}
function openSocialSharePopup(platform,data,option){
var url=encodeURIComponent(data["url"]);
var image_url=encodeURIComponent(data["image"]);
var title=encodeURIComponent(data["title"]);
var content=encodeURIComponent(data["content"]);
if(typeof(mb_hybrid_app)!=='undefined'&&mb_hybrid_app!=""){
option="location=yes,hideurlbar=no";
}
if(platform=="facebook"){
openWindow("http://www.facebook.com/sharer.php?u="+url+"&t="+title,popupName,option);
}else if(platform=="twitter"){
if(mb_options["device_type"]=="desktop"){
openWindow("http://twitter.com/share?url="+url+"&text="+title,popupName,option);
}else{
if(typeof(mb_hybrid_app)!=='undefined'&&mb_hybrid_app!=""&&typeof(checkAppConnect)=="function"){
var is_connect=checkAppConnect("socialshare", {"name":"com.twitter.android","scheme":"twitter","param":platform});
if(is_connect=="true"){
moveURL("tw
}else if(is_connect=="false"){
openWindow("http://twitter.com/share?url="+url+"&text="+title,popupName,option);
}}else{
moveURL("tw
setTimeout(function(){
if(document.webkitHidden||document.hidden){
}else{
openWindow("http://twitter.com/share?url="+url+"&text="+title,popupName,option);
}}, 2000);
}}
}else if(platform=="google"){
openWindow("http://plus.google.com/share?url="+url+"&title="+title,popupName,option);
}else if(platform=="naver_blog"){
openWindow("http://blog.naver.com/openapi/share?url="+url+"&title="+title,popupName,option);
}else if(platform=="naver_line"){
if(mb_options["device_type"]=="desktop") openWindow("http://line.me/R/msg/text/?"+title+"%0A"+url,popupName,option);
else openWindow("http://line.me/R/msg/text/?"+title+"%0A"+url,popupName,option); //openWindow("line://msg/text/?"+title+"%0A"+url,popupName,option);
}else if(platform=="naver_band"){
if(mb_options["device_type"]=="desktop"){
openWindow("http://band.us/plugin/share?body="+title+"%0A"+data["url"]+"&route="+data["url"],popupName,option);
}else{
if(typeof(mb_hybrid_app)!=='undefined'&&mb_hybrid_app!=""&&typeof(checkAppConnect)=="function"){
var is_connect=checkAppConnect("socialshare", {"name":"com.nhn.android.band","scheme":"bandapp","param":platform});
if(is_connect=="true"){
moveURL("ba
}else if(is_connect=="false"){
openWindow("http://band.us/plugin/share?body="+title+"%0A"+data["url"]+"&route="+data["url"],popupName,option);
}}else{
moveURL("ba
setTimeout(function(){
if(document.webkitHidden||document.hidden){
}else{
openWindow("http://band.us/plugin/share?body="+title+"%0A"+data["url"]+"&route="+data["url"],popupName,option);
}}, 2000);
}}
}else if(platform=="kakao_story"){
if(mb_options["device_type"]=="desktop"){
Kakao.Story.share({url: data["url"],text: (data["title"])});
}else{
if(typeof(mb_hybrid_app)!=='undefined'&&mb_hybrid_app!=""&&typeof(checkAppConnect)=="function"){
var is_connect=checkAppConnect("socialshare", {"name":"com.kakao.story","scheme":"kakaostory","param":platform});
if(is_connect=="true"){
Kakao.Story.open({url: data["url"],text: (data["title"])});
}else if(is_connect=="false"){
openWindow("https://story.kakao.com/s/share?url="+data["url"]+"&text="+data["title"],popupName,option);
}}else{
Kakao.Story.open({url: data["url"],text: (data["title"])});
setTimeout(function(){
if(document.webkitHidden||document.hidden){
}else{
if(typeof(mb_hybrid_app)==='undefined'||mb_hybrid_app==""){
Kakao.Story.share({url: data["url"],text: (data["title"])});
}else{
openWindow("https://story.kakao.com/s/share?url="+data["url"]+"&text="+data["title"],popupName,option);
}}
}, 2000);
}}
}else if(platform=="kakao"){
Kakao.Link.sendDefault({ objectType: 'feed',content: {title: data["title"],description: data["content"],imageUrl: data["image"],link: {mobileWebUrl: data["url"],webUrl: data["url"]}}});
}else if(platform=="mail"){
moveURL("mailto:?subject="+data["title"]+"&body="+data["url"],"",false);
}else if(platform=="copy_link"){
let tempInput=document.createElement("input");
tempInput.value=data["url"];
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand ("copy");
document.body.removeChild(tempInput);
if(mb_options["locale"]=="ko_KR"){
alert("URL 주소가 복사되었습니다.");
}else{
alert("URL copied to clipboard.");
}}
}
function checkSocialLoginStatus(){
var data="mode=write&board_action=user_is_login&board_name=user_register";
sendDataRequest2(mb_urls["user_api"], data, checkSocialLoginStatusHandler);
}
function checkSocialLoginStatusHandler(response){
if(typeof(response)!=="undefined"){
if(response.state=="success"){
if(response.data.login=="true"){
clearInterval(socialIntervalHandler);
if(objSocialPopup) objSocialPopup.close();
var parent_window=window;
var parent_path=parent_window.location.pathname;
var parent_href=parent_window.location.href;
var redirect_to="";
if(parent_href.indexOf("redirect_to")!=-1){
var end_index=parent_href.length;
if(parent_href.indexOf("&")!=-1) end_index=parent_href.indexOf("&");
redirect_to=parent_href.substring(parent_href.indexOf("redirect_to=")+12,end_index);
if(redirect_to.indexOf(parent_window.location.host)<20) parent_window.location.href=decodeURIComponent(redirect_to);
}else{
if(jQuery(".mb-social-redirect-to").length>0){
redirect_to=jQuery(".mb-social-redirect-to").val();
}
if(redirect_to!=""){
if(redirect_to=="reload"){
parent_window.location.reload();
}else{
parent_window.location.href=decodeURIComponent(redirect_to);
}}else{
parent_window.location.href=decodeURIComponent(mb_urls["home"]);
}}
}}
}}
function requestSocialLoginData(type){
var w=464;
var h=595;
if(type=="kakao"){
w=464;
h=595;
}else if(type=="naver"){
w=580;
h=720;
}else if(type=="google"){
w=440;
h=570;
}else if(type=="facebook"){
w=996;
h=660;
}else if(type=="google"){
w=934;
h=643;
}
var remember=0;
var user_mode="";
if(jQuery(".mb-social-user-mode").length>0){
user_mode=jQuery(".mb-social-user-mode").val();
}
if(document.getElementById("rememberme")){
if(document.getElementById("rememberme").checked){
remember=1;
}}
if(typeof(mb_hybrid_app)!=="undefined"){
if(mb_hybrid_app!=""){
if(type=="google"||type=="facebook"||type=="naver"||type=="kakao"||type=="apple"){
homeSendMessage({"mode":"SOCIAL_LOGIN_POPUP","value": type});
}else{
objSocialPopup=openWindow(mb_urls["home"]+"/?mb_social=login&type="+decodeURIComponent(type)+"&user_mode="+decodeURIComponent(user_mode)+"&user_remember="+remember,"socialPopup","top=100, left=100, width="+w+"px, height="+h+"px");
}}else{
objSocialPopup=openWindow(mb_urls["home"]+"/?mb_social=login&type="+decodeURIComponent(type)+"&user_mode="+decodeURIComponent(user_mode)+"&user_remember="+remember,"socialPopup","top=100, left=100, width="+w+"px, height="+h+"px");
}}else{
objSocialPopup=openWindow(mb_urls["home"]+"/?mb_social=login&type="+decodeURIComponent(type)+"&user_mode="+decodeURIComponent(user_mode)+"&user_remember="+remember,"socialPopup","top=100, left=100, width="+w+"px, height="+h+"px");
}
if(type=="naver"||type=="facebook"){
socialIntervalHandler=setInterval(checkSocialLoginStatus,4000);
}};