function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ((!start) &&	(name != document.cookie.substring(0, name.length))) {
		return null;
	}
	if (start == -1)
		return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1)
		end = document.cookie.length;
	return unescape( document.cookie.substring(len, end));
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if (Get_Cookie(name))
		document.cookie = name+"="
			+ ((path)?";path="+path:"")
			+ ((domain)?";domain="+domain:"")
			+ ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function findObjectPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function menuLocation(imgid){
	var ymove;
	if (self.innerHeight) // all except Explorer
	{
		ymove = scrollY;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		ymove = document.documentElement.scrollTop;
	}
	else if (document.body) // other Explorers
	{
		ymove = document.body.scrollTop;
	}

	Set_Cookie('ncess_locationImg',imgid,5000,'/','','');
	impos=findObjectPos(document.getElementById(imgid));
	ycoord=impos[1]-ymove;
	Set_Cookie('ncess_locationCoordY',ycoord,5000,'/','','');
}

function mouseLocation(x,y){
	for (i=0; i<y;i++){
		menuAid.move_mouse(0, 1);
		for (j=0; j<1000;j++);
	}
}

function mouseRelocate(x){
	return;
	if (self.innerHeight) // all except Explorer
	{
		height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		height = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		height = document.body.clientHeight;
	}
	if ((img = Get_Cookie( "ncess_locationImg")) &&(coordY = Get_Cookie( "ncess_locationCoordY"))){
		Delete_Cookie( "ncess_locationImg");
		Delete_Cookie( "ncess_locationCoordY");
		pos=findObjectPos(document.getElementById(img));
		var obj=document.getElementById("menuAid");
		if ((pos[1])<height){
			obj.move_mouse(0,pos[1]-coordY-5);
		}
	};
}

// Edit files
function edit_confirmation(path) {
	var answer = confirm("Your changes will not be saved")
	if (answer){
 		window.location = path;
	}
	else{
		//alert("Thanks for sticking around!")
	}
}


function edit_alertChange(path) {
	var answer = confirm("If you have not saved your changes they will be discarded.\n\nClick OK if you have saved your changes or wish to discard them\n\nClick CANCEL to stay on the page and save your changes")
	if (answer){
 		window.location = path;
	}
	else{
		//alert("Thanks for sticking around!")
	}
}

function edit_checkExit() {
	var question = confirm("Are you sure that you want to exit?")
}
