 $(document).ready(function()
 {       
   $('#cssdropdown li.headlink').hover(        
		function() 
    { 
			$('ul', this).css('display', 'block'); 
    },       
    function() 
    { 
			$('ul', this).css('display', 'none'); 
    });       

		if ($('#show-screenshots').is('*'))
		{	
			$(function() 
			{ 				
				$('#show-screenshots a').lightBox({fixedNavigation:true}); 			
			});
		}	
		
		if ($('#home-boxes').is('*'))
		{		
			$('#home-boxes h2 a').hover( 
				function()  					
				{  
					var id = $(this).attr("class");
					$(".outer #"+id).addClass('dynamic-img-hover'); 		 	 				  
				},  					
				function()  					
				{  	
					var id = $(this).attr("class");			
					$(".outer #"+id).removeClass('dynamic-img-hover'); 
				});	
		
  
			$('#home-boxes .outer .icon img').hover( 
				function()  					
				{  
					var cls = $(this).attr("class");
					$('#home-boxes '+cls).css("color","red"); 		 	 				  
				},  					
				function()  					
				{  	
					var cls = $(this).attr("class");			
					$('#home-boxes '+cls).css("color","#ffffff");
				});	
		};
 });		 


 /***********************
 * @title shuffle 
 * @desc  rotate images functions
 ***********************/
 (function($){
   $.fn.shuffle = function() {
     return this.each(function(){
       var items = $(this).children();
       return (items.length)
         ? $(this).html($.shuffle(items))
         : this;
     });
   }
 
   $.shuffle = function(arr) {
     for(
       var j, x, i = arr.length; i;
       j = parseInt(Math.random() * i),
       x = arr[--i], arr[i] = arr[j], arr[j] = x
     );
     return arr;
   }	
 });


 $(function () {
  var img = new Image();
  $(img).load(function () {
		//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
		$(this).hide();
		$('#loader').removeClass('loading').append(this);
      $(this).fadeIn();
   }).error(function () {
			// notify the user that the image could not be loaded
	 }).attr('src', '');
 });
	
	
  /***********************
  * @title JCarousel
  * @desc  Carousel functions
  ***********************/
  function mycarousel_itemVisibleOutCallbackAfterAnimation(carousel, item, idx, state) { 
		$("#flash"+idx).hide();  
		$("#audio_player"+idx).hide();  
		$("a#c"+idx).removeClass("control-active");
  };

  function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
		$("#flash"+idx).show(); 
		$("#audio_player"+idx).show(); 
		$("a#c"+idx).addClass("control-active");
//		alert('item ' +idx+ 'is visible ' + item);
  }

  function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
		// No animation on first load of the carousel
		if (state == 'init')
			return;

    jQuery('img', item).fadeIn('slow');
  };

  function mycarousel_initCallback(carousel)  
  {
    // 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();
    });
	};	
		
		
	function flashcarousel_initCallback(carousel)  
  {
		// 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();
		});
/*	 
		jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    }); 
*/		
		jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('title')));
        return false;
    }); 	
		
		
	};
