// JavaScript Document
$(document).ready(function(){

/*Logo code*/
	$(".logo").hover(function() {
		for(i=0; i<3; i++){
			$(this).animate({backgroundPosition: '0px -10px'},{duration:20});
			$(".logo div").animate({backgroundPosition: '0px -10px'},{duration:20});
			$(this).animate({backgroundPosition: '0px 10px'},{duration:20});
			$(".logo div").animate({backgroundPosition: '0px 10px'},{duration:20});
		}
		$(this).animate({backgroundPosition: '0px 0px'},{duration:0});
		$(".logo div").animate({backgroundPosition: '0px 0px'},{duration:0});
		$(".logo div").animate({opacity: "show"});
	}, function(){
		$(".logo div").animate({opacity: "hide"}, 500);
	});
	
	
/*Top menu code*/	
	$(".lm li").hover(function() {
		$(this).find("ul:first").animate({opacity: "show", left: 20+$(this).find("a:first").width()}, "fast");
	},
        function() { 
		$(this).find("ul:first").animate({opacity: "hide", left: 30+$(this).find("a:first").width()}, "fast");
	});
	
	/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback(carousel) {
	carousel.notify=function(evt) {
		if (evt='onAfterAnimation') {
			jQuery('.jcarousel-control a').removeClass('active');
			jQuery(jQuery('.jcarousel-control a')[carousel.first-1]).addClass('active');
		}
	}
	
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);		
        return false;
    });

    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
	
	// Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

// Ride the carousel...
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
		auto: 1,
		wrap: 'last',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
	$(".jcarousel-control").find("a:first").addClass("active");
	
	$(".jcarousel-control a").click(function() {
		$(".jcarousel-control a").removeClass("active");
		$(this).addClass("active");
	});
	
	
// hide #back-top first
	$("#back-top").hide();
 
// fade in #back-top
	$(function () {
	  $(window).scroll(function () {
	   if ($(this).scrollTop() > 100) {
		$('#back-top').fadeIn();
	   } else {
		$('#back-top').fadeOut();
	   }
	  });
	
	  // scroll body to 0px on click
	  $('#back-top').click(function () {
	   $('body,html').animate({
		scrollTop: 0
	   }, 200);
	   return false;
	  });
	});
	
	
// Ie text close button
	$(".ie_div a").click(function () {
		$('.ie_div').fadeOut();
		return false;
	});
});
