IE4 = navigator.appName == "Microsoft Internet Explorer";        
NS4 = navigator.appName.substring(0,8) == "Netscape" && parseInt(navigator.appVersion) >= 4;


var screen_height=0;
var screen_width=0;

var doc_height=0;
var doc_width=0;
var doc_ref=document.referrer;
var doc_mod=document.lastModified;
var doc_date=getdate_tx();

today = new Date();
lastmod = new Date(document.lastModified)
var doc_dif_days = Math.ceil( (today.getTime()-lastmod.getTime())/(24*60*60*1000) );

function init_xArray() {
     this.length = init_xArray.arguments.length;
     for (var i = 0; i < this.length; i++) {
         this[i+1] = init_xArray.arguments[i];}
}

function getdate_tx(){
var MonthOfYearArray = new init_xArray("January","February","March","April",
                                     "May","June","July","August",
                                     "September","October","November","December");
var LastModifiedDate = new Date(document.lastModified);
return MonthOfYearArray[(LastModifiedDate.getMonth()+1)]+", "+LastModifiedDate.getDate()+" , "+LastModifiedDate.getYear();
}

function initScreen() {

screen_width=screen.width;
screen_height=screen.height;
screen_colorDepth=screen.colorDepth;
screen_pixelDepth=screen.pixelDepth;

if (document.layers) {

doc_width=window.innerWidth;
doc_height=window.innerHeight;
} 
if (document.all) {
doc_width=document.body.clientWidth;
doc_height=document.body.clientHeight;

}
 
}

//boolean to detect OS and Processor

function mac(){

        return(navigator.appVersion.lastIndexOf('Mac') != -1 );

        }

/* Netscape reports the processor type, Internet Explorer doesn't */

function ppc(){

        return(navigator.appVersion.lastIndexOf('PPC') != -1 );

        }

function intel(){

        return((navigator.appVersion.lastIndexOf('Intel') != -1) || (navigator.appVersion.lastIndexOf('; I') != -1));

        }


function linux(){

        return(navigator.appVersion.lastIndexOf('Linux') != -1 );

}

function os2(){

        return((navigator.appVersion.lastIndexOf('OS/2') != -1) || (navigator.appVersion.lastIndexOf('OS2') != -1));

        }

function win95(){

          return((navigator.appVersion.lastIndexOf('Windows 95') != -1) || (navigator.appVersion.lastIndexOf('Win95') != -1));

          }

function winNT(){

          return((navigator.appVersion.lastIndexOf('Windows NT') != -1) || (navigator.appVersion.lastIndexOf('Windows NT') != -1));

          }

function irix(){

          return(navigator.appVersion.lastIndexOf('IRIX') != -1 );

          }

function aix(){

          return(navigator.appVersion.lastIndexOf('AIX') != -1 );

          }

function sunos(){

          return(navigator.appVersion.lastIndexOf('SUNOS') != -1 );

          }

function solaris(){

          return(navigator.appVersion.lastIndexOf('Solaris') != -1 );

          }


//*** Detect and return mouse event
// require override function mousep(btn) to handle

function mclick(e){

if (navigator.appName == 'Netscape' ){
 if (e.which == 3) { mousep('right');}
 if (e.which == 2) { mousep('middle');}
 if (e.which == 1) { mousep('left');}
}
else
if (navigator.appName == 'Microsoft Internet Explorer') {
 //if (event.button==4) { mousep('scroll');} //end able this if you like to take care the scroll button
 if (event.button==3) { mousep('middle');}
 if (event.button==2) { mousep('right');}
 if (event.button==1) { mousep('left');}
}
return true;
}

document.onmousedown = mclick; 

function mousep(btn) {
//to be overrided
//nothing happen if user do not override it in its own document.
}

//*** Following is to get mouse position in document.
// result can be using : window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;

// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
    mousem(); // call external function
}

function mousem(){
//to be overrided
//nothing happen if user do not override it in its own document.

}

// Full screen function

function fullwin(url){
alert('Press Alt+F4 to close the full screen!');
window.open(url,"","fullscreen,scrollbars");
}

//reponse to key press

if (document.layers) {document.captureEvents(Event.KEYPRESS)}

function keyCare(e){

if (document.layers){ gotKey(e.which);} 
//if (document.all){gotkey(''); }

}

document.onkeypress=keyCare;

function gotKey(keyc){
//override this function

}



//reload function

function reload_doc(){
location=location; 
}

//print document

function print_doc(){
window.print();
}

//Add favor

function add_doc(){
window.external.AddFavorite(location,location);
}

//view source

function view_doc(){
location="view-source:" + window.location.href;
}

//Srcoll text in status 

function scrollStatus(seed,barText){
        var m1  = barText;
  	var msg=m1;
        var out = " ";
        var c   = 1;
	seed=parseInt(seed);

        if (seed > 100) {
                seed--;
                var cmd="scrollStatus(" + seed +",'"+m1+ "')";
                timerTwo=window.setTimeout(cmd,100);
        }

        else if (seed <= 100 && seed > 0) {
                for (c=0 ; c < seed ; c++) {
                        out+=" ";
                }
                out+=msg;
                seed--;
                var cmd="scrollStatus(" + seed +",'"+m1+ "')";
                    window.status=out;
                timerTwo=window.setTimeout(cmd,100);
        }

        else if (seed <= 0) {

                if (-seed < msg.length) {
                        out+=msg.substring(-seed,msg.length);
                        seed--;
                        var cmd="scrollStatus(" + seed +",'"+m1+ "')";
                        window.status=out;
                        timerTwo=window.setTimeout(cmd,100);
                }  else {
                        window.status=" ";
			var cmd="scrollStatus(100,'"+barText+ "')";
                        timerTwo=window.setTimeout(cmd,75);
                }
        }
}


//define water mark on document

/*Set these values, gright for how much from the right you want the layer to go
and gbottom for how much from the bottom you want it*/

var mark_right=200;
var mark_bottom=40;


/********************************************************************************
Constructing the ChangeText object
********************************************************************************/
function w_makeObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'
   	this.css=(NS4) ? eval(nest+'document.'+obj):eval(obj+'.style')							
	this.moveIt=xb_moveIt;
}
function xb_moveIt(x,y){ 
	this.x=x; this.y=y;
   	this.css.left=this.x;
	this.css.top=this.y;
}
/********************************************************************************
Initilizing the page, getting height and width to moveto and calls the 
object constructor
********************************************************************************/
var pageWidth=0;
var pageHeight=0;

function w_Init(){	
	
	oTest=new w_makeObj("wMark");

	pageWidth=(IE4)?document.body.offsetWidth-4:innerWidth;
	pageHeight=(IE4)?document.body.offsetHeight-2:innerHeight;
	w_checkIt();
	//sets the resize handler.
	//onresize=w_resized;
	if(IE4) window.onscroll=w_checkIt;
}
/********************************************************************************
This function executes onscroll in ie and every 30 millisecond in ns
and checks if the user have scrolled, and if it has it moves the layer.
********************************************************************************/
function w_checkIt(){
	if(IE4) {
oTest.moveIt(document.body.scrollLeft +pageWidth-mark_right,document.body.scrollTop+pageHeight-mark_bottom);
}
	else if(NS4){
oTest.moveIt(window.pageXOffset+pageWidth-mark_right, window.pageYOffset+pageHeight-mark_bottom)
setTimeout('w_checkIt()',30)
	}
}

//Adds a onresize event handler to handle the resizing of the window.
//function w_resized(){
//	pageWidth=(IE4)?document.body.offsetWidth-4:innerWidth;
//	pageHeight=(IE4)?document.body.offsetHeight-2:innerHeight;
//	if(IE4) {w_checkIt();}
//}
