var d = document;

    jQuery(document).ready(function() {
	//////// GALERIA CAROUSEL ////////////
	jQuery('#mycarousel').jcarousel({
	    vertical: false,
	    visible: 2,
	    scroll: 2
	});
	//////// GALERIA CAROUSEL /////////// 
	
	////////// CYCLE SLIDER//////////////
	$("#slideshow").css("overflow", "hidden");
	
	$("ul#slides").cycle({
		fx: 'fade',
		pause: 1,
		prev: '#prev',
		next: '#next'
	});
	
	$("#slideshow").hover(function() {
    	$("ul#nav").fadeIn();
  	},
  		function() {
    	$("ul#nav").fadeOut();
  	});
	////////// CYCLE SLIDER//////////////
	    
	//////// FANCYBOX //////////////////
	jQuery(".fancy_img").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				    return '<span id="fancybox-title-over">Imagem ' + (currentIndex + 1) + ' de ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});
	jQuery(".fancy_video").click(function() {
	    $.fancybox({
			    'padding'		: 0,
			    'autoScale'		: false,
			    'transitionIn'	: 'none',
			    'transitionOut'	: 'none',
			    'title'		: this.title,
			    'width'		: 640,
			    'height'		: 385,
			    'href'		: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			    'type'		: 'swf',
			    'swf'		: {
						    'wmode': 'transparent',
						    'allowfullscreen': 'true'
			    }
	    });
	    return false;
	});
    
	$("a#inline").fancybox({
	    'hideOnContentClick': false
	});	
    });
    //////// FANCYBOX //////////////////


////////////// VAI PÁGINA //////////////
function goPage(pag,div){
	$.ajax({
		type: "GET",
		url: pag,
		beforeSend: function() {
			$("#"+div).html('Carregando...');
		},
		success: function(texto){
			$("#"+div).html(texto);
		},
		error: function(txt) {
			$("#"+div).html('Erro ao listar as regiões');
		}
	});
}
////////////// VAI PÁGINA //////////////


//////// SLIDE SHOW /////////////////
function slideSwitch() {
    var $active = $('#slider IMG.active');

    if ( $active.length == 0 ) $active = $('#slider IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slider IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

function validate(egg) {
	var spam = 0;
	
	for(var i = 0; i < egg.length; i++) {	
		if(d.getElementById(egg[i]).value == null || d.getElementById(egg[i]).value == '') {
			spam = 1;
		}
	}
	if(spam == 1) {
		alert("Favor preencher todos os campos!");
	}
	else {
		d.getElementById('_form').submit();
	}
}

function validateThisForm(egg,python) {
	var spam = 0;
	
	for(var i = 0; i < egg.length; i++) {	
		if(d.getElementById(egg[i]).value == null || d.getElementById(egg[i]).value == '') {
			spam = 1;
		}
	}
	if(spam == 1) {
		alert("Favor preencher todos os campos!");
	}
	else {
		d.getElementById(python).submit();
	}
}

function validatePwd(pwd1, pwd2, egg) {
	var spam = 0;
	
	if(d.getElementById(pwd1).value == d.getElementById(pwd2).value) {
		var spam = 0;

		for(var i = 0; i < egg.length; i++) {	
			if(d.getElementById(egg[i]).value == null || d.getElementById(egg[i]).value == '') {
				spam = 1;
			}
		}
		if(spam == 1) {
			alert("Favor preencher todos os campos!");
		}
		else {
			d.getElementById('_form').submit();
		}
	}
	else {
		alert('As senhas nao conferem!');
		d.getElementById()
	}
}

function limpar(spam,egg) {
	if(spam.value == egg) {
		spam.value = '';
	}
}

function voltar(spam,egg) {
	if(spam.value == '') {
		spam.value == egg;
	}
}

					function valida_email(mail)
					{
						var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
						return er.test(mail); 
				    }		


