//===================================================================
//
//	***  All common JavaScript  ***
//
//===================================================================



//-----------------------------------------------------
//get document path
//-----------------------------------------------------
var docurl = document.URL;
var urlparts = docurl.split('/');
var urllength = urlparts.length;
var isdeep = urllength > 6;
if (isdeep) {
	var mothercategory = urlparts[0] + '/' + urlparts[1] + '/' + urlparts[2] + '/' + urlparts[3] + '/' + urlparts[4] + '/';
} else {
	var mothercategory = urlparts[0] + '/' + urlparts[1] + '/' + urlparts[2] + '/' + urlparts[3] + '/index.html/';
}



//-----------------------------------------------------
// -is user using iPad or not
//-----------------------------------------------------
var iPad = ( navigator.userAgent.indexOf('iPad') != -1 ) ? true : false ;


//-----------------------------------------------------
// -init history back
//-----------------------------------------------------

	function init_history_back() {
		var a = document.createElement('a');
		var li = document.createElement('li');
		var span1 = document.createElement('span');

		a.href = "javascript:history.back(-1)";
		li.className = "prev";
		li.appendChild(a);
		a.appendChild(span1);
		span1.innerHTML = "前のページへ";

		document.getElementById('guideNaviList').appendChild(li);
	}



//-----------------------------------------------------
// -init history back (en)
//-----------------------------------------------------

	function init_en_history_back() {
		var a = document.createElement('a');
		var li = document.createElement('li');
		var span1 = document.createElement('span');

		a.href = "javascript:history.back(-1)";
		li.className = "prev";
		li.appendChild(a);
		a.appendChild(span1);
		span1.innerHTML = "To Previous Page";

		document.getElementById('guideNaviList').appendChild(li);
	}


//-----------------------------------------------------
// -open window
//-----------------------------------------------------

	function open_popup(obj) {
		openWin=window.open(obj.href,"layout_popup","width=900,height=760,menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes");
		openWin.focus();
	}


//-----------------------------------------------------
// -checkonload event
//-----------------------------------------------------
window.onunload = function() {};


//-----------------------------------------------------
// -load external js files
//-----------------------------------------------------
var jsDir = '/common/js/';
var jsFiles = new Array();

jsFiles.push("jquery-1.6.4.min");
//topics
if ( document.URL.indexOf('/topics/') != -1 ) jsFiles.push("topicsImageChanger");
jsFiles.push("productFeatureChanger");
jsFiles.push("imageChanger");
jsFiles.push("floating");
jsFiles.push("selectColor");
jsFiles.push("accordion");
jsFiles.push("modal");
jsFiles.push("labelImageLink");
jsFiles.push("requirement");
jsFiles.push("fontsize");
jsFiles.push("globalNavi");
jsFiles.push("localNavi");
jsFiles.push("tabNavi");
jsFiles.push("home");
jsFiles.push("promotion");


var loadJS = function(js) {
	document.open();
	document.write('<script type="text/javascript" src="' + js + '.js" charset="utf-8"></script>');
	document.close();
};

(function(files, dir) {
	for (var i = 0, l = files.length; i < l; ++i) {
		var js = files[i].match(/^https?:\/\//) ? files[i] : dir + files[i];
		loadJS(js);
	}
})(jsFiles, jsDir);


