$(document).ready(function() {
    if(typeof lte_ie7 != 'undefined') {
        //fixes the carousel from showing in middle of page and then popping in on IE6; css rules in styles2.css
        $("div.footwrap").css("position", "relative");
        $("div.footwrap").show();
	 }
    var is_home, slide = true;
    if($('.home-page').length > 0) {
        is_home = true;
    }
    else {
        is_home = false;
    }
    var last_num = (is_home) ? 7 : 10;

    if(is_home) {
        $('#c_images').cycle({
            speed: 2000,
            timeout: 5000,
            pager: '#pager',
            pause: 1,
            after: function() {
                var active = $(this).attr('id');
                $('#slide-text div').hide();
                $('#slide-text div.' + active).show();
            }
        });
		
		
		$('ul.tweets').cycle({
			speed: 2000,
			timeout: 5000,
			pause: 1
		});
    }
    else {
        if($('#footslide .inner li').length < 10) {
            slide = false;
        }
    }
    if(slide) {
        var rand = Math.floor(Math.random() * $('#footslide .inner li').length);
        if(typeof lte_ie7 != 'undefined') {
            rand = 0;
            var mod_last = last_num + rand;
            $('#footslide .inner li:eq('+rand+'), #footslide .inner li:eq('+ mod_last +')').addClass('hidden_li');
            $('#left-foot-mask, #right-foot-mask').hide();
        }
        $('#footslide .inner').wCarousel({
            next: '#arrow-right',
            prev: '#arrow-left',
            start: rand,
            visible: (is_home) ? 8 : 11,
            callAfter: function(visible) {
                if(typeof lte_ie7 != 'undefined') {
                    $('#footslide .inner li').removeClass('hidden_li');
                    $(visible[0]).addClass('hidden_li');
                    $(visible[last_num]).addClass('hidden_li');
                    $('#left-foot-mask, #right-foot-mask').hide();
                }
            },
            callBefore: function() {
                if(typeof lte_ie7 != 'undefined') {
                    $('#left-foot-mask, #right-foot-mask').show();
                }
            }
        });
    }
    else {
        $('#arrow-left,#arrow-right,#left-foot-mask').hide();
        $('#footslide,#footslide .inner').css('margin-left', '0');
    }
    if(typeof lte_ie7 != 'undefined') {
        $('#footslide .inner').hover(function() {
            $(this).css('z-index', '20');
        }, function() {
            $(this).css('z-index', '0');
        });
    }
    $('#footslide li a').addClass('default');
    $('#footslide li a').hover(function() {
        /*$('#footslide .hovered').find('span,img').removeAttr('style');
        $('#footslide .hovered').removeClass('hovered').find('strong').hide();*/
        var a = this;
        $(a).removeClass('default');
        $(a).addClass('hovered');
        $(a).parent().addClass('over');
        $(a).find('img').css({

        }).animate({
            width: '168px'
        }, 200);
        $(a).find('span').css({
            width: '90px',
            top: '0',
            left: '0',
            padding: '0px',
            height: '55px'
        }).animate({
            left: '-39px',
            top: '-33px',
            padding: '4px',
            height: '124px',
            width: '168px'
        }, 200, function() {
            $(this).find('strong').css('display', 'block');
        });
        $('#bottom_menu').css('position', 'static');
    }, function() {
        $(this).removeClass('hovered').addClass('default').stop().find('span').stop();
        $(this).parent().removeClass('over');
        $('#bottom_menu').css('position', 'relative');
    });
    $('#footslide li a span').click(function() {
        window.location = $(this).parent().attr('href');
    })
    $('#menu_left p:not(.main) a[href=' + window.location.pathname + ']').addClass('active');
    $('#menu_left p.main').hover(function() {
        $(this).addClass("arrow_cat_hover");
    }, function() {
        $(this).removeClass("arrow_cat_hover");
    });
});
