',{'class': 'overlay'}),
template = d['template'] || '
',
box = d['template_id'] || '.box',
close = d['close'] || "a[rel*='dialog_close']",
title = d['title'] || '處理中..',
html = d['html'] || '',
display = d['display'] || false,
width = d['width'] || 560,
height = d['height'] || 0,
top = d['top'] || '',
left = d['left'] || '',
preload = d['preload'] || '',
callback = d['callback'] || '';
wrap.children().remove();
wrap.prepend(overlay, $(template)).hide();
wrap.find('.content').html(html);
wrap.find('.title').html(title);
if(display){
overlay.css({'width': $(document).width(), 'height': $(document).height()}).show();
$(box).find('.message').css({'width': width - 50})
$(box).css({'width': width,'height': (height ? height : $(box).outerHeight() + 33)});
var boxHeight = $(box).outerHeight() >= 400 ? ($(box).outerHeight() / 2) : $(box).outerHeight();
$(box).css({'left': (left ? left : (wrap.parent().outerWidth() / 2) - ($(box).outerWidth() /2 )) , 'top': (top ? top : (wrap.parent().height() / 2) - boxHeight)}).show();
wrap.show();
$(window).resize(function(){
overlay.css({'width': $(document).width(), 'height': $(document).height()}).show();
$(box).css({'left': (left ? left : (wrap.parent().outerWidth() / 2) - ($(box).outerWidth() /2 )) , 'top': (top ? top : (wrap.parent().height() / 2) - boxHeight)}).show();
})
if(preload instanceof Function)preload.call();
}else{
wrap.children().remove();
overlay.hide();
}
if(typeof d['html'] != 'undefined' && d['html'] != null){
$(close).bind('click',function(){
if(callback instanceof Function)callback.call();
wrap.children().remove().hide();
overlay.hide();
});
}
}
function trim(s) {
return s.replace(/^\s+|\s+$/g,'');
}
function isUndefined(v){
var s = trim(v);
return typeof s == 'undefined' || '' == s || s == null ? true: false;
}
window.fbAsyncInit = function() {
FB.init({
appId : '210840615760017',
status : true,
cookie : true,
xfbml : true,
channelURL : 'http://web.gamecyber.net/gcFacebook/apps/pf_activity_3/channel.htm',
oauth : true
});
FB.getLoginStatus(function(r){
if(r.authResponse == null){
window.top.location.href = requireuri;
}else{
document.getElementById('wrap').style.display = 'block';
var perms = scope.split(',');
for(var i in perms){
FB.api({method: 'users.hasAppPermission',uid: r.authResponse.userID,ext_perm:perms[i]},function(perms_result){
if(perms_result == 0){
window.top.location.href= requireuri + '&fbconnect=1';
}
});
}
$('.submit').click(function(){
var data = {
ac: $('.ac').val(),
gcid: $('.gcid').val(),
username: $('.username').val(),
email: $('.email').val()
};
FB.api({
method: 'pages.isFan',
page_id: '179046795608007',
uid: r.authResponse.userID
},function(pf_fans){
if(pf_fans){
FB.api({
method: 'pages.isFan',
page_id: '371476906270918',
uid: r.authResponse.userID
},function(freeinghk_fans){
if(freeinghk_fans){
if(!isUndefined(data.ac) && !isUndefined(data.gcid) && !isUndefined(data.username) && !isUndefined(data.email)){
var pattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
if(data['email'].search(pattern) != -1){
dialog({display:true});
var params = {
method: 'feed',
name: '《海賊艦隊》',
message: '',
link: 'http://web.gamecyber.net/gcFacebook/apps/pf_activity_3/',
picture: 'http://web.gamecyber.net/gcFacebook/themes/pf/activity_3/images/500x500_02.jpg',
caption: 'pf.gamecyber.net',
description: '◇◆◇繼「星辰」及「幻月之歌」後另一大作..《海賊艦隊》10.23 OBT羅蘭船長 vs 海賊王!頂上戰爭∼序幕!尋找海賊懸賞!'
};
FB.api('/me/feed', 'post', params , function(response){
if (!response || response.error){}
$.post('json.php',{join:true, data: data},function(result){
$('.form').find('input').each(function(){$(this).val('');});
if(result.status){
dialog({title: '成功', html: '您已經成功參加了今次活動!', display:true});
}else{
dialog({title: '錯誤', html: ''+ result.error +'', display:true});
}
},'json');
});
}else{
alert("您填寫電郵不正確!");
}
}else{
alert("請填妥所有空格!");
}
}else{
dialog({title: '錯誤', html: '請讚好《逃出香港!》專頁!', display:true});
}
});
}else{
dialog({title: '錯誤', html: '請讚好《海賊艦隊》專頁!', display:true});
}
});
});
}
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/zh_HK/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));