﻿<!--
   document.domain= "kkbooks.tw";
/***************** turn page script **********************************/
    var Book_Speed=30;
    var Book_NUM=2;
    var displayWidth;
    var displayHeight;
    var pageNum = 7;
    var blankpage= 'bookimage/blank.gif';
    var bookImageDir= 'http://s3.amazonaws.com/kkbookimg/';    
	
    var B_Angle=new Array(Book_NUM);
    var B_CrImg=new Array(Book_NUM);
    var B_MaxW=new Array(Book_NUM);
    var B_Direction=new Array(Book_NUM);
	var B_MSz=new Array(Book_NUM);
	var B_Pre_Img=new Array(Book_NUM);
	var B_Init=new Array(Book_NUM);
	var MidOffset=new Array(Book_NUM);
	var timeoutID=new Array(Book_NUM);
    var Book_Image_Width=new Array(Book_NUM);
    var Book_Image_Height=new Array(Book_NUM);
  	var Book_Image_Ratio=new Array(Book_NUM);
  	
  	Book_Image_Sources = new Array(Book_NUM,pageNum+1);
  	
	function resetImageBook(num)
	{
		B_Angle[num]=0;
		B_CrImg[num]=2;
		B_Direction[num]=1;
		B_Init[num]=-1;
		
		B_LI=document.getElementById("LI"+num);
		B_RI=document.getElementById("RI"+num);
		B_MI=document.getElementById("MI"+num);
		
		if(B_Pre_Img[num][1].width/ B_Pre_Img[num][1].height < (displayWidth/2)/displayHeight )
		{
			Book_Image_Ratio[num] = displayHeight / B_Pre_Img[num][1].height;
		}
		else
		{
			Book_Image_Ratio[num] = displayWidth /2 / B_Pre_Img[num][1].width;
		}
		
	    Book_Image_Width[num]=B_Pre_Img[num][1].width*Book_Image_Ratio[num];;
        Book_Image_Height[num]=B_Pre_Img[num][1].height*Book_Image_Ratio[num];
		
		if(Book_Image_Width[num]==0)
			Book_Image_Width[num]=displayWidth/2;
		if(Book_Image_Height[num]==0)
			Book_Image_Height[num]=displayHeight;
			
		B_LI.style.borderStyle=B_MI.style.borderStyle=B_RI.style.borderStyle="solid";
		B_LI.style.borderWidth=0+"px";
		B_MI.style.borderWidth=1+"px";
		B_RI.style.borderWidth=1+"px";
		B_LI.style.borderColor="gray";
		B_MI.style.borderColor="gray";
		B_RI.style.borderColor="gray";

		displayWidth = Book_Image_Width[0]*2;
		displayHeight =Book_Image_Height[0]+110;
					
		window.resizeTo(displayWidth,displayHeight);
		
		document.getElementById("toolbar").style.width = displayWidth;
		
		B_LI.style.position=B_MI.style.position=B_RI.style.position="absolute";
		B_LI.style.float=B_MI.style.float=B_RI.style.float="none";
    	B_LI.style.zIndex=B_RI.style.zIndex=0;B_MI.style.zIndex=1;
		B_LI.style.top=0+"px";
		B_LI.style.left=(displayWidth-Book_Image_Width[num]*2)+"px";
		B_MI.style.top=0+"px";
		B_MI.style.left=(displayWidth-Book_Image_Width[num]*2)+Book_Image_Width[num]+1+"px";
		B_RI.style.top=0+"px";
		B_RI.style.left=(displayWidth-Book_Image_Width[num]*2)+Book_Image_Width[num]+1+"px";
		B_LI.style.height=Book_Image_Height[num]+"px";
		B_MI.style.height=Book_Image_Height[num]+"px";
		B_RI.style.height=Book_Image_Height[num]+"px";
		B_LI.style.width=Book_Image_Width[num]+"px";
		B_MI.style.width=Book_Image_Width[num]+"px";
		B_RI.style.width=Book_Image_Width[num]+"px";
		

			
		B_LI.src=B_Pre_Img[num][0].src;

		B_MI.src=B_Pre_Img[num][1].src;
			
		B_RI.src=B_Pre_Img[num][3].src;

	}
	function initImageBook(num,imageFileNamePrefix, awidth, aheight){
		displayWidth = awidth;
		displayHeight = aheight;
		B_Pre_Img[num]=new Array(Book_Image_Sources.length);
		
	    if(document.getElementById){
	    	
	    	B_Pre_Img[num][0]=new Image();
	    	B_Pre_Img[num][0].src=blankpage;
	    		
			for(i=0;i<pageNum;i++){
				B_Pre_Img[num][i+1]=new Image();
				B_Pre_Img[num][i+1].src=bookImageDir+imageFileNamePrefix+"-"+i+".jpg";
			}
				
	     }
	}

	function TurnBookImages(num){
            
            var B_TI;
		    B_LI=document.getElementById("LI"+num);
			B_RI=document.getElementById("RI"+num);
			B_MI=document.getElementById("MI"+num);
			
			B_MSz[num]=Math.abs(Math.round(Math.cos(B_Angle[num])*Book_Image_Width[num]));
			
			MidOffset[num]=B_Direction[num]?Book_Image_Width[num]+1:Book_Image_Width[num]-B_MSz[num];
            
			B_MI.style.left=(displayWidth-Book_Image_Width[num]*2)+MidOffset[num]+"px";
			B_MI.style.width=B_MSz[num]+"px";
			
			B_Angle[num]+=Book_Speed/720*Math.PI;
						
			if(B_Angle[num]>=Math.PI/2&&B_Direction[num])
			{
				B_Direction[num]=0;
				B_MI.src=B_Pre_Img[num][B_CrImg[num]].src;
				B_CrImg[num]++;
			}
			
			if(B_Angle[num]>=Math.PI)
			{
				// book next page
				clearTimeout(timeoutID[num]);
				B_Direction[num]=1;
				
				/*
				B_TI=B_LI;
				B_LI=B_MI;
				B_MI=B_TI;
				*/
				B_TI=B_LI.src;
				B_LI.src=B_MI.src;
				B_MI.src=B_TI;
				
				B_LI.style.borderWidth=1+"px";
				
				B_MI.style.left=(displayWidth-Book_Image_Width[num]*2)+Book_Image_Width[num]+1+"px";
				B_MI.src=B_Pre_Img[num][B_CrImg[num]].src;
                
               if(B_CrImg[num]==pageNum)
               {
               	 B_Init[num]=0;
		       }
		       
		       B_RI.src=B_Pre_Img[num][B_CrImg[num]+2].src;
			   
			   B_LI.style.zIndex=1;
			   B_MI.style.zIndex=2;
			   B_Angle[num]=0;
	
			   B_CrImg[num]++;
		}
		else 
			timeoutID[num] = setTimeout("TurnBookImages("+num+")",100);
		
    }

	function B_NextLnk(num){
	  if(B_Init[num])
	     TurnBookImages(num);
	  else
	  	  resetImageBook(num);
	}



  function popitup(url) {
  	/*
    leftpos=screen.width-400;
    para = "height=400,width=600,left="+leftpos+",top=0";
    */
    leftpos=screen.width*1/3-50;
    para = "height="+screen.height*2/3+",width="+screen.width*2/3+",left="+leftpos+",top=50,location=no,menubar=no,resizable=no,scrollbar=no,status=no,toolbar=no";
    newwindow=window.open(url,'BookViwer',para);    
    if (window.focus) { newwindow.focus() }
    return false; } 

function ReplaceAll(strOrg,strFind,strReplace)
{
	/*
  var index = 0;
  while(strOrg.indexOf(strFind,index) != -1)
  {
  strOrg = strOrg.replace(strFind,strReplace);
  index = strOrg.indexOf(strFind,index);
  }
  */
  return strOrg
}

/* ********************************************************************* */

function initPhotoSlideShow()
{
	
    RunSlideShow("photoss","photossimg","http://s3.amazonaws.com/kkbookimg/20080102.jpg;http://s3.amazonaws.com/kkbookimg/20080103.jpg;http://s3.amazonaws.com/kkbookimg/20080104.jpg;http://s3.amazonaws.com/kkbookimg/20080201.jpg;http://s3.amazonaws.com/kkbookimg/20080501.jpg;http://s3.amazonaws.com/kkbookimg/20080701.jpg;http://s3.amazonaws.com/kkbookimg/20080802.jpg;http://s3.amazonaws.com/kkbookimg/20080801.jpg;http://s3.amazonaws.com/kkbookimg/20090501.jpg;http://s3.amazonaws.com/kkbookimg/20091001.jpg;http://s3.amazonaws.com/kkbookimg/20091201.jpg;http://s3.amazonaws.com/kkbookimg/20090701.jpg;http://s3.amazonaws.com/kkbookimg/20100101.jpg",5)

}

//www.cryer.co.uk (c) 2004 and www.brainerror.net ver 1.3 (c) June 7,2004
//were reference for the following Javascript slide show code
// modified by Geoffrey, Mar. 2006
function changeOpac(opacity, id)
{
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(divid, imageid, imagefile, millisec)
{
  var speed = Math.round(millisec / 10);
  var timer = 0;

  //set the current image as background
  //alert(document.getElementById(imageid).src);
  document.getElementById(divid).style.backgroundImage = "url('" + document.getElementById(imageid).src + "')";
  
  //make image transparent
  changeOpac(0, imageid);

  //make new image
  document.getElementById(imageid).src = imagefile;

  //fade in image
  for(i = 0; i <= 100; i++)
  {
    setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
    timer++;
  }
}

var slideCache = new Array();

function RunSlideShow(divid,imageid,imageFiles,displaySecs)
{
  var imageSeparator = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparator);
  
  changeOpac(0, imageid);
  blendimage(divid,imageid,nextImage,200);

  var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)+ ';' + nextImage;
  setTimeout("RunSlideShow('"+divid+"','"+imageid+"','"+futureImages+"',"+displaySecs+")",displaySecs*1000);

  // Cache the next image to improve performance.
  imageSeparator = futureImages.indexOf(";");
  nextImage = futureImages.substring(0,imageSeparator);
  if (slideCache[nextImage] == null)
  {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].src = nextImage;
  }
}

//Recent Comments Widget originally by Blogger Templates and updated by Blogger Buster
function showrecentcomments(json)
{
  var a_rc=8;var m_rc=true;var n_rc=true;var o_rc=35;
  
  var outCommentHtml = "<ul>";
  for(var i=0;i<a_rc;i++)
  {
     var b_rc=json.feed.entry[i];
     var c_rc;
     if(i==json.feed.entry.length)
       break;
     
     for(var k=0;k<b_rc.link.length;k++)
     {
       if(b_rc.link[k].rel=='alternate')
       {
          c_rc=b_rc.link[k].href;
          break;
       }
     }
     c_rc=c_rc.replace("#","#comment-");
     var d_rc=c_rc.split("#");
     d_rc=d_rc[0];
     var e_rc=d_rc.split("/");
     e_rc=e_rc[5];
     e_rc=e_rc.split(".html");
     e_rc=e_rc[0];
     var f_rc=e_rc.replace(/-/g," ");
     f_rc=f_rc.link(d_rc);
     var g_rc=b_rc.published.$t;
     var h_rc=g_rc.substring(0,4);
     var i_rc=g_rc.substring(5,7);
     var j_rc=g_rc.substring(8,10);
     var k_rc=new Array();
     k_rc[1]="Jan";
     k_rc[2]="Feb";
     k_rc[3]="Mar";
     k_rc[4]="Apr";
     k_rc[5]="May";
     k_rc[6]="Jun";
     k_rc[7]="Jul";
     k_rc[8]="Aug";
     k_rc[9]="Sep";
     k_rc[10]="Oct";
     k_rc[11]="Nov";
     k_rc[12]="Dec";
     if("content" in b_rc)
     {
        var l_rc=b_rc.content.$t;
     }
     else if("summary" in b_rc)
     {
        var l_rc=b_rc.summary.$t;
     }
     else 
        var l_rc="";
     
     var re=/<\S[^>]*>/g;
     l_rc=l_rc.replace(re,"");
     outCommentHtml = outCommentHtml + '<li><a href="'+c_rc+'">'+b_rc.author[0].name.$t+'</a>';
     
     if(m_rc==true)
       outCommentHtml = outCommentHtml +'('+parseInt(i_rc,10)+'/'+j_rc+')';
     
     outCommentHtml = outCommentHtml +'的回應：<span class="wordwrap">';
     
     l_rc = ReplaceAll(l_rc," ","");
     l_rc = ReplaceAll(l_rc,"　","");
	
     if(l_rc.length<o_rc)
     {
        outCommentHtml = outCommentHtml +'『';
        outCommentHtml = outCommentHtml +l_rc;
        outCommentHtml = outCommentHtml +'』</span></li>';
     }
     else
     {
        outCommentHtml = outCommentHtml +'『';
        l_rc=l_rc.substring(0,o_rc);
        //var p_rc=l_rc.lastIndexOf(" ");
        //l_rc=l_rc.substring(0,p_rc);
        outCommentHtml = outCommentHtml +l_rc+'...』</span></li>';
      }
      
   }
   outCommentHtml = outCommentHtml +'</ul><div style="font-size:70%;text-align:center"><a href="http://www.bloggerbuster.com/2007/08/recent-comments-widget-update-this.html">Add this widget to your blog</a></div>';
   
   document.getElementById("rcdiv").innerHTML= outCommentHtml;
}


function listLabels(root){
	
	
	var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        var go = false;
        /* 判断是否包括数字和字母 */
        if (input.match(/[A-Za-z0-9\+\/\=]/g)){
            go = true;
        }
        input = Base64._utf8_encode(input);

        while (i < input.length) {
            /* 如果包括数字和字母，按特殊方式处理，否则用base64编码 */
            if (go){
                chr1 = input.charCodeAt(i++);
                if (chr1<127){
                    output = output +input.charAt(i-1);
                    continue;
                }
                output = output + '=' + chr1.toString(16).toUpperCase();
                continue;
            }

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }
        /* 将结果中的斜杠替换成两个下划线 */
        output = output.replace(/\//g,"__");
        return output;
    },


    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    }

};
    var baseURL = 'http://www.kkbooks.tw/search/label/';
    var baseHeading = "Labels";
    var isFTP = true;
    var entry = root.entry;
    var category = entry.category;
    labelSort = new Array();
    
    
    var _GET = window.location.href.substr(window.location.href.indexOf('?') + 1).split(/&|;/);
    	
    var data = _GET[0];
    
    var splitted = data.split("=");
    var currentLabel = decodeURIComponent(splitted[1]);


    for(p in category){
        labelSort[labelSort.length] = [category[p].term];
    }
    
    labelSort.sort();
    
    var outLabelHtml = "<ul>";
    
    for (var r=0; r < labelSort.length; r++){
    	outLabelHtml = outLabelHtml +'<li>';
    	if(currentLabel==labelSort[r])
    		outLabelHtml = outLabelHtml +'> ';
    	
    	if(labelSort[r]=="７－１１付款取書")
    	  outLabelHtml = outLabelHtml +'<img src="http://www2.kkbooks.tw/images/711icon.gif" align="absmiddle" style="border: 0px white solid !important;height: 16px"/>';
    	outLabelHtml = outLabelHtml +'<a href="'+baseURL+encodeURIComponent(labelSort[r])+'?label='+encodeURIComponent(labelSort[r])+'" >';
    	//outLabelHtml = outLabelHtml +'<a href="'+baseURL+Base64.encode(labelSort[r]+'')+'.html?label='+encodeURIComponent(labelSort[r])+'" >';
        outLabelHtml = outLabelHtml +labelSort[r]+'';
        outLabelHtml = outLabelHtml +'</a>';

    	if(currentLabel==labelSort[r])
    		outLabelHtml = outLabelHtml +' <';
    }
    
    outLabelHtml = outLabelHtml+'</ul>';
    
    document.getElementById("lbdiv").innerHTML= outLabelHtml;
    
}

function insertNickTitle(nickname)
{
	var associativeArray = [];
    associativeArray["PeiYu"] = "(凱風媽媽)";
    associativeArray["妮妮醬"] = "(小瑪姊姊)";
    associativeArray["Geoffrey"] = "(卡瑪爸爸)";
    associativeArray["yating"] = "(小瑪姊姊)";
    var defaultName = "(小瑪姊姊)";
    	
    var output;
    if(associativeArray[nickname] == undefined)
    	output = defaultName;
    else
    	output = associativeArray[nickname];
    	
    
    document.write(output);

}

function addBookmarkForBrowser() {
   if (document.all){
      window.external.AddFavorite("http://www.kkbooks.tw", "凱風卡瑪兒童書店");
   } else {
      window.sidebar.addPanel("凱風卡瑪兒童書店", "http://www.kkbooks.tw", "");
   }
} 

/* -- social bookmark -- */

function trim(str) {while (str.charAt(0) == ' '){str = str.substring(1, str.length);}while (str.charAt(str.length - 1) == ' '){str = str.substring(0, str.length - 1);}return str;}
function removelast(str) {while (str.charAt(str.length - 1) == '#') {str = str.substring(0, str.length - 1);}return str;}

function dt() {return trim(document.title);}
function lf() {return removelast(location.href);}
function ct() {w=window;d=document;return w.getSelection?w.getSelection():(d.getSelection?d.getSelection():(d.selection?d.selection.createRange().text:''));}

function edt() {return encodeURIComponent(dt());}
function elf() {return encodeURIComponent(lf());}
function ect() {return encodeURIComponent(ct());}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(parent.document.defaultView && parent.document.defaultView.getComputedStyle){
		strValue = parent.document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function initBlogPage()
{
  //document.getElementById('terms').value = "輸入書名或作者";
  //initPhotoSlideShow();
  setTimeout("nextShowBookinfo()",500);
}

/* updated version show book info */


  function insertNB(ean)
  {
      insertBookInfo(ean,1);
  }
  
  function insertOrderMe(keyid)
  {
  	  var HTMLText="";

      HTMLText= HTMLText+"==><a href=\"/SCartModify.jsp?go=add&totalnum=1&nmid1=on&nmkeyid1="+keyid+"&backurl="+document.location+"\" target=\"login\">我想訂購這本書，請放入購物車！</a>"
  	  
  	  document.write(HTMLText);  	  
  }
  
  var reqCounter=0;
  var maxQuene = 100;
  var bookQueueEAN = new Array(maxQuene);
  var bookQueueCounter = new Array(maxQuene);
  var bookQueueType = new Array(maxQuene);
  var topBookQueue=0;
  var downBookQueue=0;
  
  var outputQueueEAN = "";
  var outputQueueCounter = 0;
  var outputQueueType = 0;
  
  function pushBookQueue(ean,s,type)
  {
  	  if(topBookQueue>=maxQuene)
  	     return false;

  	  bookQueueEAN[topBookQueue]=ean;
  	  bookQueueCounter[topBookQueue]=s;
  	  bookQueueType[topBookQueue]=type;

  	  topBookQueue++;
  }
  
  function popBookQuene()
  {
  	  if(downBookQueue>topBookQueue-1)
  	  	  return false;
  	  
  	  outputQueueEAN = bookQueueEAN[downBookQueue];
  	  outputQueueCounter = bookQueueCounter[downBookQueue];
  	  outputQueueType = bookQueueType[downBookQueue];
  	  
  	  downBookQueue++;
  	  return true;
  }
  
  function nextShowBookinfo()
  {
  	  if(popBookQuene()==true)
  	  {
  	  	  document.getElementById('icd').contentWindow.loadBookInfo2(outputQueueEAN,outputQueueCounter,outputQueueType);
  	  }
  }
  
  function insertBookInfo(ean,type)
  {
  	  var HTMLText="";
  	  reqCounter++;
  	  
  	  if(type==1)
  	     HTMLText = "<div class=\"ibookcontent1\" id=\"bookinfo-"+reqCounter+"\"></div>";
  	  else if(type==2)
  	  	 HTMLText = "<div class=\"ibookcontent2\" id=\"bookinfo-"+reqCounter+"\"></div>";
  	  else if(type==3)
  	  	 HTMLText = "<div class=\"ibookcontent3\" id=\"bookinfo-"+reqCounter+"\"></div>";
  	  else if(type==4)
  	  	 HTMLText = "<div class=\"ibookcontent4\" id=\"bookinfo-"+reqCounter+"\"></div>";
  	  else
  	  	 HTMLText = "<div class=\"ibookcontent1\" id=\"bookinfo-"+reqCounter+"\"></div>";
  	  
  	  document.write(HTMLText); 
  	  
      pushBookQueue(ean,reqCounter,type);
  	  
  }

// -- this function is not in parent, but in iframe --
function loadBookInfo2(ean,s,type)
{

    document.domain = "kkbooks.tw";
    var HTMLTextInner;
    var rutenURL;
    
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    //http_request.overrideMimeType('text/xml');
    
    if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
        
    http_request.onreadystatechange = function(){
      if (http_request.readyState == 4) {
            if (http_request.status == 200) {
            	
                var xmldoc = http_request.responseXML;
                var itemList = xmldoc.getElementsByTagName("bookinfo");
                var eancode;
                rutenURL="";
                //alert(http_request.responseText );
                //alert(itemList.length);
                
                for (var i = 0; i < itemList.length ; i++) 
                { 
                	var nodeList = itemList.item(i).childNodes;
                	
                	for (var j = 0; j < nodeList.length ; j++) 
                	{
                        var node = nodeList.item(j);
                        
                        if (node.nodeName == "display")
                        	HTMLTextInner = node.firstChild.nodeValue;
                        if (node.nodeName == "ean")
                        	eancode = node.firstChild.nodeValue;
                        if (node.nodeName == "rutenurl")
                            rutenURL = node.firstChild.nodeValue;
                    }
                }
                
                //alert(eancode);
                HTMLTextInner = ReplaceAll(HTMLTextInner,"$backlink$",document.location);
                parent.document.getElementById("bookinfo-"+s).style.backgroundImage = "none";
                parent.document.getElementById("bookinfo-"+s).innerHTML = HTMLTextInner;
                
                if(rutenURL.length>0)
                  parent.document.getElementById("bookinfo-"+s).parentNode.innerHTML = '<br/><img src="http://www2.kkbooks.tw/images/711icon.gif" align="absmiddle" style="border: 0px white solid !important;"/>本商品亦可在凱風卡瑪<a href="'+rutenURL+'">露天拍賣下單</a>，<span style="color: red">全省7-11便利商店付款取貨！</span><a href="'+rutenURL+'">立即前往購買>> </a>'+ parent.document.getElementById("bookinfo-"+s).parentNode.innerHTML +'<div style="clear: both"></div><img src="http://www.kkbooks.tw/images/711icon.gif" align="absmiddle" style="border: 0px white solid !important;"/>本商品亦可在凱風卡瑪<a href="'+rutenURL+'">露天拍賣下單</a>，<span style="color: red">全省7-11便利商店付款取貨！</span><a href="'+rutenURL+'">立即前往購買>> </a>';
                
                setTimeout('parent.nextShowBookinfo();',50);
                 	
            } else {
            	parent.document.getElementById("bookinfo-"+s).style.backgroundImage = "none";
            	parent.document.getElementById("bookinfo-"+s).innerHTML = "<small>timeout</small>";
            }
        }
    };
    
    if(getStyle(parent.document.getElementById("bookinfo-"+s).parentNode,"display")!="none")
    {
    //alert("bookinfo-"+s);

      http_request.open('GET', 'http://www2.kkbooks.tw/ajaxBookinfo.jsp?ean='+ean+'&type='+type, true);
      http_request.send(null);
    }
    else
    	setTimeout('parent.nextShowBookinfo();',50);
}

// ----------------------- end of iframe function

function popitup(url) {
    leftpos=screen.width-400;
    para = "height=450,width=750,left="+leftpos+",top=0"+",scrollbars=yes, resizable=no";

    newwindow=window.open(url,'itemViewer',para);    
    if (window.focus) { newwindow.focus() }
    return false; 
} 
function showFindBook(name)
{
	popitup('http://www.findbook.tw/exec/search?keyword='+name);
}
function showGoogle(name)
{
	popitup('http://www.google.com/search?ie=UTF-8&oe=UTF-8&hl=zh-TW&q='+name);
}	    

function sendQuery()
{
	document.all.mainView.src='viewBookByCat.jsp?cat=99&keyword='+ encodeURIComponent(document.getElementById('terms').value);
}

function sendQuery2()
{
	document.href.src='bookDB.jsp?cat=99&q1='+ encodeURIComponent(document.getElementById('terms').value);
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
     {
     	  sendQuery();
          return false;
     }
     else
          return true;
}

var hintFlag = 0;

function clearHint()
{
	if(hintFlag==0)
	{
		document.getElementById('terms').value = "";
		document.getElementById('terms').style.color = "black";
		
		hintFlag = 1;
	}
}

function newCheckOut()
{
	document.getElementById('checkoutbg').style.display = 'block';
	document.getElementById('checkoutbg').style.width = document.body.clientWidth+"px";
	if(document.getElementById('page').offsetHeight > document.body.clientHeight)
	  document.getElementById('checkoutbg').style.height =document.getElementById('page').offsetHeight+"px";
	else
	  document.getElementById('checkoutbg').style.height = document.body.clientHeight+"px";
	
	document.getElementById('checkoutbg').style.backgroundColor = 'black';
	document.getElementById('checkoutbg').style.filter = ' alpha(opacity=70)';
	document.getElementById('checkoutbg').style.opacity = ' 0.7';
	document.getElementById('checkoutbg').style.left = '0';
	document.getElementById('checkoutbg').style.top = '0';
	
	document.getElementById('checkoutbox').style.display = 'block';
	document.getElementById('checkoutbox').style.position = 'absolute';
	document.getElementById('checkoutbox').style.left = (document.body.clientWidth-650)/2 + "px";
	document.getElementById('checkoutbox').style.top = '20px';
	document.getElementById('checkoutbox').style.width = '650px';
	document.getElementById('checkoutbox').style.height = '600px';
	document.getElementById('checkoutbox').style.border = '5px solid gray';
	document.getElementById('checkoutbox').style.backgroundColor = 'white';
	
	document.getElementById('checkoutbox').innerHTML="<iframe src=\"http://www2.kkbooks.tw/viewNewCheckout.jsp\" width=\"640\" height=\"600\" style=\"border:0px solid #000000\" frameborder=\"0\" scrolling=\"auto\"></iframe>";

	document.getElementById('closeBt').style.display = 'block';
    document.getElementById('closeBt').style.position = 'absolute';
	document.getElementById('closeBt').style.left = (document.body.clientWidth-650)/2 + 630 + "px";
	document.getElementById('closeBt').style.top = '15px';
    window.scroll(0,0);
}

function closeCheckOut()
{
	document.getElementById('checkoutbg').style.display = 'none';
	document.getElementById('checkoutbox').style.display = 'none';
	document.getElementById('closeBt').style.display = 'none';
	location.reload();
}
//-->
