function centraliza(largura,altura){
	window.moveTo((window.screen.width-largura)/2,(window.screen.height-altura)/2);
}
function abreJanela(arquivo,nome,barra,largura,altura) {
	window.open(arquivo,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+barra+",width="+largura+",height="+altura);
}
function redimenciona(){
	var i=0;
	function resize() {
		if (navigator.appName == 'Netscape') i=40;
		if (document.images[0]) window.resizeTo(document.images[0].width +50, document.images[0].height+80-i);
		if (window.moveTo((window.screen.width-document.images[0].width)/2,(window.screen.height-document.images[0].height)/2));
	}
}
var css_browser_selector = function() {
	var 
		ua = navigator.userAgent.toLowerCase(),
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
	var c = b+os+' js';
	h.className += h.className?' '+c:c;
}();

var ie =(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns =(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);
function ajustar_cep(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if ((tecla == 8)||(tecla == 46)||(tecla == 39)||(tecla == 37)||(tecla == 36)||(tecla == 35)||(tecla == 9)) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 5) {
            input.value += "-";
        }
    }
    return true;
}

function ajustar_data(input, evento) {
	var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
	if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
		return true;
	}
	if (tecla < 48 || tecla > 57) {
		evento.returnValue = false;
		return false;
	}
	else {
		if (input.value.length == 2 || input.value.length == 5) {
			input.value += "/";
		}
	}
	return true;
}

function ajustar_tel(input, evento) {
	var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
	if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
		return true;
	}
	if (tecla < 48 || tecla > 57) {
		evento.returnValue = false;
		return false;
	}
	else {
		if (input.value.length == 4) {
			input.value += "-";
		}
	}
	return true;
}

function ajustar_res(input, evento) {
	var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
	if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
		return true;
	}
	if (tecla < 48 || tecla > 57) {
		evento.returnValue = false;
		return false;
	}
	else {
		if (input.value.length == 1) {
			document.forms[0].txtTelResidencial.focus();
		}
	}
	return true;
}

function ajustar_com(input, evento) {
	var tecla = (evento.keyCode ? evento.keyCode : evento.which ? evento.which : evento.charCode);
	if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
		return true;
	}
	if (tecla < 48 || tecla > 57) {
		evento.returnValue = false;
		return false;
	}
	else {
		if (input.value.length == 1) {
			document.forms[0].txtTelComercial.focus();
		}
	}
}

function pdsViewImage(i,name) {
    window.open('imageViewer.asp?gdir=' + name + '&gsn=' + i,'csp_imageViewerWin','width=300,height=200');
    return;
}

function montaSWF(arquivo,largura,altura,action){
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="swf/'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="FlashVars" value="'+ action +'&clearCache='+ data +'" />');
	document.write('<embed FlashVars="'+ action +'&clearCache='+ data +'" wmode="transparent" menu="false" src="swf/'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}
function montaSWF2(arquivo,action){
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="707" height="100%">');
	document.write('<param name="movie" value="'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="scale" value="noscale" />');
	document.write('<param name="salign" value="t" />');
	document.write('<param name="align" value="top" />');
	document.write('<param name="FlashVars" value="'+ action +'&clearCache='+ data +'" />');
	document.write('<embed align="top" salign="t" scale="noscale" FlashVars="'+ action +'&clearCache='+ data +'" wmode="transparent" menu="false" src="'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="707" height="100%"></embed>');
	document.write('</object>');
}
function estica(param){
	var dv = document.getElementById("esticaGaleria");
	dv.style.height = param+"px";
}
function validaGaleria(select){
    window.location="galeria.asp?idgaleria=" + select.value;
}