$(document).ready(function(){				   
	$('.testimonials').cycle({ 
		fx:     'fade',
		cleartype: 1,
		speed:   600, 
		timeout: 7000
	});
	


	$(".btn-slide").click(function(){ 
		if($("#panel").css("display") == "none")
		{
			$("#panel").slideDown('fast');
			$("a.btn-slide").html("Fechar Clientes ")
		}
		else
		{
			$("#panel").slideUp('fast');
			$("a.btn-slide").html("Login Clientes ")
		}
	});

$(".menuTitCategoriaNoticiasMidia").click(function(){ 
	if($(".menuSubCategoriaNoticiasMidia").css("display") == "none")
		$(".menuSubCategoriaNoticiasMidia").slideDown('fast');
	else
		$(".menuSubCategoriaNoticiasMidia").slideUp('fast');

});

$(".menuTitCategoriaNoticiasResumo").click(function(){
	if($(".menuSubCategoriaNoticiasResumo").css("display") == "none")
		$(".menuSubCategoriaNoticiasResumo").slideDown('fast');
	else
		$(".menuSubCategoriaNoticiasResumo").slideUp('fast');
});	

$("#faq1").toggle(function () {
	$(".faq1").fadeIn('slow');
  },
  function () {
	$(".faq1").fadeOut('slow');
  }
);

$("#faq2").toggle(function () {
	$(".faq2").fadeIn('slow');
  },
  function () {
	$(".faq2").fadeOut('slow');
  }
);

$("#faq3").toggle(function () {
	$(".faq3").fadeIn('slow');
  },
  function () {
	$(".faq3").fadeOut('slow');
  }
);

$("#faq4").toggle(function () {
	$(".faq4").fadeIn('slow');
  },
  function () {
	$(".faq4").fadeOut('slow');
  }
);

$("#faq5").toggle(function () {
	$(".faq5").fadeIn('slow');
  },
  function () {
	$(".faq5").fadeOut('slow');
  }
);

$("#faq6").toggle(function () {
	$(".faq6").fadeIn('slow');
  },
  function () {
	$(".faq6").fadeOut('slow');
  }
);

$("#faq7").toggle(function () {
	$(".faq7").fadeIn('slow');
  },
  function () {
	$(".faq7").fadeOut('slow');
  }
);

$("#faq8").toggle(function () {
	$(".faq8").fadeIn('slow');
  },
  function () {
	$(".faq8").fadeOut('slow');
  }
);

$("#faq9").toggle(function () {
	$(".faq9").fadeIn('slow');
  },
  function () {
	$(".faq9").fadeOut('slow');
  }
);

$("#faq10").toggle(function () {
	$(".faq10").fadeIn('slow');
  },
  function () {
	$(".faq10").fadeOut('slow');
  }
);

$("#faq11").toggle(function () {
	$(".faq11").fadeIn('slow');
  },
  function () {
	$(".faq11").fadeOut('slow');
  }
);

$("#taxas").toggle(function () {
	$(".faq1").fadeIn('slow');
	$(".faq8").fadeOut('slow');
  },
  function () {
	$(".faq1").fadeOut('slow');
  }
);

$("#sagaceImprensa").toggle(function () {
	$(".sagaceImprensa").fadeIn('slow');
  },
  function () {
	$(".sagaceImprensa").fadeOut('slow');
  }
);

$(document).ready(function(){
		$(".colorBoxSagace").colorbox();
	});

});

$(document).ready(function(){
	$(".fotos a").colorbox();
});

$(document).ready(function(){
		$('#namidia').jCarouselLite({
		auto: 4000,
		speed: 500,
		vertical: true,
		visible: 2 
	});
});

$(document).ready(function(){
	$("#ctl00_cph_body_ModalidadeID_4").click(function() {
									 
		$(".classCreditoImovel").show('fast');
		
		
	});
	$("#ctl00_cph_body_ModalidadeID_1").click(function() {
								 
		$(".classCreditoImovel").hide('fast');
		
	});
	$("#ctl00_cph_body_ModalidadeID_2").click(function() {
								 
		$(".classCreditoImovel").hide('fast');
		
	});
	$("#ctl00_cph_body_ModalidadeID_3").click(function() {
								 
		$(".classCreditoImovel").hide('fast');
		
	});
	
	$("#ctl00_cph_body_btnOpcaoAvancada").click(function() {
								 
		$(".classOpcoesAvancadas").toggle('fast');
		
	});
});

$(document).ready(function(){
	$(".dataNascimento").mask("99/99/9999");
});

function Get(key){
    var r = new RegExp('[?&]');
    var param = location.href.split(r);
    
    for(i = 1; i < param.length; i++){
        if(param[i].search(key) >= 0)
        {
            var a = param[i].split('=');
            return a[1];
        }
    }
    
    return ''; 
}

function MM_validateForm() {
//  ---------------------------------------
	//alert(this.id);
	
	if (document.getElementById) {
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		firstField = new Array();
		for (i=0; i<(args.length-2); i+=4) {
			test=args[i+2];
			label = args[i+3];
			val=document.getElementById(args[i]);
			if (val) {
				nm=val.name;
				elInput = val;
				elInput.className = "";
				if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) {
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1)) {
							errors+='- '+label+' inválido.\n';
							elInput.className = "campoErrado";
							firstField.push(elInput);
						}
					} else if (test!='R') {
						num = parseFloat(val);
						if (isNaN(val)) {
							errors+='- '+label+' deve ser um número válido.\n';
							elInput.className = "campoErrado";
							firstField.push(elInput);
						}
						if (test.indexOf('inRange') != -1) {
							p=test.indexOf(':');
							min=test.substring(8,p);
							max=test.substring(p+1);
							if (num<min || max<num) {
								errors+='- '+label+' deve ser um número entre '+min+' e '+max+'.\n';
								elInput.className = "campoErrado";
								firstField.push(elInput);
							}
						}
					}
				} else if (test.charAt(0) == 'R') {
					errors += '- '+label+' é obrigatório.\n';
					elInput.className = "campoErrado";
					firstField.push(elInput);
				}
			}
		}
		if (errors) {
			alert('Os seguintes erros ocorreram:\n'+errors);
			firstField[0].focus();
		}
		
		document.MM_returnValue = (errors == '');
		/*if(document.MM_returnValue)
			$("#form1 input[type=submit]").hide();*/
		$("#form1 input[type=submit]").attr("disabled",document.MM_returnValue);
	}
}

function MM_validateForm() {
    //  ---------------------------------------
    if (document.getElementById) {
        var i, p, q, nm, test, num, min, max, errors = '', args = MM_validateForm.arguments;
        firstField = new Array();
        for (i = 0; i < (args.length - 2); i += 4) {
            test = args[i + 2];
            label = args[i + 3];
            val = document.getElementById(args[i]);
            if (val) {
                nm = val.name;
                elInput = val;
                elInput.className = "";
                if ((val = val.value) != "") {
                    if (test.indexOf('isEmail') != -1) {
                        p = val.indexOf('@');
                        if (p < 1 || p == (val.length - 1)) {
                            errors += '- ' + label + ' inválido.\n';
                            elInput.className = "campoErrado";
                            firstField.push(elInput);
                        }
                    } else if (test != 'R') {
                        num = parseFloat(val);
                        if (isNaN(val)) {
                            errors += '- ' + label + ' deve ser um número válido.\n';
                            elInput.className = "campoErrado";
                            firstField.push(elInput);
                        }
                        if (test.indexOf('inRange') != -1) {
                            p = test.indexOf(':');
                            min = test.substring(8, p);
                            max = test.substring(p + 1);
                            if (num < min || max < num) {
                                errors += '- ' + label + ' deve ser um número entre ' + min + ' e ' + max + '.\n';
                                elInput.className = "campoErrado";
                                firstField.push(elInput);
                            }
                        }
                    }
                } else if (test.charAt(0) == 'R') {
                    errors += '- ' + label + ' é obrigatório.\n';
                    elInput.className = "campoErrado";
                    firstField.push(elInput);
                }
            }
        }
        if (errors) {
            alert('Os seguintes erros ocorreram:\n' + errors);
            firstField[0].focus();
        }
        document.MM_returnValue = (errors == '');
    }
}
