$(function () {
	if ($.browser.msie && $.browser.version < 7)
		return;

	$('#datasheet li')
		.removeClass('highlight')
		.find('a')
		.append('<span class="hover" />').each(function ()
		{
			var $span = $('> span.hover', this).css('opacity', 0);
			
			$(this).hover(function ()
			{
				// on hover
				$span.stop().fadeTo(800, 1);
			},
			function ()
			{
				// off hover
				$span.stop().fadeTo(1500, 0);
			});
		});
});


// Simple Spy effect on homepage
$(function () {
    $('ul.spy').simpleSpy();
});


(function ($) {
    
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 3;
    interval = interval || 5000;
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = $list.find('> li:first').height();
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
        $list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function spy() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            // Create a hover for the spy images
	        $(".spy img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPicsSmall");
			}, function(){
				$(this).removeClass("hoverPicsSmall");
				$(this).addClass("widePics");
			});
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);


	$(document).ready(function(){
	
			//animate the menu links on the page-load
			$('#topBar_home')
			.css('opacity', 0)
			.animate({opacity: 1, top: 0, }, 1500);
			
			//Reduce the opacity of all the <span> elements in the menu in order to hide the text links
			$('#topBar_home').find("span").each(function(i) {
	        	$(this).css('opacity', 0);
	        	});
	        	
	        $('#topBar').find("span").each(function(i) {
	        	$(this).css('opacity', 0);
	        	});
	        	
	        // Create a hover for the homepage list images
	        $("#homeFeatures img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPicsLarge");
			}, function(){
				$(this).removeClass("hoverPicsLarge");
				$(this).addClass("widePics");
			});
			
			
	        // Create a hover for the product list images
	        $("#productList img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPics");
			}, function(){
				$(this).removeClass("hoverPics");
				$(this).addClass("widePics");
			});
			
			// Create a hover for the Gallery list images
	        $("#galleryList img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPics");
			}, function(){
				$(this).removeClass("hoverPics");
				$(this).addClass("widePics");
			});
			
			// Create a hover for the Gallery Detail Code images
	        $(".galleryRight a img").hover( function() {
	        	$(this).removeClass("widePics");
				$(this).addClass("hoverPics");
			}, function(){
				$(this).removeClass("hoverPics");
				$(this).addClass("widePics");
			});	
			
			
			
			
		
	        
	        //cycle through images within the ID div
	        $('#rotate').cycle({ 
			    fx:    'fade', 
			    pause:  5500 
			 });
			 
			$('#detailImage').cycle({ 
			    fx:     'fade', 
    			speed:   800, 
    			timeout: 6000, 
    			next:   '#detailImage', 
    			pause:   1
			 });
			
			
			//writing for odd and even rows in a table
			$('tr:not([th]):odd').addClass('odd');
			$('tr:not([th]):even').addClass('even'); 
			 
	
			 
			 	
	        

	 });    