// JavaScript Document
function fecha(){
	var obj = document.getElementById("bloqTela")
	var objFt = document.getElementById("aumentaFoto")
	obj.style.display = 'none'
	objFt.style.display = 'none'
	
}
function posicionaPopUp(obj){
	var left = (document.documentElement.offsetWidth-550)/2
	obj.style.left = left + "px"
}
function ativa(q){
	var obj = document.getElementById("bloqTela")
	var objFt = document.getElementById("aumentaFoto")
	var h = document.documentElement.offsetHeight
	var w = document.documentElement.offsetWidth
	var innerHTML = '\n\r<img src="'+ q +'" style="width:400px; height:300px; border:#FFFFFF solid 15px;" ><br /><a href="#" onclick="fecha()" style="font-size:26px;">X</a>\n\r'
	obj.style.width = w + "px"
	obj.style.height = (h+333) + "px"
	obj.style.display = ''
	obj.style.zIndex = '10'

	posicionaPopUp(objFt)
	objFt.innerHTML = innerHTML
	objFt.style.zIndex = '11'
	objFt.style.display = ''
}

// Example:
// var b = new BrowserInfo();
// alert(b.version); 
function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}



function mudaRodape(top){
	/*
	** função mudaRodape altera a posição da imagem 
	** do rodapé para ajustar ao conteúdo da página
	*/
	try{
		var b = new BrowserInfo();
		var posicao;
		var obj = document.getElementById("rodape");
		var tudo = document.getElementById("tudo");
		for(var i=0;i<tudo.childNodes.length;i++){
			if(tudo.childNodes[i].offsetHeight){
				top = tudo.childNodes[i].offsetHeight;
//				alert(top);
			}
		}
			posicao = (top-22);
/*
		if(b.name == "Netscape"){
			posicao = (top-22);
		}else{
			posicao = (top-170);
		}
*/
		obj.style.top = posicao + "px";
	}catch(e){
		alert(e.message);
	}
}

function aumenta(q){
	innerHTML = '\n\r<img src="'+ q +'" style="width:400px; height:300px; border:#FFFFFF solid 5px;">\n\r'
	document.getElementById("aumentaFoto").innerHTML = innerHTML
	document.getElementById("aumentaFoto").style.top = Math.ceil(0.5 * 300)+'px'
	document.getElementById("aumentaFoto").style.left = Math.ceil(0.5 * (document.documentElement.offsetWidth-(document.documentElement.offsetWidth * 0.3)))+'px'
	document.getElementById("aumentaFoto").style.visibility = 'visible'
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function verificaTam(caminho,q){
	var largura = 0;
	var altura = 0;
	var foto = new Image();
	if (navigator.appName=="Netscape"){foto.src = caminho; }
	else if (navigator.appName=="Microsoft Internet Explorer"){foto.src = caminho + '#';}
	var intervalo = setInterval( function() {
		if (foto.complete == true) {
				height = foto.height;
				width = foto.width;
				if(foto.width>foto.height) {largura = 90; altura = (90*1.5556);}
				else if(foto.width<foto.height) {largura = (90/1.5556); altura = 90;}
		str_html = "\n\r"
			+ "<div class=\"hoverbox\"><li><a href=\"#\"><img src=\"" + caminho + "\" width=\"" + largura + "\" height=\"" + altura + "\" border=\"0\" /><img src=\"" + caminho + "\" width=\"" + largura + "\" height=\"" + altura + "\" class=\"preview\" /></a></li></div>" + "\n\r";
//		alert(str_html);
//			document.getElementById("mostraAtivaFotos").style.visibility = 'visible';
			document.getElementById("fotos"+q).innerHTML += str_html;
			clearInterval(intervalo);
		}
	},250);
}
function mascara_tel(v){
	v.value=v.value.replace(/\D/g,"") //Remove tudo o que não é dígito
//	v.value=v.value.replace(/^(\d\d)(\d)/g,"($1)$2") //Coloca parênteses em volta dos dois primeiros dígitos
	v.value=v.value.replace(/(\d{4})(\d)/,"$1-$2") //Coloca hífen entre o quarto e o quinto dígitos
	return v.value
}
function mascara_telDDD(v){
	v.value=v.value.replace(/\D/g,"") //Remove tudo o que não é dígito
	v.value=v.value.replace(/^(\d\d)(\d)/g,"($1)$2") //Coloca parênteses em volta dos dois primeiros dígitos
	v.value=v.value.replace(/(\d{4})(\d)/,"$1-$2") //Coloca hífen entre o quarto e o quinto dígitos
	return v.value
}
function numeros(v){
	v.value=v.value.replace(/\D/g,"") //Remove tudo o que não é dígito
	return v.value
}
