function selectionaPrimeiroCampo() {
	var campo = document.body.getElementsByTagName("INPUT");
	var campo = campo[0];	
	if (campo != null) {
		campo.focus();	
	}
}
function pegaEmail(){
	var email = getCookie("email");
	document.getElementById('Email').value = email;
	if (email != "" && email != null)
		document.getElementById('Salvar').checked = true
}
function focusLogin() {
	email = document.getElementById('Email');
	senha = document.getElementById('Senha');
	if (email.value == "")
		email.focus();
	else
		senha.focus();
}
function validaResolucao(){
	var largura = window.screen.availWidth;
	var altura = window.screen.availHeight;
	if (largura < 800 && altura < 600) {
		alert("é recomendado uma resolução de no mínimo de 800x600 para que o sistema seja visualizado corretamente!");
	}
}
function salvarEmail(email) {	
	if (document.getElementById('Salvar').checked == true) {
		setCookie("email", email);	
	} else {
		setCookie("email", "");	
	}
}
function setCookie( name, value ) {
	var expDays = 30;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
	var expires = exp; 
	var bla = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
	document.cookie = bla;
}
function getCookie( name ) {
	var search = name + "=";
	if (document.cookie.length > 0) { // Existem cookies
			offset = document.cookie.indexOf(search)
			if (offset != -1) { // Existe o cookie "name"
					offset += search.length // inicio do conteudo do cookie
					end = document.cookie.indexOf(";", offset) // fim do conteudo
					if (end == -1) end = document.cookie.length;
					return unescape(document.cookie.substring(offset, end));
			} else {
					return "";
			}
	} else {
			return "";
	}
}
function url(obj){
	//alert(obj.value);
	var valor = obj.value;
	if (valor != null && valor != "") {
		if(valor.indexOf('http://') == -1) {
			obj.value = "http://" + obj.value;
		}
	}
}
MyWindow=null; 
function abrirJanela(theURL,winName,features) { 
	if(MyWindow != null) {   
		if(!MyWindow.closed) {                                  
			MyWindow.close();                               
			MyWindow = window.open(theURL,winName,features);                           
		} else {                             
			MyWindow = window.open(theURL,winName,features);                           
		}   
	} else {          
		MyWindow = window.open(theURL,winName,features); 
	}
}
function excluiRegistro(id) {	
	if(confirm("Você realmente deseja excluir este registro?\nAo deletar ele outros registro poderão ser afetados!")){
		document.location.href="?did="+id;
	}	
}
function excluiRegistroConsulta(id, modulo) {	
	if(confirm("Você realmente deseja excluir este registro?\nAo deletar ele outros registro poderão ser afetados!")){
		document.location.href="?Modulo=" + modulo + "&did="+id;
	}	
}
function excluiImagem(id, idPai) {	
	if(confirm("Você realmente deseja excluir esta imagem?")){
		document.location.href="?didImg="+id+"&id="+idPai;
	}	
}
function logOut() {	
	if(confirm("Você realmente deseja sair?")){
		document.location.href="?logout";
	}	
}
function addGuiLine() {
	var plusTag = event.srcElement;
	var parentTag = plusTag.parentElement; 
	var newTag = parentTag.cloneNode(true);
	parentTag.insertAdjacentElement("afterEnd", newTag);
	var imgTags = newTag.getElementsByTagName("IMG");
	for (var i = 0; i < imgTags.length; i++) {
		imgTags[i].style.visibility = "visible";
	}
	fixFileUploadNames();
}
function fixFileUploadNames() {
	var inps = document.body.getElementsByTagName("INPUT");
	for (var i = 0; i < inps.length; i++) {
			var inpTag = inps[i];
			if (inpTag.type == "file") {	
				inpTag.name = "Imagem_" + i;
				//Mostra o nome do campo de imagem
				//alert(inpTag.name);
			}
	}
}
function delGuiLine() {
	var minusTag = event.srcElement;
	var parentTag = minusTag.parentElement; // move to minus
	parentTag.removeNode(true);//parentElement.removeChild(parentTag);
}
function sendData(data, campoData, form){	
	var campo = eval("window.opener.document." + form + "." + campoData);
	campo.value = data;
	self.close();
}
function numbers_only(objeto, evt){
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if (evt) {
		var ntecla = (evt.which) ? evt.which : evt.keyCode;
		//alert(ntecla);
		if (ntecla > 47 && ntecla<58 || ntecla==46 || ntecla==8) 
			return true;
		else 
			return false;
	}
}
function mostrarOcultar(obj) {
	if (obj.style.display == 'none') { 
		obj.style.display ='inline'; 
	} else {  
		obj.style.display ='none'; 
	} 
}
function mostrarOcultarFornecedor(obj) {
	obj1 = document.getElementById(obj);
	if (obj1.style.display == 'none') { 
		obj1.style.display =''; 
	} else {  
		obj1.style.display ='none'; 
	} 
}
function lowerCase(obj) {
	obj.value = obj.value.toLowerCase();
}
