// JavaScript do Menu
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace
	(" over", "");
   }
   }
  }
 }
}
window.onload=startList;


// CYCLES E CAROUSEL
$(document).ready(function(){
	$('#cycleBanners').after('<div id="barraBanners">').cycle({ 
		fx:     'fade', 
		speed:  600, 
		timeout: 6000, 
		pager:  '#barraBanners' 
	});
	
	
	$("#cycleAtuacao .cycleCorporacoes").jCarouselLite({
		btnNext: "#cycleAtuacao .next",
		btnPrev: "#cycleAtuacao .prev",
		auto: 3500,
		speed: 800,
		visible: 3,
		cleartype: 1
	});
	
	$("#boxParceiros .cycleParceiros").jCarouselLite({
		btnNext: "#boxParceiros .next",
		btnPrev: "#boxParceiros .prev",
		auto: 3500,
		speed: 800,
		visible: 1,
		cleartype: 1
	});
});	


// FADE IN FADE OUT
$(document).ready(function(){
	$("#homeFadeInOut a").fadeTo("fast", 1.5); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$("#homeFadeInOut a").hover(function(){
		$(this).fadeTo("fast", 0.0); // This should set the opacity to 100% on hover
	},function(){
		$(this).fadeTo("fast", 1.5); // This should set the opacity back to 30% on mouseout
	});
});


// SLIDESHOW
$(function() {
	$('#slideshowProduto .album-fotos').after('<ul id="navSlideshow">').cycle({
		fx: 'fade',
		speed: 1000,
		timeout:  3200,
		pager:  '#navSlideshow',
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="#"><img src="' + $(slide).find("img").attr("src") + '" width="60" height="50" /></a></li>';
		}
	});
	
	$("#slideshowProduto .album-fotos a").slideshow();
});


// TOOLTIP
$(function() { 
	$('.cycleCorporacoes a').tooltip({
		track: true, 
		delay: 0, 
		showURL: false, 
		extraClass: "right" 
	}); 
});


// FORMULARIOS
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 == '');
	}
}


$(function() {
	$('#test3').crossSlide({
	fade: 1
	}, [
	{
	  src:  'img/1.jpg',
	  from: '100% 80% 1x',
	  to:   '100% 0% 1.7x',
	  time: 6
	}, {
	  src:  'img/2.jpg',
	  from: 'top left',
	  to:   'bottom right 1.5x',
	  time: 6
	}, {
	  src:  'img/3.jpg',
	  from: '100% 80% 1.5x',
	  to:   '80% 0% 1.1x',
	  time: 6
	}, {
	  src:  'img/4.jpg',
	  from: '100% 50%',
	  to:   '30% 50% 1.5x',
	  time: 6
	}, {
	  src:  'img/5.jpg',
	  from: '100% 80% 1.5x',
	  to:   '80% 0% 1.1x',
	  time: 6
	}
	]);
});
	
