// JavaScript Document

function changeImg(obj, src) {
	obj.src = src;
}

function abrir_blank(url) {
	window.open(url, '_blank', '');
}
function checkMail(form_name, field_name) {
	var frm = document.forms[form_name];
	var campo = frm[field_name].value;
	var newreg = /@\b/gi;         //set up search parameters
	if (campo.match(newreg)) {   	//see if found
		var newarray = campo.match(newreg);
		if (newarray.length == 1) return true;
		else {
			alert("Digite um e-mail válido!");
			return false;
		}
	}
	else {
		alert("Digite um e-mail válido!");
		return false;
	}
	return true;
}
function show_hide_div(obj) {
	if (document.getElementById(obj).style.visibility != "visible") {
		document.getElementById(obj).style.visibility = "visible";
		document.getElementById(obj).style.position = "relative";
	}
	else {
		document.getElementById(obj).style.visibility = "hidden";
		document.getElementById(obj).style.position = "absolute";
		document.getElementById(obj).style.left = "0px";
		document.getElementById(obj).style.top = "0px";
	}
}
function mais_menos(obj, ref) {
	if (document.getElementById(ref).style.visibility == "visible")
		document.getElementById(obj).src = 'gifs/menos.gif';
	else {
		document.getElementById(obj).src = 'gifs/mais.gif';
	}
}
function ampliar(url, txt, w, h) {
	window.open('img.php?id='+ url +'&txt='+ txt, '_blank', 'scrollbars=1, width='+w+', height='+h+', resizable=false, toolbar=false, left=50, top=50');
}

function windowCenter(x) {
	
	var winW = 800, winH = 600;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		else {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	return (winW / 2) - (770 / 2) + x;
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}