﻿// JavaScript Document
var loc_url	=	location.href;
var url_arr	=	loc_url.split('http://');
var url_dom_arr	=	url_arr[1].split('/');
var loc_domain	=	url_dom_arr[0];
var domain_arr	=	loc_domain.split('.');
var dom_length	=	domain_arr.length;
if(domain_arr[(domain_arr.length-1)]	==	''){var add=1;}else{var add=0;}
var mydomain=domain_arr[(dom_length-(2+parseInt(add)))]+'.'+domain_arr[(dom_length-(1+parseInt(add)))];
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");};
String.prototype.ByteCount=function(){var txt = this.replace(/(<.*?>)/ig,"");txt = txt.replace(/([\u0391-\uFFE5])/ig, "11");var count = txt.length;return count;}
String.prototype.ubbcode=function(){var str;str=this.replace(/\[img(.+?)\]/ig,"<img src=\"/images/chat/chat_$1.gif\" />");
/*str=str.replace(/\[b\]([^\[\]]*)\[\/b\]/ig, "<b>$1</b>");
str=str.replace(/\[strong\]([^\[\]]*)\[\/strong\]/ig, "<strong>$1</strong>");
str=str.replace(/\[i\]([^\[\]]*)\[\/i\]/ig, "<i>$1</i>");
str=str.replace(/\[u\]([^\[\]]*)\[\/u\]/ig, "<u>$1</u>");*/
return str;}
String.prototype.getQuery = function(name) 
{var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");var r = this.substr(this.indexOf("\?")+1).match(reg);if (r!=null) return unescape(r[2]); return null;}
function isIE(){var browser = navigator.appVersion;if(browser.indexOf("MSIE") >= 1){return true;}else{return false;}}
function replaceUrl(LocUrl,paramName,paramVal){var re=eval('/('+ paramName+'=)([^&]*)/gi');var mre=LocUrl.match(re);if (mre!=null){var nUrl = LocUrl.replace(re,paramName+'='+paramVal);}else{nUrl=LocUrl+'&'+paramName+'='+paramVal;}this.location = nUrl;}
function getCode() {G('getcode').value='';G('codeimg').innerHTML = '<img style="cursor: pointer;cursor: hand" src="/GetCode.asp?t='+Math.random()+'" height="16px"  title="看不清！" onclick="getCode();" />';}
function chkCode(thisinput){var thisval=thisinput.value.trim();var fmname=thisinput.id;if(thisval!=''){var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url="/ajaxpost.asp?action=getcode&getcode="+thisval+"";ajaxobj.callback=function(xmlobj) {var response=xmlobj.responseText;if(response!='1'){G('codetxt').className = "err";G('codetxt').innerHTML='验证码错误';}else{G('codetxt').className = "suc";G('codetxt').innerHTML='验证码正确';}};ajaxobj.send();}else{G('codetxt').className = "null";G('codetxt').innerHTML='请输入验证码';}}
function bookmarkit(){var myHerf=top.location.href;
var title=document.title;try{if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')){window.sidebar.addPanel(title,myHerf,title);}else{window.external.AddFavorite(myHerf,title);}}catch(e){}return false;};function CopyCode(cpText){if(copy2Clipboard(cpText)!=false){alert("复制成功！你可以使用粘贴或(Ctrl+V)功能与其他好友一同分享！ ");}}copy2Clipboard=function(txt){if(window.clipboardData){window.clipboardData.clearData();window.clipboardData.setData("Text",txt);}else if(navigator.userAgent.indexOf("Opera")!=-1){window.location=txt;}else if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}catch(e){alert("您的firefox安全限制限制您进行剪贴板操作，请打开’about:config’将signed.applets.codebase_principal_support’设置为true’之后重试，相对路径为firefox根目录/greprefs/all.js");return false;}var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);if(!clip)return;var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);if(!trans)return;trans.addDataFlavor('text/unicode');var str=new Object();var len=new Object();var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);var copytext=txt;str.data=copytext;trans.setTransferData("text/unicode",str,copytext.length*2);var clipid=Components.interfaces.nsIClipboard;if(!clip)return false;clip.setData(trans,null,clipid.kGlobalClipboard);}}
function XmlHttpObj(){var XmlRequest=false;try{XmlRequest = new XMLHttpRequest();} catch (trymicrosoft){try{XmlRequest = new ActiveXObject("Msxml2.XMLHTTP");}catch (othermicrosoft){try{XmlRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (failed){XmlRequest = false;}}}if (!XmlRequest){alert("can't create XMLHttpRequest object.");}return XmlRequest;};function AJAXRequest(){var xmlObj = XmlHttpObj();if (!xmlObj) return false;var CBfunc,ObjSelf;ObjSelf=this;this.method="POST";this.url;this.async=true;this.content="";this.callback=function(cbobj){return;};this.send=function(){if(!this.method||!this.url||!this.async) return false;xmlObj.open (this.method, this.url, this.async);if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlObj.onreadystatechange=function(){if(xmlObj.readyState==4) {if(xmlObj.status==200) {ObjSelf.callback(xmlObj);}}};if(this.method=="POST") xmlObj.send(this.content);else xmlObj.send(null);}}
//激活在线
function ActiveOnline(channelid){var ajaxobj=new AJAXRequest;ajaxobj.method="POST";ajaxobj.url="/actonline.asp?channelid="+channelid+"&state="+escape(document.title.toString())+"";ajaxobj.callback=function(xmlobj) {var response = xmlobj.responseText;updateonline(response);};ajaxobj.send();}function updateonline(oStr){eval(oStr);var allonlieid=G("allonline");var useronlieid=G("useronline");var guestonlieid=G("guestonline");if(allonlieid){allonlieid.innerHTML=allonline.toString();}if(useronlieid){useronlieid.innerHTML=useronline.toString();}if(guestonlieid){guestonlieid.innerHTML=guestonline.toString();}}
//在线状态
function UserStats(){var uid=getCookie("userid");var uname=getCookie("username");if (uid!='' && uid!=null){var topstr="";var nurl="http://www."+mydomain+"/html/user/index_"+uid+".htm";topstr+='<li id="lname">欢迎您：<a href="'+nurl+'">'+uname+'</a></li>';topstr+='<li id="tool">您的个人主页是：'+nurl+'</li>';topstr+='<li id="tool"><a href="javascript:CopyCode(\''+nurl+'\');"><img src="/images/btn03.jpg"></a> <a href="/logout.asp"><img src="/images/btn04.jpg"></a></li>';G('lg').innerHTML=topstr;}}
//通用下拉创建
function selCreate(selObj,TextVal,Value,selVal){var oOpt=document.createElement("option");var sText=document.createTextNode(TextVal);oOpt.setAttribute("value",Value);if (Value==selVal){oOpt.setAttribute("selected","selected");}oOpt.appendChild(sText);selObj.appendChild(oOpt);}
//select表单选取
function selectSetItem(Obj,Val){if (Obj){for (i=0;i<Obj.length;i++){if (Obj.options[i].value==Val||(","+Val+",").indexOf(","+Obj.options[i].value+",")!=-1){Obj.options[i].selected=true;};};};}
//单选表单选取 Obj 表单名，VAL所选的值
function chkradio(Obj,Val){if (Obj){for (i=0;i<Obj.length;i++){if (Obj[i].value==Val){Obj[i].checked=true;break;};};};}
//多选表单选取 Obj 表单名，VAL所选的值
function chkcheckbox(Obj,Val){if (Obj){Val = ","+Val+",";if (Obj.length==null){if(Val.indexOf(","+Obj.value+",")!=-1){Obj.checked=true;};}for (i=0;i<Obj.length;i++){if(Val.indexOf(","+Obj[i].value+",")!=-1){Obj[i].checked=true;};};};}
//复选框事件
function CheckAll(form){for (var i=0;i<form.elements.length;i++){var e = form.elements[i];if (e.name != 'chkall' && e.type=='checkbox'){e.checked = form.chkall.checked;}}}
//身高年龄
function selage(selName,selVal,sex,sType){var vStr='--请选择--';if(sType==1){vStr='--不限--'};var frmobj=G(selName);var j=24;var m=64;frmobj.length=0;frmobj.options.add(new Option(vStr,"0"));if (sex=='1'){j=20;m=60;};for (i=j;i<=m;i++){selCreate(frmobj,i,i,selVal);}}
function getheight(selName,selVal,sex,sType){var vStr='--请选择--';if(sType==1){vStr='--不限--'};var frmobj=G(selName);var j=160;var m=220;frmobj.length=0;if (sex=='1'){j=140;m=200}frmobj.options.add(new Option(vStr,"0"));for (i=j;i<=m;i++){selCreate(frmobj,i,i,selVal);}}
//登录表单默认值
function userlogin(thisinput) {var val = thisinput.value;if (val == '邮箱/会员名/ID/手机'){thisinput.value = '';}if (val == '' || val == null){thisinput.value = '邮箱/会员名/ID/手机';}}
function tabit(btn){var idname = new String(btn.id);var s = idname.indexOf("_");var e = idname.lastIndexOf("_")+1;var tabName = idname.substr(0, s);var id = parseInt(idname.substr(e, 1));var tabNumber = btn.parentNode.childNodes.length;for(i=0;i<tabNumber;i++){G(tabName+"_div_"+i).style.display = "none";G(tabName+"_btn_"+i).className = "";};G(tabName+"_div_"+id).style.display = "block";btn.className = "curr";};
function getCookie(name){var userVal=null;var str_tmp= readCookie(name);if(!str_tmp){return false;}var end = str_tmp.indexOf("&");if (end!='-1'){ userVal=str_tmp.substr(0,end);}else{userVal=str_tmp;};return userVal;}
function readCookie(name){var arr,reg=new RegExp("(^|)"+name+"=([^;]*)(;|$)");if(arr=document.cookie.match(reg)){return decodeURIComponent(arr[2]);}else{return null;}}
function writeCookie(name, value, days){var expires = "";if (days!=null) {date = new Date((new Date()).getTime() + days *24* 3600000);expires = "; expires="+date.toGMTString();};document.cookie = name+"="+value+expires+"; path=/";}
function frm_submit(frmObj){var form_obj = G(frmObj);form_obj.submit();}
function SucTxt(divid,txt){G(divid).className = "suc";G(divid).innerHTML = txt;}
function NullTxt(divid){G(divid).className = "null";G(divid).innerHTML = '系统未检测到您的输入<img align=absmiddle src=images/error_notice_right.png />';}
function SetNull(divid){G(divid).className = "null";G(divid).innerHTML = '';}
function ErrTxt(divid,txt){G(divid).className = "err";G(divid).innerHTML = txt;}
function winPop(Obj){var cType=1;if(Obj.type){cType=Obj.type;};var isReload=false;if(Obj.reload){isReload=eval(Obj.reload);};var sContent="contentUrl";if(cType=='2'){sContent="contentHtml"};if(cType=='4'){sContent="alertCon"};var iUrl="";if(Obj.url){iUrl=Obj.url;};var iScroll='no';if(Obj.scroll){iScroll=Obj.scroll;};var iShow=true;if(Obj.ishow){iShow=eval(Obj.ishow);};var isDrag=false;if(Obj.drag){isDrag=eval(Obj.drag);};var iwidth=380;if(Obj.width){iwidth=Obj.width};var iheight=80;if(Obj.height){iheight=Obj.height};pop=new Popup({contentType:cType,isReloadOnClose:isReload,isSupportDraging:isDrag,width:iwidth,height:iheight,isHaveTitle:iShow,scrollType:iScroll});
pop.setContent("title",Obj.title);pop.setContent(sContent,iUrl);pop.build();pop.show();if(Obj.form){G(Obj.form).target=pop.iframeIdName;}if(Obj.next){nextStep(Obj.next,Obj.goTo);}};function nextStep(sType,goTo){var closeTime=2500;switch (sType){case 1:setTimeout(function(){pop.close()},closeTime);break;case 2:setTimeout("location.reload();",closeTime);break;case 3:setTimeout("location.href='"+goTo+"'",closeTime);break;default:break;}}
var Ptimer,PopHeight,Si=0;
function rPopSize(Size,M){PopHeight=parseInt(G('ifr_popup0').style.height,10);if (M==0){Si+=1}else{Si=Si-1};G('ifr_popup0').style.height=PopHeight+Si+'px';G('dialogBoxShadow').style.height=PopHeight+26+Si+'px';if(M==0){if (PopHeight>=Size){window.clearInterval(Ptimer);}}else{if (PopHeight<=Size){window.clearInterval(Ptimer);};}}
function popSize(Size){if(Size>parseInt(G('ifr_popup0').style.height,10)){Ptimer=window.setInterval('rPopSize('+Size+',0)',1);}else{Ptimer=window.setInterval('rPopSize('+Size+',1)',1);}}//动态改变弹出窗口高度
//function popSize(Size){G('ifr_popup0').style.height=Size+'px';G('dialogBoxShadow').style.height=Size+26+'px';}
function show_div(divid){if (G(divid).style.display = 'none'){G(divid).style.display = 'block';}else{G(divid).style.display = 'none';}}
/*鼠标显示层*/
function pop_show(event,divid,title,info){xpos=0;ypos=0;var htmlStr='';if(isIE()){var Ypos;var Xpos;var Offwidth;var Offheight;var standardCompat =document.compatMode.toLowerCase();/*alert(standardCompat);*/if (standardCompat == "css1compat"){Ypos = document.documentElement.scrollTop;}else if (standardCompat == "backcompat" || standardCompat == "quirksmode" ){Ypos = document.body.scrollTop;}var top_tmp=event.clientY+Ypos;var left_tmp=event.clientX;}else{var top_tmp=event.pageY;var left_tmp=event.pageX;}left_tmp+=xpos + 30;top_tmp+=ypos - 70;if(title!=''){htmlStr += '<strong>'+title+'</strong><br/>';};if(info!=''){htmlStr += '<em>'+info+'</em><br/>';G(divid).innerHTML = htmlStr;};G(divid).style.left=left_tmp+'px';G(divid).style.top=top_tmp+'px';G(divid).style.display= '';}
function chklogin(){if (getCookie("userid")==0){alert("对不起，请先登录！");location.href='/login.asp';return false;}return true;}
/*功能按钮*/
function favorites(id){if(chklogin()){winPop({title:'我的收藏',url:'/users/clicked.asp?action=click&sortid=1&userid='+id+''});}}
function chat(id){if(chklogin()){winPop({title:'在线聊天',ishow:'false',url:'/chat/index.asp?action=call&userid='+id+'',height:'175',width:'420'});}}
function friend(id,type){if(chklogin()){winPop({title:'加为好友',ishow:'false',url:'/users/friend.asp?action=form&type='+type+'&userid='+id+'',height:'170',width:'420'});}}
function userwire(id){if(chklogin()){winPop({title:'委托红娘',ishow:'false',url:'/users/friend.asp?action=wire&userid='+id+'',height:'190',width:'420'});}}
/*点击统计*/
function count(channelid,id){var ajaxobj=new AJAXRequest;ajaxobj.method='POST';ajaxobj.url='/count.asp?action=count&channelid='+channelid+'&id='+id+'';ajaxobj.callback=function(xmlobj) {var response = xmlobj.responseText;updateCount(response);};ajaxobj.send();}function updateCount(str){var strArray=str.split(',');var viewid=G("views");var markid=G("remark");if(viewid){viewid.innerHTML=strArray[0];};if(markid){markid.innerHTML=strArray[1];}}
function setiFrame(iframename){var pTar = null;if (document.getElementById){pTar = G(iframename);}else{eval('pTar = ' + iframename + ';');}if (pTar && !window.opera){pTar.style.display="block";if (pTar.contentDocument && pTar.contentDocument.documentElement.scrollHeight){pTar.height =0;pTar.height=pTar.contentDocument.documentElement.scrollHeight;}else if (pTar.Document && pTar.Document.body.scrollHeight){pTar.height = pTar.Document.body.scrollHeight;}}}
function localurl(url){window.location.href=url;}
