// JavaScript Document
function getid(id){return document.getElementById(id);}
function gettag(tag){return document.getElementsByTagName(tag)}
function getChildTag(id,tag){return id.getElementsByTagName(tag)}
function getclass(className){return getElementsByClassName(className)}
var $c=function(array){var nArray = [];for (var i=0;i<array.length;i++) nArray.push(array[i]);return nArray;};
    Array.prototype.each=function(func){for(var i=0,l=this.length;i<l;i++) {func(this[i],i);};};
var getElementsByClassName=function(cn){
	    var hasClass=function(w,Name){
	    var hasClass = false;
        w.className.split(' ').each(function(s){
            if (s == Name) hasClass = true;
        });
        return hasClass;
            }; 
        var elems =document.getElementsByTagName("*")||document.all;
            var elemList = [];
           $c(elems).each(function(e){
               if(hasClass(e,cn)){elemList.push(e);}
           })
            return $c(elemList);
    };        
//goto_top
var sh,shtimer,shc;
//返回顶端
function top(){
	sh=document.documentElement.scrollTop;
	shc=Math.round(sh*0.10);
	if(sh>0){etop();}	
	}
function etop(){
	sh-=shc;
	if(shc>12){
		shc-=6;
		}
	if(sh>=0){ 
	window.scrollTo(0,sh);
	shtimer=setTimeout("etop()",10);
	}else{
		window.scrollTo(0,0);
		clearTimeout(shtimer);
		}
	}
//window.onscroll=function(){gotop_p()};
//top_button
function gotop_p(){
 var id=getid("gotop");
 id.style.right=(document.body.clientWidth/2-500)+"px";
 id.style.top=(window.screen.height*0.8+document.documentElement.scrollTop)+"px";
	}
//scroll_band
var s,s2,s3,timer;
function init(){
s=getid("div1");
s2=getid("div2");
s3=getid("div3");
s3.innerHTML=s2.innerHTML;
timer=setInterval(mar,30)
}
function mar(){
if(s2.offsetWidth<=s.scrollLeft){
s.scrollLeft-=s2.offsetWidth;
}else{s.scrollLeft++;}
}
//menu
function menu(){
var m=document.getElementById("add_menu").getElementsByTagName("li");
var cm=document.getElementById("child_menu");
for(var i=0;i<m.length;i++){
	m[i].className="coffee_add_m"+(i+1);
	m[i].index=i;
	m[i].onmouseover=function(){this.style.backgroundImage="url(http://images.ge.the9.com/images_gev5/bar/images2/coffee_add_menu2.jpg)";if(this.index==m.length-1){cm.style.display="block";cm.style.left=(document.body.clientWidth/2+210)+"px";}};
	m[i].onmouseout=function(){this.style.backgroundImage="url(http://images.ge.the9.com/images_gev5/bar/images2/coffee_add_menu1.jpg)";if(this.index==m.length-1){cm.style.display="none";}};	
	m[i].getElementsByTagName("a")[0].onfocus=function(){this.blur()};
	}
}
//tabs
function tabs(){
	if(document.getElementById("tabs")!=null){
  var tab=document.getElementById("tabs").getElementsByTagName("a"),li=document.getElementById("tabs").getElementsByTagName("li");
  tab[0].onclick=function(){tabs_hidden();li[0].className="current1_2";if(getclass("content_left_bottom2_lc").length>0){getclass("content_left_bottom2_lc")[1].style.display="block";getclass("content_left_bottom2_lc")[0].style.display="none";}};
  tab[1].onclick=function(){tabs_hidden();li[1].className="current";if(getclass("content_left_bottom2_lc").length>0){getclass("content_left_bottom2_lc")[0].style.display="block";getclass("content_left_bottom2_lc")[1].style.display="none";}};
  if(tab.length>2){
	  if(tab.length==3){tab[2].onclick=function(){tabs_hidden();li[2].className="current3_2";};}else{
	  tab[2].onclick=function(){tabs_hidden();li[2].className="current";};
      tab[3].onclick=function(){tabs_hidden();li[3].className="current3_2";};
	  }
  }
  for(var i=0;i<tab.length;i++){tab[i].onfocus=function(){this.blur()};}
	}
}
function tabs_hidden(){
  var li=document.getElementById("tabs").getElementsByTagName("li");
  li[0].className="current1";
  li[1].className="";
  if(li.length>2){
	  if(li.length==3){li[2].className="current3";}else{
  li[2].className=""
  li[3].className="current3";
	  }
  }
	}
//png
var title;
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters))
    {
       for(var j=0; j<document.images.length; j++)
       {
          var img = document.images[j]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
          {
             var imgID = (img.id) ? "id='" + img.id + "' " : ""
             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
             var imgStyle = "display:inline-block;" + img.style.cssText
             if (img.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
             var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
             img.outerHTML = strNewHTML
             j = j-1
          }
       }
    }    
}
window.onload=function(){
	init();
	menu();
	tabs();
	correctPNG();	
}
//reply
function reply(){
var container=getclass("content_left_band_line2");
var button=getclass("l_c_b1");
var reply_box=document.createElement("div");
reply_box.innerHTML="<textarea>输入回复内容</textarea><div><input type=\"button\" value=\"发布\" class=\"l_c_b1_p\"/></div>";
for(var i=0;i<button.length;i++){
button[i].index=i;
button[i].onclick=function(){reply_box.style.display="block";reply_box.setAttribute("num",this.index);container[this.index].appendChild(reply_box);reply_box.className="content_left_band_line2_div3";getclass("l_c_b1_p")[0].onclick=function(){var txt=getChildTag(reply_box,"textarea")[0];alert("你回复了第"+String(parseInt(reply_box.getAttribute("num"))+1)+"条留言\n\n你回复的内容是："+txt.value);reply_box.style.display="none";};};
}
}


function show_message(){
   var h=document.body.scrollHeight,w=document.body.scrollWidth,bg=document.getElementById("bg"),oct=document.getElementById("oc"),oh=window.screen.height;
   bg.style.height=h>oh?h+"px":oh+"px";
   bg.style.width=w+"px";
   bg.className="office_bg";
   oct.className="mhp_message";
   document.getElementById("f_c_i").value="";
   oct.style.left=Math.round((w-336)/2)+"px";
   oct.style.top=Math.round((oh-160)/2)+"px";
   document.getElementsByTagName("select")[0].style.visibility="hidden";
}

function hidden(){
	document.getElementById("bg").className="office_bg2";
	document.getElementById("oc").className="office_bg2";
	document.getElementsByTagName("select")[0].style.visibility="visible";
	}
function check(){
	var it=document.getElementById("f_c_i");
	if(it.value==""||it.value=="请填写内容!"){alert("你还未填写留言！");it.value="请填写内容!";} else{hidden();alert("留言成功！");}
	}

function clear_title(tid){
	if(!title){
		document.getElementById(tid).value="";
		title=!title;
		}
	}
//radio
function change_select(id){
	for(i=1;i<=3;i++){
		document.getElementById("pr"+i).className="content_left_pa_radio";
		}
	document.getElementById(id).className="content_left_pa_radio_selected";
	}
	
//下拉框select
<!-- 
var groups,group,temp;
    function Init(){
    groups=document.getElementById("example").options.length
    group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()
	group[0][0]=new Option("你所在的服务器","")
    group[1][0]=new Option("雷波多","b0_1")
    group[1][1]=new Option("波尔德","b0_2")
    group[1][2]=new Option("雄狮平原","b0_3")
	group[1][3]=new Option("女巫峡谷","b0_4")
    group[1][4]=new Option("烈火岛","b0_5")
    group[1][5]=new Option("魔女沼泽","b0_6")

	group[2][0]=new Option("科贝拉","b1_1")
    group[2][1]=new Option("伯纳河","b1_2")
    group[2][2]=new Option("拜尔罗","b1_3")
	group[2][3]=new Option("女神之湖","b1_4")
    group[2][4]=new Option("切尼萨","b1_5")
    group[2][5]=new Option("王宫花园","b1_6")

	group[3][0]=new Option("纯白之地","b2_1")
    group[3][1]=new Option("提斯丛林","b2_2")
	
	group[4][0]=new Option("王者之战","b3_1")

    temp=document.getElementById("stage2")
	//document.getElementById("m1").style.display="none";
	document.getElementById("example").style.visibility="visible";
    document.getElementById("stage2").style.visibility="visible";
	}
    function redirect(x)
    {
        for (m=temp.options.length-1;m>0;m--)
        temp.options[m]=null
        for (i=0;i<group[x].length;i++)
        {
            temp.options[i]=new Option(group[x][i].text,group[x][i].value)
        }
        temp.options[0].selected=true
    }
    function go()
    {
        var id=temp.options[temp.selectedIndex].value;
    }
//-->