/*-----------------------------------------
  共有Javascript
 -----------------------------------------*/
var Q = '"';


/**
 * EventListener.js
 * Powered by hisato http://chibinowa.net/
 */
 
var EventListener = {
    add: function(obj, event, funcname, capture)
    {
        if (obj.addEventListener)
            obj.addEventListener(event, funcname, capture);
        else if (obj.attachEvent)
            obj.attachEvent("on" + event, funcname);
    },
    remove: function(obj, event, funcname, capture)
    {
        if (obj.removeEventListener)
            obj.removeEventListener(event, funcname, capture);
        else if (obj.detachEvent)
            obj.detachEvent("on" + event, funcname);
    }
};


var UA = {

    UA: navigator.userAgent,

    init: function()
    {
	    if (UA.UA.indexOf('Opera') == -1 && UA.UA.indexOf('MSIE') != -1) {
	        UA.Name = 'ie';
	    }
	    else if (UA.UA.indexOf('Gecko/') != -1) {
	        UA.Name = 'gecko';
	    }
	    else if (UA.UA.indexOf('Opera') != -1) {
	        UA.Name = 'opera';
	    }
    },

    check: function(name)
    {
        if (name == UA.Name) {
            return true;
        }
    }
};
UA.init();


/**
 * ObFade.js
 * Powered by hisato http://chibinowa.net/
 */
 
var ObFade = {

	// 初期化
	init: function(o_display, startalpha)
	{
		if (startalpha > 0) {
			if (o_display.filters) {
				o_display.style.filter = "alpha(opacity=0)";
				o_display.filters.alpha.opacity = startalpha*100;
			}
			else {
				o_display.style.MozOpacity = startalpha;
			}
			return true;
		}
		return false
	},

	// フェードイン
	fadein: function(o_display, stopalpha, moven)
	{
		if (o_display.filters && o_display.filters.alpha.opacity < stopalpha*100) {
			o_display.filters.alpha.opacity *= moven;
		}
		else if (o_display.style.MozOpacity < stopalpha) {
			o_display.style.MozOpacity *= moven;
		}
		else {
			return false
		}
		return true
	},

	// フェードアウト
	fadeout: function(o_display, stopalpha, moven)
	{
		if (o_display.filters && o_display.filters.alpha.opacity > stopalpha*100) {
			o_display.filters.alpha.opacity /= moven;
		}
		else if (o_display.style.MozOpacity > stopalpha) {
			o_display.style.MozOpacity /= moven;
		}
		else {
			return false
		}
		return true
	}

};

/**
 * MousePos 座標取得
 * Powered by hisato http://chibinowa.net/
 */

var MousePos = {

	// マウスX座標(スクロールを含む)
	getMousePosY: function(e)
	{
		if (e.pageX)
			return e.pageY;
		else
			return e.clientY + MousePos.getScrollTop();
	},

	// マウスX座標(スクロールを含む)
	getMousePosX: function(e)
	{
		if (e.pageX)
			return e.pageX;
		else
			return e.clientX + MousePos.getScrollLeft();
	},

	// 縦スクロール取得
	getScrollTop: function()
	{
		if (window.pageYOffset)
			return window.pageYOffset;
		if (document.compatMode == 'BackCompat')
			return document.body.scrollTop;
		if (document.body.scrollTop)
		    return document.body.scrollTop;
		if (document.documentElement.scrollTop)
			return document.documentElement.scrollTop;
		return 0;
	},

	// 横スクロール取得
	getScrollLeft: function()
	{
		if (window.pageXOffset)
			return window.pageXOffset;
		if (document.compatMode == 'BackCompat')
			return document.body.scrollLeft;
		if (document.body.scrollLeft)
		    return document.body.scrollLeft;
		if (document.documentElement.scrollLeft)
			return document.documentElement.scrollLeft;
		return 0;
	}

};







/* 実行確認ダイアログ */
function checkConfirm(msg)
{
    if(window.confirm(msg)) {
        return true;
    }
    return false;
}

/* サブウィンドウ */
function newWindow(url, name, width, height, scroll)
{
    var options = new Array();
    if (width) options.push('width=' + width);
    if (height) options.push('height=' + height);
    if (scroll) options.push('scrollbars=' + scroll);
    window.open(url, name, options.join(", "));
    return false;
}

/* ターゲット指定窓 */
function targetWindow(url, name)
{
    window.open(url, name);
    return false;
}

function layViews(id)
{
    mod = document.all ? document.all[id] : document.getElementById(id);
    mod.style.display = mod.style.display == 'none' ? 'block' : 'none';
}

function layViewsHidden(my)
{
    mod = document.all ? document.all[my] : document.getElementById(my);
    mod.style.display = 'none';
}

var f = {};
function checkText(clockobj, opentxt, closetxt)
{
    if (f[clockobj]) {
        clockobj.innerHTML = opentxt;
        f[clockobj]=false;
    }
    else {
        clockobj.innerHTML = closetxt;
        f[clockobj]=true;
    }
}

function resetForm(target_id)
{
    document.getElementById(target_id).reset()
}


/**
 * QuickWin.js
 * Powered by hisato http://chibinowa.net/
 */

function QuickWin()
{
    this.winid = null;
    this.open = function(file_name, window_name, width, height, option)
    {
        this.winid = window.open(file_name, window_name, "width="+width+",height="+height+","+ option);
        return this.winid;
    }
    this.getParentVar = function(obj, name)
    {
        if (typeof window.opener[obj] == 'object')
            return window.opener[obj][name];
    }
    this.setParentVar = function(obj, name, value)
    {
        if (typeof window.opener[obj] == 'object')
            window.opener[obj][name] = value;
    }
    this.setVar = function(name, value)
    {
        this[name] = value;
    }
}


