// JavaScript Document

/*MMOsite top & mmosite footer*/
function holicHeader(){
   mmoHeader()
}
function holicFooter(){
   mmoFooter()
}

///////////////////////////*Book mark*///////////////////////////
function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}


////////////////////* Ask & Answer*//////////////////////////////////////////
function showAsk(status,url,id)
{

document.getElementById("ifram").src=url+"answer_"+id+"_"+status+".htm";
}
function showUrl(sourceUrl,gameid, title)
{

window.open(sourceUrl+"?title="+title+"&parentid="+gameid,"_blank");
} 


///////////////////////////////////////////////////////////
// "Live Clock" script (3.0)
// By Mark Plachetta (astroboy@zip.com.au)
// http://www.zip.com.au/~astroboy/liveclock/
///////////////////////////////////////////////////////////

var LC_Style=[
	"Arial",			// clock font
	"2",				// font size
	"black",			// font colour
	"white",			// background colour
	"The time is: ",	// html before time
	"",					// html after time
	300,				// clock width
	0,					// 12(1) or 24(0) hour?
	1,					// update never(0) secondly(1) minutely(2)
	0,					// no date(0) dd/mm/yy(1) mm/dd/yy(2) DDDD MMMM(3) DDDD MMMM YYYY(4)
	0,					// abbreviate days/months yes(1) no(0)
	null				// gmt offset (null to disable)
];

///////////////////////////////////////////////////////////

var LC_IE=(document.all);
var LC_NS=(document.layers);
var LC_N6=(window.sidebar);
var LC_Old=(!LC_IE && !LC_NS && !LC_N6);

var LC_Clocks=new Array();

var LC_DaysOfWeek=[
	["Sunday","Sun"],
	["Monday","Mon"],
	["Tuesday","Tue"],
	["Wednesday","Wed"],
	["Thursday","Thu"],
	["Friday","Fri"],
	["Saturday","Sat"]
];

var LC_MonthsOfYear=[
	["January","Jan"],
	["February","Feb"],
	["March","Mar"],
	["April","Apr"],
	["May","May"],
	["June","Jun"],
	["July","Jul"],
	["August","Aug"],
	["September","Sep"],
	["October","Oct"],
	["November","Nov"],
	["December","Dec"]
];

var LC_ClockUpdate=[0,1000,60000];

///////////////////////////////////////////////////////////

function LC_CreateClock(c) {
	if(LC_IE||LC_N6){clockTags='<span id="'+c.Name+'" style="width:'+c.Width+'px;background-color:'+c.BackColor+'"></span>'}
	else if(LC_NS){clockTags='<ilayer width="'+c.Width+'" bgColor="'+c.BackColor+'" id="'+c.Name+'Pos"><layer id="'+c.Name+'"></layer></ilayer>'}

	if(!LC_Old){document.write(clockTags)}
	else{LC_UpdateClock(LC_Clocks.length-1)}
}

function LC_InitializeClocks(){
	LC_OtherOnloads();
	if(LC_Old){return}
	for(i=0;i<LC_Clocks.length;i++){
		LC_UpdateClock(i);
		if (LC_Clocks[i].Update) {
			eval('var '+LC_Clocks[i].Name+'=setInterval("LC_UpdateClock("+'+i+'+")",'+LC_ClockUpdate[LC_Clocks[i].Update]+')');
		}
	}
}

function LC_UpdateClock(Clock){
	var c=LC_Clocks[Clock];

	var t=new Date();
	
	if(!isNaN(c.GMT)){
	var offset=t.getTimezoneOffset();
	if(navigator.appVersion.indexOf('MSIE 3') != -1){offset=offset*(-1)}
		t.setTime(t.getTime()+offset*60000);
		t.setTime(t.getTime()+c.GMT*3600000);
	}
	
	var day=t.getDay();
	var md=t.getDate();
	var mnth=t.getMonth();
	var hrs=t.getHours();
	var mins=t.getMinutes();
	var secs=t.getSeconds();
	var yr=t.getYear();

	if(yr<1900){yr+=1900}

	if(c.DisplayDate>=3){
		md+="";
		abbrev="th";
		if(md.charAt(md.length-2)!=1){
			var tmp=md.charAt(md.length-1);
			if(tmp==1){abbrev="st"}
			else if(tmp==2){abbrev="nd"}
			else if(tmp==3){abbrev="rd"}
		}
		md+=abbrev;
	}

	var ampm="";
	if(c.Hour12==1){
		ampm="AM";
		if(hrs>=12){ampm="PM"; hrs-=12}
		if(hrs==0){hrs=12}
	}
	if(mins<=9){mins="0"+mins}
	if(secs<=9){secs="0"+secs}

	var html = '<font color="'+c.FntColor+'" face="'+c.FntFace+'" size="'+c.FntSize+'">';
	html+=c.OpenTags;
	html+=hrs+':'+mins;
	if(c.Update==1){html+=':'+secs}
	if(c.Hour12){html+=' '+ampm}
	if(c.DisplayDate==1){html+=' '+md+'/'+(mnth+1)+'/'+yr}
	if(c.DisplayDate==2){html+=' ('+LC_DaysOfWeek[day][c.Abbreviate]+', '+md+'/'+(mnth+1)+')'}
	if(c.DisplayDate>=3){html+=' on '+LC_DaysOfWeek[day][c.Abbreviate]+', '+md+' '+LC_MonthsOfYear[mnth][c.Abbreviate]}
	if(c.DisplayDate>=4){html+=' '+yr}
	html+=c.CloseTags;
	html+='</font>';

	if(LC_NS){
		var l=document.layers[c.Name+"Pos"].document.layers[c.Name].document;
		l.open();
		l.write(html);
		l.close();
	}else if(LC_N6||LC_IE){
		document.getElementById(c.Name).innerHTML=html;
	}else{
		document.write(html);
	}
}

function LiveClock(a,b,c,d,e,f,g,h,i,j,k,l){
	this.Name='LiveClock'+LC_Clocks.length;
	this.FntFace=a||LC_Style[0];
	this.FntSize=b||LC_Style[1];
	this.FntColor=c||LC_Style[2];
	this.BackColor=d||LC_Style[3];
	this.OpenTags=e||LC_Style[4];
	this.CloseTags=f||LC_Style[5];
	this.Width=g||LC_Style[6];
	this.Hour12=h||LC_Style[7];
	this.Update=i||LC_Style[8];
	this.Abbreviate=j||LC_Style[10];
	this.DisplayDate=k||LC_Style[9];
	this.GMT=l||LC_Style[11];
	LC_Clocks[LC_Clocks.length]=this;
	LC_CreateClock(this);
}

///////////////////////////////////////////////////////////

LC_OtherOnloads=(window.onload)?window.onload:new Function;




///////////////////////////////////*Flash News*///////////////////////////////////////////
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=6000; 
	var show_text=1; 
	var txtcolor="dddddd";
	var bgcolor="000000";
	var imag=new Array();
	var link=new Array();
	var text=new Array();

	var flashUrl = 'http://images.mmosite.com/12sky2/images/flash/viewer.swf';


   for(var i=0;i<fpic.length;i++){
   imag[i]=fpic[i].src;
   }  

	var swf_height=pic_height;
	var pics="", links="", texts="";
	for(var i=0; i<imag.length; i++){
		pics=pics+("|"+imag[i]);
		links=links+("|"+flink[i]);
		
		
		links = links.replace(/(&)/g,"+");
		texts=texts+("|"+text[i]);
	}
	
	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 />"); 
}


/////////////////////////////////////*public_tabchange*///////////////////////////////////
function picon(id){
var ie=document.all?true:false;
if(ie){
id.filters.alpha.opacity=0
}else{
id.style.MozOpacity=0
}
}
function picoff(id){
var ie=document.all?true:false;
if(ie){
id.filters.alpha.opacity=100
}else{
id.style.MozOpacity=1
}
}

/*****************************************************
 * mySlideOutMenu
 * http://mySlideOutMenus.sourceforge.net/
 * 
 * a nice little script to create exclusive, slide-out
 * menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
 * mac and win32. I've got no linux or unix to test on but 
 * it should(?) work... 
 *
 * Licensed under AFL 2.0
 * http://www.opensource.org/licenses/afl-2.0.php
 *
 * Revised: 
 * - 08/29/2002 : added .hideAll()
 * - 04/15/2004 : added .writeCSS() to support more 
 *                than 30 menus.
 *
 * --youngpup--
 *****************************************************/



mySlideOutMenu.Registry = []
mySlideOutMenu.aniLen = 250
mySlideOutMenu.hideDelay = 500
mySlideOutMenu.minCPUResolution = 10

// constructor
function mySlideOutMenu(id, dir, left, top, width, height)
{

	
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0

	this.css = "";

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "mySlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		mySlideOutMenu.Registry[id] = this

		var d = document

		var strCSS = "";
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '		
		strCSS += 'overflow:hidden; z-index:10000; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += '}'

		this.css = strCSS;

		this.load()
	}
}

mySlideOutMenu.writeCSS = function() {
	document.writeln('<style type="text/css">');

	for (var id in mySlideOutMenu.Registry) {
		document.writeln(mySlideOutMenu.Registry[id].css);
	}

	document.writeln('</style>');
}

mySlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / mySlideOutMenu.aniLen / mySlideOutMenu.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("mySlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("mySlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide()
	}
}
	
mySlideOutMenu.showMenu = function(id)
{
	var reg = mySlideOutMenu.Registry
	var obj = mySlideOutMenu.Registry[id]
	
	if (obj.container) {
		obj.over = true

		// close other menus.
		for (menu in reg) if (id != menu) mySlideOutMenu.hide(menu)

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}

}

mySlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = mySlideOutMenu.Registry[id]
	if (obj.container) {
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("mySlideOutMenu.hide('" + id + "')", mySlideOutMenu.hideDelay);
	}
}

mySlideOutMenu.hideAll = function()
{
	var reg = mySlideOutMenu.Registry
	for (menu in reg) {
		mySlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}

mySlideOutMenu.hide = function(id)
{
	var obj = mySlideOutMenu.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

mySlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", mySlideOutMenu.minCPUResolution)
}

mySlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > mySlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(mySlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

mySlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}

mySlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
mySlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
mySlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

// events
mySlideOutMenu.prototype.onactivate		= function() { }
mySlideOutMenu.prototype.ondeactivate	= function() { }

var $ = function(i){return document.getElementById(i);}
var ua = navigator.userAgent.toLowerCase();
var isIE = (ua.indexOf("msie") > -1),isIE7 = (ua.indexOf("msie 7") > -1),isOpera = (ua.indexOf("opera") > -1),isSafari = (ua.indexOf("webkit") != -1 || ua.indexOf("khtml") != -1),isGecko = (!isSafari && ua.indexOf("gecko") > -1);

var switchpage = function(o, n, p){
   var ol = $(o+p);
   var cl = $(o+n);
   ol.style.display="none";
   cl.style.display="";
}

var p1 = 1;
function showpages(num){   
   switchpage("p1_", num, p1);
   p1 = num;
   
}

var p2 = 1;
function showpages2(num){   
   switchpage("p2_", num, p2);
   p2 = num;
   
}

/*****************************************************
 * mmosite flashmenu  gmfun.js
 *****************************************************/
function neton(element,value)
{
	
		if(window.addEventListener)
		{
		   // Mozilla, Netscape, Firefox
			element.addEventListener("mouseout", function(){ change_opacity("pic"+value,'up'); },true);
		}else{
			element.attachEvent("onmouseout", function(){ change_opacity("pic"+value,'up'); });
		}

}
function netout(element,value)
{
		if(window.addEventListener)
		{
		   // Mozilla, Netscape, Firefox
			element.addEventListener("mouseover", function(){ change_opacity("pic"+value,'down'); },true);
			}else{
			element.attachEvent("onmouseover", function(){ change_opacity("pic"+value,'down'); });
		
		}
}
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;//n:dtime
  var timers=new Array(n);
  var c=document.getElementById("beni").getElementsByTagName("div");
  for(var i=0;i<c.length;i++){
    c[i].index=i;
    c[i].onmouseover=function(){doSlide(this);setstyle(this,"on");}
	document.getElementById("s" + i).className="dian";
	if(c[i].className=="tag tagon"){
	document.getElementById("s" + i).className="dian2";
	}


  }
  
  //right onclick
  toright.onclick=function(){
   var c=document.getElementById("beni").getElementsByTagName("div");
   for(var i=0;i<c.length;i++){
	    if(c[i].className=="tag tagon"){
		tagindex=i;
		}  
   }
   if(tagindex < 3){
   doSlide(c[tagindex+1]);
   setstyle(c[tagindex+1],"on");
   }
  }
  //left onclick
  toleft.onclick=function(){
   var c=document.getElementById("beni").getElementsByTagName("div");
   for(var i=0;i<c.length;i++){
	    if(c[i].className=="tag tagon"){
		tagindex=i;
		}  
   }
   if(tagindex > 0){
   doSlide(c[tagindex-1]);
   setstyle(c[tagindex-1],"on");
   }
  }
		

  function setstyle(ci){
		  var c=document.getElementById("beni").getElementsByTagName("div");
	      for(var i=0;i<c.length;i++){
		  c[i].className="tag";
		  }
		  ci.className="tag tagon";
		  
	      for(var i=0;i<c.length;i++){
	document.getElementById("s" + i).className="dian";
	if(c[i].className=="tag tagon"){
	document.getElementById("s" + i ).className="dian2";
	}
		  }
  }
  
  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);
    })();
  }
}


