/* ------------------------------------------------------------------------
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);
    });
});

$(document).ready(function(){

    // Sidebar Accordion Menu Hover Effect:
		
		$("#main-nav li .move-item").hover(
			function () {
				$(this).stop().animate({ paddingLeft: "25px" }, 200);
			}, 
			function () {
				$(this).stop().animate({ paddingLeft: "15px" }, 200);
			}
		);


});

function show(num){
	numTotal=2;		
	$("#acordion"+num).show(900);
	for (i=1;i<=numTotal;i++) {			
		if(i!=num){
		 $("#acordion"+i).hide(300);				
		} 
	}
}

function showProd(){
	$("#masProd").show(900);
	javascript:$.scrollTo( "#masProd", 800 );
}

function ampliaCesta(id){
	$("#masProd"+id).toggle(900);
}





// Create the tooltips only on document load
$(document).ready(function() 
{
   // Use the each() method to gain access to each elements attributes
   $('.qtip').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 src="'+ $(this).attr('rel') +'" alt="'+ $(this).attr('title') +'" />',
            title: {
               text: $(this).attr('title'), // Give the tooltip a title using each elements text
               button: 'Close' // Show a close link in the title
            }
         },
         position: {
            corner: {
               target: 'topMiddle', // Position the tooltip above the link
               tooltip: 'topMiddle'
            },
            adjust: {
               screen: false // 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
         }
      })
   });
   
   
});


/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 180;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		//this.t = this.title;
		//this.title = "";	
		//var c = (this.t != "") ? "<br/>" + this.t : "";
		//alert(this.title);
		$("body").append("<p id='preview'><img src='"+ this.rel +"' alt='Image preview' /></p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
	setInterval('swapImages()', 5000);
});




