﻿/* ALL BLUR */

var LID = 0;

function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring



/* POPUP */
function OpenWindow(url,winName,intWidth,intHeight,intScrollbars) {
window.open(url,winName,"width="+intWidth+",height="+intHeight+",scrollbars="+intScrollbars+"") ;
}



/* ShowHideLayers */
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}



/* FLASH */
function swf_game(src,w,h){
	html = "";
	html += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"'>";
	html += "<param name='movie' value='"+src+"'>";
	html += "<param name='quality' value='high'>";
	html += "<param name='base' value='.'>";
	html += "<embed src='"+src+"' base='.' width='"+w+"' height='"+h+"' quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'><\/embed>";
	html += "<\/object>";
	document.write(html);
}

function swf(url_root, w, h){

   	  document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
      +" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' "
      +" width='"+w+"' Height='"+h+"'>"
      +"<param name='movie' value='"+url_root+"'>"
      +"<param name='quality' value='high'>"
      //+"<param name='bgcolor' value='#"+bgcolor+"'>"
      +"<param name='wmode' value='transparent'>"
      +"<embed src='"+url_root+"' "
      +" wmode='transparent' quality='high' width='"+w+"' height='"+h+"' "
      +" type='application/x-shockwave-flash' "
      +" pluginspage='http://www.macromedia.com/shockwav/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>"
      +"</embed></object>");
}

function swf_gamemode(url_root, w, h){

   	  document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
      +" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' "
      +" width='"+w+"' Height='"+h+"'>"
      +"<param name='movie' value='"+url_root+"'>"
      +"<param name='quality' value='high'>"
      //+"<param name='bgcolor' value='#"+bgcolor+"'>"
      //+"<param name='wmode' value='transparent'>"
      +"<embed src='"+url_root+"' "
      +" wmode='transparent' quality='high' width='"+w+"' height='"+h+"' "
      +" type='application/x-shockwave-flash' "
      +" pluginspage='http://www.macromedia.com/shockwav/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>"
      +"</embed></object>");
}


/* top icon */
function topBtn(yy)
{
	LID++;
	document.write("<div id='ico_"+LID+"' style='position:absolute; top:"+yy+"px; width:46px; height:31px; z-index:100; text-align:right'>");
	document.write("<a href='#logo'><img src='http://static.nexon.co.jp/danpara/common/ico_top.gif' width='31' height='31'></a></div>");
}

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 CheckChar_Length(obj, length_limit)
{
	var length = getByteLength(obj.value)
	if (length > length_limit) 
	{
		alert("全角"+length_limit/2+"文字以内で入力してください。");
		obj.focus();
	}
}