// MAIN SLIDESHOW (images)

$(function() {
	var imgWrapper = $('#slider > img');
	// only show the first image, hide the rest
	imgWrapper.hide().filter(':first').show();
	
	$('#slider_nav ul li a').click(function () {
	
	    // check if this item doesn't have class "current"
	    // if it has class "current" it must not execute the script again
	    if (this.className.indexOf('current') == -1){
	    	imgWrapper.hide();
	    	imgWrapper.filter(this.hash).fadeIn(500);
	    	$('#slider_nav ul li a').removeClass('current');
	    	$(this).addClass('current');
	    }
	    return false;
	});
});

// BOTTOM SLIDESHOW (content slideshow on the home page)

$(function() {
	var contentWrapper = $('#slider2 > .item');
	// only show the first item, hide the rest
	contentWrapper.hide().filter(':first').show();
	
	$('#slider2_nav ul li a').click(function () {
	
	    // check if this item doesn't have class "current"
	    // if it has class "current" it must not execute the script again
	    if (this.className.indexOf('current') == -1){
	    	contentWrapper.hide();
	    	contentWrapper.filter(this.hash).fadeIn(500);
	    	$('#slider2_nav ul li a').removeClass('current');
	    	$(this).addClass('current');
	    }
	    return false;
	});
});

$(document).ready(function() {
    

    $('div#marquesina marquee').marquee('pointer').mouseover(function () {
        $(this).trigger('stop');
    }).mouseout(function () {
        $(this).trigger('start');
    }).mousemove(function (event) {
        if ($(this).data('drag') == true) {
            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
        }
    }).mousedown(function (event) {
        $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
    }).mouseup(function () {
        $(this).data('drag', false);
    });



    
    $('#submitform').ajaxForm({
       	target: '#error',
       	beforeSubmit: function() {
    	$('#error').append('<p class="loading">Enviando...</p>');
    	},
    	success: function() {
    	$('#error p.loading').fadeOut();
    	$('#error').fadeIn('slow');
    	}
    });
      
});

