// JavaScript Document
$(document).ready(function() {
	$(".momentoinicio").show();						   
	intervaloRich = setInterval(fechaRich,8000);
})

function fechaRich(){
	$(".momentoinicio").slideUp("slow");
}

$(document).ready(function() {
	$('.rodahome').cycle({ 
		fx:      'fade', 
		speed:    500, 
		timeout:  8000 
	});

	$('.rodapousada').cycle({ 
		fx:      'fade', 
		speed:    500, 
		timeout:  8000 
	});

	$('.rodacozinha').cycle({ 
		fx:      'fade', 
		speed:    500, 
		timeout:  8000 
	});
	$('#fotoschale').after('<div id="barrafotos">').cycle({ 
		fx:     'fade', 
		speed:   600, 
		timeout: 6000, 
		pager:  '#barrafotos',
		cleartypeNoBg:true,
		pagerAnchorBuilder: function(idx, slide) {
		return '<li><a href="#"><img src="' + $(slide).find("img").attr("src") + '" width="136" height="80" /></a></li>';
		}
	});
});



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 == '');
	}
}

