//ログインフォームBG・テキスト表示制御
function hideText(object){
	document.getElementById(object).style.display = "none";
}

function actBG(name){
	switch(name){
		case "id":near_name = "pw"; break;
		case "pw":near_name = "id"; break;
	}
	var trg = "login-" + name;
	var near = "login-" + near_name;
	var trg_txt = name + "text";
	var near_txt = near_name + "text";

	document.getElementById(trg).style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/global/login_formbg_" + name + "_act.gif)";
	document.getElementById(near).style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/global/login_formbg_" + near_name + ".gif)";
	document.getElementById(trg_txt).style.backgroundPosition = "left bottom";
	document.getElementById(near_txt).style.backgroundPosition = "left top";
}

function RestoreText(object,frm){
	if (frm.value == ""){
		document.getElementById(object).style.display = "block";
	}
}


function backlistBgOn(obj){
	obj.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/global/backlist_bg_f.gif)";
}
function backlistBgOff(obj){
	obj.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/global/backlist_bg.gif)";
}

function show_obj(obj){
	document.getElementById(obj).style.display = "block";
}
function hide_obj(obj){
	document.getElementById(obj).style.display = "none";
}

function bbs_fuki_fcs(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_btm_f.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_top_f.gif)";
	obj.parentNode.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_bg_f.gif)";
}
function bbs_fuki_def(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_btm.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_top.gif)";
	obj.parentNode.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/bbs_fuki_bg.gif)";
}

function changeBG(obj){
	obj.parentNode.parentNode.parentNode.parentNode.parentNode.style.backgroundPosition = "right top";
}
function returnBG(obj){
	obj.parentNode.parentNode.parentNode.parentNode.parentNode.style.backgroundPosition = "left top";
}

function deleteOn(obj){
	obj.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/global/fuki_delete.gif)";
}
function deleteOff(obj){
	obj.parentNode.style.backgroundImage = "none";
}

function changeFrm(linkName){
	document.getElementById(linkName).style.backgroundPosition = 'left bottom';
	document.getElementById(linkName + 'txt').style.color = '#be0000';
}
function returnFrm(linkName){
	document.getElementById(linkName).style.backgroundPosition = 'left top';
	document.getElementById(linkName + 'txt').style.color = '#656555';
}

function fa_new_chbg(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_arrival_foot_f.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_arrival_bg_f.gif)";
}
function fa_new_def(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_arrival_foot.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_arrival_bg.gif)";
}

function fa_res_chbg(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_result_btm_f.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_result_bg_f.gif)";
}
function fa_res_def(obj){
	obj.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_result_btm.gif)";
	obj.parentNode.parentNode.parentNode.style.backgroundImage = "url(http://static.nexon.co.jp/maplestory_4th/community/fanart_result_bg.gif)";
}


function imgResize(img){ 
	img1= new Image(); 
	img1.src=(img); 
	imgControll(img); 
	} 

function imgControll(img){ 
	if((img1.width!=0)&&(img1.height!=0)){ 
		viewImage(img); 
	} 
	else{ 
		controller="imgControll('"+img+"')"; 
		intervalID=setTimeout(controller,20); 
	} 
} 

function viewImage(img){ 
		W=img1.width; 
		H=img1.height;  
		O="width="+W+",height="+H; 
		imgWin=window.open("","",O); 
		imgWin.document.write("<html><head><title>Maplestory</title></head>");
		imgWin.document.write("<body topmargin=0 leftmargin=0>");
		imgWin.document.write("<img src="+img+" onclick='self.close()'>");
		imgWin.document.close();
} 		

function chbbs(view,hide){
	document.getElementById(view).style.display = "block";
	document.getElementById(hide).style.display = "none";
}

function CheckChar_Length(obj, length_limit)
{
	var length = getByteLength(obj.value)
	if (length > length_limit) 
	{
		alert("全角"+ length_limit/2 +"文字以内で入力してください。");
		obj.focus();
		return false;
	}
	return true;
}

function JS_trim(data)
{
	for(var i=0;i<data.length;i++)
	{
		var digit = data.charAt(i)
		if ( digit == " ")	continue; 
		else return 1;
	}
	return -1;
}

function getByteLength(s)
{ 
	var len = 0; 
	if ( s == null ) return 0; 
	for(var i=0;i<s.length;i++)
	{ 
		var c = escape(s.charAt(i)); 
		if ( c.length == 1 ) len ++; 
		else if ( c.indexOf("%u") != -1 ) len += 2; 
		else if ( c.indexOf("%") != -1 ) len += c.length/3; 
	} 
	return len; 
} 

function swf(pass,widthsize,heightsize){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + widthsize + '" height="' + heightsize + '" align="middle">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="' + pass + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="' + pass + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + widthsize + '" height="' + heightsize + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
function swf2(pass,widthsize,heightsize,name){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + widthsize + '" height="' + heightsize + '" id="' + name + '" align="middle">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="' + pass + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="' + pass + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + widthsize + '" height="' + heightsize + '" name="' + name + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
function swf3(pass,widthsize,heightsize){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + widthsize + '" height="' + heightsize + '" align="middle">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="' + pass + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="base" value="." />');
	document.write('<embed src="' + pass + '" quality="high" wmode="transparent" bgcolor="#ffffff" base="." width="' + widthsize + '" height="' + heightsize + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function scrolls(x,y) {
	window.scrollTo(x,y);
}

function openSpeechCha(){
	document.getElementById('btmchara').style.zIndex = 200;
}
function closeSpeechCha(){
	document.getElementById('btmchara').style.zIndex = 1;
}

function openWorldMaple(){
	document.getElementById('btm-left-over').style.left = '15px';
	document.getElementById('btmchara').style.zIndex = 200;
	if (navigator.appName.indexOf("Microsoft") != -1){
		document.getElementById('world').openWorldMaple();
	}

}
function closeWorldMaple(){
	document.getElementById('btm-left-over').style.left = '-9999px';
	document.getElementById('btmchara').style.zIndex = 1;
}

/* FanartPuzzle */
function openPuzzle(){
	document.getElementById('fanartpuzzle-real').style.display = 'block';
	document.getElementById('btmchara').style.zIndex = 200;
	//pageTracker._trackPageview('/puzzle/resultPuzzle.html');
}
function closePuzzle(){
	//thisMovie("puzzleSample").sendToActionScript();
	document.getElementById('fanartpuzzle-real').style.display = 'none';
	document.getElementById('btmchara').style.zIndex = 1;
}
function openSamplePuzzle(){
	document.getElementById('fanartpuzzle-sample').style.display = 'block';
}
function closeSamplePuzzle(){
	//thisMovie("puzzleSample").sendToActionScript();
	document.getElementById('fanartpuzzle-sample').style.display = 'none';
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function viewPuzzle() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="puzzleSample" width="640" height="400">');
	document.write('<param name="movie" value="http://static.nexon.co.jp/maplestory_4th/swf/minigame/fanart_puzzle/fanartpuzzle.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<embed src="http://static.nexon.co.jp/maplestory_4th/swf/minigame/fanart_puzzle/fanartpuzzle.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="640" height="400" name="puzzleSample" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	document.write('</embed>');
	document.write('</object>');
}
function viewSamplePuzzle() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="puzzleSample" width="254" height="254">');
	document.write('<param name="movie" value="http://static.nexon.co.jp/maplestory_4th/community/puzzleSample.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<embed src="http://static.nexon.co.jp/maplestory_4th/community/puzzleSample.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="254" height="254" name="puzzleSample" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	document.write('</embed>');
	document.write('</object>');
}

