//-----------------------------------------------------
//variable definition
//-----------------------------------------------------


//OS
var mac = (navigator.appVersion.indexOf("Mac") != -1)? true : false;

//browser
var nn = (navigator.appName.indexOf("Netscape",0) != -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;


//-----------------------------------------------------
//set css
//-----------------------------------------------------

var cssFile;

if(mac){
	if (nn) {
		cssFile = "/COMMON/CSS/base_macnn.css";
	}
}

if (cssFile) {
	if (document.getElementById && !opera5 && !opera6 && !(mac && ie5) && !icab){
		var head = document.getElementsByTagName('HEAD').item(0);
		var newLink = document.createElement('LINK');
		newLink.rel = "stylesheet";
		newLink.type = "text/css";
		newLink.href = cssFile;
		head.appendChild(newLink);
	}else{
		document.open();
		document.write('<link rel="stylesheet" href="' + cssFile + '" type="text/css">');
		document.close();
	}
}


//-----------------------------------------------------
//window open
//-----------------------------------------------------


function checkEvent(targetObj,windowW,windowH,scrollbarOption,eventObj){
	var eventType;
	var keycode;
	
	if(window.event){
		keycode = event.keyCode;
		eventType = event.type;
	}
	else if(eventObj){
		keycode = eventObj.which;
		eventType = eventObj.type;
	}
	
	if(keycode == 13 && eventType == 'keypress'){
		openFigWindow(targetObj,windowW,windowH,scrollbarOption);
	}
}

function openFigWindow(targetObj,windowW,windowH,scrollbarOption){
	var windowName = targetObj.target;
	var uri = targetObj.href;
	var options = 'toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=' + (scrollbarOption?'yes':'no') + ',resizable=yes,width=' + windowW + ',height=' + windowH;
	
	if(!window.scrollbars){
		if(scrollbarOption)windowName += '_02';
	}
	
	newWindow = window.open(uri,windowName,options);
	newWindow.focus();
	
	if(newWindow.scrollbars){
		if(scrollbarOption){
			newWindow.scrollbars.visible = true;
		}
		else{
			newWindow.scrollbars.visible = false;
		}
	}
	
	if(!(typeof newWindow.resizeBy == 'undefined')){
		var newWindowW = 0;
		var newWindowH = 0;
		var differenceW = 0;
		var differenceH = 0;
		
		//Opera,Safari,over NN4
		if(newWindow.innerWidth){
			newWindowW = newWindow.innerWidth;
			newWindowH = newWindow.innerHeight;
		}
		
		//WinIE6 standardmode
		else if(newWindow.document.compatMode == 'CSS1Compat'){
			newWindowW = newWindow.document.documentElement.clientWidth;
			newWindowH = newWindow.document.documentElement.clientHeight;
		}
		
		//over IE5
		else if(newWindow.document.body && newWindow.document.body.clientWidth){
			newWindowW = newWindow.document.body.clientWidth;
			newWindowH = newWindow.document.body.clientHeight;
		}
		
		if(newWindowW && newWindowH){
			differenceW = (scrollbarOption?windowW+15:windowW) - newWindowW;
			differenceH = windowH - newWindowH;
			newWindow.resizeBy(differenceW,differenceH);
		}
	}
}


//-----------------------------------------------------
//page print
//-----------------------------------------------------


function pagePrint(){
	if(window.print)this.window.print();
}


//-----------------------------------------------------
//swap image
//-----------------------------------------------------


function swapImage(targetObj,imageSrc){
	if(preloadFlag && (document.all || document.getElementById)){
		targetObj.src = imageSrc;
	}
}




