
// Globals

LCB_version = 3.1;
_mac   =navigator.userAgent.toLowerCase().indexOf('mac')!=-1;
_ie512 =navigator.userAgent.toLowerCase().indexOf('msie 5.12')!=-1;
_kon   =navigator.userAgent.toLowerCase().indexOf('konqueror')!=-1;
_safari=navigator.userAgent.toLowerCase().indexOf('safari')!=-1;
_dom = document.all?(document.getElementById?2:1):
                    (document.getElementById?4:
                    (document.layers?3:0));

// ----------------------------------------
// Debug
// ----------------------------------------
function debugMes(str)
{
	obj_layerDebug = document.getElementById('layerDebug');
	if( obj_layerDebug ){
		obj_layerDebug.innerHTML = "" + str + ":" + Math.floor(Math.random() * 16);
	}
}

// ================================================================
//
// Objects
//
// ================================================================

// ----------------------------------------
// Array
if(!Array.prototype.push){
	Array.prototype.push = function(arg1){
		this[this.length] = arg1;
	}
}

// ----------------------------------------
// Position
function Position(x,y){
	this.x = x - 0;
	this.y = y - 0;
}
Position.prototype.toString = function()
{
	return "x=" + this.x + ":y=" + this.y;
}

// ----------------------------------------
// Size
function Size(x,y){
  this.width	= x ? x - 0: 0;
  this.height	= y ? y - 0: 0;
}
Size.prototype.set = function( width, height )
{
	this.width  = width - 0;
	this.height = height - 0;
}
Size.prototype.toString = function()
{
	return "width=" + this.width + ":height=" + this.height;
}

// ================================================================
//
// Event Handler
//
// ================================================================

function JMap2EventHandler(thisObj, eventName, arg2, arg3, arg4, arg5)
{
  var thisObj2 = thisObj;
  thisObj = null;
  return function( thisEvent ){
    if( !thisEvent ){
      thisEvent = window.event;
    }
	if( thisEvent && !thisEvent.target){
		thisEvent.target = thisEvent.srcElement;
    }
	thisObj2[eventName](thisEvent, arg2, arg3, arg4, arg5)
  }
}

function JMap2AttachEvent(ra,w,Rb)
{
  if( obj_browser.browser == "safari" && w == "dblclick" ){
    ra["on"+w]=Rb;
    return
  }
  if(ra.addEventListener){
    ra.addEventListener(w,Rb,false)
  }else if(ra.attachEvent){
    ra.attachEvent("on"+w,Rb)
  }else{
    if( Rb ){
	    ra["on"+w] = Rb;
	}else{
		window["on" + ra ] = w;
	}
  }
}

function JMap2DetachEvent(ra,w,Rb){
  if(ra.removeEventListener){
    ra.removeEventListener(w,Rb,false)
  }else if(ra.detachEvent){
    ra.detachEvent("on"+w,Rb)
  }else{
    ra["on"+w]=null
  }
}

function JMap2CancelBubble(b){
  if( obj_browser.browser == 'ie' ){
    window.event.cancelBubble=true
  }else{
    b.cancelBubble=true;
    b.preventDefault();
    b.stopPropagation()
  }
}

// ================================================================
//
// getElementsByClassName(className, tagName, parentElement)
//
// ================================================================
function getElementsByClassName(className, tagName, parentElement)
{
	tagName = tagName || "*";
	parentElement = parentElement || document;
	var elements = new Array();
	var regExp   = new RegExp('(^|\\s)' + className + '(\\s|$)');
	var element = parentElement.getElementsByTagName(tagName);

	for (var i=0, n=element.length; i<n; i++){
		if(regExp.test(element[i].className)){
			elements.push(element[i]);
		}
	}
	return elements;
}

// ================================================================
//
// xFunctions
//
// ================================================================
function xThisDocument( thisDocument )
{
	return thisDocument ? thisDocument : window.document;
}

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}
function xDefNum( num )
{
	return num - 0;
}

// xGetElementById
function xGetElementById(e, thisDocument)
{
  thisDocument = xThisDocument( thisDocument );

  if(typeof(e)!='string') return e;
  if(thisDocument.getElementById) e=thisDocument.getElementById(e);
  else if(thisDocument.all) e=thisDocument.all[e];
  else e=null;
  return e;
}

// xPagePos
function xPageX(e)
{
  if (!(e=xGetElementById(e))) return 0;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return x;
}
function xPageY(e)
{
  if (!(e=xGetElementById(e))) return 0;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return y;
}

// xInnerHtml
function xInnerHtml(e,h)
{
  if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
  var s = e.innerHTML;
  if (xStr(h)) {e.innerHTML = h;}
  return s;
}

// xEvent
function xEvent(evt) // object prototype
{
  var e = evt || window.event;
  if(!e) return;
  if(e.type) this.type = e.type;
  if(e.target) this.target = e.target;
  else if(e.srcElement) this.target = e.srcElement;

  if (e.keyCode) { this.keyCode = e.keyCode; } // for moz/fb, if keyCode==0 use which
  else if (xDef(e.which) && e.type.indexOf('key')!=-1) { this.keyCode = e.which; }

  this.shiftKey = e.shiftKey;
  this.ctrlKey = e.ctrlKey;
  this.altKey = e.altKey;
}

// createDiv
function xCreateDiv( thisDocument )
{
	thisDocument = xThisDocument( thisDocument );
	return thisDocument.createElement("div");
}

function xScrollTop(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}

function xScrollMoveDivTop(div, num)
{
  if( xDef(div) ){
	div.scrollTop = num;
  }
}

function xScrollLeft(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}

function xClientWidth()
{
  var w=0;
  if( window.self && self.innerWidth ) w=window.innerWidth;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}

function xClientHeight()
{
  var h=0;
  if( window.self && self.innerWidth ) h=window.innerHeight;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}

// ================================================================
//
// Libs
//
// ================================================================

function never()
{
  return false
}

function getListArgs( arguments )
{
	var list = new Array();

	for (var i = 0; i < arguments.length; i++) {
		list[i] = arguments[i];
	}

	return list;
}

function getCopyArray( list )
{
	var list_new = new Array();
	for (var i = 0; i < list.length; i++) {
		list_new[i] = list[i];
	}
	return list_new;
}

function delSpaceTab(str)
{
	str = str.replace(/[\t\s]/g,"");
	str = str.replace(/[　]/g,"");
	return str;
}

function strToInt(str)
{
	str = str.replace(/０/g,"0");
	str = str.replace(/１/g,"1");
	str = str.replace(/２/g,"2");
	str = str.replace(/３/g,"3");
	str = str.replace(/４/g,"4");
	str = str.replace(/５/g,"5");
	str = str.replace(/６/g,"6");
	str = str.replace(/７/g,"7");
	str = str.replace(/８/g,"8");
	str = str.replace(/９/g,"9");
	str = str.replace(/．/g,".");
	str = str.replace(/ー/g,"-");
	str = str.replace(/－/g,"-");

	return str;
}

function strLen(str)
{
   len = 0;
   str = escape(str);
   for (i = 0; i < str.length; i++, len++) {
      if (str.charAt(i) == "%") {
         if (str.charAt(++i) == "u") {
            i += 3;
            len++;
         }
         i++;
      }
   }
   return len;
}

function revBool(bool)
{
	if( bool == false ){
		return true;
	}else{
		return false;
	}
}

// isNull
function isNull(str)
{
	if(str == "" || !str){
		return true;
	}
	if( str.match(/[\n\s　]/) ){
		if( str.match(/[^\n\s　]/) ){
			return false;
		}else{
			return true;
		}
	}

	return false;;
}
function isNotNull(str)
{
	return revBool( isNull(str) );
}

// isRoman
function isRoman(str)
{
	if( str.match(/[^a-zA-Z0-9\-\_\s　]/) ){
        return false;
	}else{
		return true;
	}
}
function isNotRoman(str)
{
	return revBool( isRoman(str) );
}

// isNum
function isNum(str)
{
	if(	isNull(str) || (str.match(/[^0-9\.]/)) ){
		return false;
	}else{
		return true;
	}
}
function isNotNum(str)
{
	return revBool( isNum(str) );
}

// isEmail
function isEmail(str)
{
	if(		isNull(str)								// 未入力チェック
		||  (str.match(/[^a-zA-Z0-9\.@\-_]/))		// 特殊文字確認
		||	(str.match(/[\-\._@]$/) )				// 特殊文字が最後にきていないか確認
		||	(!str.match(/@/))						// @マークの存在を確認
		||	(str.match(/@[a-zA-Z0-9\.@\-_]*@/) )	// @マークの２度入力確認
		||	(str.match(/ /) )						// スペースが含まれていないか確認
		||	(!str.match(/\./) )						// .の有無を確認
	){
		return false;
	}else{
		return true;
	}
}
function isNotEmail(str)
{
	return revBool( isEmail(str) );
}

// ================================================================
//
// Div
//
// ================================================================

// -------------------------------
// pos
function initDivPos(div){
  if(_dom==4){
    div.style.left=div.offsetLeft+'px';
    div.style.top =div.offsetTop +'px';
  } else if(_dom==2 || _dom==1){
    div.style.pixelLeft=div.offsetLeft;
    div.style.pixelTop =div.offsetTop;
  }
  return div;
}
function setDivPosXY( div, x, y )
{
	setDivPosX( div, x );
	setDivPosY( div, y );
}
function setDivPosX( div, x )
{
	div.style.left	= x + 'px';
}
function setDivPosY( div, y )
{
	div.style.top	= y + 'px';
}
function setDivPos( div, objPos )
{
	setDivPosXY( div, objPos.x, objPos.y );
}
// -------------------------------
// size
function initDivSize(div){
  if(_dom==4){
    div.style.width  = div.offsetWidth +'px';
    div.style.height = div.offsetHeight+'px';
  } else if(_dom==2 || _dom==1){
    div.style.pixelWidth  = div.offsetWidth;
    div.style.pixelHeight = div.offsetHeight;
  }
  return div;
}
function getDivWidth (div){
  if(_dom==4 || _dom==2) return div.offsetWidth;
  if(_dom==1)            return div.style.pixelWidth;
  if(_dom==3)            return div.clip.width;
  return 0;
}
function getDivHeight(div){
  if(_dom==4 || _dom==2) return div.offsetHeight;
  if(_dom==1)            return div.style.pixelHeight;
  if(_dom==3)            return div.clip.height;
  return 0;
}
function getDivSize(div)
{
	initDivSize(div);
	return new Size( getDivWidth(div), getDivHeight(div) );
}
function setDivSizeW( div, width )
{
	div.style.width	= width + 'px';
}
function setDivSizeH( div, height )
{
	div.style.height= height + 'px';
}
function setDivSizeWH( div, width, height )
{
	setDivSizeW( div, width );
	setDivSizeH( div, height );
}
function setDivSize( div, objSize )
{
	setDivSizeW( div, objSize.width );
	setDivSizeH( div, objSize.height );
}

// z-index
function setDivZindex( div, zIndex )
{
	div.style.zIndex = zIndex;
}

// -------------------------------
// show, hide
function showDiv(div)
{
	div.style.visibility = 'visible';
}
function showDivBlock(div)
{
	div.style.display = 'block';
}
function hideDiv(div)
{
	div.style.visibility = 'hidden';
}
function hideDivBlock(div)
{
	div.style.display = 'none';
}

// ================================================================
//
// Browser
//
// ================================================================
function xBrowser()
{
	var agent	= navigator.userAgent.toLowerCase();
	var appName = navigator.appName.toLowerCase();

	this.browser		 = "";
	this.bool_mozilla	 = null;
	this.browser_version = 0;
	this.os				 = "";

	if( agent.indexOf("opera") != -1 ){
		this.browser = 'opera';
		if( agent.indexOf("opera 7") =! -1){
			this.browser_version = 7;
		}
	}else if( agent.indexOf("msie") != -1 && document.all ){
		this.browser = 'ie';
		if( agent.indexOf("msie 5") != -1 ){
			this.browser_version = 5;
		}else
		if( agent.indexOf("msie 6") != -1 ){
			this.browser_version = 6;
		}
	}else if( agent.indexOf("firefox") != -1 ){
		this.browser = 'firefox';
		if( agent.indexOf("firefox/0.1") != -1 ){
			this.browser_version = 1;
		}else
		if( agent.indexOf("firefox/0") != -1 ){
			this.browser_version = 0;
		}
		if( agent.indexOf("mozilla") != -1 ){
			this.bool_mozilla = 1;
		}
	}else if( agent.indexOf("safari") != -1 ){
		this.browser = 'safari';
		if( agent.indexOf("safari/48") != -1 ){
			this.browser_version = 48;
		}
	}else if( appName.indexOf("Netscape") !=-1 ){
		if( agent.indexOf("mozilla") != -1 ){
			this.bool_mozilla = 1;
		}
		if( agent.indexOf("mozilla/4") !=-1 ){
			this.browser = 'netscape';
			this.browser_version = 4;
		}else
		if( agent.indexOf("netscape6") !=-1 ){
			this.browser = 'netscape';
			this.browser_version = 6;
		}else
		if( agent.indexOf("netscape7") !=-1 ){
			this.browser = 'netscape';
			this.browser_version = 7;
		}else
		if( agent.indexOf("netscape") =-1 ){
			this.browser = 'Mozilla';
			if( agent.indexOf("rv:1") != -1 ){
				this.browser_version = 1;
			}else
			if( agent.indexOf("rv:0") != -1 ){
				this.browser_version = 0;
			}
		}
	}
	if( agent.indexOf("win") != -1 ){
		this.os = 'win';
	}
	if( agent.indexOf("mac") != -1 ){
		this.os = 'mac';
	}
}
xBrowser.prototype.getMousePos = function( event )
{
	var posX, posY;

	if( this.browser == 'ie' ){
		posX = event.clientX + document.body.scrollLeft;
		posY = event.clientY + document.body.scrollTop;
	}else
	if(		this.browser == 'firefox'
		||	this.browser == 'netscape'
	){
		posX = event.pageX;
		posY = event.pageY;
	}

	return new Position( posX, posY );
}
var obj_browser = new xBrowser();

// ================================================================
//
// jLib
//
// ================================================================
function jLib()
{
	this.thisDocument = window.document;
}

// ---------------------------------
// Form
jLib.prototype.getFormObj = function( formName, thisDocument )
{
	if( thisDocument ){
		return thisDocument.forms[formName];
	}else{
		return this.thisDocument.forms[formName];
	}
}

jLib.prototype.getFormValue = function( form, keyname )
{
	return form.elements[keyname].value;
}

jLib.prototype.setFormValue = function( form, keyname, keyvalue )
{
	if( form != null ){
		if( this.checkExistFormTag( form, keyname ) ){
			form.elements[keyname].value = keyvalue;
		}else{
			this.appendForm_tag( form, this.createFormTag( keyname, keyvalue ) );
		}
	}
}

jLib.prototype.appendForm_tag = function( form, inputTag )
{
	form.appendChild( inputTag );
}

jLib.prototype.checkExistFormTag = function( form, keyname )
{
	if( form.elements[keyname] != null ){
		return true;
	}else{
		return false;
	}
}

jLib.prototype.createFormTag = function( keyname, keyvalue )
{
	var hiddenObj	= this.thisDocument.createElement("input");

	hiddenObj.type  = "hidden";
	hiddenObj.id	= keyname;
	hiddenObj.name  = keyname;
	hiddenObj.value = keyvalue;

	return hiddenObj;
}

jLib.prototype.importFormParam = function( from_FormName, from_KeyName, to_FormName, to_KeyName, thisDocument )
{
	thisDocument = xThisDocument( thisDocument );

	var obj_from	= this.getFormObj( from_FormName, thisDocument );
	var obj_to		= this.getFormObj( to_FormName, thisDocument );
	this.setFormValue( obj_to, to_KeyName, this.getFormValue(obj_from, from_KeyName) );
}


//----------------------------------------------------------
function getLoadGMapArg()
{
	var arg = location.search;
	arg = arg.replace(/\?/, "");
	return arg.split(':');
}

//----------------------------------------------------------
function getAccUrl()
{
	var url = '/acc-bin/acc/acclog_json.cgi?';

	url += "referrer=" + document.referrer + "&";
	url += "width=" + screen.width + "&";
	url += "height=" + screen.height + "&";
	url += "color=" + screen.colorDepth + "&";
	url += "url=" + escape(window.location.href) + "&";
	url += 'randam_link=' + Math.ceil( (Math.random() * 65535) + (Math.random() * 65535) );

	return url;
}

var jlib = new jLib();


