urlsitio = "http://www.butterfly.com.py/bt/";
loadgif1 = '<div style="width: 637px; height: 427px; text-align: center;"><br /><br /><br /><br /><br /><br /><br /><img src="'+urlsitio+'layouts/butterfly2010/images/load.gif"/></div>';

$(document).ready(function(){
    $(".fade").fadeTo("fast", 0.009);
        $(".fade").mouseover(function () {
            $(this).fadeTo("fast", 1);
        });
	$(".fade").mouseout(function () {
            $(this).fadeTo("slow", 0.009);
        });
	
	$('#rotar').cycle({ 
	fx:     'fade', 
	delay:  -1000 
	});
	
	$(".tab_content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();

	$("ul.tabs li").click(function()
       {
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();

		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
	/*var galleries = $('.ad-gallery').adGallery({
	loader_image: urlsitio+'layouts/butterfly2010/images/load.gif',
	width: 640, 
	height: 480,
	slideshow: {
	enable: true,
	autostart: true,
	speed: 5000,
	start_label: 'Play',
	stop_label: 'Pausa',
	stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
	countdown_prefix: '(', // Wrap around the countdown
	countdown_sufix: ')',
	onStart: function() {
	// Do something wild when the slideshow starts
	},
	onStop: function() {
	// Do something wild when the slideshow stops
	}
	},
    effect: 'slide-hori' // 'slide-vert', 'resize', 'fade', 'none' or false

	});*/
});

function mailing(php){
	var nombre = $("#nombre2").val();
	var email = $("#email2").val();
	$("#form_contacto2").html('<div style="width: 244px; height: 117px; text-align: center;"><br /><br /><img src="'+urlsitio+'layouts/butterfly2010/images/load.gif"/></div>');
	$("#form_contacto2").load(urlsitio+'modulos/pages/'+php,{'email':email,'nombre':nombre});
}

function enviar(php){
	var datos=$("#form_contacto").serialize();
	$("#form_contacto").html('<div style="width: 630px; height: 420px; text-align: center;"><br /><br /><br /><br /><br /><br /><br /><img src="'+urlsitio+'layouts/butterfly2010/images/load.gif"/></div>');
	$(document).ready(function(){
	$.ajax({
	type: "POST",
	url: urlsitio+"modulos/pages/"+php,
	data: datos,
	success:  function(msg){
                $("#form_contacto").html(msg);
                }
	});
    });
}
function validar_envio(a,tipo){
	$(document).ready(function(){
	a = a.split("+");
	c = a.length;
	var x=0;
        var contar = 0;
	for (x=0; x<c; x++){
	sel = $("input[name='"+a[x]+"']");
	valo = sel.val().length;
	    if(valo > 2){
		    sel.css({'border':'1px solid #78b505','background-color':'#d3fa84'});
		    contar=contar+1;
		    }else{
		    sel.css({'border':'1px solid #b30000','background-color':'#ff8875'});
		}
	    }
	    if (c == contar && valo != ""){
		if(tipo == "contacto"){
		enviar('envio.php');
		}
		if(tipo =="sugerencia"){
		enviar('sugerencia.php');
		}
		if(tipo =="suscripcion"){
		mailing('suscripcion.php');
	    }
            }
	});
}

