// JavaScript Document


JAPI._browserLibrary = {

	isDOM : function(){
		return document.getElementById? 1 : 0;	
	}, // end function

	isIE : function(){
		return document.all ? 1 : 0;	
	}, // end function
	
	isNS4 : function(){
		return navigator.appName == 'Netscape' && !JAPI.browser().isDOM() ? 1 : 0;
	}, // end function
	
	isIE4 : function(){
		return JAPI.browser().isIE() && !JAPI.browser().isDOM() ? 1 : 0;
	}, // end function
	
	isDyn : function(){
		return JAPI.browser().isDOM() || JAPI.browser().isIE() || JAPI.browser().isNS4();
	}, // end function
	
	isOpera : function(){
		return window.opera ? 1 : 0;
	}, // end function

	isSafari : function(){
		return /Safari/.test(navigator.userAgent);
	}, // end function

	isDHTML : function(){
		return document.getElementById || document.all || document.layers;
	}, // end function

	printStatus : function(status_message){
		window.status = status_message;
	}, // end function

	getWidth : function(node){
		if(JAPI.browser().isIE()){
			return node.offsetWidth;
		} else {
			return JAPI.common().getStyle(node, "width");
		} // end if
	}, // end function
	
	getHeight : function(node){
		if(JAPI.browser().isIE()){
			return node.offsetHeight;
		} else {
			return JAPI.common().getStyle(node, "height");
		} // end if
	}, // end function

	getScreenWidth : function() {
		var sWidth = 0;
		
		if (self.innerWidth) {
			sWidth = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			sWidth = document.documentElement.clientWidth;
		} else if (document.body) {
			sWidth = document.body.clientWidth;
		} // end if..elseif..elseif
		
		return sWidth;
	}, // end function

	getScreenHeight : function() {
		var sHeight = 0;
		
		if (self.innerHeight) {
			sHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			sHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			sHeight = document.body.clientHeight;
		} // end if..elseif..elseif
		
		return sHeight;
	}, // end function

	getXOverflow : function(node) {
		xw = JAPI.browser().getScreenWidth();
		xd = JAPI.common().getStyle(node, "left");
		xp = JAPI.browser().getWidth(node);
		alert(xd +":"+ xp +":"+ xw);
		return xd + xp - xw;
	}, // end function


	getYOverflow : function(node) {
		yw = JAPI.browser().getScreenHeight();
		yd = JAPI.common().getStyle(node, "top");
		yp = JAPI.browser().getHieght(node);
		
		return yd + yp - yw;
	}, // end function

	printMouseStatus : function(e){
		var x = 0;
		var y = 0;
		
		//alert("print mouse status event triggered");
		
		if(!e) var e=window.event;
		var evt = e;
		
		if(e == null) {
			return
		} else {
			x = JAPI.coordinate().getCursorXPosition(e);
			y = JAPI.coordinate().getCursorYPosition(e);
			var message = "Cursor ("+x+"px:"+y+"px)";
			JAPI.browser().printStatus(message);
		} // end if..else
		
	}, // end function

	setMouseCursorStatus : function(status){
		if(status == true || status == 1 || status == "on" || status == "ON" || status == "On"){
			// status is on
			//window.alert("Cursor Status On");
			JAPI.browser().printStatus("Cursor Status On");
			JAPI.common().addEvent(document, "mousemove", JAPI.browser().printMouseStatus, false);
		} else {
			// status is off
			JAPI.browser().printStatus("Cursor Status Off");
			JAPI.common().removeEvent(document, "mousemove", JAPI.browser().printMouseStatus, false);
		} // end if
	} // end function

} // end Library
