// 京(UTF-8)


window.onload = function(){
	rollOvers();
};



// Roll Over Images
function rollOvers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'btn') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_current'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_current'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

// Hide Box
function viewBox(dt,img,boxid) {
	dt.style.display = "block";
	if (img) {
		img.src = 'images/s_menu_' + boxid + '_current.gif';
	}
}
function hideBox(dt,img,boxid) {
	dt.style.display = "none";
	if (img) {
		img.src = 'images/s_menu_' + boxid + '.gif';
	}
}
function showList(boxid) {
	var ref = "";
	var img = "";
	var docref = "";
	var docimg = "";

	ref = "ref_" + boxid;
	img = "img_" + boxid;
	docref = document.getElementById(ref);
	docimg = document.getElementById(img);
	if (docref.style.display == 'none' || docref.style.display == '') {
		viewBox(docref,docimg,boxid);
	} else {
		hideBox(docref,docimg,boxid);
	}
}

function centerWindow(wx,wy,file) {
	x = (screen.width  - wx) / 2;
	y = (screen.height - wy) / 2;
	subWin = window.open( file, "sub", "left="+x+", top="+y+", width="+wx+", height="+wy );
}

// Write Cookie
function setCookie(nam, val, exp){
	if(nam && val && exp){
		var d = new Date();
		d.setTime(d.getTime() + (exp * 1000 * 60 * 60 * 24));
		exp = d.toGMTString();
		document.cookie = nam + "=" + escape(val) + ";expires=" + exp;
		return true;
	}
	
	return false;
}

// Read Cookie
function getCookie(nam){
	nam += "=";
	var c = document.cookie + ";";
	var s = c.indexOf(nam);
	if(s != -1){
		var e = c.indexOf(";", s);
		return unescape(c.substring(s + nam.length, e));
	}
	
	return false;
}
