Date.prototype.toFormatString = function(fs)
{
	if(fs.length == 1)
	{ 
		return this.getFullYear() + fs + (this.getMonth() + 1) + fs + this.getDate(); 
	}
		fs = fs.replace("yyyy",this.getFullYear());
		if (this.getMonth() + 1 < 10) {
			fs = fs.replace("mm", '0'+(this.getMonth() + 1));
		}else{
			fs = fs.replace("mm", (this.getMonth() + 1));
		}
		if (this.getDate() < 10) {
			fs = fs.replace("dd", '0'+this.getDate());
		}else{
			fs = fs.replace("dd",this.getDate());
		}
		if (this.getHours() < 10) {
			fs = fs.replace("HH", '0'+this.getHours());
		}
		else {
			fs = fs.replace("HH", this.getHours());
		}
		if (this.getMinutes() < 10) {
			fs = fs.replace("MM", '0'+this.getMinutes());
		}
		else {
			fs = fs.replace("MM", this.getMinutes());
		}
		if (this.getSeconds() < 10) {
			fs = fs.replace("SS", '0'+this.getSeconds());
		}
		else {
			fs = fs.replace("SS", this.getSeconds());
		}
		fs = fs.replace("ms", this.getMilliseconds());
	return fs;
};

function openMBook(bkid,page){

var pathid;
    var strFullPath=window.document.location.href;
	var strPath=window.document.location.pathname;
	var pos=strFullPath.indexOf(strPath);
	var prePath=strFullPath.substring(0,pos);
	var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
	pathid = prePath+postPath ;

    if(bkid.length==37)
    {
      if(bkid.substring(0,1)=='M')//多媒体
      {
         bkid=bkid.substring(1,37);
      }
      else//电子版
      {
        bkid=bkid.substring(1,37);
        var opdate = new Date().toFormatString('yyyy-mm-dd HH:MM:SS.ms');
		//var url = 'reader/book-1-.htm?bkwzid='+bkid+'&opdate='+opdate+(page==null?'':'&order='+page);
		var url = 'reader/book-1-.htm?bkwzid='+bkid+'&opdate='+opdate+(page==null?'':'&order='+page)+'&pathid='+encodeURIComponent(pathid);//encodeURIComponent()
		var options = 'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,width=1024,height=710,top=50,left=50';
		window.open(url,'popup',options);
		return;
	  }
    }
	var opdate = new Date().toFormatString('yyyy-mm-dd HH:MM:SS.ms');
	//var url = 'reader/book.htm?id='+bkid+'&opdate='+opdate+(page==null?'':'&page='+page);
	var url = 'reader/book.htm?id='+bkid+'&opdate='+opdate+(page==null?'':'&page='+page)+'&pathid='+encodeURIComponent(pathid);//encodeURIComponent()
var options = 'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,width=1024,height=710,top=50,left=50';
window.open(url,'popup',options);

};
function record()
{
  var Jsurl=location.search; 	
  var JsRequest = new Object(); 
  if(Jsurl.indexOf("?")!=-1) { 
	var str = Jsurl.substr(1); 
	var strs = str.split("&"); 
	for(var i=0;i<strs.length;i++) { 
		JsRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 
	} 
  }
  
  var listid=JsRequest['listid'];
  var xmlurl='behind/preread.aspx';
  var myAjax=new Ajax.Request(xmlurl,{method: 'get', asynchronous: true,parameters: 'listid='+listid, onComplete: gethits});
  
};

function gethits(x)
{
  var ret=x.responseText;
  document.getElementById('hits').innerHTML=ret+"人";
}; 

