/**
 * @author Webmaster
 */

$(document).ready(function(){
  //mais vendidos
  /*contador=1;
  $curr = $("#mvlivros");
  $curr.css("background-image", "url(imgs/menuactive.png)");*/

  //lançamentos
  contador2=1;
  $curr2 = $("#lclivros");
  $curr2.css("background-image", "url(imgs/menuactive.png)");
});

/*function slideSwitch() {
    $(document).ready(function(){
          //slideshow mais vendidos
          $curr = $curr.next();
          contador++;
          $("div.box2 a.txt2").css("background-image", "none");
          $("div.box2 a.txt2").css("text-shadow", "1px 1px 1px #BBBBBB");
          $curr.css("background-image", "url(imgs/menuactive.png)");
          $curr.css("text-shadow", "1px 1px 1px #555555");
          var cat=$curr.attr('href');
          var modelo='maisvendidos';
          $.ajax({
              type: "POST",
              url: "php_banner1.php",
              data: "modelo="+modelo+"&categoria="+cat,
              beforeSend: function() {
                $('.menuBanner #box-m-v').html('<div class="carregaitens">Carregando</div>');
              },
              success: function(data){
      			/*if (jQuery.support.opacity) {
      				$('.menuBanner #box-m-v').html(data).fadeTo("fast", 1).children('div').animate({
      					opacity: "show",
      					top: "-55"
      				}, "slow").fadeTo("fast", 0.8).fadeTo("fast", 1);
      			} else {*/
      				/*$('.menuBanner #box-m-v').html(data).children('div')
      					.animate({top: "-55"}, "slow")
                        .hide()
      					.fadeIn('normal');
                //}
              }
          });
          if(contador==6) {
            $curr = $("#mvlivros").prev();
            contador=0;
          }
    })

}*/



function slideSwitch2() {
    $(document).ready(function(){
          //slideshow lançamentos
          $curr2 = $curr2.next();
          contador2++;
          $("div.box2l a.txt2").css("background-image", "none");
          $("div.box2l a.txt2").css("text-shadow", "1px 1px 1px #BBBBBB");
          $curr2.css("background-image", "url(imgs/menuactive.png)");
          $curr2.css("text-shadow", "1px 1px 1px #555555");
          var cat=$curr2.attr('href');
          var modelo='lancamentos';
          $.ajax({
              type: "POST",
              url: "php_banner2.php",
              data: "modelo="+modelo+"&categoria="+cat,
              beforeSend: function() {
                  $('.menuBanner #box-l').html('<div class="carregaitens">Carregando</div>');
              },
              success: function(data){
      			/*if (jQuery.support.opacity) {
      				$('.menuBanner #box-m-v').html(data).fadeTo("fast", 1).children('div').animate({
      					opacity: "show",
      					top: "-55"
      				}, "slow").fadeTo("fast", 0.8).fadeTo("fast", 1);
      			} else {*/
      				$('.menuBanner #box-l').html(data).children('div')
      					.animate({top: "-55"}, "slow")
                        .hide()
      					.fadeIn('normal');
                //}
              }
          });
          if(contador2==6) {
            $curr2 = $("#lclivros").prev();
            contador2=0;
          }
    })

}




$(document).ready(function(){

  //setInterval( "slideSwitch()", 5000 );

  setInterval( "slideSwitch2()", 8000 );

  $('div#p-cateq').cycle({
	fx: 'blindY',
	cleartype: true,
    cleartypeNoBg: true
  });

  $('div#p-minis').cycle({
	fx: 'blindY',
	cleartype: true,
    cleartypeNoBg: true
  });

  $('div#p-dizim').cycle({
	fx: 'blindY',
	cleartype: true,
    cleartypeNoBg: true
  });

  $('a#a_lancamento').click(function(){
	$('#m_mais-vendidos').slideUp();
	$('#m_lancamentos').slideDown();
	return false;
  });

/*  $('a#a_maisvend').click(function(){
	$('#m_lancamentos').slideUp();
	$('#m_mais-vendidos').slideDown();
	return false;
  });
*/
  $('.menuBanner .box2 a.txt1, .menuBanner .box2l a.txt1').click(function(){
  	return false;
  });


  $("div.carregaitens").show();
/*
  //mais vendidos
  $('.menuBanner .box2 a.txt2').click(function(){
  	//$('.menuBanner #box-m-v').html('<div class="carregaitens">Carregando</div>');
	$('.menuBanner .box2 a.txt2').css({
		'background-image':'none',
		'text-shadow':'1px 1px 1px #BBBBBB'
	});
	$(this).css({
		'background-image':'url(imgs/menuactive.png)',
		'text-shadow':'1px 1px 1px #555555'
	});
  	var cat=$(this).attr('href');
	var modelo=$(this).attr('rel');
    $.ajax({
        type: "POST",
        url: "php_banner1.php",
        data: "modelo="+modelo+"&categoria="+cat,
        beforeSend: function() {
            $('.menuBanner #box-m-v').html('<div class="carregaitens">Carregando</div>');
          },
        success: function(data){
			if (jQuery.support.opacity) {
				$('.menuBanner #box-m-v').html(data).fadeTo("fast", 1).children('div').animate({
					opacity: "show",
					top: "-55"
				}, "slow").fadeTo("fast", 0.8).fadeTo("fast", 1);
			} else {
				$('.menuBanner #box-m-v').html(data).children('div')
					.animate({top: "-55"}, "slow")
					.show();
			}
        }
    });
    var idelemento=$(this).attr('id');
    $curr = $("#"+idelemento);
    if(cat==6) {
        $curr = $("#mvlivros").prev();
        contador=0;
    } else {
        contador=cat;
    }
  	return false;
  });*/

  //lancamentos
  $('.menuBanner .box2l a.txt2').click(function(){
	$('.menuBanner .box2l a.txt2').css({
		'background-image':'none',
		'text-shadow':'1px 1px 1px #BBBBBB'
	});
	$(this).css({
		'background-image':'url(imgs/menuactive.png)',
		'text-shadow':'1px 1px 1px #555555'
	});
  	var cat=$(this).attr('href');
	var modelo=$(this).attr('rel');
    $.ajax({
        type: "POST",
        url: "php_banner2.php",
        data: "modelo="+modelo+"&categoria="+cat,
        beforeSend: function() {
            $('.menuBanner #box-l').html('<div class="carregaitens">Carregando</div>');
        },
        success: function(data){
			if (jQuery.support.opacity) {
				$('.menuBanner #box-l').html(data).fadeTo("fast", 1).children('div').animate({
					opacity: "show",
					top: "-55"
				}, "slow").fadeTo("fast", 0.8).fadeTo("fast", 1);
			} else {
				$('.menuBanner #box-l').html(data).children('div')
					.animate({top: "-55"}, "slow")
					.show();
			}
        }
    });
    var idelemento=$(this).attr('id');
    $curr2 = $("#"+idelemento);
    if(cat==6) {
        $curr2 = $("#lclivros").prev();
        contador2=0;
    } else {
        contador2=cat;
    }
  	return false;
  });

});


