function init() {
	applyPopups(); // Para o popup em 'empresa.aspx'

	if(isIE()) { // Tira as bordas dos checkboxes em 'orcamento.aspx'
		checkbox();
	}
}

function isIE() {
	var nav = navigator.userAgent.toLowerCase();
  var is_ie = (nav.indexOf("msie") != -1);
	return is_ie;
}

function checkbox() {
	var chk = document.getElementById("conteudo").getElementsByTagName("input");
	if (chk != null) {
		for (i = 0; i < chk.length; i++) {
			if(chk[i].type == "checkbox") {
				chk[i].style.border = "none";
			}
		}
	}
}

function applyPopups() {
  a = document.getElementById("conteudo").getElementsByTagName("a");
  for(i=0; i<a.length; i++) {
    if(a[i].getAttribute("rel") && a[i].getAttribute("rel") == "external") {
      a[i].onclick = function() {
				popup(this, "console", 517, 328);
        return false;
      }
    }
  }
}

function popup(url, type, strWidth, strHeight) {
	//closeWin();

// O popup sempre fica centralizado

	var left = (screen.width - strWidth) / 2;
	var top = (screen.height - strHeight) / 2;

	if (type == "fullscreen") {
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}

	var tools = "";
	if (type == "standard" || type == "fullscreen")
		tools = "resizable=yes, toolbar=yes, location=yes, scrollbars=yes, menubar=yes, width=" + strWidth + ", height=" + strHeight + ", top=" + top + ", left=" + left;
	if (type == "console")
		tools = "resizable=no, toolbar=no, location=no, scrollbars=no, width=" + strWidth + ", height=" + strHeight + ", top=" + top + ", left=" + left;
	if (type == "console_mais")
		tools = "resizable=yes, toolbar=no, location=no, scrollbars=yes, width=" + strWidth + ", height=" + strHeight + ", top=" + top + ", left=" + left;

	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
	newWindow.document.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
	newWindow.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"pt-br\">");
	newWindow.document.writeln("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
	newWindow.document.writeln("<title>Yara Alimentos</title>");
	newWindow.document.writeln("<link href=\"app_themes/default/comum.css\" rel=\"stylesheet\" type=\"text/css\" />");
	newWindow.document.writeln("</head><body><div><img src=\"" + url + "\" width=\"517\" height=\"328\" alt=\"\" /></div></body></html>");
}

function closeWin() {
	if (newWindow != null) {
		if(!newWindow.closed)
			newWindow.close();
		}
}

window.onload = init;
