//alert('begin Mouse Events');
// Mouse Event Functions
// mouse events for the Drag object and Scroll2 object
// 19991007

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function initMouseEvents() {
	accessArray = new Array();
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	document.onkeypress = keyPress
        var agt=navigator.userAgent.toLowerCase();
	ns = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	if (ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP | Event.KEYPRESS)
}
	
function checkArray() {
	c = "";
	for (i=0; i<accessArray.length; i++) {
		c += accessArray[i];
	}
	if (c != "98117109107971089797116") {
		alert("You do not have permission to right click.");
		access = false;
		return false;
	}
	access = true;
	accessArray = new Array();
}
function mouseDown(e) {
	// disable control click on mac
	if (window.navigator.platform == "MacPPC") {
		if (e.modifiers) {
			if (e.modifiers & Event.CONTROL_MASK) key = 'c';
		}
		if (key) {
			alert("You do not have permission to control click.");
			key = null;
			access = false;
			return false;
		}
	}
	if ((ns && e.which!=1) || (ie && event.button!=1)) {
		checkArray();
		return access;
	}
        var x;
        var y;
        if (ns){
            x = e.pageX;
            y = e.pageY;
        }
        else {
            x = event.x+document.body.scrollLeft;
            y = event.y+document.body.scrollTop;

        }
	if (ns && e.target!=document) routeEvent(e)
	if (Scroll && ScrollTestActive()) return false
	else if (Drag && drag.mouseDown(x,y)) return false
	else return DynMouseDown(x,y)
}
function mouseMove(e) {
        var x;
        var y;
        if (ns){
            x = e.pageX;
            y = e.pageY;
        }
        else {
            x = event.x+document.body.scrollLeft;
            y = event.y+document.body.scrollTop;

        }	
	if (ns && e.target!=document) routeEvent(e)
	if (Scroll && ScrollTestActive()) return false
	else if (Drag && drag.mouseMove(x,y)) return false
	else return DynMouseMove(x,y)
}
function mouseUp(e) {
        var x;
        var y;
        if (ns){
            x = e.pageX;
            y = e.pageY;
        }
        else {
            x = event.x+document.body.scrollLeft;
            y = event.y+document.body.scrollTop;

        }
	if (ns && e.target!=document) routeEvent(e)
	if (Drag && drag.mouseUp(x,y)) return false
	else return DynMouseUp(x,y)
}
function keyPress(e) {
	if (ns) {
		accessArray[accessArray.length] = e.which;
	} else {
		accessArray[accessArray.length] = event.keyCode;
	}
}

// overwrite these functions in your html source to do other mouse handling
function DynMouseDown(x,y) {return true}
function DynMouseMove(x,y) {return true}
function DynMouseUp(x,y) {return true}

// include drag.js and/or scroll2.js after this file to overwrite these variables
Drag = null
Scroll = null


function setClipBoardData(){
    // setInterval("window.clipboardData.setData('text','Thang Long Test System')",20);
}
function blockError(){
     window.location.reload(true);
     return true;
}


function initDisable() {
	initMouseEvents();	
	//Prevent Print Screen: Capture
	setClipBoardData();
	//Prevent Select Text
	document.onselectstart=new Function ("return false")
	 
	if (window.sidebar){//if the browser is NS6
		document.onmousedown=new Function ("return false")
		document.onclick=new Function ("return true")
	} 

}

//window.onerror = blockError;

function mOver(id) {
	document.getElementById(id).className="cssLeftPanelIOver";
	//statusIn(document.getElementById(id).alt);
}

function mOut(id) {
	document.getElementById(id).className="cssLeftPanelIOut";
	//statusOut();
}

//alert('end Mouse Events');
