/*cmfu main javascript*/ var domainName = '.qidian.com',tophref,thishref; try{ tophref=top.location.href.toLowerCase(); thishref=this.location.href.toLowerCase(); }catch(e){}; if(this != top && tophref!=null && tophref.indexOf("localhost") < 0 || thishref!=null && thishref.indexOf("localhost") < 0){ try{ if(this != top && top.location.href.toLowerCase().indexOf("qidian.com") < 0) top.location.href="http://www.qidian.com";}catch(e){}; if(this.location.href.toLowerCase().indexOf("qidian.com") < 0) top.location.href="http://www.qidian.com"; } String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); } String.prototype.trimEnd = function(trimString){ var re = new RegExp(trimString+"*$","g");return this.replace(re, "");}; String.prototype.len=function(){ return this.replace(/[^\x00-\xff]/g,'aa').length; }; function StringBuilder(value){ this.strings = new Array(""); this.append(value);}; StringBuilder.prototype.append = function(value){ if(value) this.strings.push(value);}; StringBuilder.prototype.clear = function (){ this.strings.length = 1;} StringBuilder.prototype.toString = function (){ return this.strings.join("");} if (!String._FORMAT_SEPARATOR){ String._FORMAT_SEPARATOR = String.fromCharCode(0x1f); String._FORMAT_ARGS_PATTERN = new RegExp('^[^' + String._FORMAT_SEPARATOR + ']*'+ new Array(100).join('(?:.([^' + String._FORMAT_SEPARATOR + ']*))?')); }; if (!String.format){ String.format = function (s){ return Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR).replace(String._FORMAT_ARGS_PATTERN, s);}; }; if (!''.format){ String.prototype.format = function (){ return (String._FORMAT_SEPARATOR +Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR)).replace(String._FORMAT_ARGS_PATTERN, this); }; }; function checkLoginByCookie(){ var cookieId="AUTHTEST"; if(window.location.href.toLowerCase().indexOf("qidian.com") > -1) cookieId="cmfuToken"; if((GetCookie(cookieId)!=null && GetCookie(cookieId).length > 0 )) return true; else{ if(GetCookie('cmfu_al') != null && GetCookie('cmfu_al').length > 0) return true;}; return false; }; function getUrlParam(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (r!=null) return unescape(r[2]); else return null; }; function $(objName){ if(document.getElementById) return document.getElementById(objName ); else if(document.layers) return eval("document.layers['" + objName +"']"); else return eval('document.all.' + objName); }; function eventBind(elem, eventName, handler){//事件多播绑定代码 if (elem.addEventListener) elem.addEventListener(eventName, handler, false); else if (elem.attachEvent) elem.attachEvent("on" + eventName, handler); }; function DateAdd(BaseDate, interval, DatePart){ var dateObj = new Date(BaseDate.replace("-",",")); var millisecond=1; var second=millisecond*1000; var minute=second*60; var hour=minute*60; var day=hour*24; var year=day*365; var newDate; var dVal = new Date(dateObj) var dVal = dVal.valueOf(); switch(DatePart){ case "ms": newDate=new Date(dVal+millisecond*interval); break; case "s": newDate=new Date(dVal+second*interval); break; case "mi": newDate=new Date(dVal+minute*interval); break; case "h": newDate=new Date(dVal+hour*interval); break; case "d": newDate=new Date(dVal+day*interval); break; case "y": newDate=new Date(dVal+year*interval); break; default: return escape("日期格式不对"); }; newDate = new Date(newDate); return newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + newDate.getDate() ; }; Date.prototype.AddDays=function (interval){ var dateObj = this; var millisecond=1; var second=millisecond*1000; var minute=second*60; var hour=minute*60; var day=hour*24; var year=day*365; var newDate; var dVal = new Date(dateObj); var dVal=dVal.valueOf(); newDate=new Date(dVal+day*interval); newDate = new Date(newDate); return newDate; }; function SetCookie(name, value){ var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2].toGMTString() : (new Date()).AddDays(30).toGMTString();; var path = (argc > 3) ? argv[3] : "/"; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; var content = name + "=" + escape(value) + ";"; if(expires != null) content += " expires=" + expires + ";"; if(path != null) content += " path=" + path + ";"; if(domain != null) content += " domain=" + domain + ";"; document.cookie = content; }; function GetCookie(cookieName) { var cookieString = document.cookie; var start = cookieString.indexOf(cookieName + '='); if (start == -1) return null; // 加上等号的原因是避免在某些 Cookie 的值里有与cookieName一样的字符串 start += cookieName.length + 1; var end = cookieString.indexOf(';', start); if (end == -1) return unescape(cookieString.substring(start)); return unescape(cookieString.substring(start, end)); }; function GetAdSettingCookie(cookieName){//获取广告条件cookie 有汉字避免乱码 var cookieString = document.cookie; var start = cookieString.indexOf(cookieName + '='); if (start == -1) return null; start += cookieName.length + 1; var end = cookieString.indexOf(';', start); if (end == -1) return decodeURIComponent(cookieString.substring(start)); return decodeURIComponent(cookieString.substring(start, end)); }; function ShowConditionAd(conditionId,notConditionId,adType,areaList,channelIdList,bookIdList,sex,startAge,endAge,vip) {//显示条件广告逻辑---符合条件广告设置的条件显示否则显示下一个广告 var showConditionAd=false,cSettings; var adCookieValue=GetAdSettingCookie("userInfoForAd"); if(typeof(adCookieValue)!='undefined' && adCookieValue!=null){ cSettings=adCookieValue.split(",");//区域、性别、年龄、是否vip if(cSettings.length==4){ if((areaList=='无' || areaList.indexOf(cSettings[0])>=0) && (sex=='无' || sex==cSettings[1]) && ((startAge==0 && endAge==0) || (endAge>cSettings[2] && startAge<=cSettings[2])) && (vip==-1 || vip==cSetting[3])){ showConditionAd=true; }; }; }; if(typeof(JChannelId)!='undefined'){ if(channelIdList!='无' && channelIdList.indexOf(JChannelId)>=0) showConditionAd=true; }; if(typeof(JBookId)!='undefined'){ if(bookIdList!='无' && bookIdList.indexOf(JBookId)>=0) showConditionAd=true; }; if(adType==1){//弹窗广告 var objName; if(showConditionAd==true) objName="QidianBackPop"+conditionId;//显示条件广告 else objName="QidianBackPop"+notConditionId; ExcutePop(objName);//在admanager.cs 426行定义 }else{ if(showConditionAd==true){//显示条件广告 document.getElementById(conditionId).style.display=""; document.getElementById(notConditionId).style.display="none"; }else{ document.getElementById(conditionId).style.display="none"; document.getElementById(notConditionId).style.display=""; }; }; }; function TextBoxOnFocus(txtControl,strDefaultText){ if (txtControl.value==strDefaultText) txtControl.value=""; };//文本框得到焦点 function TextBoxOnBlur(txtControl,strDefaultText){ if (txtControl.value.replace(/(^[\s]*)|([\s]*$)/g,"")=="") txtControl.value=strDefaultText;}; //文本框失去焦点 function GetCurrentRawUrl(){//获取当前请求的相对路径 var retUrl= document.location.href,retDomain=document.location.host; retUrl=retUrl.replace(retDomain,""); retUrl=retUrl.replace("http://",""); return escape(retUrl); }; function MultiSendWin(subject,content){//弹出群发消息窗口 var win =window.open(uploadURL+"?subject=" + subject + "&content=" +content,"","menubar=no,width=480,height=550,resizeable=no",""); return false; }; function ShowServerMessage(result){ try{eval(result.value);}catch(e){}; }; function KeydownSubmitForm(btnId){//回车提交表单 var btn=document.getElementById(btnId); if (btn!=null&& event.keyCode== 13){ event.returnValue=false; event.keyCode=9; btn.click(); }; }; function MDown(Object){//ReadChapter -抵用券js Obj=Object.id; document.all(Obj).setCapture(); pX=event.x-document.all(Obj).style.pixelLeft; pY=event.y-document.all(Obj).style.pixelTop; }; function MMove(){ if(Obj!=''){ document.all(Obj).style.left=event.x-pX; document.all(Obj).style.top=event.y-pY; }; }; function MUp(){ if(Obj!=''){ document.all(Obj).releaseCapture(); Obj=''; };}; function LayerClose(divDiscount){ document.getElementById(divDiscount).style.visibility="hidden"; };//关闭抵用券信息 function LayerShow(divDiscount,discountPrize){/*显示抵用券信息*/ var prizeUI = document.getElementById(divDiscount); prizeUI.style.left = screen.width-530; prizeUI.style.top = screen.Height - 480; prizeUI.style.visibility="visible"; document.getElementById("lblPrize1").innerHTML=document.getElementById("lblPrize2").innerHTML=discountPrize; window.setInterval("LayerClose('" + divDiscount + "')",15000); }; function HideMenu(menuid){//帮助masterpage用 var obj = document.getElementById(menuid); if(obj.style.display == "none") obj.style.display = ""; else obj.style.display = "none"; if(obj.style.display == ""){ var tmpId = "M0"; for(var i =1 ;i<= 9; i++){ var myid = tmpId + i; if(myid != menuid) document.getElementById(myid).style.display = "none"; }; }; }; function ShowLoginDiv() { var builder = new StringBuilder(); builder.append("
| 登录 | "); builder.append("× |
| "); builder.append(" | |