$(document).ready(function(){
	industry = "contract";
   $( '#flip' ).jcoverflip({
          current: 2,
          beforeCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 210 - 110*offset + 20*offset )+'px', bottom: '20px' }, { } ),
			//$.jcoverflip.animationElement( el, { left:  width: '100px', height: '100px', bottom: '20px' }, { } ),
             // $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,100-20*offset*offset) + 'px' }, {} )
			$.jcoverflip.animationElement( el.find( 'img' ), { width: '65px', height: '65px' }, {} )
            ];
          },
          afterCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 + 110 + 110*offset )+'px', bottom: '20px' }, { } ),
				//$.jcoverflip.animationElement( el, { left:  width: '100px', height: '100px', bottom: '20px' }, { } ),
             // $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,100-20*offset*offset) + 'px' }, {} )
			$.jcoverflip.animationElement( el.find( 'img' ), { width: '65px', height: '65px' }, {} )
            ];
          },
          currentCss: function( el, container ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 66 )+'px', bottom: 0 }, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), { width: '130px', height: '130px'  }, { } )
            ];
          },
          change: function(event, ui){

            $('#scrollbar').slider('value', ui.to*10);
			
          },
		  stop: function() {
			  $("#flip > li > img").each(function (index) {
				if ($(this).attr("style").indexOf("130px") != -1) {
					industry = $(this).attr("id");
				}
			});
			
			
		  }
        });
        
        
        $('#scrollbar').slider({
		  value: 50,
          stop: function(event, ui) {
            if(event.originalEvent) {
              var newVal = Math.round(ui.value/10);
              $( '#flip' ).jcoverflip( 'current', newVal );
              $('#scrollbar').slider('value', newVal*10);
            }
          }
        });

 
  });

function mycarousel_initCallback(carousel)
{
    // 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-playPause a#pauseIt').bind('click', function() {
		carousel.stopAuto();
		$('#pauseIt').removeClass('showIt').addClass('hideIt');
		$('#playIt').removeClass('hideIt').addClass('showIt');
	});
	
	jQuery('.jcarousel-playPause a#playIt').bind('click', function() {
		carousel.startAuto();
		carousel.next();
		$('#playIt').removeClass('showIt').addClass('hideIt');
		$('#pauseIt').removeClass('hideIt').addClass('showIt');
	});
};


jQuery(document).ready(function() {
    jQuery("#carouselHome").jcarousel({
        scroll: 1,
		auto: 10,
		wrap: 'last',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
		itemVisibleInCallback: {
            onAfterAnimation: function(c, o, i, s) {
			   i = (i - 1) % $('#carouselHome li').size();
			  jQuery('.jcarousel-control a').removeClass('active').addClass('inactive');
              jQuery('.jcarousel-control a:eq(' + i + ')').removeClass('inactive').addClass('active');
            }
          }
    });
});

/*function pausePlay() {
	$("#pauseButton").removeClass("showIt").addClass("hideIt");
	$("#playButton").removeClass("hideIt").addClass("showIt");
}
$(document).ready(function() {
	$("#pauseButton").click(function() {
		stopAuto();
		$(this).removeClass("showIt").addClass("hideIt");
		$("#playButton").removeClass("hideIt").addClass("showIt");
	});
	
	$("#playButton").click(function() {
		startAuto();
		$(this).removeClass("showIt").addClass("hideIt");
		$("#pauseButton").removeClass("hideIt").addClass("showIt");
	});
});*/
