//*************************************************************//
// JS library Var1.0
// Made by Tsuchiya Hayato. 2006.05
//*************************************************************//

JSpath = "/common/js/"
loadJS("set.js","flash.js");

function loadJS(){
	for(var i=0;i<arguments.length;i++){
		document.write('<script type="text/javascript" src="' + JSpath + arguments[i] + '"><\/script>');
	}
}

DOM=(document.all)?(document.getElementById)?3:2:
	(document.getElementById)?4:
	(document.layers)?1:0;

function addLoadEvent(func) {
	var oldonload = window.onload;
	window.onload = function() {
		if(typeof window.onload != 'function') oldonload();
		func();
	}
}

function addUnLoadEvent(func) {
	var oldonunload = window.onunload;
	window.onunload = function() {
		if(typeof window.onunload != 'function') oldonunload();
		func();
	}
}

function $() {
	var elements=new Array();
	for (var i=0; i<arguments.length; i++){
		var element=arguments[i];
		element =
		(typeof(element)=="object") ? element :
		(DOM>=3) ? document.getElementById(element) :
		(DOM==2) ? document.all(element) :
		null;

		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}


function getDOM(obj){
	return objID =
	(typeof(obj)=="object") ? obj :
	(DOM>=3) ? document.getElementById(obj) :
	(DOM==2) ? document.all(obj) :
	null;
}
function getElementsByClass(searchClass,node,tag) {
	if (node==null) node = document;
	if (tag == null) tag = '*';
	var els = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i=0,x=0,Element= new Array(); i<els.length; i++){
		if (pattern.test(els[i].className)) Element[x++]=els[i];
	}
	return Element;
}


//===================================================================
//
//	***  browser CSS  ***
//
//===================================================================


//-----------------------------------------------------
//variable definition
//-----------------------------------------------------


//OS
var mac = (navigator.appVersion.indexOf("Mac") != -1)? true : false;

//browser
var nn = (navigator.appName.indexOf("Netscape",0) != -1)? true : false;
var nn4 = (document.layers)? true : false;
var nn6 = (navigator.userAgent.indexOf("Netscape6") != -1)? true : false;
var opera = (navigator.userAgent.indexOf("Opera") != -1)? true : false;
var opera6 = (navigator.userAgent.indexOf("Opera/6") != -1)? true : false;
var opera5 = (navigator.userAgent.indexOf("Opera/5") != -1)? true : false;
var icab = (navigator.userAgent.indexOf("iCab") != -1)? true : false;
var mac = (navigator.appVersion.indexOf("Mac") != -1)? true : false;
var ie5 = (navigator.userAgent.indexOf("MSIE 5") != -1)? true : false;
var safari = (navigator.userAgent.indexOf("Safari") != -1)? true : false;
var cssFile;

//-----------------------------------------------------
//set CSS
//-----------------------------------------------------

if(opera){
	cssFile = "/common/css/fixoperall.css";
}
if(mac){
	if(safari){
		cssFile = "/Common/Css/FixMacSafari.css";
	} else if(ie5){
		cssFile = "/Common/Css/FixMacIE.css";
	}
} else {
	if(nn6){
		cssFile = "/Common/Css/FixWinNN6.css";
	}
}

if(cssFile){
	document.open();
	document.write('<link rel="stylesheet" href="' + cssFile + '" type="text/css">');
	document.close();
}

//-----------------------------------------------------
// openWin
//-----------------------------------------------------

var gAgent = navigator.userAgent;
var gAppVer = navigator.appVersion;

var gBrowser = navigator.appName;
var gPlatform = null;
var gVersion = null;

if (gAgent.indexOf('Mac') != -1) {
	gPlatform = "Mac";
} else if (gAgent.indexOf('Win') != -1) {
	gPlatform = "Win";
} else {
	gPlatform = "other";
}

if (gAgent.indexOf('MSIE') != -1) {
	gVersion = gAgent.substring((gAgent.indexOf('MSIE') + 5), (gAgent.indexOf('MSIE') + 9));
	gBrowser = "MSIE";

} else if (gAgent.indexOf('MSIE') == -1) {
	gVersion = gAppVer.substring(0,4);
	if (gAgent.indexOf('Gecko') != -1) {
		if (gAgent.indexOf('Netscape') != -1) {
			gVersion = gAgent.substring((gAgent.indexOf('Netscape') + 9), (gAgent.indexOf('Netscape') + 12));
		}
	}
	// NN
	if (gBrowser == "Netscape") {
		gBrowser = "NN";
	}
	// Safari
	if (gAgent.indexOf('Safari') != -1) {
		gBrowser = "Safari";
	}
}

if (gVersion.indexOf(';') != -1) {
	gVersion = gVersion.substring(0, gVersion.indexOf(';'));
}
if (gVersion.indexOf(' ') != -1) {
	gVersion = gVersion.substring(0, gVersion.indexOf(' '));
}

if (!gNewWindow) {
	var gNewWindow = null;
}

function openWin(url, n, w, h, st){
	var width = parseInt(w);
	var height = parseInt(h);
	var toolbar;
	var location;
	var directories;
	var status;
	var menubar;
	var resizable;
	var scrollbars;
	var dependent;

	st.charAt(0) == '1'	?  toolbar = 'yes' 		: toolbar = 'no';
	st.charAt(1) == '1'	?  location = 'yes' 	: location = 'no';
	st.charAt(2) == '1'	?  directories = 'yes' 	: directories = 'no';
	st.charAt(3) == '1'	?  status = 'yes' 		: status = 'no';
	st.charAt(4) == '1'	?  menubar = 'yes' 		: menubar = 'no';
	st.charAt(5) == '1'	?  resizable = 'yes' 	: resizable = 'no';
	st.charAt(6) == '1'	?  scrollbars = 'yes' 	: scrollbars = 'no';
	st.charAt(7) == '1'	?  dependent = 'yes' 	: dependent = 'no';

	if (location == 'yes') {
		// NN5 over
		if (gBrowser == "NN" && gVersion >= 5) {
			width += 0;
			height += 0;

		// NN4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "NN" && gVersion >= 4) {
			width += 15;
			height += 15;

		// NN4(for Win)

		} else if (gBrowser == "NN" && gVersion >= 4) {
			width += 0;
			height += 0;

		// IE5 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 5) {
			width += 0;
			height += 19;

		// IE4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 4) {
			width += 2;
			height += 6;

		// IE6(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 6) {
			width += 0;
			height -= 19;

		// IE5(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 5) {
			width += 0;
			height -= 19;

		// IE4(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 4) {
			width += 0;
			height -= 19;

		// safari for Mac
		} else if (gPlatform == "Mac" && gBrowser == "Safari" && gVersion >= 0) {
			width += -2;
			height += 50;

		// other
		} else {
			width += 0;
			height += 0;
		}
	}

	if (scrollbars == 'yes') {
		// NN5 over
		if (gBrowser == "NN" && gVersion >= 5) {
			width += 15;
			height += 1;

		// NN4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "NN" && gVersion >= 4) {
			width += 15;
			height -= 0;

		// NN4(for Win)
		} else if (gBrowser == "NN" && gVersion >= 4) {
			width += 16;
			height -= 0;

		// IE5 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 5) {
			width -= 0;
			height -= 16;

		// IE4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 4) {
			width -= 0;
			height -= 14;

		// IE5(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 5) {
			width += 16;
			height += 0;

		// IE4(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 4) {
			width += 16;
			height += 0;

		// other
		} else {
			width += 15;
			height += 3;
		}
	} else {
		// NN5 over
		if (gBrowser == "NN" && gVersion >= 5) {
			width += 1;
			height += 1;

		// NN4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "NN" && gVersion >= 4) {
			width -= 0;
			height -= 0;

		// NN4(for Win)
		} else if (gBrowser == "NN" && gVersion >= 4) {
			width -= 0;
			height -= 0;

		// IE5 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 5) {
			width -= 0;
			height -= 0;

		// IE4 for Mac
		} else if (gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 4) {
			width -= 0;
			height += 2;

		// IE5(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 5) {
			width += 0;
			height += 0;

		// IE4(for Win)
		} else if (gBrowser == "MSIE" && gVersion >= 4) {
			width += 0;
			height += 0;

		// other
		} else {
			width += 0;
			height += 0;
		}
	}


	if (status == 'yes') {
		// NN4 for Mac
		if (gPlatform == "Mac" && gBrowser == "NN" && gVersion >= 4 && gVersion < 5) {
			width -= 15;
			height -= 15;

		// IE4 for Mac
		}else if(gPlatform == "Mac" && gBrowser == "MSIE" && gVersion >= 4 && gVersion < 5){
			width -= 0;
			height += 16;

		}
	}


	if (status == 'no') {
		// NN4
		if (gBrowser == "NN" && gVersion >= 4 && gVersion < 5) {
			width -= 0;
			height -= 0;

		// NN5 over
		}else if (gPlatform == "Mac" && gBrowser == "NN") {
			width += 0;
			height += 80;

		// NN5 over
		}else if (gPlatform == "Win" && gBrowser == "NN") {
			width += 0;
			height += 20;

		// safari for Mac
		} else if (gPlatform == "Mac" && gBrowser == "Safari" && gVersion >= 0) {
			width += 0;
			height += 20;

		}
	}


	var win_size = 'width=' + width + ',height=' + height;
	var win_attr = 'toolbar=' + toolbar + ',location=' + location + ',directories=' + directories + ',status=' + status + ',menubar=' + menubar + ',resizable=' + resizable + ',scrollbars=' + scrollbars + ',dependent=' + dependent;

	var w = window.open(url, n, win_attr + ',' + win_size);
	return false;
}

fullwin = null;

function openWinFull(url, n){
	var toolbar = 'no';
	var location = 'no';
	var directories = 'no';
	var status = 'no';
	var menubar = 'no';
	var resizable = 'yes';
	var scrollbars = 'no';
	var dependent = 'no';
	var x_point = 0;
	var y_point = 0;
	var a_width = screen.availWidth;
	var a_height = screen.availHeight;
	var width = screen.width;
	var height = screen.height;
	var win_attr = 'toolbar=' + toolbar + ',location=' + location + ',directories=' + directories + 
					',status=' + status + ',menubar=' + menubar + ',resizable=' + resizable + ',scrollbars=' + 
					scrollbars + ',dependent=' + dependent + ', left=' + x_point + ',top=' + y_point;
	
	if (gPlatform == "Win") {
		if (gBrowser == "NN") {
			if (gVersion < 5) {
				a_width -= 12;
				a_height -= 30;
			} else {
				a_width -= 10;
				a_height -= 27;
			}
		} else 	if (gBrowser == "MSIE") {
			a_width -= 10;
			a_height -= 30;
		} else {
			a_width -= 0;
			a_height -= 0;
		}
		var win_size = 'width=' + a_width + ',height=' + a_height;
		fullwin = window.open(url,n, win_attr + ',' + win_size);
	}
	else if (gPlatform == "Mac") {
		var win_size = 'width=' + width + ',height=' + height;
		fullwin = window.open(url,n, win_attr + ',' + win_size);
		fullwin.resizeTo(width, height);
		
		if(gBrowser != "Safari"){
			fullwin.resizeBy(a_width - width, a_height - height);
		}
	}
	else{
		var win_size = 'width=' + width + ',height=' + height;
		fullwin = window.open(url,n, win_attr + ',' + win_size);
	}
}
//Event management
function setMouseOver(ID,func){
	$(ID).onmouseover = function(event){eval(func);}
}
function setMouseOut(ID,func){
	$(ID).onmouseout = function(event){eval(func);}
}
function setMouseClick(ID,func){
	$(ID).onclick = function(event){eval(func);}
}
function setMouseDblClick(ID,func){
	$(ID).ondblclick = function(event){eval(func);}
}
function setMouseUp(ID,func){
	$(ID).onmouseup = function(event){eval(func);}
}
function setMouseMove(ID,func){
	$(ID).onmousemove = function(event){eval(func);}
}
function setMouseDown(ID,func){
	$(ID).onmousedown = function(event){eval(func);}
}
function setOnFocus(ID,func){
	$(ID).onfocus = function(event){eval(func);}
}
function setOnChange(ID,func){
	$(ID).onchange = function(event){eval(func);}
}
function setAnchor(ID,func){
	$(ID).href = "javascript:"+func;
}
if(nn4){
	document.captureEvents(Event.MOUSEMOVE);
	document.captureEvents(Event.MOUSEUP);
	document.captureEvents(Event.MOUSEDOWN);
	document.captureEvents(Event.MOUSECLICK);
}
if(window.opera){
	op_dmydoc ='<div id="dmy"'+'style="position:absolute;'+'z-index:0;'+'left:100%;top:100%">'+'</div>';
	document.write(op_dmydoc);
}

function setDisplay(ID,condition){
	obj = $(ID);
	if(DOM>=2){
		obj.style.display = condition;
	}
	if(DOM==1){
		obj.display = condition;
	}
}
function setColor(ID,Num){
	obj=$(ID);
	obj.style.color = Num;
}

function setTxtDeco(ID,Style){
	obj=$(ID);
	obj.style.textDecoration = Style;
}

var differsPass = ""
function getDiffersPass(){
	lang = "/"+document.getElementsByTagName("body")[0].id.toLowerCase()+"/";
	pageLocale = this.location.toString();
	if(pageLocale.indexOf(lang)!=-1){
		differsPass = pageLocale.substring(pageLocale.indexOf(lang)+lang.length,pageLocale.length);
	}
	return differsPass;
}

var periodTime = 7*24*60*60*1000;

function getCookie(key){
	Ctmp = document.cookie+";";
	Ctmp1 = Ctmp.indexOf(key,0);
	if(Ctmp1 != -1){
		Ctmp = Ctmp.substring(Ctmp1,Ctmp.length);
		var start=Ctmp.indexOf("=",0)+1;
		var end = Ctmp.indexOf(";",start);
		return (unescape(Ctmp.substring(start,end)));
	}
	return("");
}
function setCookie(key,val){
	cExpire = new Date();
	cExpire.setTime(cExpire.getTime() + periodTime);
	Ctmp = key+"="+escape(val)+";";
	Ctmp += "expires=" + cExpire.toGMTString()+";";
	document.cookie = Ctmp;
}
function delCookie(){
	if(document.cookie != ""){
		tmp = document.cookie.split(";");
		cExpire = new Date();
		cExpire.setYear(cExpire.getYear() - 1);
		for(i=0; i<tmp.length; i++){
			cName = tmp[i].split("=")[0];
			document.cookie = cName + "=;expires=" + cExpire.toGMTString();
		}
	}
	return false;
}

function getDirectChild(_Parent,_ChildAry){
	for(i=0,DirectChild = new Array(); i<_ChildAry.length; i++)
		if(_ChildAry[i].parentNode == _Parent)DirectChild.push(_ChildAry[i]);
	return DirectChild;
}


//*************************************************************//
// Copyright(C) 2006 KINOTROPE, INC. All Rights Reserved.
//*************************************************************//
