$(function() {
bindInterest();
bindInterestSchool();
});
function bindInterest() {
$('#interestRecipe').click(function() {
var follow = $('#recipeFollow').val();
var target = $(this).attr('target') + '&follow=' + follow;
$.getJSON(target,function(json){
var recipeId = $('#interestRecipeId').val();
if(follow == 'true'){
$('#interestImg').removeClass('interest_off');
$('#interestImg').addClass('interest_on');
$(".deliCur span em").text(json[0].interestCnt);
$('#recipeFollow').val('false');
//お気に入りレシピのトータルイベント数
trackEvent('recipeInterest','vote','recipeId='+recipeId);
}else{
$('#interestImg').removeClass('interest_on');
$('#interestImg').addClass('interest_off');
$(".deliCur span em").text(json[0].interestCnt);
$('#recipeFollow').val('true');
}
});
return false;
});
}
function bindInterestSchool() {
$('.interestSchool').click(function() {
var follow = $('#schoolFollow').val();
var target = $(this).attr('target') + '&follow=' + follow;
$.getJSON(target, function(json){
var schoolId = $('#interestSchoolId').val();
if(follow == 'true'){
$('#btnFav').closest('.addfav').addClass('off');
$('#btnFav span').text('フォロー中');
$('#btnFavFooter').addClass('off');
$('#btnFavFooter').text('フォロー中');
$('#schoolFollow').val('false');
//お気に入り教室のトータルイベント数
trackEvent('schoolInterest','vote','schoolId='+schoolId);
//クーポン取得時ポップアップ表示
if(json[0].coupon){
$('#popup-window-coupon').css('display', '');
}
}else{
$('#btnFav').closest('.addfav').removeClass('off');
$('#btnFav span').text('フォローする');
$('#btnFavFooter').removeClass('off');
$('#btnFavFooter').text('フォローする');
$('#schoolFollow').val('true');
}
});
return false;
});
}
function addschool(imageOn,schoolId,btnName) {
var url = "/do/mypage/school/interest/json";
url = url + "?schoolId=" + schoolId;
trackEvent('schoolInterest','vote','schoolId='+schoolId);
$.getJSON(url, function(json){
//alert("教室をフォローしました。")
if (btnName == "bt_fv_off.gif"){
//教室TOP NameBox/Footer
$('#btnFav').closest('.addfav').addClass('off');
$('#btnFav span').text('フォロー中');
$('#btnFavFooter').addClass('off');
$('#btnFavFooter').text('フォロー中');
$('#schoolFollow').val('false');
$('#btnFavFooterLink').css('display','none');
//クーポン取得時ポップアップ表示
if(json[0].coupon){
$('#popup-window-coupon').css('display', '');
}
}else if(btnName == "btn_fav_off.png"){
//マイページ
document.getElementById(imageOn).innerHTML = '';
}else if(btnName == "i_fav_off.png"){
//教室検索一覧
$('#'+imageOn).replaceWith('');
}
});
return false;
}
function addrecipe(imageOn,recipeId,btnName) {
if(!((imageOn.indexOf(".")==0)||(imageOn.indexOf("#")==0))){
imageOn = "#"+imageOn;
}
imageOn = imageOn.replace('[','\\[');
imageOn = imageOn.replace(']','\\]');
if(btnName == "btn_favrec_off.png"){
$(imageOn).replaceWith('');
}else{
$(imageOn).replaceWith('');
}
var url = "/do/mypage/recipe/interest";
url = url + "?recipeId=" + recipeId;
trackEvent('recipeInterest','vote','recipeId='+recipeId);
var t = 'text/plain';
var x = window.ActiveXObject ? g('Msxml2.XMLHTTP') || g('Microsoft.XMLHTTP') : new XMLHttpRequest();
// ASynchronous AJAX
x.overrideMimeType && x.overrideMimeType(t);
x.open("GET", url, true);
x.send(null);
alert("お気に入りに追加しました。")
return false;
}
function g(s) {
x = 0;
try {
x = new ActiveXObject(s);
} catch (s) {
}
return x;
};