//===================================================================
//
//	***  All common JavaScript  ***
//
//===================================================================

//-----------------------------------------------------
//ie b.g. cache fix（IE6 での hover時の背景画像ちらつき《動作の遅延が発生する》に対処）
//-----------------------------------------------------

	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {}


//-----------------------------------------------------
//magical lines for ie （IE での document へのアクセス向上）
//-----------------------------------------------------

	/*@cc_on _d=document;eval('var document=_d')@*/


//-----------------------------------------------------
//check whether if navigator is Safari or not
//-----------------------------------------------------

	var isSafari = false;



//-----------------------------------------------------
//easy getelementbyid
//-----------------------------------------------------

	function $$(id) {
		e = document.getElementById(id);
		return e;
	}


//-----------------------------------------------------
// -init clsoe button （このページを閉じる）
//-----------------------------------------------------

	function init_close_btn() {
		var e = document.createElement('a'), f = document.createElement('li');
		e.href = "javascript:window.close()";
		e.innerHTML = "このページを閉じる";
		f.className = "close";
		f.appendChild(e);
		$$('footerNavigationList').appendChild(f);
		$$('footerNavigationList').className += " withCloseButton";
	}


//-----------------------------------------------------
// -init history back （前のページへ戻る）
//-----------------------------------------------------

	function init_history_back() {
		var e = document.createElement('a'), f = document.createElement('li');
		e.href = "javascript:history.back(-1)";
		e.innerHTML = "前のページへ戻る";
		f.className = "prev";
		f.appendChild(e);
		$$('footerNavigationList').appendChild(f);
	}


//-----------------------------------------------------
//- attach events when loaded
//-----------------------------------------------------
if ( window.addEventListener ) {
	window.addEventListener( "load", set, false );
} else if ( window.attachEvent ) {
	window.attachEvent( "onload", set );
} else {
	window.onload = set();
}


//-----------------------------------------------------
// attach actions when open HTML （ボタンの入れ替え）
//-----------------------------------------------------
function set() {
	var img = document.getElementsByTagName('img');
	for ( var i = 0, imgLength = img.length ; i < imgLength ; i ++ ) {
			var cn = img[i].className.toLowerCase().split(' ');
			for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
				if ( cn[j] == 'over' ) {
					img[i].onmouseover = function() {
						rollOverOn(this);
					}
					img[i].onmouseout = function() {
						rollOverOff(this);
					}
				}
			}
	}
	var img = document.getElementsByTagName('input');
	for ( var i = 0, imgLength = img.length ; i < imgLength ; i ++ ) {
		var cn = img[i].className.toLowerCase().split(' ');
		for ( var j = 0, varCnt = cn.length ; j < varCnt ; j ++ ) {
			if ( cn[j] == 'over' ) {
				img[i].onmouseover = function() {
					rollOverOn(this);
				}
				img[i].onmouseout = function() {
					rollOverOff(this);
				}
			}
		}
	}
}

function rollOverOn(obj) {
	if (obj.src.indexOf("_on") == -1 ){
		obj.src = obj.src.replace(/(.*)\.([a-z]{3})$/g,'$1_on.$2');
	}
}
function rollOverOff(obj) {
	if (obj.id != "ignore") {
		obj.src = obj.src.replace(/(.*)_on\.([a-z]{3})$/g,'$1.$2');
	}
}

//-----------------------------------------------------
//open popup
//-----------------------------------------------------

	function open_width_popup(obj) { var subWin1 = window.open(obj.href,"pg_layout_column1",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,width=794,height=800');subWin1.focus(); }
	function open_width_popup(obj) { var subWin2 = window.open(obj.href,"pg_layout_column2",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,width=794,height=800');subWin2.focus(); }
	function open_width_popup(obj) { var subWin3 = window.open(obj.href,"pg_layout_column3",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes,width=794,height=800');subWin3.focus(); }
	function open_width_smart(obj) { var subWin4 = window.open(obj.href,"pg_layout_column1",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=not,width=354,height=576');subWin4.focus(); }
	function open_width_smart(obj) { var subWin5 = window.open(obj.href,"pg_layout_column2",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=not,width=354,height=576');subWin5.focus(); }
	function open_width_smart(obj) { var subWin6 = window.open(obj.href,"pg_layout_column3",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=not,width=354,height=576');subWin6.focus(); }


//-----------------------------------------------------
//focus parent
//-----------------------------------------------------

	function focus_parent() {
		window.opener.focus();
	}

	function parent_locate(url) {
		if (window.opener!=undefined) {
			window.opener.location.href=url;
		} else {
			window.open(url,"pg_layout_column1",'resizable=yes,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');
		}
		focus_parent()
	}


//-----------------------------------------------------
//define and set window name
//-----------------------------------------------------

	function setWindowName() {
		switch ( document.body.id ) {
			case "layout_column1":
				window.name = "pg_layout_column1";
				break;
			case "layout_column2":
				window.name = "pg_layout_column2";
				break;
			case "layout_column3":
				window.name = "pg_layout_column3";
				break;
			default:
				window.name = "pg_layout_column1";
				break;
		}
	}

