
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;
}

function Campo(obj, objnext) {
	if (obj.value.length == obj.getAttribute("maxlength")) {
		objnext.focus();
	}
}



/* 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;
		}	
	}

}


