function addToBookShelf(Id,vId)
{Ajax.call('/index.php?form=BookAction','a=BookShelf&nid='+Id+'&vid='+vId,BookShelfResponse,'POST','JSON');}
function RemoveBook(Id)
{Ajax.call('/index.php?form=BookAction','a=RemoveBook&nid='+Id,RemoveResponse,'POST','JSON');}
function addToBookVote(Id)
{Ajax.call('/index.php?form=BookAction','a=BookVote&nid='+Id,BookShelfResponse,'POST','JSON');}
function refreshbook(Id)
{Ajax.call('/index.php?page=showbook&ajax=1','nid='+Id,RemoveResponse,'POST','JSON');}
function GotoRead(Id)
{Ajax.call('/index.php?page=GoRead&ajax=1','nid='+Id,GotoReadResponse,'POST','JSON');}
function GotoReadResponse(result)
{window.location="/index.php?page=readbook&nid="+result.content;}
function BookShelfResponse(result)
{alert(result.message);}
function RemoveResponse(result)
{alert(result.message);if(result.error==0){document.location.reload();}}
function signInResponse(result)
{toggleLoader(false);var done=result.substr(0,1);var content=result.substr(2);if(done==1)
{document.getElementById('member-zone').innerHTML=content;}
else
{alert(content);}}
function gotoPage(page,id,type)
{Ajax.call('comment.php?act=gotopage','page='+page+'&id='+id+'&type='+type,gotoPageResponse,'GET','JSON');}
function gotoPageResponse(result)
{document.getElementById("ECS_COMMENT").innerHTML=result.content;}
function getFormatedPrice(price)
{if(currencyFormat.indexOf("%s")>-1)
{return currencyFormat.replace('%s',advFormatNumber(price,2));}
else if(currencyFormat.indexOf("%d")>-1)
{return currencyFormat.replace('%d',advFormatNumber(price,0));}
else
{return price;}}
function getAttr(cat_id)
{var tbodies=document.getElementsByTagName('tbody');for(i=0;i<tbodies.length;i++)
{if(tbodies[i].id.substr(0,10)=='goods_type')tbodies[i].style.display='none';}
var type_body='goods_type_'+cat_id;try
{document.getElementById(type_body).style.display='';}
catch(e)
{}}
function advFormatNumber(value,num)
{var a_str=formatNumber(value,num);var a_int=parseFloat(a_str);if(value.toString().length>a_str.length)
{var b_str=value.toString().substring(a_str.length,a_str.length+1);var b_int=parseFloat(b_str);if(b_int<5)
{return a_str;}
else
{var bonus_str,bonus_int;if(num==0)
{bonus_int=1;}
else
{bonus_str="0."
for(var i=1;i<num;i++)
bonus_str+="0";bonus_str+="1";bonus_int=parseFloat(bonus_str);}
a_str=formatNumber(a_int+bonus_int,num)}}
return a_str;}
function formatNumber(value,num)
{var a,b,c,i;a=value.toString();b=a.indexOf('.');c=a.length;if(num==0)
{if(b!=-1)
{a=a.substring(0,b);}}
else
{if(b==-1)
{a=a+".";for(i=1;i<=num;i++)
{a=a+"0";}}
else
{a=a.substring(0,b+num+1);for(i=c;i<=b+num;i++)
{a=a+"0";}}}
return a;}
function set_insure_status()
{var shippingId=getRadioValue('shipping');var insure_fee=0;if(shippingId>0)
{if(document.forms['theForm'].elements['insure_'+shippingId])
{insure_fee=document.forms['theForm'].elements['insure_'+shippingId].value;}
if(document.forms['theForm'].elements['need_insure'])
{document.forms['theForm'].elements['need_insure'].checked=false;}
if(document.getElementById("ecs_insure_cell"))
{if(insure_fee>0)
{document.getElementById("ecs_insure_cell").style.display='';setValue(document.getElementById("ecs_insure_fee_cell"),getFormatedPrice(insure_fee));}
else
{document.getElementById("ecs_insure_cell").style.display="none";setValue(document.getElementById("ecs_insure_fee_cell"),'');}}}}
function changePayment(pay_id)
{calculateOrderFee();}
function getCoordinate(obj)
{var pos={"x":0,"y":0}
pos.x=document.body.offsetLeft;pos.y=document.body.offsetTop;do
{pos.x+=obj.offsetLeft;pos.y+=obj.offsetTop;obj=obj.offsetParent;}
while(obj.tagName.toUpperCase()!='BODY')
return pos;}
function showCatalog(obj)
{var pos=getCoordinate(obj);var div=document.getElementById('ECS_CATALOG');if(div&&div.style.display!='block')
{div.style.display='block';div.style.left=pos.x+"px";div.style.top=(pos.y+obj.offsetHeight-1)+"px";}}
function hideCatalog(obj)
{var div=document.getElementById('ECS_CATALOG');if(div&&div.style.display!='none')div.style.display="none";}
function sendHashMail()
{Ajax.call('user.php?act=send_hash_mail','',sendHashMailResponse,'GET','JSON')}
function sendHashMailResponse(result)
{alert(result.message);}
function orderQuery()
{var order_sn=document.forms['ecsOrderQuery']['order_sn'].value;var reg=/^[\.0-9]+/;if(order_sn.length<10||!reg.test(order_sn))
{alert(invalid_order_sn);return;}
Ajax.call('user.php?act=order_query&order_sn=s'+order_sn,'',orderQueryResponse,'GET','JSON');}
function orderQueryResponse(result)
{if(result.message.length>0)
{alert(result.message);}
if(result.error==0)
{var div=document.getElementById('ECS_ORDER_QUERY');div.innerHTML=result.content;}}
function display_mode(str)
{document.getElementById('display').value=str;setTimeout(doSubmit,0);function doSubmit(){document.forms['listform'].submit();}}
function fixpng()
{var arVersion=navigator.appVersion.split("MSIE")
var version=parseFloat(arVersion[1])
if((version>=5.5)&&(document.body.filters))
{for(var i=0;i<document.images.length;i++)
{var img=document.images[i]
var imgName=img.src.toUpperCase()
if(imgName.substring(imgName.length-3,imgName.length)=="PNG")
{var imgID=(img.id)?"id='"+img.id+"' ":""
var imgClass=(img.className)?"class='"+img.className+"' ":""
var imgTitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' "
var imgStyle="display:inline-block;"+img.style.cssText
if(img.align=="left")imgStyle="float:left;"+imgStyle
if(img.align=="right")imgStyle="float:right;"+imgStyle
if(img.parentElement.href)imgStyle="cursor:hand;"+imgStyle
var strNewHTML="<span "+imgID+imgClass+imgTitle
+" style=\""+"width:"+img.width+"px; height:"+img.height+"px;"+imgStyle+";"
+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+"(src=\'"+img.src+"\', sizingMethod='scale');\"></span>"
img.outerHTML=strNewHTML
i=i-1}}}}