/**************************************************************************************
*
*javaScriptLib_thiaoouba.js 
* for: 
*        Netscape Communicator and Internet Explorer browsers 
*        version 4.0 and up                                                 
*                                                         
**************************************************************************************/
//-----------------------------------------------------------------------------
// show all objects properties.
//-----------------------------------------------------------------------------
function show_props(obj, obj_name, whichProp) {
   var result = ""
  	switch( whichProp){
		case "all":	
  			 for (var i in obj){ 
				result += "<b>"+obj_name + "." + i + "</b>"+" = " + obj[i] + "<br>"
				//document.write('<br>"'+i+'" = "'+obj[i]+'" ');
			}
   			 return result
		break;
		default : 
  			 for (var i in obj){ 
				result += "<b>"+obj_name + "." + i + "</b>"+" = " + obj[i] + "<br>"
				//document.write('<br>"'+i+'" = "'+obj[i]+'" ');
			}
   			 return result
	}
 }
	
//-----------------------------------------------------------------------------
// go to page that is exhibited in a frame
//-----------------------------------------------------------------------------
	function goToPageThatInAFrame(familyName, extention){
					if (navigator.appName == "Netscape")  {
								explainName = String(top.frames[2].location);
								//debugWindow.document.write('<!h6>top frame = "'+top.frames[2].location+'" </h6>');
								}
					if (navigator.appName == "Microsoft Internet Explorer")  {
								explainName = String(top.frames[3].location);
								//debugWindow.document.write('<!h6>top frame = "'+top.frames[3].location+'" </h6>');
								}

								var location = 0;
								for (var i = 0; i < explainName.length; i++) { 
	  									//debugWindow.document.write('<!h6>string = "'+explainName.charAt(i)+'"  location = "'+i+'"</h6>');
	   								if  (explainName.charAt(i) == "/"){
																location = i;
												}	
								}
								//document.write('<!h6>location = "'+location+'" </h6>');
								explainName = explainName.slice(location+1, explainName.length);
								constString1 = String(familyName);
								constString2 = String(extention);
								//debugWindow.document.write('<!h6>explainName = "'+explainName+'"</h6>');
								var startIndex = explainName.lastIndexOf(constString1) + constString1.length;
								var lastIndex = explainName.lastIndexOf(constString2);
								var strPageNumber = explainName.slice(startIndex, lastIndex);
								pageNumber = new Number(strPageNumber);
								//debugWindow.document.write('<!h6>startIndex = "'+startIndex+'" lastIndex = "'+lastIndex+'" strPageNumber = "'+strPageNumber+'" pageNumber = "'+pageNumber+'"</h6>');
								explainName.concat("./", explainName);
								return explainName
	}
/*------------------------------------
get frame top and bottom
------------------------------------*/
function getFrameTopBottom(_frameName){
/*
input: _frameName
outPut: result[top,right,bottom,left]
*/
var result = new Array();
  if (isMinIE4){
    if (parent.frames.length==0){
      result[0] = 0;//top
      result[3] = 0;//left 
      result[2] = result[0] + document.body.clientHeight;//bottom  
      result[1] = result[3] + document.body.clientWidth;//right
    }
    else{
      result[0] = parent.eval(_frameName).screenTop;//top
      result[3] = parent.eval(_frameName).screenLeft;//left
      result[2] = result[0] + parent.eval(_frameName).document.body.clientHeight;//bottom
      result[1] = result[3] + parent.eval(_frameName).document.body.clientWidth;//right
    }
  }
  if (isMinNS4){
    if (parent.frames.length==0){
      result[0] = 0;//top
      result[3] = 0;//left 
      result[2] = result[0] + parseInt(parent.innerHeight);//bottom  
      result[1] = result[3] + parseInt(parent.innerWidth);//right
    
    }
    else{
      result[0] = 0;//top
      result[3] = 0;//left  
      result[2] = result[0] + parent.eval(_frameName).innerHeight;//bottom  
      result[1] = result[3] + parent.eval(_frameName).innerWidth;//right
    }
  }
  return result;
} 
/*------------------------------------
capture event handler on mouse move
------------------------------------*/
var booCaptureEventMouseMove = false;
function captureEventMouseMove(){
 if (booCaptureEventMouseMove) return;
 booCaptureEventMouseMove = true;
 
 if (isMinNS4)  document.captureEvents(Event.MOUSEMOVE);
 document.onmousemove = getMousePosition;
} 
/*------------------------------------
event handler get mouse position
------------------------------------*/
function getMousePosition(e) {

  // Save cursor position using browser-specific code.

  if (isMinNS4) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  if (isMinIE4) {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  }
  
           if (isMinIE4){
            var str = "";
                str += "X=" + window.event.clientX;
                str += ", ";
                str += "Y=" + window.event.clientY;
                window.status = str; // display in status bar
                }
            if(isMinNS4){
                var str = "";
                str += "X=" + e.pageX;
                str += ", ";
                str += "Y=" + e.pageY;
                window.status = str; // display in status bar
            }
  
  return true;
}  
/*------------------------------------------------------------------------------
event handler on mouse move
------------------------------------------------------------------------------*/
 
function handlerMouseMove(e) {
         x = (isMinNS4) ? e.pageX : document.body.scrollLeft + event.clientX;
         y = (isMinNS4) ? e.pageY : document.body.scrollTop + event.clientY;
         

         if (isMinIE4){
            var str = "";
                str += "X=" + window.event.clientX;
                str += ", ";
                str += "Y=" + window.event.clientY;
                //window.status = str; // display in status bar
                }
            if(isMinNS4){
                var str = "";
                str += "X=" + e.pageX;
                str += ", ";
                str += "Y=" + e.pageY;
                //window.status = str; // display in status bar
            }
}
/*------------------------------------
browser detection
------------------------------------*/
function Is() {
    agent  = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla')   !=   -1) &&
                 ((agent.indexOf('spoofer')   ==   -1) &&
                 (agent.indexOf('compatible') ==   -1)));
    this.ns2   = (this.ns && (this.major      ==    3));
    this.ns3   = (this.ns && (this.major      ==    3));
    this.ns4b  = (this.ns && (this.major      ==    4) &&
                 (this.minor                  <= 4.03));
    this.ns4   = (this.ns && (this.major      >=    4));
    this.ns6    = (this.ns && (this.major     >=    5));
    this.ie    = (agent.indexOf("msie")       !=   -1);
    this.ie3   = (this.ie && (this.major      <     4));
    this.ie4   = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.0")   ==   -1));
    this.ie5   = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.0")   !=   -1));
    this.ie55  = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.5")   !=   -1));
}

var is = new Is();

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = ".document"
    xpos = "e.pageX";
    ypos = "e.pageY";
} else if(is.ie4 || is.ie5) {
    doc = "document.all";
    sty = ".style";
    htm = ""
    xpos = "event.x";
    ypos = "event.y";
}