/*______________________________________

  MK JavaScript Lib.(Limited Edition)

  Copyright (C) 1999-2003
  Mami Komura All rights reserved.
  http://www.warehouse56.com/

______________________________________*/

var UA  = navigator.userAgent;
var Mac = navigator.appVersion.indexOf('Mac',0) != -1;
var Win = navigator.appVersion.indexOf('Win',0) != -1;
var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
var NN  = navigator.appName.indexOf("Netscape",0) != -1;
var NN4 = document.layers;
var Moz = UA.indexOf("Gecko/") != -1;
var Opera  = window.opera;
var Opera6 = navigator.userAgent.indexOf("Opera 6") != -1;
var Opera7 = navigator.userAgent.indexOf("Opera 7") != -1;
var Safari = UA.indexOf("Safari") != -1;
var Vmajor = parseInt(navigator.appVersion); // ex. 3
var Vminor = parseFloat(navigator.appVersion); // ex. 3.01
var WinIE55 = ((Win && navigator.appVersion.indexOf('MSIE 5.5',0) != -1));
var MacIE5 = ((Mac && navigator.appVersion.indexOf('MSIE 5.',0) != -1));
var MacIE4 = ((Mac && navigator.appVersion.indexOf('MSIE 4.',0) != -1));
var MacIE3 = ((Mac && navigator.appVersion.indexOf('MSIE 3.',0) != -1));
var iCab = (navigator.userAgent.indexOf("iCab",0) != -1);

function preloadImg(imgName) {
 if (document.images) (new Image()).src = imgName;
}

function swapImage(target,src) { // 020507
 var NN4_layerPath;
 if (arguments.length > 2 && document.layers) {
  NN4_layerPath = "";
  for (i=2; i<arguments.length; i++) NN4_layerPath += 'document.layers["' + arguments[i] + '"].';
  eval(NN4_layerPath + 'document.images["' + target + '"]').src = src;
  return;
 }
 document.images[target].src = src;
}

function openWindow(url,title,options) {
 var newWin;
 if (!!window && url) {
  if (!title) title = "_blank";
  if (!options) {
   options = "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,favorites=yes";
  }
  newWin = window.open(url,title,options);
  if (!WinIE55) newWin.focus();
 }
}

function openWindowFull(url){
 h = screen.availHeight;
 w = screen.availWidth;
 window.open(url,"window1","height="+h+",width="+w+",top=0,left=0,resizable=yes");
}

/* js component for "reloading page onResize"
   original source: resize.js 0.3 970811 by gary smith */
 if(!window.saveInnerWidth && document.layers) {
   window.onresize = resizeIt;
   window.saveInnerWidth = window.innerWidth;
   window.saveInnerHeight = window.innerHeight;
 }
function resizeIt() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}

function setObj(id) {
	if (document.all) {
		return document.all(id);
	} else if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.layers) {
		return document.layers[id];
	}
	return false;
}

// ========== layer control ==========

function moveDivTo(lyrname,Xpx,Ypx) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		obj.style.pixelLeft = Xpx;
		obj.style.pixelTop  = Ypx;
	} else if (document.getElementById && obj.style) {
		obj.style.left = Xpx + 'px';
		obj.style.top  = Ypx + 'px';
	} else if (document.layers) {
		obj.moveTo(Xpx,Ypx);
	}
}

function cngPosX(lyrname,Xpx) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		obj.style.pixelLeft = Xpx;
	} else if (document.getElementById && obj.style) {
		obj.style.left  = Xpx + 'px';
	} else if (document.layers) {
		obj.left = Xpx;
	}
}

function cngPosY(lyrname,Ypx) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		obj.style.pixelTop = Ypx;
	} else if (document.getElementById && obj.style) {
		obj.style.top  = Ypx + 'px';
	} else if (document.layers) {
		obj.top = Ypx;
	}
}

function moveDivBy(lyrname,Xpx,Ypx) {
	var obj = setObj(lyrname);
	Xpx = parseInt(Xpx); Ypx = parseInt(Ypx);
	if (document.all && obj.style) {
		obj.style.pixelLeft = Xpx + getDivPosX(lyrname);
		obj.style.pixelTop  = Ypx + getDivPosY(lyrname);
	} else if (document.getElementById && obj.style) {
		obj.style.left = Xpx + getDivPosX(lyrname) + 'px';
		obj.style.top  = Ypx + getDivPosY(lyrname) + 'px';
	} else if (document.layers) {
		obj.moveTo(Xpx,Ypx);
	}
}

function getDivPosX(lyrname) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		return parseInt(obj.style.pixelLeft);
	} else if (document.getElementById && obj.style) {
		if (Moz) {
			style = getComputedStyle(obj,null);
			return parseInt(style.getPropertyValue('left'));
		}
		if (Safari) return obj.offsetLeft;
		return parseInt(obj.style.left);
	} else if (document.layers) {
		return parseInt(obj.left);
	}
	return '';
}

function getDivPosY(lyrname) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		return parseInt(obj.style.pixelTop);
	} else if (document.getElementById && obj.style) {
		if (Moz) {
			style = getComputedStyle(obj,null);
			return parseInt(style.getPropertyValue('top'));
		}
		if (Safari) return obj.offsetTop;
		return parseInt(obj.style.top);
	} else if (document.layers) {
		return parseInt(obj.top);
	}
	return '';
}

function getDivWidth(lyrname) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		return obj.clientWidth;
	} else if (document.getElementById && obj.style) {
		if (Moz) {
			style=getComputedStyle(obj,null);
			return parseInt(style.getPropertyValue('width'));
		}
		if (Safari) return obj.offsetWidth;
		return parseInt(obj.style.width);
	} else if (document.layers) {
		return obj.clip.width;
	}
	return '';
}

function getDivHeight(lyrname) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		return obj.clientHeight;
	} else if (document.getElementById && obj.style) {
		if (Moz) {
			style=getComputedStyle(obj,null);
			return parseInt(style.getPropertyValue('height'));
		}
		if (Safari) return obj.offsetHeight;
		return parseInt(obj.style.height);
	} else if (document.layers) {
		return obj.clip.height;
	}
	return '';
}

function setVisiblity(target, str) {
	var obj = setObj(target);
	var values = new Array(2);
	if ((document.getElementById || document.all) && obj.style) {
		if (str == null) str = ( obj.style.visibility == 'hidden' ) ? 1 : 0;
		obj.style.visibility = (str > 0) ? 'visible' : 'hidden';
	} else if (document.layers) {
		if (str == null) str = ( obj.visibility == 'hide' ) ? 1 : 0;
		obj.visibility = (str > 0) ? 'show' : 'hide';
	}
}

