$(document).ready(function(){
	/* efeito para retirar os valores default dos campos input e textarea ao dar foto*/
	$('input[type=text],input[type=password],textarea').each(function(){
		var input = $(this);
		if(input.attr('testDV') == 'true'){
			$(this).focus(function(){
				if(this.value === this.defaultValue){
					if((this.type == 'text') && (this.id.indexOf('_PW') > -1)){
						input.css('display','none');
						var elms = document.getElementsByName(this.name.substr(0,this.name.length-1));
						if(elms.length == 1){
							$(elms[0]).css('display','').focus();
						}
					} else {
						this.value = '';
					}
				}
			});
			$(this).blur(function(){
				if(this.value == ''){
					if((this.type == 'password') && (this.id.indexOf('_PW') > -1)){
						input.css('display','none');
						var elms = document.getElementsByName(this.name+'2');
						if(elms.length == 1){
							$(elms[0]).css('display','');
						}
					} else {
						this.value = this.defaultValue;
					}
				}
			});
		}
	});
	$('select').each(function(){
		var atual = $(this);
		var atualDiv = $('#'+atual.attr('id')+'_div');
		if(atualDiv.length == 1){
			atual.removeClass('aberto').addClass('fechado');
			atual.css('z-index','10');

			atual.click(function(){
				atual.removeClass('fechado').addClass('aberto');
			}).focus(function(){
				atual.removeClass('fechado').addClass('aberto');
			}).change(function(){
				atual.css('z-index','10');
				atual.removeClass('aberto').addClass('fechado');
				atualDiv.html(this.options[this.selectedIndex].text+'<span class="sbaixo"></span>');
			});
		}
	});
	$(window).resize(function(){
		rodarodape();		
	});  
	rodarodape();
	
	$('#opencad').click(function(e){
		e.preventDefault();
		if(!divCadastroOK){
			var l = ($(document).width() / 2) + 157;
			$('#divCadastro').css({left:l,display:'block'}).prependTo('body');
			divCadastroOK = true;
		}
		$('#divCadastro').animate({top:130},200);
	});
	$('#closeCad').click(function(e){
		e.preventDefault();
		$('#divCadastro').animate({top:-500},200);
	});
	$('#ufcad_CMB1').change(function(){
		loadChild('ufcad_CMB1','cidadecad_CMB1','../common/routines.php?action=loadCidadeByUf',{id_uf:gebi('ufcad_CMB1').value});
	});
});
var divCadastroOK = false;
var rodarodape = function(){
	//rodape = $(document).height()-362;
	rodape = $(document).height()-362;
  	$('.fundoRodape').css({'top':rodape+"px"});
};
