var themeno;

function getCookie(NameOfCookie) {
	if (document.cookie.length > 0) {
		begin = document.cookie.indexOf(NameOfCookie+'=');
		if (begin != -1) {
			begin += NameOfCookie.length+1;
			end = document.cookie.indexOf(';', begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		}
	}
	return null;
}

function setCookie(NameOfCookie, value, expirehours) {
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expirehours * 3600 * 1000));
	document.cookie = NameOfCookie + '=' + escape(value) + ';path=/;' + ((expirehours == null) ? '' : '; expires=' + ExpireDate.toGMTString());
}

function checkcookies() {
//	login = getCookie('login');
//	if (login != null) {
//		document.getElementById('welcome').innerHTML = "±z¦n¡I" + login;
//	}
}

function checktheme() {
	themeno = getCookie('DBTHEME');
	if (themeno == null) {
		themeno = 1;
		setCookie('DBTHEME',1,9999);
	}
	document.write('<link rel="stylesheet" type"text/css" href="/home2/css/c' + themeno + '.css">');
}

function changetheme(tno) {
	if (tno == null) {tno = 1;}
	setCookie('DBTHEME',tno,9999);
	window.location.href="/ch/home_1024_c.cgi"
}

function checkimage() {
	var i,x,a=document.images;
	for (i=0; i < a.length; i++) {
		x = a[i].src;
		x = x.replace("c0_", "c" + themeno + "_");
		a[i].src = x;
	}
}

checktheme();