﻿/// <reference name="MicrosoftAjax.js" />
/// <reference path="jquery-1.3.2-vsdoc2.js" />
/// <reference path="common.js" />
/// <reference path="EICv3.js" />

///////////////////////////////////////////////////////////////////
//
//  Metodo do MediaBox no home do Rio Quente
//  Por Karl Douglas Nordfelt - Focusnetworks Brasil 20/10/2009
//
///////////////////////////////////////////////////////////////////
/*
eic.mediaBox = function(values) {

    var settings = {
        isMoving:       false,
        isExploring:    false,
        width:          $('#listMediaBox li img').outerWidth(),
        speed:          500,
        widthPromotion: $('#BoxPromocao').outerWidth(),
        widthExplorar:  $('#listMediaBox li img').outerWidth() - ( $('#lnkExplorar').outerWidth() / 2 )
    };  

    if (typeof (values) != 'undefined') {
        if (typeof(values.width) != 'undefined') {
            settings.width = values.width;
        }
        if (typeof(values.speed) != 'undefined') {
            settings.speed = values.speed;
        }
        if (typeof(values.widthPromotion) != 'undefined') {
            settings.widthPromotion = values.widthPromotion;
        }
        if (typeof(values.widthExplorar) != 'undefined') {
            settings.widthExplorar = values.widthExplorar
        }
    }

    var animateMediaBox = function(steps) {
        $('#listMediaBox').animate({ marginLeft: '-' + (settings.width * steps) + 'px' }, settings.speed, function() { settings.isMoving = false; });
    };

    $('#lnksMediaBox a').each(function(i) {
        $(this).click(function() {

            if (!settings.isMoving) {
                settings.isMoving = true;
                $('#lnksMediaBox a').removeClass('on');
                this.className = 'on';
                animateMediaBox(i);
            }

            return false;
        });
    });

    $('#lnkExplorar').click(function() {

        if (!settings.isMoving) {
            settings.isMoving = true;

            var selectedIndex = 0;

            if (settings.isExploring) {
                settings.isExploring = false;
                $('#BoxPromocao').animate({ left: '0px' }, settings.speed);
                $('#lnkExplorar').animate({ right: '0px' }, settings.speed);

                $('#listMediaBox').animate({ marginLeft: '0px' }, settings.speed, function() {
                    $('#lnksMediaBox').show().find('a').each(function(i) {
                        if (this.className != 'on') {
                            $('#listMediaBox > li:eq(' + i + ')').show();
                        }
                        else {
                            selectedIndex = i;
                        }
                    });
                    $('#listMediaBox').css({ marginLeft: '-' + (selectedIndex * settings.width) + 'px' });
                    settings.isMoving = false;
                });
            }
            else {
                settings.isExploring = true;
                $('#BoxPromocao').animate({ left: '-' + settings.widthPromotion + 'px' }, settings.speed);
                $('#lnkExplorar').animate({ right: settings.widthExplorar + 'px' }, settings.speed);

                $('#lnksMediaBox').hide().find('a').each(function(i) {
                    if (this.className != 'on') {
                        $('#listMediaBox > li:eq(' + i + ')').hide();
                    }
                    else {
                        selectedIndex = i;
                    }
                });

                $('#listMediaBox').css({ marginLeft: '0px' })

                animateMediaBox(1);
            }
        }

        return false;
    });
};
*/

var delay = 0;

//$('.jcarousel-list, .jcarousel-item h3, .jcarousel-item p, .jcarousel-item .info, .jcarousel-item ').mousedown(function(e) {
$('.jcarousel-list').mousedown(function(e) {

    var startPos = e.pageY;

    $(this).css({ cursos: 'n-resize' }).mousemove(function(e) {

        var parent = $(this).closest('.jcarousel-container');

        if (startPos > (e.pageY + delay)) {
            parent.find('.jcarousel-next').click();
        }
        else if (startPos < (e.pageY - delay)) {
            parent.find('.jcarousel-prev').click();
        }
        
    });

    return false;
}).mouseup(function() {
    $(this).unbind('mousemove').css({ cursos: 'default' });
}).mouseout(function() {
    $(this).unbind('mousemove').css({ cursos: 'default' });
});

/*setInterval('verificaDestaques()', 5000);
function verificaDestaques(){
	totalUL = $('.jcarousel-list').length;

	for(var i=0; i < totalUL; i++)
	{
		var totalLi = $('.jcarousel-list:eq('+i+') li').length - 1;
		var top_ul = $('.jcarousel-list:eq('+i+')').css('top').replace("px", "").replace("-", "");

		if(top_ul < (totalLi*109)){
			$('.jcarousel-list:eq('+i+')').parent().parent().find('.jcarousel-next').click();
		}else if(top_ul == (totalLi*109)){
			totalLi = totalLi+1;
			$('.jcarousel-list:eq("+i+")').parent().parent().find('.jcarousel-prev').queue(function(){
				var strEval='';
				for(var index = 0; index < totalLi; index++)
					strEval = "$(this).click();";
				
				eval(strEval);
			});
		}
	}
}*/