var ispageloaded=false;
//var URL_MAIN='';
//var URL_MY='';
document.domain="runrungo.com";
addEvent(window,"load",pageinit);
setTimeout(function(){if(!ispageloaded)pageinit();},10000);
function pageinit(){ispageloaded=true;}
function nolinkline(){for(var ii=0; ii<document.links.length; ii++)document.links[ii].onfocus=function(){this.blur();};}
function URLEncode(str){try{var i,temp,p,q;  var result="";  for(i=0;i<str.length;i++){    temp = str.charCodeAt(i);   if(temp>=0x4e00){     execScript("ascCode=hex(asc(\""+str.charAt(i)+"\"))", "vbscript");    result+=ascCode.replace(/(.{2})/g, "%$1");    }else{     result+=escape(str.charAt(i));    }   }  return result;}catch(e){return str;}}
function SendMsg(revid,rev,subject,message,event){
	try{
		if(ispageloaded){
			var tmpid='__TMP_WRITEMSG__';
			var s='<div class="popbox"><div class="inner"><h4><span>发送消息</span></h4><form target="frmPageBuffer" method="post" action="@@mainurl/writemsg.html?action=1&p=1"><input type="hidden" value="@@revid" name="revid" /><p style="padding-top:10px;"><label class="floatlabel">发送到：</label><input type="text" style="width:180px;" class="input4" onfocus="this.className=\'input2\'" onblur="this.className=\'input4\'" readonly value="@@rev" /></p><p style="padding-top:10px;"><label class="floatlabel">标题：</label><input type="text" style="width:260px;" class="input4" onfocus="this.className=\'input2\'" onblur="this.className=\'input4\'" name="subject" value="@@subject" /></p><p style="padding-top:10px;"><label class="floatlabel">内容：</label><textarea name="message" style="margin:0;width:260px;height:100px;" class="input4" onfocus="this.className=\'input2\'" onblur="this.className=\'input4\'" rows="5" cols="5">@@message</textarea></p><p style="padding-top:10px;"><label class="floatlabel">&nbsp;</label><input type="submit" class="search-bt" value="发送" /> <input type="button" class="search-bt" value="取消" onclick="javascript:document.body.removeChild(document.getElementById(\'__dstid__\'));" /></p></form></div></div>';
			s=s.replace("@@revid",revid);
			s=s.replace("@@rev",rev);
			s=s.replace("@@subject",subject);
			s=s.replace("@@message",message);
			s=s.replace("@@mainurl",URL_MY);
			if(!document.getElementById(tmpid)){
				var newDiv = document.createElement("div");
				newDiv.id = tmpid;
				newDiv.style.display='none';
				document.body.appendChild(newDiv);
			}
			document.getElementById(tmpid).innerHTML=s;
			showTipWindow('new'+tmpid,tmpid,0,(window.event||event));
			return true;
		}else{return false;}
	}catch(e){return false;}
}
function UpdateItemlist(id,val,rev){
	try{
		var o=document.getElementsByName(id);
		var t="";
		for(var i=0;i<o.length;i++)
			if((!rev&&o[i].checked)||(rev&&!o[i].checked)){if(t!="")t=t+",";t=t+o[i].value;}
		eval(val+'=t;');
	}catch(e){}
}
function copyIt(id) {
	try{
		var o = document.getElementById(id);
		o.select();
		window.clipboardData.clearData();
		window.clipboardData.setData("text",o.value);
	}catch(e){alert('请利用ctrl+c 手动拷贝');o.select();}
}
function copyData(s,ss) {
	try{
		window.clipboardData.clearData();
		window.clipboardData.setData("text",s);
		if(ss.length>0)alert(ss);
	}catch(e){alert('浏览器不支持，请利用ctrl+c 手动拷贝');}
}
function CardSwitch(s,ss,cur,cur_c,not_c){
	try{
		var o=s.split(ss);
		for(var i=0;i<o.length;i++)
			if(document.getElementById(o[i]))document.getElementById(o[i]).className=not_c;
		if(document.getElementById(cur))document.getElementById(cur).className=cur_c;
	}catch(e){}
}
function DisplaySwitch(s,ss,cur){
	try{
		var o=s.split(ss);
		for(var i=0;i<o.length;i++)
			if(document.getElementById(o[i]))document.getElementById(o[i]).style.display='none';
		if(document.getElementById(cur))document.getElementById(cur).style.display='';
	}catch(e){}
}
var __resize_arr__=new Array();
function resizeimg(o,w,h){
	try{
		if(o){
			var o_w,o_h;
			o_w=o.width;o_h=o.height;
			if(o_w>w){
				o.height=o_h*w/o_w;
				o.width=w;
			}
			if(o_h>h){
				o.width=o_w*h/o_h;
				o.height=h;
			}
		}
	}catch(e){}
}
function ResizeImgEx(o){
	try{
		if(o.id)o.o=document.getElementById(o.id);
		if(o.o){
			//处理例外事件
			if(o.err){
				o.o.width=o.w;
				o.o.height=o.h;
				return;
			}
			var o_w,o_h;
			if(typeof(o.width)!='undefined'&&typeof(o.height)!='undefined'){
				o_w=o.width;o_h=o.height;
			}else if(o.o.width==0||o.o.height==0){
				var oo=document.createElement("img");
				__resize_arr__[__resize_arr__.length]=o.o;
				eval("oo.onload=function(){ResizeImgEx({o:__resize_arr__["+(__resize_arr__.length-1)+"],width:this.width,height:this.height,w:"+o.w+",h:"+o.h+"});};");
				oo.src=o.o.src;
				return;
			}else{
				o_w=o.o.width;o_h=o.o.height;
			}
			if(o_w>o.w){
				o.o.height=o_h*o.w/o_w;
				o.o.width=o.w;
				o_w=o.o.width;o_h=o.o.height;
			}
			if(o_h>o.h){
				o.o.width=o_w*o.h/o_h;
				o.o.height=o.h;
			}
		}
	}catch(e){}
}
function copycontenttexttotextarea(src,dst){try{document.getElementById(dst).value=document.getElementById(src).innerText?document.getElementById(src).innerText:document.getElementById(src).textContent;}catch(e){}}
function movecursortoendintextarea(src){try{document.getElementById(src).focus();var range=document.getElementById(src).createTextRange();range.collapse(false);range.moveEnd('character',0);range.select();}catch(e){}}
function doQuote(o){
	try{
		var dst=document.getElementById(o.dst);
		copycontenttexttotextarea(o.src,o.dst);
		dst.value=dst.value.replace(/[\x0d\x0a]*\[quote\][\s\S]*?\[\/quote\][\x0d\x0a]*/gi,"");
		dst.value='[quote]'+(o.text?o.text+"\n":'')+dst.value+'[/quote]\n';
		movecursortoendintextarea(o.dst);
	}catch(e){}
}

function ShowHideDiv(o,s0,s1){
	try{
		var o=document.getElementById(o);
		o.style.display = s0;
		o.className = s1;
	}catch(e){}
}
function copy(text){
	if(window.clipboardData){//判断是否具有clipboardData对象，IE
	   window.clipboardData.setData("Text",text);
	}else if(window.netscape){//判断是否存在netscape对象，FF
	   try{//用try来尝试使用对象
	       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
	   }catch(e){//如果不能使用剪贴板，提示用户出错
	       return false;
	   }
	   var clip,trans,str={},clipid;
	   if(!(clip=Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard))) return;
	   if(!(trans=Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable))) return;
	   trans.addDataFlavor("text/unicode");
	   str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
	   str.data=text;
	   trans.setTransferData("text/unicode",str,text.length*2);
	   clipid=Components.interfaces.nsIClipboard;
	   try{
	       clip.setData(trans,null,clipid.kGlobalClipboard);
	   }catch(e){return false}
	}return true;
}
function checkall(o,n){
  var i=0;
  var os=document.getElementsByName(o);
  for(;i<os.length;i++){
    if(!os[i].disabled)os[i].checked=n;
  }
}
function _ScrollTextW(arr){
  try{
    var t=0;
  	eval(arr[4]+' = ('+arr[4]+'+1)%('+arr[1]+'.length)');
  	eval('document.getElementById("'+arr[0]+'").style.top=('+arr[5]+'-'+arr[4]+'*'+arr[5]+')+"px";');
  	eval('t='+parseInt(arr[5]*0.6)+'-'+arr[4]+'*'+arr[5]+';');
  	eval('setTimeout(\'document.getElementById("'+arr[0]+'").style.top="'+t+'px"\',100);');
  	eval('t='+parseInt(arr[5]*0.3)+'-'+arr[4]+'*'+arr[5]+';');
  	eval('setTimeout(\'document.getElementById("'+arr[0]+'").style.top="'+t+'px"\',200);');
  	eval('t='+parseInt(arr[5]*0.1)+'-'+arr[4]+'*'+arr[5]+';');
  	eval('setTimeout(\'document.getElementById("'+arr[0]+'").style.top="'+t+'px"\',300);');
  	eval('t=0-'+arr[4]+'*'+arr[5]+';');
  	eval('setTimeout(\'document.getElementById("'+arr[0]+'").style.top="'+t+'px"\',400);');
	}catch(e){}
}
function _CreateScrollTextW(arr){//arr-配置数组，0-目标呈现ID，1-公告内容数组，2-滚动定时器handle，3-配置数组名字，4-当前index，5-行距，6-间隔
  try{
    var t,broadcastList;
    eval('if(!window.'+arr[1]+')broadcastList=new Array("&nbsp;");else broadcastList=window.'+arr[1]+';');
  	document.getElementById(arr[0]).innerHTML=broadcastList.join("<br>");
  	eval('if(broadcastList.length>1 && !'+arr[2]+')	'+arr[2]+' = setInterval("ScrollTextW('+arr[3]+')",'+arr[6]+');');
  	eval('document.getElementById("'+arr[0]+'").onmouseover = function(){clearInterval('+arr[2]+');}');
  	eval('document.getElementById("'+arr[0]+'").onmouseout = function(){'+arr[2]+' = setInterval("ScrollTextW('+arr[3]+')",'+arr[6]+');}');
  }catch(e){}
}
function ScrollTextW(o){
  try{
    var t1=t2=t3=t4=0,oo;
    if(o.obj)oo=o.obj;else oo=document.getElementById(o.id);
  	o.cur = ++o.cur%o.count;
  	t1=parseInt(o.lineheight*0.6)-o.cur*o.lineheight;
  	setTimeout(function(){oo.style.margin=t1+"px 0 0 0";},100);
  	t2=parseInt(o.lineheight*0.3)-o.cur*o.lineheight;
  	setTimeout(function(){oo.style.margin=t2+"px 0 0 0";},200);
  	t3=parseInt(o.lineheight*0.1)-o.cur*o.lineheight;
  	setTimeout(function(){oo.style.margin=t3+"px 0 0 0";},300);
  	t4=0-o.cur*o.lineheight;
  	setTimeout(function(){oo.style.margin=t4+"px 0 0 0";},400);
	}catch(e){}
}
function CreateScrollTextW(o){//id-目标呈现ID，arr-公告内容数组，count-条目总数，tmr-滚动定时器handle，cur-当前index，lineheight-行距，timestep-间隔
  try{
    var t,broadcastList,oo;
    if(o.cur==undefined)o.cur=0;
    if(o.tmr==undefined)o.tmr=0;
    if(o.obj)oo=o.obj;else oo=document.getElementById(o.id);
    if(o.arr!=undefined){
    	broadcastList=o.arr;
  		oo.innerHTML=broadcastList.join("<br />");
  		o.count=o.arr.length;
  	}
  	if(o.count>1 && !o.tmr)o.tmr = setInterval(function(){ScrollTextW(o);},o.timestep);
  	oo.onmouseover = function(){clearInterval(o.tmr);};
  	oo.onmouseout = function(){o.tmr = setInterval(function(){ScrollTextW(o);},o.timestep);};
  }catch(e){}
}
function setobjectdisplay(o,s){
	try{
		var oo;
		oo=document.getElementById(o);
		oo.style.display=s;
	}catch(e){}
}
function addEvent( obj, type, fn ) { 
   if ( obj.attachEvent ) { 
     obj['e'+type+fn] = fn; 
     obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
     obj.attachEvent( 'on'+type, obj[type+fn] ); 
   } else 
     obj.addEventListener( type, fn, false ); 
} 
function removeEvent( obj, type, fn ) { 
   if ( obj.detachEvent ) { 
     obj.detachEvent( 'on'+type, obj[type+fn] ); 
     obj[type+fn] = null; 
   } else 
     obj.removeEventListener( type, fn, false ); 
}
function select_init(o){//o,id,arr,simple,_1,_2
  var i=0;
  try{
    var oo;
  	if(o.o)oo=o.o;else oo=document.getElementById(o.id);
    oo.length=0;
    for(i=0;i<o.arr.length;i++){
      if(o.simple){
        oo[oo.length]=new Option(o.arr[i],o.arr[i]);
      }else{
        oo[oo.length]=new Option(o.arr[i][o._1?o._1:0],o.arr[i][o._2?o._2:0]);
      }
    }
    oo.onchange();
  }catch(e){}
}
function select_change(o){//o,o1,id,id1,arr
  var i=0,j=0;
  var s="";
  var oo,oo1;
  if(o.o)oo=o.o;else oo=document.getElementById(o.id);
  if(o.o1)oo1=o.o1;else oo1=document.getElementById(o.id1);
  try{
    s=oo[oo.selectedIndex].value;
    for(i=0;i<o.arr.length;i++){
      if(s==o.arr[i][0]){j=i+1;break;}
    }
    if(j>0){
      j--;
      s=o.arr[j][1].split("|||");
      select_init({simple:true,o:oo1,arr:s});
    }
  }catch(e){}
}
function select_special(o){//o,id,index,value,text
  var i=0;
  try{
  	var oo;
  	if(o.o)oo=o.o;else oo=document.getElementById(o.id);
  	if(o.index){
      oo.selectedIndex=o.index;
    }else if(o.value){
      for(i=0;i<oo.length;i++){
        if(oo[i].value==o.value){
          oo.selectedIndex=i;
          break;
        }
      }
    }else if(o.text){
      for(i=0;i<oo.length;i++){
        if(oo[i].text==o.text){
          oo.selectedIndex=i;
          break;
        }
      }
    }
    oo.onchange();
  }catch(e){}
}
function showTipWindow(_id,_id1,iscursor,e){
	try{
		if(!ispageloaded)return false;
		var m = "mask";
		var o=document.getElementById(_id);
		var DivLeft,DivTop,scrollH,scrollW,curH,curW,curX,curY;
		var nwidth,nheight;
		scrollH=(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);
		scrollW=(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0);
		curH=(document.documentElement.clientHeight||document.body.clientHeight);
		curW=(document.documentElement.clientWidth||document.body.clientWidth);
		curX=(e.clientX?e.clientX:30);
		curY=(e.clientY?e.clientY:30);
		if (o) document.body.removeChild(o);
		var newDiv = document.createElement("div");
		newDiv.id = _id;
		newDiv.name = _id;
		newDiv.style.position = "absolute";
		newDiv.style.zIndex = "999";
		newDiv.style.background = "transparent";
		newDiv.innerHTML = document.getElementById(_id1).innerHTML.replace(/__dstid__/g,_id)+'<iframe src="javascript:false" id="'+_id+'_frame" style="border:none;position:absolute; visibility:inherit;top:0px;left:0px;z-index:-1;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\';"></iframe>';
		document.body.appendChild(newDiv);
		nwidth=newDiv.offsetWidth||newDiv.clientWidth;
		nheight=newDiv.offsetHeight||newDiv.clientHeight;
		if(nwidth<1&&arguments[4])nwidth=arguments[4];
		if(nheight<1&&arguments[5])nheight=arguments[5];
		if(iscursor)DivTop = (curY+scrollH);else DivTop = ((curH&&nheight?parseInt((curH-nheight)/2):(curH?parseInt(curH/2):400))+scrollH);
		if(iscursor)DivLeft = (curX - nwidth);else DivLeft=parseInt(curW - nwidth)/2;
		if(DivLeft<30)DivLeft=30;
		if(document.curW-DivLeft<30)DivLeft=curW-30;
		if(DivTop<30)DivTop=30;
		if(scrollH+curH-DivTop<70)DivTop=scrollH+curH-70;
		newDiv.style.left=DivLeft+"px";
		newDiv.style.top=DivTop+"px";
		document.getElementById(_id+'_frame').style.width=nwidth;
		document.getElementById(_id+'_frame').style.height=nheight;
		//alert(curW+" "+curH+" "+nwidth+" "+nheight+" "+DivTop+" "+DivLeft);
		return true;
	}catch(e){return false;}
}
function createdropmenu(id){
	var sfEls = document.getElementById(id);
	sfEls.onmouseover=function() {
		this.className+=" sfhover";
	}
	sfEls.onmouseout=function() {
		this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	}
}
function createdropmenus(id){
	var sfEls = document.getElementById(id).getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function onlynum(e){
	e=e||event;
  if(!(e.keyCode>=48&&e.keyCode<=57)&&!(e.keyCode>=96&&e.keyCode<=105)&&e.keyCode>31){return false;}//&&!(e.keyCode>=112&&e.keyCode<=123)
  return true;
}
function insertCode(o,s1,s2) {
	try{
		if(document.selection&&document.selection.type=="Text"){
			var range = document.selection.createRange();
			range.text=s1+range.text+s2;
		}else{
			AddTxt=s1+s2;
			insertText(o,AddTxt);
		}
	}catch(e){}
}
function insertText(o,NewCode){
	try{
		var oo=(o.obj?o.obj:document.getElementById(o.id));
		if(document.all){
			if(oo.createTextRange&&oo.caretPos){
				var caretPos=oo.caretPos;
				caretPos.text+=caretPos.text.charAt(caretPos.text.length-2)==' '?NewCode+' ':NewCode;
			}else if(oo){
				oo.value+=NewCode;
			}else{
				oo.value=NewCode;
			}
			oo.focus();
		}else{
			oo.value+=NewCode;
			oo.focus();
		}
	}catch(e){}
}
function digObject(o){try{var s="";var oo=(o.obj?o.obj:document.getElementById(o.id));for(var i in oo)s+=i+":"+oo[i]+"\n";return s;}catch(e){}}
function CtrlEnter(src,event){var e=event||window.event;if(e.ctrlKey && e.keyCode==13) document.getElementById(src).click();}

function SetHome(obj){
	var vrl="http://www.runrungo.com"
	try{
	   obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e){
	   if(window.netscape) {
		 try {
		  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		 } 
		 catch (e) { 
		  alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
		 }
		 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		 prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}
function AddFavorite(){
	var sTitle="人人购 RunRunGo! - 每天第一个惊喜，从人人购开始"
	var sURL="http://www.runrungo.com"
	
	try
	{
		window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
		try
		{
		   window.sidebar.addPanel(sTitle, sURL, "");
		}
		catch (e)
		{
		   alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}
function showEmotList(p){
	try{
		if(!this._i)this._i=10;
		n=this._i;
		if(p>0)n+=9;
		else n-=9;
		if(n<1||n>47||n%9!=1)return false;
		var i=0,s="";
		for(i=n;i<=n+8&&i<=47;i++){
			if(i%3==1)s+="<div>";
			s+='<li><img onclick="bbsPost.insertSmilies(\'[em'+"00".substr(0,2-i.toString().length).toString()+i+']\')" src="/misc/images/emot/em'+"00".substr(0,2-i.toString().length).toString()+i+'.gif" /></li>';
			if(i%3==0)s+='</div>';
		}
		if(i%3!=1)s+="</div>";
		document.getElementById('emotlist_inner').innerHTML=s;
		this._i=n;
		return true;
	}catch(e){return false;}
}
function showSubMenu(id,id1){
	try{
		$('#'+id1).css({left:$('#'+id).offset().left,top:$('#'+id).offset().top+$('#'+id).height()+5});
		$('#'+id).hover(
			function(){
				$('#'+id1).css('display','block');
				$('._Search').hide();
				this.tmrOut=0;
			},
			function(){
				this.tmrOut=setTimeout(function(){$('#'+id1).mouseout();},200);
			}
		);
		$('#'+id1).hover(
			function(){
				if($('#'+id)[0].tmrOut)clearTimeout($('#'+id)[0].tmrOut);
				$('#'+id)[0].tmrOut=0;
			},
			function(){
				$('#'+id1).css('display','none');
				$('._Search').show();
			}
		);
	}catch(e){}
}