﻿$(window).load(function() {
    $('.factura li').qtip({
        content: {
            attr: 'alt'
        },
        show: {
            event: 'click mouseenter'
        },
        hide: {
            delay: 50
        },
        style: {
            classes: 'ui-tooltip-shadow ui-tooltip-jtools'
        },
        position: {
            my: 'top center', // Use the corner...
            at: 'bottom center' // ...and opposite corner
        }
    });
    $('.tip').qtip({
        content: {
            attr: 'alt'
        },
        show: {
            event: 'click mouseenter'
        },
        hide: {
            delay: 50
        },
        style: {
            classes: 'ui-tooltip-shadow ui-tooltip-youtube'
        },
        position: {
            my: 'left center', // Use the corner...
            at: 'right center' // ...and opposite corner
        }
    });

    $('#slider').nivoSlider({
        effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: true, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function() { }, // Triggers before a slide transition
        afterChange: function() { }, // Triggers after a slide transition
        slideshowEnd: function() { }, // Triggers after all slides have been shown
        lastSlide: function() { }, // Triggers when last slide is shown
        afterLoad: function() { } // Triggers when slider has loaded
    });
    $("ul.opciones li").hover(function() {
        $(this).css({ 'z-index': '10' }); /*Add a higher z-index value so this image stays on top*/
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
		    marginTop: '-0px', /* The next 4 lines will vertically align this image */
		    marginLeft: '-0px',
		    top: '0%',
		    left: '1%',
		    width: '295px', /* Set new width */
		    height: '91px', /* Set new height */
		    padding: '0px'
		}, 50); /* this value of "200" is the speed of how fast/slow this hover animates */

    }, function() {
        $(this).css({ 'z-index': '0' }); /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
		    marginTop: '0', /* Set alignment back to default */
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '292px', /* Set width back to default */
		    height: '91px', /* Set height back to default */
		    padding: '0px'
		}, 50);
    });
    $("ul.precios li").hover(function() {
        $(this).css({ 'z-index': '10' }); /*Add a higher z-index value so this image stays on top*/
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
		    marginTop: '-30px', /* The next 4 lines will vertically align this image */
		    marginLeft: '-10px',
		    top: '5%',
		    left: '1%',
		    width: '140px', /* Set new width */
		    height: '233px', /* Set new height */
		    padding: '0px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

    }, function() {
        $(this).css({ 'z-index': '0' }); /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
		    marginTop: '0', /* Set alignment back to default */
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '120px', /* Set width back to default */
		    height: '200px', /* Set height back to default */
		    padding: '0px'
		}, 400);
    });

    $("#sellopac").hover(function() {
        $(this).css({ 'z-index': '100' }); /*Add a higher z-index value so this image stays on top*/
        $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
		    marginTop: '0px', /* The next 4 lines will vertically align this image */
		    marginLeft: '-15px',
		    top: '0%',
		    left: '1%',
		    width: '150px', /* Set new width */
		    height: '158px', /* Set new height */
		    padding: '0px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

    }, function() {
        $(this).css({ 'z-index': '100' }); /* Set z-index back to 0 */
        $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
		    marginTop: '0', /* Set alignment back to default */
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '90px', /* Set width back to default */
		    height: '95px', /* Set height back to default */
		    padding: '0px'
		}, 400);
}); 
    $("#sellopac")
        $(".videos").click(function() {
            $.fancybox({
                'padding': 0,
                'autoScale': false,
                'transitionIn': 'none',
                'transitionOut': 'none',
                'title': this.title,
                'width': 680,
                'height': 495,
                'href': this.href + '&autoplay=1',
                'type': 'swf',
                'swf': {
                    'wmode': 'transparent',
                    'allowfullscreen': 'true'
                }
            });

            return false;
        });
//    $(".videos").click(function() {
//        var URL = $(this).attr('href');
//        var htm = '<iframe width="600" height="335" src="http://www.youtube.com/embed/' + URL + '?rel=1&autoplay=1" frameborder="0" allowfullscreen ></iframe>';
//        $(".video_load").html(htm);
//        return false;
//    });
    $(function() {
        //Get our elements for faster access and set overlay width
        var div = $('div.slider'),
		ul = $('ul.thumbnail_img'),
		ulPadding = 15;

        //Get menu width
        var divWidth = div.width();

        //Remove scrollbars	
        div.css({ overflow: 'hidden' });

        //Find last image container
        var lastLi = ul.find('li:last-child');

        //When user move mouse over menu
        div.mousemove(function(e) {
            //As images are loaded ul width increases,
            //so we recalculate it each time
            var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
            var left = (e.pageX - div.offset().left) * (ulWidth - divWidth) / divWidth;
            div.scrollLeft(left);
        });
    });
});     //$(window)
