/**
* Put it into shopping
*/
function addShopping(ctx,prid)
{
var url = ctx+"/insertShopping.html";
$.get(url,{prid: prid}, function (data)
{
var model = eval("("+data+")");
$("#shopCartSpan").html("("+model.totalQty[0]+")");
});
//startObjMessage('objDiv');
}
/**
* 新增用户的关键字
*/
function showMyKy()
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
$("#addKw").toggle();
$("#prodKwArea").val('').css('color','#626363').val('一次性輸入多個標籤請用空格分開。\r\n如：行銷 企業 管理\r\n若輸入的標籤內容有空格，請用引號。\r\n如："Big apple"');
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
/**
* ajax保存關鍵字,單書頁
*/
function saveProdKw()
{
var kws=$("#prodKwArea").val();
if($.trim(kws)==""||kws.indexOf("一次性輸入多個標籤請用空格分開")>=0)
{
alert('請輸入關鍵字！')
$("#prodKwArea").focus();
return false;
}
else
{
$.get('saveProdKws.html',{stkKey:kws,orid:$("#orid").val()},function(message){
if(message!=null)
{
$("#prodKwDiv").html(message);
}
});
}
}
/**
* Put it into next 觀察清單
*/
function addNextShopping(ctx,prid)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/insertWatch.html";
$.get(url,{prid: prid}, function (data) {
var model = eval("("+data+")");
$("#shopNextSpan").html("("+model.watchTotalQty[0]+")");
});
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
//活動上高放入觀察(暫用)
function addNextShopping1(ctx,prid)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/insertWatch.html";
$.get(url,{prid: prid}, function (data) {
alert('已放入收藏清單！');
});
//startObjMessage('objDiv2');
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
/**
* 單書頁加入收藏
* ctx 工程的路径
* orid 母店内码
* update_flg 操作状态 Y:加入收藏 N:取消收藏
* csize 收藏个数
*/
function add2CollectionMas(ctx,orid,update_flg,csize)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/add2CollectionMas.html";
$.getJSON(url,{orid: orid,update_flg:update_flg,csize:csize==''?0:csize}, function (data)
{
if(data.status=='Y')
{
alert('加入收藏成功！');
//收藏
$(".collection_mas").html(data.collectionSize+"收藏");
var hidden=document.getElementById("collect_size_div").value;
document.getElementById("collectValueDIV").innerHTML=parseInt(hidden)+1;
document.getElementById("collect_size_div").value=parseInt(hidden)+1;
}else if(data.status=='N')
{
alert('取消收藏成功！');
$(".collection_mas").html(data.collectionSize+"收藏");
var hidden=document.getElementById("collect_size_div").value;
document.getElementById("collectValueDIV").innerHTML=parseInt(hidden)-1;
document.getElementById("collect_size_div").value=parseInt(hidden)-1;
}else
{
alert('抱歉，系統錯誤！操作失败！');
}
});
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
/**
* 静态頁加入收藏
* ctx 工程的路径
* orid 母店内码
*/
function addCollectionMas(ctx,orid)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/add2CollectionMas.html";
$.post(url,{orid: orid,update_flg: "S"}, function (data)
{
if(data=='true')
{
alert('加入收藏成功！');
}else if(data=='false')
{
alert('您已經加入收藏！');
}else
{
alert('抱歉，系統錯誤！操作失败！');
}
});
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
/**
* 0圓下載
*/
function downLoadFreeBook(ctx,prid)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
$.ajax({
url:"registEbook.html",
data:"pid="+prid,
async: false,
success:function(url){
if(url!=null&&url!="")
{
window.location.href=url;
}
}
});
}
else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}
else
{
openMemberLogin();
}
});
}
/*
* 二手徵求
*/
function addToSeek(ctx,prid,update_flg)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/addToSeek.html?p="+Math.random();
$.getJSON(url,{prid: prid,update_flg:update_flg}, function (data)
{
if(data.status==200){
$(".add_toseek").html(data.toSeekSize+"二手徵求");
alert(data.msg);
}else{
alert(data.error);
}
});
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}
else
{
openMemberLogin();
}
});
}
var text;
var toseek;
var add_toseek;
var flg=false;
$(document).ready(function(){
var org_prod_id=$("#org_prod_id").val();
$(".add_toseek").hover(function(){
add_toseek=$(this);
text=$(this).html();
text=$.trim(text);
toseek=text.replace(/\D/g, "");
if(toseek<=98){
return;
}
text=text.replace(toseek,"");
text=text.replace("+","");
$.getJSON('/queryToSeek.html',{prid:org_prod_id},function(data){
if(data.toSeekSize>99){
flg=true;
}
$(add_toseek).html(data.toSeekSize+text);
});
},function(){
if(toseek<=98){
return;
}
if(flg==true){
$(add_toseek).html("99+"+text);
}else{
$(add_toseek).html(toseek+text);
}
});
});
//活動上高用的收藏
function add2CollectionMasForActivity(ctx,orid)
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url = ctx+"/add2CollectionMas.html";
$.get(url,{orid: orid,update_flg:'Y'}, function (data)
{
$("#starDivId").html(data);
alert('恭喜您收藏成功！');
});
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
/**
*内容简介，媒体推荐等切换
**/
function showdb(n)
{
for(var i=1;i<=8;i++)
{
if(document.getElementById("rows_title"+i)!=null)
{
document.getElementById("rows_title"+i).className="off";
}
if(document.getElementById("show_table"+i)!=null)
{
document.getElementById("show_table"+i).style.display="none";
}
if(document.getElementById("fonts_color"+i)!=null)
{
document.getElementById("fonts_color"+i).style.color="#9A9A9A";
}
}
if(document.getElementById("rows_title"+n)!=null)
{
document.getElementById("rows_title"+n).className="on";
}
if(document.getElementById("show_table"+n)!=null)
{
document.getElementById("show_table"+n).style.display="";
}
if(document.getElementById("fonts_color"+n)!=null)
{
document.getElementById("fonts_color"+n).style.color="black";
}
}
function singleshowdb(n,orid)
{
var url;
if(n==1)
{
url="pageBookByCommentMas.html";
}
else if(n==2)
{
url="pageBookByBooklistMas.html";
}
else if (n==3)
{
url="pageBookByCollcetion.html";
}
else if(n==4)
{
url="pageBookByCommunity.html";
}
$.get(url,{orid:orid}, function (msg)
{
$("#bookinfo1").html(msg);
});
for(var i=1;i<=4;i++)
{
if(document.getElementById("rows_title"+i)!=null)
{
document.getElementById("rows_title"+i).className="off";
}
if(document.getElementById("fonts_color"+i)!=null)
{
document.getElementById("fonts_color"+i).style.color="#9A9A9A";
}
}
if(document.getElementById("rows_title"+n)!=null)
{
document.getElementById("rows_title"+n).className="on";
}
if(document.getElementById("fonts_color"+n)!=null)
{
document.getElementById("fonts_color"+n).style.color="black";
}
}
/**
* 添加单书页评论
* */
function addComment(oid,pid){
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true' || msg==true){
window.location.href="comment.html?oid="+oid+"&prodId="+pid;
} else if (msg=='true_and_sso'){
openMemberSsoLogin();
}else{
openMemberLogin();
}
})
}
/*
* ec header.jsp 验证用户是否登录
*/
function ecHeader(obj){
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true' || msg==true){
window.location.href=obj;
} else if (msg=='true_and_sso'){
openMemberSsoLogin();
}else{
openMemberLogin();
}
})
}
/**
* 單數頁顯示AP分紅
*/
function showAp(cuid,flg)
{
var money=$(".show_ap_icon").html()==null?$(".show_ap_icon").offset():$(".show_ap_icon").offset();
if(flg=='Y')
{
$.post('checkMemberLogin.html',{}, function (msg)
{
if(msg=='true')
{
var url=document.URL;
var index=url.lastIndexOf("/");
var html=url.substring(index+1,url.length);
if(html=="index.html"||html=="ecTheme.html")
{
$("#rateDiv").css({'left':money.left-$("#rateDiv").width()/2+30+"px",'top':money.top+10+"px"}).slideToggle();
var genUrl="http://www.taaze.tw/apredir.html?ap"+cuid+"_d_"
var genRichUrl="<a href=\"http://www.taaze.tw/apredir.html?ap"+cuid+"_d_\">TAAZE網路書店-讓閱讀跟遊戲一樣好玩</a>"
var genRichUrlImg="<a href=\"http://www.taaze.tw/apredir.html?ap"+cuid+"_d_\"><img src=\"http://www.taaze.tw/images/logo.gif\"  border=0  title=\"TAAZE網路書店-讓閱讀跟遊戲一樣好玩\"/></a>"
$("#genUrl").val(genUrl).attr('title',genUrl);
$("#genRichUrl").val(genRichUrl).attr('title',genRichUrl);
$("#genRichUrlImg").val(genRichUrlImg).attr('title',genRichUrlImg);
}
else if(html.indexOf("sing.html?pid")!=-1)
{
var prodId=html.split("=")[1];
var imgHtml="http://media.taaze.tw/showLargeImage.html?sc="+prodId;
$("#rateDiv").css({'left':money.left-$("#rateDiv").width()/2+30+"px",'top':money.top+10+"px"}).slideToggle();
var genUrl="http://www.taaze.tw/apredir.html?ap"+cuid+"_a_"+prodId;
var genRichUrl="<a href=\"http://www.taaze.tw/apredir.html?ap"+cuid+"_a_"+prodId+"\">"+$("#spimtitle").html()+"</a>";
var genRichUrlImg="<a href=\"http://www.taaze.tw/apredir.html?ap"+cuid+"_a_"+prodId+"\"><img src=\""+imgHtml+"\" width=195 height=270 border=0 title=\""+$("#spimtitle").html()+"\"/></a>"
$("#genUrl").val(genUrl).attr('title',genUrl);
$("#genRichUrl").val(genRichUrl).attr('title',genRichUrl);
$("#genRichUrlImg").val(genRichUrlImg).attr('title',genRichUrlImg);
}
} else if (msg=='true_and_sso')
{
openMemberSsoLogin();
}else
{
openMemberLogin();
}
});
}
else
{
$("#rateDiv").css({'left':money.left-$("#rateDiv").width()/2+30+"px",'top':money.top+10+"px"}).slideToggle();
$("#rateDiv table").css('width','220px');
$(".urlTr").hide();
}
}
function reSetRichUrl(smallorbig)
{
var url=document.URL;
var index=url.lastIndexOf("/");
var html=url.substring(index+1,url.length);
var prodId=html.split("=")[1];
var imgHtml="http://media.taaze.tw/showLargeImage.html?sc="+prodId;
var widthsize=195;
var heightsize=270;
if(smallorbig=="small")
{
imgHtml="http://media.taaze.tw/showProdImage.html?sc="+prodId;
widthsize=95;
heightsize=135;
}
var genRichUrlImg=$("#genRichUrlImg").val();
var apredir=genRichUrlImg.split("<img src=");
var newUrl=apredir[0]+"<img src=\""+imgHtml+"\" width="+widthsize+" height="+heightsize+" border=0 title=\""+$("#spimtitle").html()+"\"/></a>";
//var genRichUrlImg="<a href=\"http://www.taaze.tw/apredir.html?"+cuid+"/"+url+"\"><img src=\""+imgHtml+"\" width="+widthsize+" height="+heightsize+" border=0 title=\""+$("#spimtitle").html()+"\"/></a>"
$("#genRichUrlImg").val(newUrl).attr('title',newUrl);
}

