// JavaScript Document


jQuery(document).ready(function(){
					
					
					// STOP IE6 FLICKER
	if ($.browser.msie && $.browser.version.substr(0,1)<7) { 
		document.execCommand('BackgroundImageCache', false, true);
		
	};

					
	jQuery('#viewport').carousel('.simplePrevious', '.simpleNext');
	jQuery('#viewport2').carousel('.simplePrevious2', '.simpleNext2');  
	

	$('#preview1').slideUp('slow');
	
	
	$('.Hover').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	


	$('#Signup').click(function () {
			$('#preview1').slideDown('slow');					 
								 
	});
					   
	$('#CloseSignup').click(function () {
								 
			$('#preview1').slideUp('slow');		 
								 
	});

	$(function () {
				
		$('ul.spy').simpleSpy();
		
	});

	$('.ImageHold').hover(
				
				function(){ 
					//console.log('over');
					$(this).find('.ImageTop').animate({ paddingTop: '0px'}, 500 );
				},
				function(){ 
					//console.log('out');
					$(this).find('.ImageTop').animate({ paddingTop: '90px'}, 500);
				}
						 
	);
	


});




(function ($) {
    
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 3;
    interval = interval || 8000;
    
    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();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 1;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);

