

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 Moz = navigator.userAgent.indexOf("Gecko") != -1;
var Opera = window.opera;
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 getX = 0;
var getY = 0;
var __InfoTips = new Object();

__InfoTips.id = "infoTips";
__InfoTips.bgColor = "#003399";
__InfoTips.color = "#ffffff";
__InfoTips.width = 280;
__InfoTips.modTimer = null;
__InfoTips.loaded = false;

function infoTipsInit() {
 if (document.all) {
  document.onmousemove=getEventCoords;
  __InfoTips.loaded = true;
 } else if (Moz) {
  document.addEventListener("mousemove", getEventCoords, false);
  __InfoTips.loaded = true;
 } else if (NN && Vminor >= 4.75) {
  window.captureEvents(Event.MOUSEMOVE);
  window.onmousemove=getEventCoords;
  setBackgroundColor4Lyr(__InfoTips.id , __InfoTips.bgColor);
  __InfoTips.loaded = true;
 }
}
function showChip(str) {
 if (__InfoTips.loaded) {
  var writeSrc;
  changeVisible (__InfoTips.id ,0);
  if (document.layers) {
   writeSrc = '<table border="0" cellpadding="3" cellspacing="0" width="'+ __InfoTips.width +'"><tr><td class="helpText">' + str +'<\/td><\/tr><\/table>';
  } else {
   writeSrc = '<p class="helpText">'+ str +'<\/p>';
  }
  writeLayer(__InfoTips.id ,writeSrc);
  if (__InfoTips.modTimer) clearTimeout(__InfoTips.modTimer);
  __InfoTips.modTimer = setTimeout("showInfoTips()", 200);
 }
}
function showInfoTips() {
 if (__InfoTips.loaded) {
  scw = getScrollWidth();
  sch = getScrollHeight();
  helpX = getX - 16;
  helpY = getY - getDivHeight(__InfoTips.id) - 16;
  if ( helpX > scw - getDivWidth(__InfoTips.id)) helpX = scw - getDivWidth(__InfoTips.id) - 16;
  if ( getX < getScrollLeft() + 16 ) helpX = 16;
  if ( getY < getScrollTop() + getDivHeight(__InfoTips.id)) helpY = getY + 24;
  if (!(document.layers)) {
   helpX += getScrollLeft();
   helpY += getScrollTop();
  }
  moveDivTo(__InfoTips.id ,helpX,helpY);
  changeVisible (__InfoTips.id ,1);
  if (__InfoTips.modTimer) clearTimeout(__InfoTips.modTimer);
  __InfoTips.modTimer = setTimeout("showInfoTips()",16);
 }
}
function hideInfoTips() {
 if (__InfoTips.loaded) {
  if (__InfoTips.modTimer) clearTimeout(__InfoTips.modTimer);
  changeVisible (__InfoTips.id ,0);
 }
}
function printInfoTipsCore() {
 with (document) {
  open();
  if (document.layers) {
   write('<layer name="'+ __InfoTips.id +'"><\/layer>');
  } else {
   write('<div id="'+ __InfoTips.id +'"><\/div>');
  }
  close();
 }
}
function printInfoTipsStyle() {
 var src;
 with (document) {
  open();
  src  = '<style type="text/css"><!--';
  src += '#'+ __InfoTips.id +' { position: absolute; border: solid 1px #333333; background-color: '+ __InfoTips.bgColor +'; visibility: hidden; padding: 5px; z-index: 100; width: '+ __InfoTips.width + 'px; font-family:verdana;}';
  src += '.helpText { color: '+ __InfoTips.color +'; font-size: 11px; margin: 0; }';
  src += 'p.helpText { line-height: 18px; }';
  src += '--><\/style>';
  write (src);
  close();
 }
}
/* ========== basic functions ========== */
function getEventCoords(e){
	if (IE) {
		getX = window.event.clientX;
		getY = window.event.clientY;
	} else if (Moz) {
		getX = e.clientX;
		getY = e.clientY;
	} else if (document.layers) {
		getX = e.pageX;
		getY = e.pageY;
	}
}
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;
}
// ========== Screen ==========
function getScrollTop() {
	if (IE) {
		return document.body.scrollTop;
	} else if (Moz) {
		return window.pageYOffset;
	} else if (NN) {
		return window.pageYOffset;
	}
	return 0;
}
function getScrollLeft() {
	if (IE) {
		return document.body.scrollLeft;
	} else if (Moz) {
		return window.pageXOffset;
	} else if (NN) {
		return window.pageXOffset;
	}
	return 0;
}
function getScrollWidth() {
	if (IE) {
		return document.body.scrollWidth;
	} else if (Moz) {
		return window.innerWidth;
	} else if (NN) {
		return window.innerWidth;
	}
	return 0;
}
function getScrollHeight() {
	if (IE) {
		return document.body.scrollHeight;
	} else if (Moz) {
		return window.innerHeight;
	} else if (NN) {
		return window.innerHeight;
	}
	return 0;
}
function getScreenWidth() {
	if (IE) {
		return document.body.offsetWidth;
	} else if (Moz) {
		return window.innerWidth;
	} else if (NN) {
		return window.innerWidth;
	}
	return 0;
}
function getScreenHeight() {
	if (IE) {
		return document.body.offsetHeight;
	} else if (Moz) {
		return window.innerHeight;
	} else if (NN) {
		return window.innerHeight;
	}
	return 0;
}
// ========== 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'));
		}
		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'));
		}
		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'));
		}
		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'));
		}
		return parseInt(obj.style.height);
	} else if (document.layers) {
		return obj.clip.height;
	}
	return '';
}
function resizeDivTo (lyrname,width,height) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		obj.style.pixelWidth  = width + 'px';
		obj.style.pixelHeight = height + 'px';
	} else if (document.layers) {
		obj.resizeTo(width,height);
	}
}
function setBackgroundRepeat(lyrname,order) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		obj.style.backgroundRepeat = order;
	} else if (document.layers) {
		document.layers[lyrname].backgroundRepeat = order;
	}
}
function setBackgroundColor4Lyr(lyrname,color) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		obj.style.background = color;
	} else if (document.layers) {
		obj.bgColor = color;
	}
}
function setBackgroundImage4Lyr(lyrname,url) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		obj.style.backgroundImage = (url == ('none' || null)) ? 'none' : 'url(' + url + ')';
	} else if (document.layers) {
		document.layers[lyrname].background.src = (url == ('none' || null)) ? null : url;
	}
}
function setDisplay(target, str) {
	var obj = setObj(target);
	if ((document.getElementById || document.all) && obj.style) {
		if (str == null) str = ( obj.style.display == 'none' || obj.style.display == '') ? 1 : 0;
		obj.style.display = (str > 0) ? 'block' : 'none';
	}
}
function getDisplay(target) {
	var obj = setObj(target);
	if ((document.getElementById || document.all) && obj.style) {
		return obj.style.display;
	}
}
function changeVisible(lyrname, str) {
	var obj = setObj(lyrname);
	var values = new Array(2);
	if ((document.getElementById || document.all) && obj.style) {
		values[1] = 'visible',values[0] = 'hidden';
		if (str == null) str = ( obj.style.visibility == values[0] ) ? 1 : 0;
		obj.style.visibility = (str > 0) ? values[1] : values[0];
	} else if (document.layers) {
		values[1] = 'show',values[0] = 'hide';
		if (str == null) str = ( obj.visibility == values[0] ) ? 1 : 0;
		obj.visibility = (str > 0) ? values[1] : values[0];
	}
}
function cngClip(lyrname,clipTop,clipRight,clipBottom,clipLeft) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		obj.style.clip = 'rect(' + clipTop + 'px,' + clipRight + 'px,' + clipBottom + 'px,' + clipLeft + 'px)';
	} else if (document.layers) {
		obj.clip.top = clipTop;
		obj.clip.bottom = clipBottom;
		obj.clip.left = clipLeft;
		obj.clip.right = clipRight;
	}
}
function getClipValues(lyrname,which) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		if (obj.style.clip == 'auto') return 'auto';
		var clipv = obj.style.clip.split('rect(')[1].split(')')[0].split(" ");
		if (which == "top")    return parseInt(clipv[0]);
		if (which == "right")  return parseInt(clipv[1]);
		if (which == "bottom") return parseInt(clipv[2]);
		if (which == "left")   return parseInt(clipv[3]);
	} else if (document.layers) {
		if (which == "top")    return obj.clip.top;
		if (which == "right")  return obj.clip.right;
		if (which == "bottom") return obj.clip.bottom;
		if (which == "left")   return obj.clip.left;
	}
}
function setDivZIndex(lyrname,order) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		obj.style.zIndex = order;
	} else if (document.layers) {
		obj.zIndex = order;
	}
}
function getDivZIndex(lyrname) {
	var obj = setObj(lyrname);
	if ((document.getElementById || document.all) && obj.style) {
		return obj.style.zIndex;
	} else if (document.layers) {
		return obj.zIndex;
	}	
}
function getDivScrollHeight(lyrname) {
	var obj = setObj(lyrname);
	if (document.all) {
		return obj.scrollHeight;
	} else if (document.layers) {
		return obj.document.height;
	}
	return 0;
}
function cngFontColor (targetId,r,g,b) {
	var obj = setObj(lyrname);
	if (document.all && obj.style) {
		obj.style.color = "#" + r + g + b;
	} else if (document.getElementById && obj.style) {
		obj.style.color = "#" + r + g + b;
	} else if (document.layers) {
		obj.document.fgColor = "#" + r + g + b;
	}
}
function writeLayer(lyrname,code) {
	var obj = setObj(lyrname);
	if (document.all) {
		obj.innerHTML=code;
	} else if (document.getElementById) {
		obj.innerHTML=code;
	} else if (document.layers) {
		obj.document.open();
		obj.document.write(code);
		obj.document.close();
	}
}