// ZSite CMS
// button control Javascript routines
// (c) Zagorodnikov Anton 2007-2008

function zsite_button_press(buttonid)
{
	if((dojo.byId(buttonid).className) == "zsite_button_disabled") return true;

	var btn = document.getElementById(buttonid);
	btn.style.position = "relative";
	btn.style.top = "1px";
	btn.style.left = "1px";

	setTimeout('document.getElementById(\''+buttonid+'\').style.top=\'0px\';', 50);
	setTimeout('document.getElementById(\''+buttonid+'\').style.left=\'0px\';', 50);
}

function zsite_button_submit(buttonid)
{
	var button = dojo.byId(buttonid);
	var node = button;
	while(node.tagName != "FORM")
	{
		var node = node.parentNode;
		if(node.id=="body") return false;
		if(node.parentNode == null) return false;
	}
	node.submit();
}

function zsite_button_hilight(buttonid)
{
	if((dojo.byId(buttonid).className) == "zsite_button_disabled") return true;

	var btn = document.getElementById(buttonid+"contents");
//	btn.style.background = "#ff0000";
//	btn.style.borderBottom= "#006600 2px solid";
	btn.style.textDecoration = "underline";

	//setTimeout('document.getElementById(\''+buttonid+'contents\').style.textDecoration=\'none\';', 5000);

//	alert(btn.style.text_decoration);
}

function zsite_button_delight(buttonid)
{
	if(dojo.byId(buttonid).className == "zsite_button_disabled") return true;

	var btn = document.getElementById(buttonid+"contents");
	btn.style.textDecoration = "none";
}

function zsite_button_push(buttonid, action)
{
	if(dojo.byId(buttonid).className == "zsite_button_disabled") return true;
	else
	{
		setTimeout(action, 100); //for old effects to finish
	}
	return true;
}

function zsite_button_disable(buttonid)
{
	zsite_button_delight(buttonid);
	dojo.byId(buttonid).className = "zsite_button_disabled";
	dojo.byId(buttonid).setAttribute("disabled", "disabled");
	document.getElementById(buttonid+"contents").style.color = "#999999";
}

function zsite_button_enable(buttonid)
{
	dojo.byId(buttonid).removeAttribute("disabled");
	dojo.byId(buttonid).className = "zsite_button";
	document.getElementById(buttonid+"contents").style.color = "#000000";
//	alert(buttonid);
}
