function janela(url, width, height) {
	var Win = window.open(url,"janela",'width=' + width + ',height=' + height + ',scrollbars=no,resizable=0,menubar=no,status=no,top=50,left=50');
	Win.focus();
}
function abrir(url,lar,alt) {
janela = null;
cima = (window.screen.height - alt)/2;
lado = (window.screen.width - lar)/2;
janela = window.open(url,"galeria","width="+lar+",height="+alt+",top="+cima+",left="+lado+",toolbars=no");
}

function abreJanela(url, largura, altura, scrollbar, statusbar)
{
   var esquerda = (screen.width)  ? (screen.width-largura) / 2 : 0;
   var topo     = (screen.height) ? (screen.height-altura) / 2 : 0;
   var str = 'height='+altura+', width='+largura+', top='+topo+', left='+esquerda+', scrollbars='+scrollbar+', status='+statusbar;
   var janela = window.open(url, 'imagem', str);
   janela.focus();
}

// validacao de campos
function validaForm(formobj) {

	pjReq = new Array();
	pjDef = new Array();
	pfReq = new Array("nome", "empresa", "fone", "email", "mensagem");
	pfDef = new Array("Nome", "Empresa", "Telefone", "E-mail", "Mensagem");

	fieldRequired = pjReq.concat(pfReq);
	fieldDescription = pjDef.concat(pfDef);

	var alertMsg = "Preencha os campos:\n";

	var l_Msg = alertMsg.length;
	var step = "";

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
					step = i;
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
					step = i;
				}
				break;
			case "text":
			case "password":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
					step = i;
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
					step = i;
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		janela('tpl/sucesso.htm', 400, 150);
		return true;
	} else {
		alert(alertMsg);
		return false;
	}
}

