var siteUrl = "http://accounts.mmosite.com/";

//if (typeof($) != 'function') {
//	function $(id) {
//		return document.getElementById(id);
//	}
//}


function accountsHeader(){
mmoHeader()
}
function accountsFooter(){
mmoFooter()
}


function getWindowSize(){
	return {
		Width:Math.max(document.body.scrollWidth, document.body.clientWidth),
		Height:Math.max(document.body.scrollHeight, document.body.clientHeight)
	}
}

function getDialogLoc(t_DiglogW, t_DiglogH) {
	var dde = document.documentElement;
	if (window.innerWidth) {
	  var ww = window.innerWidth;
	  var wh = window.innerHeight;
	  var bgX = window.pageXOffset;
	  var bgY = window.pageYOffset;
	} else {
	  var ww = dde.offsetWidth;
	  var wh = dde.offsetHeight;
	  var bgX = dde.scrollLeft;
	  var bgY = dde.scrollTop;
	}
	return {
		leftPos:(bgX + ((ww - t_DiglogW)/2)),
		topPos:t_DiglogY = (bgY + ((wh - t_DiglogH)/2))
	}
}


function openFrame(action, url, pmwidth, pmheight) {
	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);
	
	if (typeof(url) == 'undefined')
		url = 'index.php';
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.body.clientWidth;
//		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var clientHeight = getWindowSize().Height;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		if (typeof(pmwidth) == 'undefined')
			pmwidth = 800;
		if (typeof(pmheight) == 'undefined')
			pmheight = clientHeight * 0.9;
		if(!document.getElementById('pmlayer_bg')) {
			div = document.createElement('div');
			div.id = 'pmlayer_bg';
			div.style.position = 'absolute';
			div.style.left = div.style.top = '0px';
			div.style.width = '100%';
			div.style.height = (clientHeight > document.body.scrollHeight ? clientHeight : document.body.scrollHeight) + 'px';
			div.style.backgroundColor = '#000';
			div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=80,finishOpacity=100,style=0)';
			div.style.opacity = 0.8;
			div.style.zIndex = '98';
			document.getElementById('append_parent').appendChild(div);
			div = document.createElement('div');
			div.id = 'pmlayer';
			/*div.style.width = pmwidth + 'px';
			div.style.height = pmheight + 'px';
			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.zIndex = '99';*/
			document.getElementById('append_parent').appendChild(div);
			document.getElementById('pmlayer').innerHTML = '<div class="">' +
				'<div>' +
				'<a href="###" onclick="openFrame(\'close\')"><img src="' + siteUrl + 'images/close.gif" title="close" /></a>' +
				'<iframe id="pmframe" name="pmframe" style="width:' + pmwidth + 'px;height:100%" allowTransparency="true" frameborder="0"></iframe></div></div>';
				
				
				
				
						document.getElementById('pmlayer2').innerHTML = '<div class="winbox" id="winbox2">' +
				' <div class="winbox_bg" id="winbox_bg2"></div><div class="winbox_main" id="winbox_main2"> <div class="winbox_close" title="click to close" onclick="openDiv(\'close\')"></div>' +
				document.getElementById(div_id).innerHTML + 
				'</div></div>';
						
		document.getElementById("winbox2").style.display = "block";
		document.getElementById("winbox2").style.marginLeft = -pmwidth/2 + "px";
		if(isIE){
		document.getElementById("winbox2").style.marginTop = -pmheight/2 + "px";
		}else{
	    document.getElementById("winbox2").style.top = -pmheight/2 + "px";
		}
		document.getElementById("winbox_bg2").style.width = pmwidth + "px";
		document.getElementById("winbox_bg2").style.height = pmheight + "px";
		document.getElementById("winbox_main2").style.width = pmwidth - 20 + "px";
		document.getElementById("winbox_main2").style.height = pmheight - 20 + "px";
		
		}
		document.getElementById('pmlayer').style.display = '';
		//document.getElementById('pmlayer').style.top = getDialogLoc('', pmheight).topPos;
//		document.getElementById('pmlayer').style.top = ((clientHeight - pmheight) / 2 + scrollTop) + 'px';
		if(!url) {
			pmframe.location = 'index.php';
		} else {
			pmframe.location = url;
		}
		document.body.style.overflow = "hidden";
		document.body.scroll = "no";
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
				objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		document.getElementById('pmlayer').style.display = 'none';
		document.body.style.overflow = "auto";
		document.body.scroll = "auto";
	}
}


function showWinboxDiv(action, div_id, pmwidth, pmheight, num) {
	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);
	num = typeof(num) == 'undefined' ? '' : num;
	if (typeof(url) == 'undefined')
		url = 'index.php';
	if(action == 'open') {
		var clientWidth = document.body.clientWidth;
		var clientHeight = getWindowSize().Height;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		if (typeof(pmwidth) == 'undefined')
			pmwidth = 800;
		if (typeof(pmheight) == 'undefined')
			pmheight = clientHeight * 0.9;

			div = document.getElementById(div_id);
			div.style.width = pmwidth + 'px';
			div.style.height = pmheight + 'px';
			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.display = 'block';
			var num_added = num ? parseInt(num) : 0;
			div.style.zIndex = (95 + num_added).toString();

		document.getElementById("winbox" + num).style.display = "block";
		document.getElementById("winbox" + num).style.marginLeft = -pmwidth/2 + "px";
		
		//alert(document.getElementById("winbox" + num).style.marginLeft);
		
		if(isIE){
		document.getElementById("winbox"+ num).style.marginTop = -pmheight/2 + "px";
		}else{
	    document.getElementById("winbox"+ num).style.Top = -pmheight/2 + "px";
		}
		//document.getElementById("winbox"+ num).style.Top = -pmheight/2 + "px";
		
		document.getElementById("winbox" + num).style.marginTop = -pmheight/2 + "px";
		document.getElementById("winbox_bg" + num).style.width = pmwidth + "px";
		document.getElementById("winbox_bg" + num).style.height = pmheight + "px";
		document.getElementById("winbox_main" + num).style.width = pmwidth - 20 + "px";
		document.getElementById("winbox_main" + num).style.height = pmheight - 20 + "px";

		
		div.style.display = '';
		div.style.top = getDialogLoc('', pmheight).topPos + 'px';
		document.body.style.overflow = "hidden";
		document.body.scroll = "no";
	} else {
		document.getElementById(div_id).style.display = 'none';
	}
}

function openSecondDiv(action, div_id, pmwidth, pmheight) {
	if (typeof(url) == 'undefined')
		url = 'index.php';
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.body.clientWidth;
//		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var clientHeight = getWindowSize().Height;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		if (typeof(pmwidth) == 'undefined')
			pmwidth = 800;
		if (document.getElementById('append_parent2') == null) {
			div = document.createElement('div');
			div.id = 'append_parent2';
			document.body.appendChild(div);
		}	
			
		if (typeof(pmheight) == 'undefined')
			pmheight = clientHeight * 0.9;


			if(!document.getElementById('pmlayer2')) {
				div = document.createElement('div');
				div.id = 'pmlayer2';
				div.style.width = pmwidth + 'px';
				div.style.height = pmheight + 'px';
				div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
				div.style.position = 'absolute';
				div.style.zIndex = '99';
				document.getElementById('append_parent2').appendChild(div);
			}

			
		document.getElementById('pmlayer2').innerHTML = '<div class="winbox" id="winbox2">' +
				' <div class="winbox_bg" id="winbox_bg2"></div><div class="winbox_main" id="winbox_main2"> <div class="winbox_close" title="click to close" onclick="openSecondDiv(\'close\')"></div>' +
				document.getElementById(div_id).innerHTML + 
				'</div></div>';
						
		document.getElementById("winbox2").style.display = "block";
		document.getElementById("winbox2").style.marginLeft = -pmwidth/2 + "px";
		document.getElementById("winbox2").style.marginTop = -pmheight/2 + "px";
		document.getElementById("winbox_bg2").style.width = pmwidth + "px";
		document.getElementById("winbox_bg2").style.height = pmheight + "px";
		document.getElementById("winbox_main2").style.width = pmwidth - 20 + "px";
		document.getElementById("winbox_main2").style.height = pmheight - 20 + "px";

		
		document.getElementById('pmlayer2').style.display = '';
		document.getElementById('pmlayer2').style.top = getDialogLoc('', pmheight).topPos;
		document.body.style.overflow = "hidden";
		document.body.scroll = "no";
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
				objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		document.getElementById('pmlayer2').style.display = 'none';
		document.body.style.overflow = "auto";
		document.body.scroll = "auto";
	}
}

function openDiv(action, div_id, pmwidth, pmheight,pmtop) {

	
	if (typeof(url) == 'undefined')
		url = 'index.php';
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.body.clientWidth;
//		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var clientHeight = getWindowSize().Height;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		if (typeof(pmwidth) == 'undefined')
			pmwidth = 800;
		if (typeof(pmheight) == 'undefined')
			pmheight = clientHeight * 0.9;
			if(!document.getElementById('pmlayer')) {
				div = document.createElement('div');
				div.id = 'pmlayer';
				//div.style.width = pmwidth + 'px';
				//div.style.height = pmheight + 'px';
				//div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
				//div.style.position = 'absolute';
				//div.style.zIndex = '99';
				document.getElementById('append_parent').appendChild(div);
			}

			
		document.getElementById('pmlayer').innerHTML = '<div class="winbox" id="winbox">' +
				' <div class="winbox_bg" id="winbox_bg"></div><div class="winbox_main" id="winbox_main"> <div class="winbox_close" title="click to close" onclick="openDiv(\'close\')"></div>' +
				document.getElementById(div_id).innerHTML + 
				'</div></div>';
				
document.getElementById("winbox").style.display = "block";
document.getElementById("winbox").style.marginLeft = -pmwidth/2 + "px";
//
if(pmtop){
	document.getElementById("winbox").style.top = pmtop + "px";
	}else{
	document.getElementById("winbox").style.marginTop = -pmheight/2 + "px";
	}


document.getElementById("winbox_bg").style.width = pmwidth + "px";
document.getElementById("winbox_bg").style.height = pmheight + "px";
document.getElementById("winbox_main").style.width = pmwidth - 20 + "px";
document.getElementById("winbox_main").style.height = pmheight - 20 + "px";

//		if(!document.getElementById('pmlayer')) {
//			document.getElementById('append_parent').appendChild(div);
//			div = document.createElement('div');
//			div.id = 'pmlayer';
//			div.style.width = pmwidth + 'px';
//			div.style.height = pmheight + 'px';
//			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
//			div.style.position = 'absolute';
//			div.style.zIndex = '99';
//			document.getElementById('append_parent').appendChild(div);
////			alert(document.getElementById(div_id).innerHTML);
//		}
		
//			document.getElementById('pmlayer').innerHTML = '<div style="width: ' + pmwidth + 'px; background: #666666; margin: 5px auto; text-align: left;">' +
//				'<div style="width: ' + pmwidth + 'px; height: ' + pmheight + 'px; padding: 1px; background: #FFFFFF; border: 1px solid #7597B8; position: relative; left: -6px; top: -3px;">' +
//				'<a href="###" onclick="openDiv(\'close\')" style="position: absolute;right: 20px;top: 15px"><img border="0" src="' + siteUrl + 'images/close.gif" title="close" /> Close</a>' +
//				document.getElementById(div_id).innerHTML + 
//				'</div></div>';
		
		document.getElementById('pmlayer').style.display = '';
		//document.getElementById('pmlayer').style.top = getDialogLoc('', pmheight).topPos;
		//document.body.style.overflow = "hidden";
		document.body.scroll = "no";
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
				objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		document.getElementById('pmlayer').style.display = 'none';
		document.body.style.overflow = "auto";
		document.body.scroll = "auto";
	}
}

function showFlash(iUrl,iWidth,iHeight,iWmode)
{
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="'+ iWidth +'" height="' + iHeight +'" />';
flash = flash + '<param name="movie" value="'+ iUrl +'" />';
flash = flash + '<param name="quality" value="high" />';
flash = flash + '<param name="menu" value="false" />';
if (iWmode == 1) {
   flash = flash + '<param name="wmode" value="opaque" />';      
}
flash = flash + '<embed src="' + iUrl + '" width="'+ iWidth +'" height="'+ iHeight +'" menu="false" quality="high" ';
if (iWmode == 1) {
   flash = flash + 'wmode="opaque" ';      
}
flash = flash + ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" mwode="transparent"></embed>';
flash = flash + '</object>';

document.writeln(flash); 
//alert(flash);
}
/*type_write*/
var count=0;
function type_write(div,content){
	  //alert(content.length);

	  if(count<=content.length){
	   document.getElementById(div).innerHTML=content.substring(0,count);
	   count++;
	   type = setTimeout("type_write(\""+div+"\",\""+content+"\")",30);
	  }else{
	   clearTimeout(type); 
	  }
	  document.body.onclick = function(){ 
		   clearTimeout(type);  
		   document.getElementById(div).innerHTML=content;
	  }
	  
}
