/* ------------------------------------------------------------------------
Javascript Rollover Image
------------------------------------------------------------------------- */

$(function() {
    $('.imgrollover').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('rel'));
        $(this).attr('rel', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('rel'));
        $(this).attr('rel', currentImg);
    });
});

// iniciamos colorbox
jQuery(document).ready(function() {
	$(".colorbox").colorbox();
});

function ShowLogIn(error, page){
	if ( error === undefined ) { error = 0; }
	if ( page === undefined ) { page = 0; }
	$(document).ready(function() {
		$.fn.colorbox({
			href:'/inc/popup_login.php?page='+page+'&error='+error, 
			open:true,
			scrolling:false, 
			onComplete: function() { 
            	$('#ajaxForm input:first').focus(); 
            }
		});
	});
}

// scripts menu principal desplegable
$(document).ready(function(){

	$("ul.topnav li a.drop").mouseenter(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

// Create the tooltips only on document load
$(document).ready(function() 
{
   // Use the each() method to gain access to each elements attributes
   $('#listado_mini a[rel], #listado_normal a[rel]').each(function()
   {
      $(this).qtip(
      {
         content: {
            // Set the text to an image HTML string with the correct src URL to the loading image you want to use
            text: '<img class="throbber" src="/images/loading.gif" alt="Loading..." />',
            url: $(this).attr('rel'), // Use the rel attribute of each element for the url to load
            title: {
               text: 'Ref : '+ $(this).attr('title'), // Give the tooltip a title using each elements text
               button: 'Close' // Show a close link in the title
            }
         },
         position: {
            corner: {
               target: 'bottomMiddle', // Position the tooltip above the link
               tooltip: 'topMiddle'
            },
            adjust: {
               screen: true // Keep the tooltip on-screen at all times
            }
         },
         show: { 
            when: 'mouseover', 
            solo: true // Only show one tooltip at a time
         },
         hide: 'unfocus',
         style: {
            tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
            border: {
               width: 0,
               radius: 4
            },
            name: 'light', // Use the default light style
            width: 200 // Set the tooltip width
         }
      })
   });
   
   $('#items .no-stock, #items .itm-nostock').qtip(
   {
      content: 'Articulo no disponible actualmente(Ni en web ni en tienda)', 
      style: {
        tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
        border: {
           width: 0,
           radius: 4
        },
        name: 'red'
     }

   });
   
   $('#items .add-cart').qtip(
   {
      content: 'A&ntilde;adir articulo a la cesta',
      style: {
        tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
        border: {
           width: 0,
           radius: 4
        },
        name: 'blue'
     }
   });
   
    $('#items .add-faves').qtip(
   {
      content: 'Guardar articulo en mis favoritos', 
      style: {
        tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
        border: {
           width: 0,
           radius: 4
        },
        name: 'blue'
     }

   });
   
});


