
function CacheImagens() {
	cacheArr = new Array(
					"../imagens/topo/menu/menu-contato-h.gif",
					"../imagens/topo/menu/menu-convenios-h.gif",
					"../imagens/topo/menu/menu-horarios-h.gif",
					"../imagens/topo/menu/menu-localizacao-h.gif",
					"../imagens/topo/menu/menu-noticias-h.gif"
					);
	imageCache = new Array();
	
	for (a = 0; a < cacheArr.length; a++) {
		imageCache[a] = new Image();
		imageCache[a].src = cacheArr[a];
	}
}

CacheImagens();


function Janela(e, w, h, p) {
	try {
		param = "";
		if (p != null)
			param = ", " + p;

		centrox = (screen.width / 2) - (w / 2);
		centroy = (screen.height / 2) - (h / 2);

		if (navigator.appName.indexOf("Opera") != -1) {
			test = (screen.height - (screen.height * 0.25));
			centroy = (test / 2) - (h / 2);
		}
		if (navigator.appName.indexOf("Explorer") != -1) {
			w += 20;
		}

		window.open(e.href, '', "left=" + centrox + ", top=" + centroy + ", width=" + w + ", height=" + h + "" + param);

		if (window.event)
			event.returnValue = false;
	}
	catch(e) {
		if (window.event)
			event.returnValue = true;
		
	}
	return false;
}

function ValidarFormulario(Form) {
	Campos = Form.getElementsByTagName("input");
	for (a = 0; a < Campos.length; a++) {
		if (Campos[a].type == "text" && Campos[a].getAttribute("obrigatorio") != null && Campos[a].value.length == 0) {
			alert("Campo de preenchimento obrigatório.");
			Campos[a].focus();
			return false;
		}
	}
	
	Campos = Form.getElementsByTagName("select");
	for (a = 0; a < Campos.length; a++) {
		if (Campos[a].getAttribute("obrigatorio") != null && Campos[a].options[Campos[a].selectedIndex].value.length == "") {
			alert("Campo de preenchimento obrigatório.");
			Campos[a].focus();
			return false;
		}
	}
	
	Campos = Form.getElementsByTagName("textarea");
	for (a = 0; a < Campos.length; a++) {
		if (Campos[a].getAttribute("obrigatorio") != null && Campos[a].value.length == 0) {
			alert("Campo de preenchimento obrigatório.");
			Campos[a].focus();
			return false;
		}
	}
	
	return true;
}


/* Noticias - Ajax */

var List_Noticias_UL_Ref;

function List_Noticias_UL_Click(Elemento, Mes, Ano) {
	List_Noticias_UL_Ref = Elemento;
	_Default.List_Noticias(Mes, Ano, List_Noticias_CallBack);
}

function List_Noticias_CallBack(response) {
	List_Noticias_UL_Ref.innerHTML = response.value;
}


/* Oculta texto do campo */

function campoFocusValueClass(obj) {

	obj.onfocus = function() {

		if (this.campoFocusValor == null){
			this.campoFocusValor = this.value;
			this.value = "";
		}
		else {
			if (this.value == this.campoFocusValor)
				this.value = "";
		}
	}
	
	obj.onblur = function() {
		if (this.value == ""){
			this.value = this.campoFocusValor;
		}	
	}

}




function trocaPagina(url){
	var status = AjaxRequest.get(
		{
		'onLoading'  : function(req1) { 
			window.document.getElementById('DVConteudoContainer').innerHTML = '';
			//parent.document.getElementById('divCarregandoPrincipal').style.display = '';
			},
		'url'        : url,
		'parameters' : { 'por_id' : ''},
		'onSuccess'  : function(req) { 
			realizaTroca(unescape(req.responseText), null);
		}
		}
	);
}

function realizaTroca(sDesc, operacao){
	//parent.document.getElementById('divCarregandoPrincipal').style.display = 'none';
	
	document.getElementById('DVConteudoContainer').innerHTML = sDesc;


	dv = document.getElementById('DVConteudoContainer');

	var scripts = dv.getElementsByTagName("script");

	for(i = 0; i < scripts.length; i++)
	{
		if (scripts[i].src != null) {

			var oScript = document.createElement("script");
			oScript.src = scripts[i].src;
			document.body.appendChild(oScript);

		}
		s = scripts[i].innerHTML;
		eval(s);
	}

	var Links = dv.getElementsByTagName("a");

	for(i = 0; i < Links.length; i++)
	{
		if ((Links[i].href != null && Links[i].href.indexOf("javascript") == -1 && Links[i].onclick == null && Links[i].getAttribute("target") == null)) {
			Links[i].onclick = "trocaPagina(this.href); return false;";
		}
	}

	
	
	/*
	if(operacao == 'barraDeRolagem')
	{
		initScrollLayer();
	}
	if(operacao == 'loadRolagem'){
		initializemarquee();
	}
	*/
}


function enviaFormulario(theform) {
  var status = AjaxRequest.submit(
    theform
    ,{
      'onSuccess':function(req){
		  alert(req.responseText);
		}
    }
  );
  return status;
}