/*MMOsite top & mmosite footer*/
function aionHeader(){
	mmoHeader()
}
function aionFooter(){
	mmoFooter()
}

/*bluring*/
 
function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

/*Top flash ad*/
function playFlash(flashid){
    var fpic =document.getElementById(flashid).getElementsByTagName("img");
	var flink =document.getElementById(flashid).getElementsByTagName("a");
	var texts =document.getElementById(flashid).getElementsByTagName("a");
	var pic_width="280"; 
           var pic_height="210"; 
	var button_pos=fpic.length;
	var stop_time=4800; 
	var show_text=0; 
	var txtcolor="dddddd";
	var bgcolor="000000";
	var imag=new Array();
	var link=new Array();
	var text=new Array();

	var flashUrl = 'http://images.mmosite.com/aion/focus/viewer.swf';


   for(var i=0;i<fpic.length;i++){
   imag[i]=fpic[i].src;
   }  

	var swf_height=show_text==1?pic_height+0:pic_height;
	var pics="", links="", texts="";
	for(var i=0; i<imag.length; i++){
		pics=pics+("|"+imag[i]);
		links=links+("|"+flink[i]);

		//links=links+("|"+flink[i*2]);
		
		links = links.replace(/(&)/g,"+");
		texts=texts+("|"+text[i]);
		//alert(flink[i*2]);
	}
	
	pics=pics.substring(1);
	links=links.substring(1);
	texts=texts.substring(1);
	
	
	var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ pic_width +'" height="' + pic_height +'" /><param name="allowScriptAccess" value="always" />';
	flash = flash + '<param name="movie" value="'+ flashUrl +'" />';
	flash = flash + '<param name="quality" value="high" />';
	flash = flash + '<param name="menu" value="false" />';
	flash = flash + '<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&picwidth='+pic_width+'&picheight='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'">';
    flash = flash + '<param name="wmode" value="transparent" />';
	flash = flash + '<embed wmode="transparent" src="' + flashUrl + '" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&picwidth='+pic_width+'&picheight='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"allowScriptAccess="always"  />';
	flash = flash + '</object>';
	document.writeln(flash); 
	//document.writeln(links+"<br />"); 
}

/*****************************************************
 * mmosite flashmenu
 *****************************************************/
window.onload=function(){
  var ele=document.getElementById("scroller");
  var toleft=document.getElementById("toleft");
  var toright=document.getElementById("toright");
  var w=ele.clientWidth;
 
  var n=20,t=20
  var timers=new Array(n);
  var c=document.getElementById("beni").getElementsByTagName("a");
  for(var i=0;i<c.length;i++){
    c[i].index=i;
    c[i].onmouseover=function(){
		doSlide(this);
		setstyle(this,"on1");
	}
	document.getElementById("s" + i).className="";
	if(c[i].parentNode.className=="on1"){
		document.getElementById("s" + i).className="on2";
	}
  }
  //right onclick
  toright.onclick=function(){
   var c=document.getElementById("beni").getElementsByTagName("a");
   var tagindex;
   for(var i=0;i<c.length;i++){
	    if(c[i].parentNode.className=="on1"){
			tagindex=i;
		}  
   }
   if(tagindex < 3){
     doSlide(c[tagindex+1]);
     setstyle(c[tagindex+1],"on1");
   }
   return false;
  }
  //left onclick
  toleft.onclick=function(){
   var c=document.getElementById("beni").getElementsByTagName("a");
   var tagindex;
   for(var i=0;i<c.length;i++){
	    if(c[i].parentNode.className=="on1"){
			tagindex=i;
		}  
   }
   if(tagindex > 0){
	   doSlide(c[tagindex-1]);
	   setstyle(c[tagindex-1],"on1");
   }
   return false;
  }
		

  function setstyle(ci){
		  var c=document.getElementById("beni").getElementsByTagName("a");
	      for(var i=0;i<c.length;i++){
		  	c[i].parentNode.className="";
		  }
		  ci.parentNode.className="on1";
		  
	      for(var i=0;i<c.length;i++){
			document.getElementById("s" + i).className="";
			if(c[i].parentNode.className=="on1"){
			document.getElementById("s" + i ).className="on2";
			}
		  }
  }
  
  c=null;
  function doSlide(ir){
    var x=ele.scrollLeft;
    var d=ir.index*w-x;
	
    if(!d) return;
    for(var i=0;i<n;i++)(function(){
      if(timers[i])
        clearTimeout(timers[i]);
      var j=i;
      timers[i]=setTimeout(function(){
        ele.scrollLeft=x+Math.round(d*Math.sin(Math.PI*(j+1)/(2*n)));
      },(i+1)*t);
    })();
  }
}

/*leftmenu openshut*/
function openShutManager(oSourceObj,oTargetObj,shutAble,oOpenTip,oShutTip){
var sourceObj = typeof oSourceObj == "string" ? document.getElementById(oSourceObj) : oSourceObj;
var targetObj = typeof oTargetObj == "string" ? document.getElementById(oTargetObj) : oTargetObj;
var openTip = oOpenTip || "";
var shutTip = oShutTip || "";
if(targetObj.style.display!="none"){
   if(shutAble) return;
   targetObj.style.display="none";
   if(openTip  &&  shutTip){
    sourceObj.innerHTML = shutTip; 
   }
} else {
   targetObj.style.display="block";
   if(openTip  &&  shutTip){
    sourceObj.innerHTML = openTip; 
   }
}
}
/**************************************
setTab
***************************************/

//setTab
function setTab(id1, tag1, tabclass, id2, tag2, changeEvent, changeTime, isClick, isClickAll, fadeTime,isReturnFalse) {
  var tli = document.getElementById(id1).getElementsByTagName(tag1);
  var cli = document.getElementById(id2).getElementsByTagName(tag2);
  var temp = 0;
  var opaStep = 0.1;
  var isScroll = true;
  for (i = 0; i < tli.length; i++) {
    cli[i].style.display = "none";
  }
  tli[temp].className = tabclass;
  cli[temp].style.display = "block";
  for (i = 0; i < tli.length; i++) {
    tli[i].value = i;
    tli[i].onmouseout = function() {
      isScroll = true;
    }
    tli[i].onmouseover = function() {
      isScroll = false;
    }
    if (changeEvent == "click") {
      tli[i].onclick = function() {
        setTabCon(this.value);
				if(isReturnFalse){
						 return false;
					}
      }
    } else if (changeEvent == "hover") {
      tli[i].onmouseover = function() {
        setTabCon2(this.value);
        isScroll = false;
      }
      tli[i].onclick = function() {
        setTabCon(this.value);
       	if(isReturnFalse){
						 return false;
					}
      }
    }
  }

  //Tab1
  function setTabCon(n) {
    if (isClickAll) {
      tli[n].className = (tli[n].className == "on") ? "": "on";
      if (fadeTime) { (cli[n].style.display == "block") ? fadeOut(cli[n]) : fadeIn(cli[n]);
      } else {
        cli[n].style.display = (cli[n].style.display == "block") ? "none": "block";
      }
    } else if (isClick) {
      for (j = 0; j < tli.length; j++) {
        tli[j].className = n == j ? tabclass: "";
        if (fadeTime) {
          if (n == j) {
            if (cli[j].style.display == "none") {
              fadeIn(cli[j]);
            } else {
              fadeOut(cli[j])
            };
          } else {
            cli[j].style.display = "none";
            /*fadeOut(cli[j]);*/
          }
        } else {
          cli[j].style.display = n == j ? "block": "none";
        }
      }
      temp = n;
    } else {
      for (j = 0; j < tli.length; j++) {
        tli[j].className = n == j ? tabclass: "";
        if (fadeTime) {
          if (n == j) {
            if (cli[j].style.display == "none") {
              fadeIn(cli[j]);
            }
          } else {
            cli[j].style.display = "none";
            /*fadeOut(cli[j]);*/
          }
        } else {
          cli[j].style.display = n == j ? "block": "none";
        }
      }
      temp = n;
    }
  }

  //Tab2
  function setTabCon2(n) {
    for (j = 0; j < tli.length; j++) {
      tli[j].className = n == j ? tabclass: "";
      if (fadeTime) {
        if (n == j) {
          if (cli[j].style.display == "none") {
            fadeIn(cli[j]);
          }
        } else {
          cli[j].style.display = "none";
          /*fadeOut(cli[j]);*/
        }
      } else {
        cli[j].style.display = n == j ? "block": "none";
      }
    }
    temp = n;
  }

  //setAlpha
  function setAlpha(obj, opa) {
    document.all ? obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opa * 100 + ")": obj.style.opacity = opa;
		
  }

  //FadeIn
  function fadeIn(obj) {
    obj.style.display = "block";
    var opa = 0;
    function setFadeIn() {
		
      if (opa < 1) {
        setAlpha(obj, opa);
        opa += opaStep;
        setTimeout(setFadeIn, fadeTime);
      }
    }
    setFadeIn();
  }

  //FadeOut
  function fadeOut(obj) {
    var opa = 1;
    function setFadeOut() {
      if (opa > 0) {
        setAlpha(obj, opa);
        opa -= opaStep;
        setTimeout(setFadeOut, fadeTime);
      } else {
        obj.style.display = "none";
      }
    }
    setFadeOut();
  }

  //Set changeTime
  if (changeTime) {
    function setTiming() {
      if (isScroll) {
        setTabCon2(temp);
        temp++;
        temp = (temp == tli.length) ? 0 : temp;
      }
      setTimeout(setTiming, changeTime);
    }
    setTiming();
  }
}
/**************************************
setTrBg
***************************************/

//td background
function setTrBg(id,tagName, color1, color2) {
  var trs = document.getElementById(id).getElementsByTagName(tagName);
    for (j = 0; j < trs.length; j++) {
      trs[j].style.backgroundColor = (j % 2 == 0) ? color1: color2;
  }
}

/*navigation*/

new mySlideOutMenu("menu1", "down", 50, 52, 600, 30);
	new mySlideOutMenu("menu2", "down", 175, 52, 600, 30);
	new mySlideOutMenu("menu3", "down", 280, 52, 600, 30);
	new mySlideOutMenu("menu4", "down", 260, 52, 600, 30);
	new mySlideOutMenu("menu5", "down", 300, 52, 600, 30);
	new mySlideOutMenu("menu6", "down", 390, 52, 600, 30);
    mySlideOutMenu.writeCSS();
	

var Fid = function(i){return document.getElementById(i);}

var switchMusic = function(o, n, p){
   var ol = Fid(o+p);
   var cl = Fid(o+n);
   ol.style.display="none";
   cl.style.display="";
}
var doClearStyle = function( num,tab,newStyle ){
	var li = Fid( tab ).getElementsByTagName( "li" );
	for( var i = 0; i < li.length; i++ ){
		if( ( num-1 ) == i ){
			li[i].className = newStyle;
		} else {
			li[i].className = "";
		}
	}
}
/**
*第一个标签切换
*/
var m1 = 1;
function xx( num ){  
   doClearStyle( num,"tab_02","tab_on" );
   
   switchMusic("xtab2_cnt", num, m1);
   m1 = num;
   return false;
}

function doDisplay( no ){
	Fid( "xx" + no ).style.display = Fid( "xx" + no ).style.display == "none"? "block":"none";
	return false;
}