if($.cookie("css"))
{
    $("#style").attr("href",$.cookie("css"));
}
$(document).ready(function() {

    

    $("#skins a").click(function() {
      
            $("#style").attr("href",$(this).attr('rel'));
            $.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});

          $("#green").attr('src', 'img/btn-green-skin.jpg');
          $("#red").attr('src', 'img/btn-red-skin.jpg');
          $("#blue").attr('src', 'img/btn-blue-skin.jpg');

          color = $(this).attr('title');
            $("#"+color).attr('src', 'img/btn-'+color+'-skin_2.jpg'); //botones de skins
          //  $(".color").attr('src', 'img/ver-mas-'+color+'.png'); //boton de "ver mas" en INICIO

           /* if(color=="red"){
                $("#calendar_tmpl td.date_has_event").css({'background-image':'url(../img/cuadro-seleccionado-blue.jpg)'});
            }*/

          return false;
    });

      //jcoverflip
  $(function(){
   jQuery( '#flip' ).jcoverflip({
          current: 2,

          beforeCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, {left: ( container.width( )/2 - 200 - 90*offset + 20*offset )+'px', bottom: '5px'}, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), {width: Math.max(10,80-20*offset*offset) + 'px'}, {} )
            ];
          },
          afterCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, {left: ( container.width( )/2 + 75 + 90*offset )+'px', bottom: '5px'}, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), {width: Math.max(10,80-20*offset*offset) + 'px'}, {} )
            ];
          },
          currentCss: function( el, container ){
            return [
              $.jcoverflip.animationElement( el, {left: ( container.width( )/2 - 100 )+'px', bottom: 0}, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), {width: '150px'}, { } )              
            ];
          },
          change: function(event, ui){
            jQuery('#scrollbar').slider('value', ui.to*15);
          
          }
        });

       

        jQuery('#scrollbar').slider({
          value: 50,
          stop: function(event, ui) {
            if(event.originalEvent) {
              var newVal = Math.round(ui.value/15);
              jQuery( '#flip' ).jcoverflip( 'current', newVal );
              jQuery('#scrollbar').slider('value', newVal*15);
            }
          }
        });

  });


var font_btn_clicked = 0;

// Increase Font Size
$(".increaseFont").click(function(){
    font_btn_clicked+=1;
    
   if( font_btn_clicked == 3)
   { 
       $(".increaseFont").attr("disabled", "disabled");
       $(".decreaseFont").removeAttr("disabled");
   }
   else{ 
       $(".increaseFont").removeAttr("disabled");

    var currentFontSize = $('html').css('font-size');
    
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    $('html').css('font-size', newFontSize);
   }

    return false;
});


// Decrease Font Size
$(".decreaseFont").click(function(){
    font_btn_clicked-=1;
    
    if( font_btn_clicked == 0)
   {     
       $(".decreaseFont").attr("disabled", "disabled");
       $(".increaseFont").removeAttr("disabled");
   }else
   {
       $(".decreaseFont").removeAttr("disabled");
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*0.8;
        $('html').css('font-size', newFontSize);
    }

    return false;
});

 // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
    
    $(".increaseFont").removeAttr("disabled");
    $(".decreaseFont").removeAttr("disabled");

     return false;
  });



});//end jQuery ready



