/*
$$ - retorna um objeto com base no ID | id do objeto
$$$ - retorna os objetos xhtml referente ao documento principal ou a determinado objeto | objeto(false para document) - nome do objeto xhtml
addFavorite - adiciona um link ao favoritos | link absoluto - título
disableButton - desabilita os botões de um formulário | objeto formulário
disableEnableInput - habilita/desabilita um input com base em um checkbox | object checkbox - id do input a ser desabilitado/habilitado
getURL - função para ser utilizada no flash | link
hideShow - mostra/esconde um objeto | objeto
redirectAction - redireciona a página com base em um valor selecionado em um objeto select | objeto select
refreshPage - atualiza uma página
resetInput - reseta um input | objeto input - classe css
setLoading - insere uma imagem "carregando" | objeto
toBlur - muda o foco de um campo ao atingir o valor máximo (maxlength) de um objeto | objeto a ser verificado o maxlength - objeto que receberá o foco
*/
function $$(id) {
	return document.getElementById(id);
}
function $$$(xhtmlObj,xhtmlName){
	var $obj = xhtmlObj;
	var $name = xhtmlName;
	return $obj===false ? document.getElementsByTagName($name) : $obj.getElementsByTagName($name);
}
function addFavorite(addFavoriteLink, addFavoriteTitle){
	var $link = addFavoriteLink;
	var $title = addFavoriteTitle;
	if(document.all){
		window.external.AddFavorite($link, $title);
	}else if(window.sidebar){
		window.sidebar.addPanel($title, $link, "");
	}
}
function disableButton(disableButtonForm){
	var $form = disableButtonForm;
	var $inputs = $form.getElementsByTagName('input');
	for(var $i=0;$i<$inputs.length;$i++){
		$input = $inputs[$i];
		$att = $input.getAttribute('type');
		if($att=='submit' || $att=='button' || $att=='reset'){
			$input.setAttribute('disabled','disabled');
		}
	}
}
function disableEnableInput(disableEnableInputCheckbox,disableEnableInputId){
	var $checkbox = disableEnableInputCheckbox;
	var $obj = $$(disableEnableInputId);
	if($checkbox.checked===true){
		$obj.value = '';
		$obj.setAttribute('disabled','disabled');
	}else{
		$obj.removeAttribute('disabled');
	}
}
function getURL(getURLAddress){
	var $address = getURLAddress;
	self.location = ROOT_HTTP+$address;
}
function hideShow(hideShowId){
	var $obj = $$(hideShowId);
	if($obj.style.display=='' || $obj.style.display=='none'){
		$obj.style.display = 'block';
	}else{
		$obj.style.display = 'none';
	}
}
function redirectAction(redirectActionSelect){
	var $obj = redirectActionSelect;
	if($obj.value!='-1'){
		self.location = $obj.value;
	}
}
function refreshPage(){
	location.reload();
}
function resetInput(resetInputObj, resetInputClass){
	var $obj = resetInputObj;
	var $class = resetInputClass;
	var $value = $obj.value;
	var $default = $obj.defaultValue;
	if($value==$default){
		$obj.value = '';
	}else if($value==''){
		$obj.value= $default;
	}
	if($value==$default||$value==''){
		if($class!=''){
			$obj.setAttribute('class',$class);
			$obj.setAttribute('className',$class);
		}
	}
}
function setLoading(setLoadingObj){
	var $obj = setLoadingObj;
	$obj.innerHTML = '<p style="margin:0;padding:0;border:0;text-align:center;"><img src="'+ROOT_HTTP+'atributos/imagens/global/loading.gif" /></p>';
}
function toBlur(toBlurObj,toBlurTo){
	var $obj = toBlurObj;
	var $value = $obj.value;
	var $limit = $obj.getAttribute('maxlength');
	var $to = $$(toBlurTo);
	if($value.length>=$limit){
		$to.focus();
	}
}
