//Disables text selection in set area. Code written by DynamicDrive.com
function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
		target.style.cursor = "default"
}

function validateName(thename){
	if(thename === null) return;
	if(thename == "" || thename == "*Guest*"){
		alert("Choosen name is invalid.");
		return;
	}	
	if(thename.length > 15){
		alert("Choosen name is too long.\nMax is 15 characters.");
		return;
	}
	newName(thename);
}

function newName(thename){
	var date = new Date();
	date.setTime(date.getTime()+(90*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "acecalcsusername="+thename+expires+"; path=/";
	window.location.reload();
}

function DivDisplay(method, thisDiv) {
	var ele = document.getElementById(thisDiv);
	if(method == "Hide") {
    	ele.style.display = "none";
  	}else if (method == "Show"){
		ele.style.display = "block";
	}else if (method == "Toggle"){
		if(ele.style.display == "none")
				ele.style.display = "block";
		else	ele.style.display = "none";
	}
}