function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function AdicionarFoto(codigo){
	pop_up('det_fotoator.asp?codigo='+codigo, 450, 500, 0, 0, 1);
}
<!-- inicio campo requerido
function checkrequired(which) {
var pass=true;
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name.substring(0,8)=="required") {
			if (((tempobj.type=="text"||tempobj.type=="textarea") &&	tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0))
				{
				pass=false;
				break;
				}
      }
   }
}
	if (!pass) {
	shortFieldName=tempobj.name.substring(8,30).toUpperCase();
	alert("Por favor preencha o campo "+shortFieldName+".");
	tempobj.focus();
	return false;
	}
	else {
			for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				tempobj.name=tempobj.name.substring(8,30);
				//alert(tempobj.name); testando se aparece o nome do campo sem o required
			}
			}
		return true;
		}
}
//  fim campo requerido -->


function CrC(url){
	var d = new Date();
	var crc = d.getTime();
	url = url.replace('?','?crc='+crc+'&');	
	return url;
}
function EnviaContato(email) { //v1
	  //MM_openBrWindow('enviacontato.asp?quem='+email,'','width=400,height=450');
	  MM_openBrWindow('enviacontato.php?quem='+email,'','width=400,height=450');
}

function AbreJanelaX(arquivo) { //v1
	  MM_openBrWindow(arquivo,'0','width=650,height=450,scrollbars=yes');
}
function AbreJanela(arquivo) { //v1
	  MM_openBrWindow(arquivo,'0','width=650,height=450,scrollbars=no');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	if(winName=="0"){
		winName="interno";
		}
	if(features=="0"){
		features="width=780,height=550,scrollbars=no";
		}
		
  window.open(theURL,winName,features);
}

/*Montar obj XMLHTTP pro ajax*/
function montar_XMLHttp()
{
	try{
	//tenta criar XML 
		xmlhttp = new XMLHttpRequest();
		}catch(ee){
		//se for MOZILA
		try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
		//Se for IE
			try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

/*fim XMLHTTP*/
/* inicio excluirarquivo */
function confirm_exclusao(tabela,campo,id,exibir)
{
	var resposta=confirm("Confirma a exclusão de ("+exibir+")?")
	if (resposta) {
		var iddiv="row"+id;

		//alert(eval(iddiv).style.display);
		xmlhttp	=	montar_XMLHttp();
		url	=	"../inc/excluir.php?id="+id+"&tabela="+tabela+"&campo="+campo;
		xmlhttp.open("GET", url,false);
		xmlhttp.onreadystatechange=function() {
			if(xmlhttp.readyState==4){
				eval(iddiv).style.display="none";
				alert(exibir+": "+xmlhttp.responseText);
			}//if state
		}//funcao
		xmlhttp.send(null)
	}//if resposta
}

/* fim excluirarquivo */


/*exibe e oculta layer*/
function showhidelayer(iddiv){

	if(document.getElementById(iddiv).style.display=='none')
	{
		document.getElementById(iddiv).style.display='block';
	} else { 
		document.getElementById(iddiv).style.display='none';
	}
}
/*função para exibir um swf e facilitar a vida!
exemplo de como chamar a funcao:
exibe_swf('../swf/index.swf', 770, 550, 'transparent');*/

function exibe_swf(arquivo, largura, altura, wmode)
{
	arquivo = CrC(arquivo+"?");
	
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+largura+"' height='"+altura+"'>");
	document.write("<param name='movie' value='"+arquivo+"' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='wmode' value='"+wmode+"' />");
	document.write("<param name='menu' value='false' />");
	document.write("<embed src='"+arquivo+"' width='"+largura+"' height='"+altura+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='"+wmode+"' menu='false'></embed>");
	document.write("</object>");
}


/*Funcao generica para confirmar exclusão
t=tabela
c=campo
id=indice
exibir=oque aparece para o usuario*/
function confirm_exclusaoOLD(t,c,id,exibir) {
var resposta=confirm("Confirma a exclusão de ("+exibir+")?")
	if (resposta) {
		excluirregistro('../inc/excluir.php?tabela='+t+'&campo='+c+'&id='+id,'','scrollbars=no,width=200,height=150,left=5000');
	}
}

/*Link para select onchange="menudesalto(this);"*/
function menudesalto(objeto){ //v3.0
  window.location=objeto.options[objeto.selectedIndex].value;
}

/* Inicio link para botoes
LinkBotao('self','arquivo.ext');return document.ValorRetorno;
*/
function LinkBotao() { //v3.0
  var i, args=LinkBotao.arguments; document.ValorRetorno = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//Fim link para botoes

// inicio conta caracteres
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characteRSf left' counter
else 
	countfield.value = maxlimit - field.value.length;
}
//fim conta caracteres

function troca_cor(element,cor)
{
	element.style.backgroundColor=cor;
}

function pop_up(local, w, h, scrollbars, status, resizable)
{
	largura = screen.width;
	altura = screen.height;
	XX = (largura-w)/2;
	YY = (altura-h)/2;
	janela =
	window.open(local,'POP_UP','width='+w+',height='+h+',left='+XX+',top='+YY+',scrollbars='+scrollbars+',status='+status+',resizable='+resizable+',toolbar=no,directories=no,menubar=no');
	janela.focus();
}

// inicio campo requerido
function checkrequired(which) {
var pass=true;
if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name.substring(0,8)=="required") {
			if (((tempobj.type=="text"||tempobj.type=="textarea") &&	tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0))
				{
				pass=false;
				break;
				}
      }
   }
}
	if (!pass) {
	shortFieldName=tempobj.name.substring(8,30).toUpperCase();
	alert("Por favor preencha o campo "+shortFieldName+".");
	tempobj.focus();
	return false;
	}
	else {
			for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				tempobj.name=tempobj.name.substring(8,30);
				//alert(tempobj.name); testando se aparece o nome do campo sem o required
			}
			}
		return true;
		}
}
//  fim campo requerido 
function muda_img(caminho)
{
	document.images.fotog.src = caminho;
}

function proximafoto(nrfoto){
	if(Math.floor(nrfoto)>0){
		document.getElementById('novafoto').value="Substituir foto nr." + nrfoto ;
		document.getElementById('selecionada').value = nrfoto;
	}else{
		nrfoto = document.getElementById('proxima').value;
		document.getElementById('novafoto').value="Adicionar foto nr." + nrfoto ;
		document.getElementById('selecionada').value = nrfoto;
	}
	
//	alert(document.getElementById('proxima').value);
}
