//Função para carregar o conteúdo do site.
function loadXMLDoc(url, valor)
{ 
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url+'?coduf='+valor+'&name=municipio', true);
        req.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
        req.open("GET", url+'?coduf='+valor+'&name=municipio', true);
            req.send();
        }
    }
}
function processReqChange()
{   
	document.getElementById("carrega").innerHTML = "Carregando...";
    // apenas quando o estado for "completado"
    if (req.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (req.status == 200) {
            // procura pela div id="atualiza" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById("carrega").innerHTML = req.responseText;
			 // executa scripts
            //extraiScript(req.responseText);
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}
function municipios(valor)
{
    loadXMLDoc('lista_municipios.php', valor);
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function tel(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}

function exibetipo(){

elem2 = document.getElementById('tipofinalidade');
elem = document.getElementById('tipo');

if (elem2.value=='Residencial') {
	document.getElementById('dorm').disabled = false;
	

 HTML = '<select name="tipo_imv" class="form_list" id="tipo_imv" onchange="bloqueia_dorm()">';
 HTML +='<option value="" selected></option>';
 HTML +='<option value="Casa">Casa</option>';
 HTML +='<option value="Sala Living ou Kit">Sala Living/Kit</option>';
 HTML +='<option value="Apartamento Padrão">Apartamento Padrão</option>';
 HTML +='<option value="Cobertura">Cobertura</option>';
 HTML +='<option value="Terreno">Terreno</option>';
 HTML +='</select>';
elem.innerHTML = HTML;
}
else {
	
 HTML = '<select name="tipo_imv" class="form_list" id="tipo_imv">';
 HTML +='<option value="" selected></option>';
 HTML +='</select>';
elem.innerHTML = HTML;

document.getElementById('dorm').disabled = true;
	
	}

}

function bloqueia_dorm() {
	
	if ((document.getElementById('tipo_imv').value=="Sala Living ou Kit") || (document.getElementById('tipo_imv').value=="Terreno")) {
		document.getElementById('dorm').disabled = true;
		}
		else {
			
			document.getElementById('dorm').disabled = false;
			}
	
	}

function validaAmigo() {

	if ( $('nome').value == "" ) {
		alert("Por favor, informe o nome!");
		$('nome').style.backgroundColor = "#EEEEEE";
		$('nome').focus();
		return false;
	}
	if ( $('nomea').value == "" ) {
		alert("Por favor, informe o nome de seu amigo!");
		$('nomea').style.backgroundColor = "#EEEEEE";
		$('nomea').focus();
		return false;
	}
	
	if($('email').value.indexOf("@")==-1 || $('email').value.indexOf(".")==-1){
	alert("Formato de e-mail inválido");						
	$('email').value = "";
	$('email').style.backgroundColor = "#EEEEEE";
	$('email').focus();
	return false;
	}



	return true;
}



function popup(caminho1,nome1,largura1,altura1,rolagem1) {
	var esquerda1 = (screen.width - largura1) / 2;
	var cima1 = (screen.height - altura1) / 2 -50;
	window.open(caminho1,nome1,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + rolagem1 + ',resizable=no,copyhistory=no,top=' + cima1 + ',left=' + esquerda1 + ',width=' + largura1 + ',height=' + altura1);
}
function $(s) {
	return document.getElementById(s);
}

function GravaDados() {
	if ( $('email').value == "" ) {
		alert("Por favor, informe o e-mail!");
		$('email').style.backgroundColor = "#EEEEEE";
		$('email').focus();
		return false;
	}
	
	if($('email').value.indexOf("@")==-1 || $('email').value.indexOf(".")==-1){
	alert("Formato de e-mail inválido");						
	$('email').value = "";
	$('email').style.backgroundColor = "#EEEEEE";
	$('email').focus();
	return false;
	}

	if($('email').value !=  $('email_confirma').value){
	alert("E-mail e confirmação de e-mail estão diferentes. Verifique.");	
	$('email').style.backgroundColor = "#EEEEEE";
	$('email').focus();
	return false;
	}

	if ( $('nome').value == "" ) {
		alert("Por favor, informe o nome!");
		$('nome').style.backgroundColor = "#EEEEEE";
		$('nome').focus();
		return false;
	}

	
	if ( $('senha').value == "" ) {
		alert("Por favor, informe a senha!");
		$('senha').style.backgroundColor = "#EEEEEE";
		$('senha').focus();
		return false;
	}
 	
	if($('senha').value !=  $('senha_confirma').value){
	alert("Senha e confirmação de senha estão diferentes. Por favor re-digite.");						
	$('senha').value = "";
	$('senha_confirma').value = "";
	$('senha').style.backgroundColor = "#EEEEEE";
	$('senha').focus();
	return false;
	}

	return true;
}
function EnviaEmail() {
	
	if (document.form1.nome.value=="") {
			  
			   alert("É obrigatório preencher o Nome!\n\nPor favor, preencha corretamente!");
			   document.form1.nome.style.backgroundColor = "#EEEEEE";
			   document.form1.nome.focus();
			   return false;
} 
	
	if($('email').value.indexOf("@")==-1 || $('email').value.indexOf(".")==-1){
	alert("Formato de e-mail inválido");	
	  document.form1.email.style.backgroundColor = "#EEEEEE";
	$('email').focus();
	return false;
	}
	
		if (document.form1.telefone.value=="") {
			  
			   alert("É obrigatório preencher o Telefone!\n\nPor favor, preencha corretamente!");
			   document.form1.telefone.style.backgroundColor = "#EEEEEE";
			   document.form1.telefone.focus();
			   return false;
}
	if (document.form1.assunto.value=="") {
			  
			   alert("É obrigatório preencher o Assunto!\n\nPor favor, preencha corretamente!");
			   document.form1.assunto.style.backgroundColor = "#EEEEEE";
			   document.form1.assunto.focus();
			   return false;
}
	if (document.form1.texto.value=="") {
			  
			   alert("É obrigatório preencher a Mensagem!\n\nPor favor, preencha corretamente!");
			   document.form1.texto.style.backgroundColor = "#EEEEEE";
			   document.form1.texto.focus();
			   return false;
}
	
	return true;
	
}
function passa(nome){
  nome.bgColor = "#ffffff";
}
function tira(nome){
  nome.bgColor = "#FFFFFF";
}
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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
function verifica()
{

if (document.oferta.valor.value=="") {
			  
			   alert("É obrigatório preencher o Valor!\n\nPor favor, preencha corretamente!");
			   document.oferta.valor.style.backgroundColor = "#EEEEEE";
			   document.oferta.valor.focus();
			   return false;
} 

if (document.oferta.endereco.value=="") {
			  
			   alert("É obrigatório preencher o Endereço!\n\nPor favor, preencha corretamente!");
			   document.oferta.endereco.style.backgroundColor = "#EEEEEE";
			   document.oferta.endereco.focus();
			   return false;
} 

if (document.oferta.cidade.value=="") {
			  
			   alert("É obrigatório preencher a cidade!\n\nPor favor, preencha corretamente!");
			   document.oferta.cidade.style.backgroundColor = "#EEEEEE";
			   document.oferta.cidade.focus();
			   return false;
} 

if (document.oferta.estado.value=="") {
			  
			   alert("É obrigatório preencher o Estado!\n\nPor favor, preencha corretamente!");
			   document.oferta.estado.style.backgroundColor = "#EEEEEE";
			   document.oferta.estado.focus();
			   return false;
} 

if (document.oferta.vend.value=="") {
			  
			   alert("É obrigatório preencher o seu Nome!\n\nPor favor, preencha corretamente!");
			   document.oferta.vend.style.backgroundColor = "#EEEEEE";
			   document.oferta.vend.focus();
			   return false;
} 

if($('email').value.indexOf("@")==-1 || $('email').value.indexOf(".")==-1){
	alert("Formato de e-mail inválido");	
	  document.oferta.email.style.backgroundColor = "#EEEEEE";
	$('email').focus();
	return false;
	}

if (document.oferta.telefone.value=="") {
			  
			   alert("É obrigatório preencher o telefone!\n\nPor favor, preencha corretamente!");
			   document.oferta.telefone.style.backgroundColor = "#EEEEEE";
			   document.oferta.telefone.focus();
			   return false;
} 

document.oferta.submit();
}
//Formata moeda e verifica se só números são digitados.
function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8))
return true;
//if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}

function Limpar(valor, validos) { 
// retira caracteres invalidos da string 
var result = ""; 
var aux; 
for (var i=0; i < valor.length; i++) { 
aux = validos.indexOf(valor.substring(i, i+1)); 
if (aux>=0) { 
result += aux; 
} 
} 
return result; 
}

function m2(valor, area)
{
	 if (valor != '' && area != 0){
	  return Math.round(valor / area)+'.00';
	 }
	 else
	 {
		return ''; 
	 }
}
Mascaras = {
IsIE: navigator.appName.toLowerCase().indexOf('microsoft')!=-1,
AZ: /[A-Z]/i,
Acentos: /[À-ÿ]/i,
Num: /[0-9]/,
carregar: function(parte){
 var Tags = ['input','textarea'];
 if (typeof parte == "undefined") parte = document;
 for(var z=0;z<Tags.length;z++){
  Inputs=parte.getElementsByTagName(Tags[z]);
  for(var i=0;i<Inputs.length;i++)
   if(('button,image,hidden,submit,reset').indexOf(Inputs[i].type.toLowerCase())==-1)
    this.aplicar(Inputs[i]);
 }
},
aplicar: function(campo){
 tipo = campo.getAttribute('tipo');
 if (!tipo || campo.type == "select-one") return;
 orientacao = campo.getAttribute('orientacao');
 mascara = campo.getAttribute('mascara');
 if (tipo.toLowerCase() == "decimal"){
  orientacao = "esquerda";
  casasdecimais = campo.getAttribute('casasdecimais');
  tamanho = campo.getAttribute('maxLength');
  if (!tamanho || tamanho > 50)
   tamanho = 10;
  if (!casasdecimais)
   casasdecimais = 2;
  campo.setAttribute("mascara", this.geraMascaraDecimal(tamanho, casasdecimais));
  campo.setAttribute("tipo", "numerico");
  campo.setAttribute("orientacao", orientacao);
 }
 if (orientacao && orientacao.toLowerCase() == "esquerda") campo.style.textAlign = "right";
 if (mascara) campo.setAttribute("maxLength", mascara.length);
 if (tipo){
  campo.onkeypress = function(e){ return Mascaras.onkeypress(e?e:event); };
  campo.onkeyup = function(e){ Mascaras.onkeyup(e?e:event, campo) };
 }
 campo.setAttribute("snegativo", ((campo.value).substr(0,1) == "-" ? "s" : "n"));
},
onkeypress: function(e){
 KeyCode = this.IsIE ? event.keyCode : e.which;
 campo =  this.IsIE ? event.srcElement : e.target;
 readonly = campo.getAttribute('readonly');
 if (readonly) return;
 maxlength = campo.getAttribute('maxlength');
 pt = campo.getAttribute('pt');
 selecao = this.selecao(campo);
 if (selecao.length > 0 && KeyCode != 0){
  campo.value = ""; return true;
 }
 if (KeyCode == 0) return true;
 Char = String.fromCharCode(KeyCode);
 valor = campo.value;
 mascara = campo.getAttribute('mascara');
 if (KeyCode != 8){
  tipo = campo.getAttribute('tipo').toLowerCase();
  negativo = campo.getAttribute('negativo');
  if(negativo && KeyCode == 45){
   snegativo = campo.getAttribute('snegativo');
   snegativo = (snegativo == "s" ? "n" : "s");
   campo.setAttribute("snegativo", snegativo);
  }else{
   valor += Char
   if (tipo == "numerico" && Char.search(this.Num) == -1) return false;
   if (KeyCode != 32 && tipo == "caracter" && Char.search(this.AZ) == -1 && Char.search(this.Acentos) == -1) return false;
  }
 }
 if (mascara){
  this.aplicarMascara(campo, valor);
  return false;
 }
 return true;
},
onkeyup: function(e, campo){
 KeyCode = this.IsIE ? event.keyCode : e.which;
 if (KeyCode != 9 && KeyCode != 16 && KeyCode != 109){
  valor = campo.value;
  if (KeyCode == 8 && !this.IsIE) valor = valor.substr(0,valor.length-1);
  this.aplicarMascara(campo, valor);
 }
},
aplicarMascara: function(campo, valor){
 mascara = campo.getAttribute('mascara');
 if (!mascara) return;
 negativo = campo.getAttribute('negativo');
 snegativo = campo.getAttribute('snegativo');
 if (negativo && valor.substr(0,1) == "-") 
  valor = valor.substr(1,valor.length-1);
 orientacao = campo.getAttribute('orientacao');
 var i = 0;
 for(i=0;i<mascara.length;i++){
  caracter = mascara.substr(i,1);
  if (caracter != "#") valor = valor.replace(caracter, "");
 }
 retorno = "";
 if (orientacao != "esquerda"){
  contador = 0;
  for(i=0;i<mascara.length;i++){
   caracter = mascara.substr(i,1);
   if (caracter == "#"){
    retorno += valor.substr(contador,1);
    contador++;
   }else
    retorno += caracter;
   if(contador >= valor.length) break;
  }
 }else{
  contador = valor.length-1;
  for(i=mascara.length-1;i>=0;i--){
   if(contador < 0) break;
   caracter = mascara.substr(i,1);
   if (caracter == "#"){
    retorno = valor.substr(contador,1) + retorno;
    contador--;
   }else
    retorno = caracter + retorno;
  }
 }
 if (negativo && snegativo == "s")
  retorno = "-" + retorno;
 campo.value = retorno;
},
geraMascaraDecimal: function(tam, decimais){
 var retorno = ""; var contador = 0; var i = 0;
 decimais = parseInt(decimais);
 for (i=0;i<(tam-(decimais+1));i++){
  retorno = "#" + retorno;
  contador++;
  if (contador == 3){
   retorno = "." + retorno;
   contador=0;
  }
 }
 retorno = retorno + ",";
 for (i=0;i<decimais;i++) retorno += "#";
 return retorno;
},
selecao: function(campo){
 if (this.IsIE)
  return document.selection.createRange().text;
 else
  return (campo.value).substr(campo.selectionStart, (campo.selectionEnd - campo.selectionStart));
},
formataValor: function (valor, decimais){
 valor = valor.split('.');
 if (valor.length == 1) valor[1] = "";
 for(var i=valor[1].length;i<decimais;i++)
  valor[1] += "0"; 
 valor[1] = valor[1].substr(0,2);
 return (valor[0] + "." + valor[1]);
}
};
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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}