
var op = /opera 5|opera\/5/i.test(navigator.userAgent);
var ie = !op && /msie/i.test(navigator.userAgent);
var mz = !op && /mozilla\/5/i.test(navigator.userAgent);
if (ie && window.attachEvent) {
	window.attachEvent("onload", function () {
		var scrollBorderColor	=	"silver";
		var scrollFaceColor		=	"#EFEFEF";
		with (document.body.style) {
			scrollbarDarkShadowColor	=	scrollBorderColor;
			scrollbar3dLightColor		=	scrollBorderColor;
			scrollbarArrowColor			=	"white";
			scrollbarBaseColor			=	scrollFaceColor;
			scrollbarFaceColor			=	scrollBorderColor;
			scrollbarHighlightColor		=	scrollFaceColor;
			scrollbarShadowColor		=	scrollFaceColor;
			scrollbarTrackColor			=	scrollFaceColor;
		}
	});
}

function doOver() {
	var toEl = getReal(window.event.toElement, "className", "coolButton");
	var fromEl = getReal(window.event.fromElement, "className", "coolButton");
	if (toEl == fromEl) return;
	var el = toEl;
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present

	if ((el.className == "coolButton") && !cDisabled) {
		makeRaised(el);
	}
}

function doOut() {
	var toEl = getReal(window.event.toElement, "className", "coolButton");
	var fromEl = getReal(window.event.fromElement, "className", "coolButton");
	if (toEl == fromEl) return;
	var el = fromEl;

	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present

	if ((el.className == "coolButton") && !cDisabled) {
		makeFlat(el);0
	}

}

function doDown() {
	el = getReal(window.event.srcElement, "className", "coolButton");
	
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if ((el.className == "coolButton") && !cDisabled) {
		makePressed(el);
	}
}


function doUp() {
	el = getReal(window.event.srcElement, "className", "coolButton");
	
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if ((el.className == "coolButton") && !cDisabled) {
		makeRaised(el);
	}
}
//½áÊøÊÂ¼þ

function findChildren(el, type, value) {
	var children = el.children;
	var tmp = new Array();
	var j=0;
	
	for (var i=0; i<children.length; i++) {
		if (eval("children[i]." + type + "==\"" + value + "\"")) {
			tmp[tmp.length] = children[i];
		}
		tmp = tmp.concat(findChildren(children[i], type, value));
	}
	
	return tmp;
}



function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}
//start style
function makeFlat(el) {
	with (el.style) {
		background = "";
		border="1px #F1F1F1 solid";
	}
}

function makeRaised(el) {
	with (el.style) {
		borderLeft   = "1px solid #999999";
		borderRight  = "1px solid #999999";
		borderTop    = "1px solid #999999";
		borderBottom = "1px solid #999999";
		backgroundColor	=	"#CCCCCC";
	}
}

function makePressed(el) {
	with (el.style) {
		borderLeft   = "1px solid #999999";
		borderRight  = "1px solid #999999";
		borderTop    = "1px solid #999999";
		borderBottom = "1px solid #999999";
		backgrounColor	=	"#F1F1F1";
	}
}

function doDblClick(){
	document.selection.empty();
}

function initCoolButtons() {
	document.onmouseover = doOver;
	document.onmouseout  = doOut;
	document.onmousedown = doDown;
	document.onmouseup   = doUp;
	//document.ondblclick= 	doDblClick;
}

initCoolButtons();
