
function toggle(ident){
	if(document.getElementById(ident).style.display == "inline"){
		document.getElementById(ident).style.display ="none";
	} else {
		document.getElementById(ident).style.display ="inline";
	}
}
function on(obj){
obj.style.fontWeight="bolder";
obj.style.textDecoration="underline";
obj.title="Click to show this tab.";
}

function off(obj){
obj.style.fontWeight="normal";
obj.style.textDecoration="none";
}
var t;
function apps() {
document.getElementById('apps').style.display="block";
closeit();
}

function closeit() {
t=setTimeout("document.getElementById('apps').style.display='none'",5000);
t=setTimeout("clearTimeout(t);",5100);
}

function linksin() {
document.getElementById('links').style.display="block";
}

function linksaway() {
document.getElementById('links').style.display="none";
}

function weblink(z)
{
var l="http://www.khaoticirc.net/webapps/"+z+".php";
location.href=l;
}

function clearitem(z){
document.getElementById(z).defaultValue="";
}

function rand(x) {
var p = Math.random();
if (p >= .8){
document.body.style.backgroundColor="gray";
}
else if(p <= .7){
	if(p > .5) {
		document.body.style.backgroundColor="lightslategray";
	}
else if(p <= .3){
document.body.style.backgroundColor="black";
}
}
else {
document.body.style.backgroundColor="black";
}
}

function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
		limitCount.style.color='red';
	}
	else {
		limitCount.innerHTML = limitNum - limitField.value.length;
		limitCount.style.color='green';
	}	
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function on(obj){
obj.style.textDecoration="underline;"
obj.style.fontWeight="bold";
obj.title="Click to show this tab";
obj.style.cursor="hand";
obj.style.cursor="pointer";
}

function off(obj){
obj.style.textDecoration="none;"
obj.style.fontWeight="normal";

}

function counter(id,type) {
var num = new Number(document.getElementById(id).value);
var interval = new Number(document.getElementById("int").value);
if(type == "-"){
document.getElementById(id).value = num-interval;
}
else if(type == "+"){
document.getElementById(id).value = num+interval;
}
setCookie(id,document.getElementById(id).value,7);
}

var etr=1;
function heh(id){
document.getElementById("stop").value=etr;
etr = etr + 1;
}
function stopwatch(id,type,ref) {
var num = 0;
if(type == "clr"){
clearTimeout(t);
document.getElementById('tot').innerHTML="Last time was stopped at "+document.getElementById("stop").value+" seconds";
ref.value = ">";
document.getElementById(id).value="0";
etr = 1;
}
else if(type == "play"){
if(ref.value == ">"){
ref.value = "||";
t=setInterval("heh()",1000);
} else {
ref.value = ">";
clearTimeout(t);
document.getElementById('tot').innerHTML="Last time was stopped at "+document.getElementById("stop").value+" seconds";
}
}
setCookie(id,document.getElementById(id).value,7);
}

function calc(id,type) {
if(type == "="){
document.getElementById(id).value = eval(document.getElementById(id).value);
}
else if(type == "clr"){
document.getElementById(id).value = "";
}
else{
document.getElementById(id).value = document.getElementById(id).value + type;
}
}

function changename(pas){
var name=prompt("Display name:",pas);
if (name!=null && name!="")  {
setCookie("name",name,7);
alert("Reloading this frame for save your name!");
location.reload();
}
}