var IE=(navigator.appName.indexOf("Internet Explorer")!=-1);var pageText;var xhr;function getXmlHttp(){var xmlhttp;try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp=false;}}
if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){xmlhttp=new XMLHttpRequest();}
return xmlhttp;}
function addToCart(asin){try{var qtyObj=document.getElementById("itm_"+asin+"_qty");var qty=qtyObj.options[qtyObj.selectedIndex].value;}catch(e){var qty=document.getElementById("itm_"+asin+"_qty").value;}
var title=document.getElementById("itm_"+asin+"_title").value;var list_price=document.getElementById("itm_"+asin+"_list_price").value;var new_price=document.getElementById("itm_"+asin+"_new_price").value;var img=document.getElementById("itm_"+asin+"_image").value;var uri=document.getElementById("uri").value;var oid=document.getElementById("itm_"+asin+"_offerid").value;oid=oid.replace("\n","");oid=oid.replace("\r","");oid=oid.replace(/%/g,"{per}");var url="/cart.php?action=add";url+="&asin="+asin;url+="&qty="+qty;url+="&title="+title;url+="&lp="+list_price;url+="&np="+new_price;url+="&img="+img;url+="&uri="+uri;url+="&oid="+oid;xhr=getXmlHttp();xhr.onreadystatechange=cartCheck;xhr.open('GET',url,true);xhr.send(null);}
function cartCheck(){if(xhr.readyState==4){if(xhr.status==200){document.getElementById('page_pop').innerHTML=xhr.responseText;if(IE){try{document.getElementById("qty_div").innerHTML="<img src='/images/dummy_select.gif'>";}catch(e){null;}
try{document.getElementById("mode").style.display="none";document.getElementById("sort1").style.display="none";document.getElementById("sort2").style.display="none";}catch(e){null;}}
showCart();}}}
function showCart(){document.getElementById("page_pop").style.display="block";document.getElementById("page_mask").style.display="block";}
function hideCart(){document.getElementById("page_pop").style.display="none";document.getElementById("page_mask").style.display="none";}
function updateQty(asin){var qtyObj=document.getElementById("itm_"+asin+"_qty");var qty=qtyObj.options[qtyObj.selectedIndex].value;window.location="/item/"+asin+"/qty/"+qty+"/cart/update.html";}
var current_thumb=1;function thumb(num,path){current_thumb=num;document.getElementById('main_img').src=path;}
function showCurrent(asin){showLarge(asin,current_thumb);}
function showImg(num,path){current_thumb=num;document.getElementById("main_img").src=path;}
function showLarge(asin,num){var win=window.open("/popup.php?asin="+asin+"&n="+num,"ImagePreview","scrollbars=yes,width=550,height=540,top=0,left=210,resizable=yes");win.focus();}
function showLarge2(num){document.getElementById("page_pop2").style.display="block";document.getElementById("page_mask").style.display="block";}
function hideLarge(){document.getElementById("page_pop2").style.display="none";document.getElementById("page_mask").style.display="none";}
function showImg2(id){var index=1;var again=true;while(again){try{var obj=document.getElementById("main_img_"+index);if(obj){if(index==id){obj.style.visibility="visibile";}else{obj.style.visibility="hidden";}}else{again=false;}}catch(e){again=false;}}}
function toggleBy(obj){if(obj.selectedIndex==0){document.getElementById("t_lbl").style.display="block";document.getElementById("t_input").style.display="block";}else{document.getElementById("t_lbl").style.display="none";document.getElementById("t_input").style.display="none";}}
function goAmazon(){window.location="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2F&tag=goodchapter-20&linkCode=ur2&camp=1789&creative=9325";}
function goURL(url){window.location=url;}
function goOffer(amAsin){window.location="http://www.amazon.com/exec/obidos/redirect?tag=goodchapter-20&path=tg/stores/offering/list/-/"+amAsin+"/all/ref=dp_pb_a/103-0209001-0340630";}
function sort(obj,search_index){var s=obj.options[obj.selectedIndex].value;xhr=getXmlHttp();xhr.onreadystatechange=sortCheck;xhr.open('GET',"/setsort.php?s="+s+"&si="+search_index,true);xhr.send(null);}
function sortCheck(){if(xhr.readyState==4){if(xhr.status==200){window.location=window.location;}}}
function load_images(){var imgs=document.getElementsByTagName("img");for(var i=0;i<imgs.length;i++){var this_img=imgs[i];if(this_img.className=="indexThumb"){var this_src=document.getElementById(this_img.id+"_src").value;this_img.src="http://ecx.images-amazon.com"+this_src;}}}
function init(){var obj=document.getElementById("leftMenuUL");if(obj){var lis=obj.getElementsByTagName("li");for(var i=0;i<lis.length;i++){var li=lis[i];li.onmouseover=function(){this.style.backgroundColor="#f6f6eb";}
li.onmouseout=function(){this.style.backgroundColor="#ffffff";}
li.onclick=function(){var a_tag=this.childNodes[0];window.location=a_tag.href;}}}
var mode_obj=document.getElementById("mode");var mode_val=mode_obj.options[mode_obj.selectedIndex].value;if(mode_val!="Books"){document.getElementById("t_lbl").style.display="none";document.getElementById("t_input").style.display="none";}
load_images();}
var slideQ=Array();var slide=1;var s_count=0;var sliding=false;var stopSlide=false;var defaultDelay=180;var nextDelay=defaultDelay;function setThumb(num){for(var i=1;i<=4;i++)document.getElementById("slideThumb"+i).className="slide_thumb";document.getElementById("slideThumb"+num).className="slide_thumb_sel";}
function stopSlide(){stopSlide=true;}
function showSlide(num){nextDelay=60000;setThumb(num);slideQ.push(num);}
function nextSlide(){nextDelay=defaultDelay;var next_num=slide+1;if(next_num>4)next_num=1;setThumb(next_num);slideQ.push(next_num);}
function checkQ(){if(sliding==false&&stopSlide==false){if(slideQ.length>0){var num=parseInt(slideQ.splice(0,1));if(slide!=num){slide=num;animateSlide(slide);}
s_count=0;}else{if(s_count>nextDelay){nextSlide();s_count=0;}
s_count++;}}
setTimeout("checkQ()",34);}
function animateSlide(num){sliding=true;for(var i=1;i<=4;i++)document.getElementById("slide"+i).style.display="none";document.getElementById("slide"+num).style.display="block";var pos=0;loopAn=function(){if(pos<606)pos+=20;if(pos>606)pos=606;document.getElementById("slide_move").style.left=(-1*pos)+"px";if(pos==606){document.getElementById("current_slide").innerHTML=document.getElementById("slide"+num).innerHTML;document.getElementById("slide_move").style.left="0px";sliding=false;}else if(stopSlide==false){setTimeout("loopAn()",34);}}
loopAn();}