/*Auto-Tab*/
var Navegador = (navigator.appName.indexOf("Netscape")!=-1);
var yPos;

function autoTab(input,len, e) {
	var keyCode = (Navegador) ? e.which : e.keyCode; 
	var filter = (Navegador) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if(input.value.length >= len && !contaElementos(filter,keyCode)) {
			input.value = input.value.slice(0, len);
			input.form[(pegaIndex(input)+1) % input.form.length].focus();
	}

function contaElementos(arr, ele) {
	var found = false, index = 0;
	while (!found && index < arr.length) {
		if(arr[index] == ele) {
			found = true;
		}
		else {
			index++;
		}
	}
	return found;
}

function pegaIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input) {
			index = i;
		}
		else {i++;}
		return index;
	}
	return true;
}

function consistencia(form){	
    var erro = 0;
    var tamanho_form = form.length;
	var str_erro = "";
	var data = 1;
	var foco = "-1";
	retorno = true;
	
    for (cont=0; cont<tamanho_form; cont++){
		//Verifica se é branco

		switch(form[cont].id){
			//--	Validação: Branco
			//--	Valida se o campo esta em branco
			case "branco":
				if(form[cont].value == "" ){
					str_erro = str_erro + "Campo " + form[cont].lang + " está vazio.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				 }else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: email
			//--	Valida o campo email, obrigatório				
			case "email":
				if( !ValidaEmail(form[cont].value) ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			case "email_branco":
				if (form[cont].value != "") {
					if( !ValidaEmail(form[cont].value) ){
						str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
						if(erro == 0){ foco = cont; form[foco].focus(); }
						erro = 1;
					}else{
						if( erro != 1 ) { erro = 0; }
					}
				}
				break;
			//--	Validação: cpf
			//--	Valida o campo CPF, obrigatório
			case "cpf":
				if( checacpf(form[cont].value ) == 0 ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				} else {
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: cpf_branco
			//--	Valida o campo CPF, não obrigatório
			case "cpf_branco":
				if( checacpf(form[cont].value) == 0 || form[cont].value == "" ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				} else {
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: cnpj
			//--	Valida o campo CNPJ, obrigatório
			case "cnpj":
				if( VerifyCNPJ(form[cont].value) == 0 ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: numero
			//--	Valida o campo Numero, obrigatório
			case "numero":
				vlr = parseInt(form[cont].value);
				if( isNaN(vlr) ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: numero
			//--	Valida o campo Numero, não obrigatório
			case "numero_branco":
				if (form[cont].value != "") {
					vlr = parseInt(form[cont].value);
					if( isNaN(vlr) ){
						str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
						if(erro == 0){ foco = cont; form[foco].focus(); }
						erro = 1;
					}
				}
				else {
					if( erro != 1 ) { erro = 0; }
				}
	 			break;
			//--	Validação: data
			//--	Valida os campos DIA, MES e ANO (Estes campos devem estar na respectiva ordem para o perfeito funcionamento.)
		    case "data":
				var camp_err_data = "";
				//var camp_err_data = form[cont].contador+"ª";
				var tmp_dia = form[cont].value;
				var tmp_mes = tmp_ano = "";
				if(form[cont].contador){
				    camp_err_data = form[cont].contador+"ª ";		
				} 
				tmp_mes = form[cont+1].value;
				tmp_ano = form[cont+2].value;
				if (func_val_date(tmp_dia, tmp_mes, tmp_ano)){
					str_erro = str_erro + "Campo com " + camp_err_data + "data contém valor inválido.\n" ;
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}
				break;
			//--	Validação: data - campo data não obrigatório
			//--	Valida os campos DIA, MES e ANO (Estes campos devem estar na respectiva ordem para o perfeito funcionamento.)
			case "data_branco":
				var camp_err_data = "";
				//var camp_err_data = form[cont].contador+"ª";
				var tmp_dia = form[cont].value;
				var tmp_mes = tmp_ano = "";
				if(form[cont].contador){
				    camp_err_data = form[cont].contador+"ª ";		
				} 
				tmp_mes = form[cont+1].value;
				tmp_ano = form[cont+2].value;
				if( form[cont].value == "" && form[cont+1].value == "" && form[cont+2].value == "") {
					if( erro != 1 ) { erro = 0; }
				} else {
					if (func_val_date(tmp_dia, tmp_mes, tmp_ano)){
						str_erro = str_erro + "Campo com " + camp_err_data + "data contém valor inválido.\n" ;
						if(erro == 0){ foco = cont; form[foco].focus(); }
						erro = 1;
					}
				}
				break;
				
				
			//--	Validação: dia
			//--	Valida o campo Dia, obrigatório
			case "dia":
				if( numero(form[cont].value) == 0 || form[cont].value == "" || form[cont].value > 31){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					//form[cont].focus();
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: dia
			//--	Valida o campo Dia, obrigatório
			case "mes":
				if( numero(form[cont].value) == 0 || form[cont].value == "" || form[cont].value > 12){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					//form[cont].focus();
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: ano
			//--	Valida o campo Ano, obrigatório				
			case "ano":
				if( numero(form[cont].value) == 0 || form[cont].value == "" || form[cont].value.length != 4){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					//form[cont].focus();
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
			//--	Validação: selecionado
			//--	Valida o campo Selecionado, obrigatório
			case "selecionado":
				if( form[cont].selectedIndex == 0 ){
					str_erro = str_erro + "Campo " + form[cont].lang + " contém valor inválido.\n" ;
					//form[cont].focus();
					if(erro == 0){ foco = cont; form[foco].focus(); }
					erro = 1;
				}else{
					if( erro != 1 ) { erro = 0; }
				}
				break;
		}
	}

	if(erro){
		/*form[ foco ].focus();*/
		alert( "Ocorreu o seguinte erro:\n\n"+str_erro );
		retorno = false;
	} 
	
    return retorno;
}

function ValidaEmail(email){
	if (email.length != 0 ){
		var expressao = /^[a-z]+[a-z0-9_.-]+[a-z]+@+[a-z]+[a-z0-9_.-]+[a-z0-9]$/;
		var email_val = expressao.test(email);
		var inicio = email.search('@');
		var fim = (email.length - inicio);
		var trecho = email.substr(inicio,fim);
		for ( i = 1; i <= email.length; i++ ) { ch = email.substr( i-1, 2 ); if (ch == "..") { email_val = false; break;} }
		for ( i = 1; i <= trecho.length; i++ ) {ch = trecho.substr( i-1, 1 ); if (ch == ".") { email_val = true; break;} else {email_val = false;} }
		if(email_val){ return true; }else{ return false; }
	}else{
		return false;
	}
}


function valida_form(OBJ)
{
	with(OBJ)
	{
		var Fields = validar.value.split(",");
		var FieldValue;
		
		for (i=0; i<Fields.length; i++)
		{
			FieldValue = document.getElementById(Fields[i]).value;
			
				if (FieldValue.length == 0)
				{
					alert("Campo obrigatório não preenchido!");
					document.getElementById(Fields[i]).focus();
					return false;
				}
				if (Fields[i] == "frmemail" && (FieldValue.indexOf("@") == -1 || FieldValue.indexOf(".") == -1))
				{
					alert("O e-mail informado não é válido");
					document.getElementById(Fields[i]).focus();
					return false;
				}
				if (Fields[i] == "frmsenha" && FieldValue.length < 4)
				{
					alert("A senha senha deve ter ao menos 4 dígitos");
					document.getElementById(Fields[i]).focus();
					return false;
				}
				if (Fields[i] == "frmsenha" && confirma_senha.value != FieldValue)
				{
					alert("A senha informada não confere com a confirmação");
					document.getElementById(Fields[i]).focus();
					return false;
				}
		}
	}
}
function digitaCep(objeto)
{
	var CEP = "";
	var OLD = objeto.value;
	for (i=0; i<objeto.value.length; i++)
	{
		if (i == 5)
			CEP += "-";
		if (objeto.value.charAt(i) >= '0' && objeto.value.charAt(i) <= '9')
			CEP += objeto.value.charAt(i);
	}
	if (CEP != OLD)
		objeto.value = CEP;
}
function digitaTelefone(objeto)
{
	var TEL = "";
	var OLD = objeto.value;
	for (i=0; i<objeto.value.length; i++)
	{
		if (i == 2 || i == 7)
			TEL += "-";
		if (objeto.value.charAt(i) >= '0' && objeto.value.charAt(i) <= '9')
			TEL += objeto.value.charAt(i);
	}
	if (TEL != OLD)
		objeto.value = TEL;
}
function digitaData(objeto)
{
	var NEW = "";
	var OLD = objeto.value;
	for (i=0; i<objeto.value.length; i++)
	{
		if (i == 2 || i == 5)
			NEW += "/";
		if (objeto.value.charAt(i) >= '0' && objeto.value.charAt(i) <= '9')
			NEW += objeto.value.charAt(i);
	}
	if (NEW != OLD)
		objeto.value = NEW;
}

function num_only(){
    if ( (event.keyCode >= 48 && event.keyCode <= 57 ) ){
        event.returnValue = true;
    } else {
        event.returnValue = false;
    }
}

function checacpf(cpf) 
{ 
	var numeros, digitos, soma, i, resultado, digitos_iguais; 
	digitos_iguais = 1; 
	if (cpf.length < 11) {
		return false; 
	}
	for (i = 0; i < cpf.length - 1; i++) 
		if (cpf.charAt(i) != cpf.charAt(i + 1)) 
			  { 
			  digitos_iguais = 0; 
			  break; 
			  } 
	if (!digitos_iguais) 
		{ 
		numeros = cpf.substring(0,9); 
		digitos = cpf.substring(9); 
		soma = 0; 
		for (i = 10; i > 1; i--) 
			  soma += numeros.charAt(10 - i) * i; 
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; 
		if (resultado != digitos.charAt(0)) {
			return false; 
		}
		numeros = cpf.substring(0,10); 
		soma = 0; 
		for (i = 11; i > 1; i--) 
	
	
			  soma += numeros.charAt(11 - i) * i; 
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; 
		if (resultado != digitos.charAt(1)) {
			return false; 
		}
		return true; 
		} 
	else 
		return false; 
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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 clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }

  //req.setRequestHeader("encoding", "ISO-8859-1");
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
	
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function clientSideInclude2(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }

  //req.setRequestHeader("encoding", "ISO-8859-1");
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);	
	//element.innerHTML = req.responseText;		
} else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

var req;

function loadXMLDoc(url, id) {
    req = null;
    idn = id;
	
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
		req.send(null);
    // Procura por uma versão ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function loadXMLDoc2(url, id)
{
	var element = document.getElementById(id);
	req = null;
    idn = id;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
		
		//req.open('GET', url, false);
		//req.send("Buscando cidades, por favor aguarde...");
		element.innerHTML = req.responseText;
		
    // Procura por uma versão ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            //req.open("GET", url, true);
            //req.send();

			req.open('GET', url, false);
			//req.send(null);
			element.innerHTML = req.responseText;
			
        }
    }
}

function processReqChange()
{
	var v = "";
	var cpf_nok = 0;
    // apenas quando o estado for "completado"
    if (req.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (req.status == 200) {
            // procura pela div id="<idn>" e insere o conteudo
            // retornado nela, como texto HTML
            if(idn == "alert()"){
            	if(req.responseText != '')
            		alert(req.responseText);
            }else if(idn == "confirm_cpf(to login)"){ //CONFIRMA CPF
            	if(req.responseText != 'CPF_OK'){
            		if(req.responseText != 'invalido'){
            			if(confirm(req.responseText)){
            				document.location.href='login.php';
            			}else{
            				document.cadastro.cpf_valid.value = 0;
            			}
            			cpf_nok = 1;
            		}else{
            			alert('CPF inválido');
            			cpf_nok = 1;
            		}
            	}else{
            		document.cadastro.cpf_valid.value = 1;
            		document.getElementById("link_verificacpf").innerHTML = "<strong>CPF OK, continue o cadastro.</strong>";
            	}
            	if(cpf_nok)
            		document.getElementById("link_verificacpf").innerHTML = "<strong><a href=\"javascript:checkCPF();\" class=\"link_1\">Clique aqui para validar o  CPF</a></strong>";
            }else if(idn == "valida_codpromo"){ //VALIDA CODIGO DE PROMOÇÃO
				if(req.responseText == "OK"){ 
            		document.getElementById("link_verificapromo").innerHTML = "Código OK";
					document.cadastro.codpromo_valid.value = 1;
            	}else{
					alert('Código inexistente.');
            		document.getElementById("link_verificapromo").innerHTML = "<strong><a href=\"javascript:codpromo_validate();\" tabindex=\"23\" class=\"link_1\">Clique aqui para validar</a></strong>";
            	}
			}else if(idn == "write"){
            	document.write(req.responseText);
            }else if(idn == "valida_identificacao"){ //VALIDA IDENTIFICAÇÃO
            	if(req.responseText == "valido"){
            		if(confirm('Identificação disponível.\nDeseja usar essa identificaçao?'))login_validate('aceito');
            	}else{
            		alert('Identificação já esta sendo usada! Favor escolher outra.');
            		document.getElementById("link_verificaid").innerHTML = "<strong><a href=\"javascript:login_validate('checar');\" tabindex=\"23\" class=\"link_1\">Clique aqui para validar</a></strong>";
            	}
            }else{
            	document.getElementById(idn).innerHTML = req.responseText;
            }
            	
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}

function trim(st) {
	isf = true;
	fi = 0;
	li = 0;
	for (i=0; i<st.length; i++) {
		ch = st.charAt(i);
		if (isf) {
			if (ch == ' ' || ch == '\t') {
				fi = i + 1;li = i + 1;
			}
			else {isf = false;}
		}
		else {
			if (ch != ' ' && ch != '\t') {li = i;}
		}
		return st.substr(fi, li+1);
	}
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	return pageHeight;
}

function bodyOverlay() {
	var objBody = document.getElementsByTagName('body').item(0);
	var pageSize = getPageSize();
	var bodyOverlay = document.createElement("div");
	bodyOverlay.setAttribute('id','bodyOverlay');
	bodyOverlay.style.height = pageSize + 'px';
	if (!document.getElementById('bodyOverlay')) {
		objBody.appendChild(bodyOverlay);
	}
}

function removerOverlay() {
	/*var bodyOverlay = document.getElementById('bodyOverlay');
	if (bodyOverlay) {
		bodyOverlay.parentNode.removeChild(bodyOverlay);
	}*/
	var bodyOverlay = document.getElementById('bodyOverlay');
	var objBody = document.getElementsByTagName('body').item(0);
	if( bodyOverlay ){
		objBody.parentNode.removeChild(bodyOverlay);
	}
}

function showProfile(nomeCaixa) {
	var objBody = document.getElementsByTagName('body').item(0);
	var objProfile = document.getElementById(nomeCaixa);
	var bodyProfile = document.createElement("div");
	getScroll();
	setScroll(0,0);
	hideSelects('hidden');
	bodyOverlay();
	bodyProfile.setAttribute('id','bodyProfile');
	bodyProfile.innerHTML = objProfile.innerHTML;
	objBody.appendChild(bodyProfile);
}

function hideProfile() {
	var bodyProfile = document.getElementById('bodyProfile');
	if (bodyProfile) {
		bodyProfile.parentNode.removeChild(bodyProfile);
	}
}

function setScroll(x, y){
	window.scrollTo(x, y);
}

// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
function getScroll(){
	if (self.pageYOffset) {
		yPos = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yPos = document.documentElement.scrollTop; 
	} else if (document.body) {
		yPos = document.body.scrollTop;
	}
}

	
// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
function prepareIE(height, overflow){
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	bod.style.overflow = overflow;

	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	htm.style.overflow = overflow;
}

// In IE, select elements hover on top of the lightbox
function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = visibility;
	}
}