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 if(bkid.substring(0,1)=='E')//电子版
      {
        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 = '/lib-comm-new/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;
	  }
	  else if(bkid.substring(0,1)=='S')//语音版
	  {
	    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 = '/lib-comm-new/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;
	  }
    }
	if(bkid.length==36)
	{
	  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 = '/lib-comm-new/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 uphits(listid,upid)
{
  $.ajax({url:'behind/uphits.aspx?listid='+listid,success:function(d)
  {
     alert('谢谢支持!');
     $('#'+upid).html(d);
  },
  error:function(e1,e2,e3){},dataType:'text'});
}

function addMagBox(listid)
{
   $.ajax({url:'behind/addToMagBox.aspx?listid='+listid,success:function(d)
  {
    if(d=='0')
      alert('添加成功');
    else if(d.length>2)
    {
      alert("请先登录收藏夹!");
      window.open('myMaglogin.aspx');
    }
    else
      alert('添加失败');
  },
  error:function(e1,e2,e3){},dataType:'text'});
}
