function mycarousel_initCallback(carousel)
{
		$('#slider_nav a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    
		// Pause autoscrolling if user moves over the external controls
    $('#slider_nav').hover(function() {
    		carousel.stopAuto();
    }, function() {
    	  carousel.startAuto();
    });
    
};

function itemVisibleIn(carousel, li, index, state)
{
    $("li#slidenav" + index + " a").addClass('currentslidenav');
    
}

function itemVisibleOut(carousel, li, index, state)
{
    $("li#slidenav" + index + " a").removeClass('currentslidenav');
}

$(document).ready(function() {
    $('#slide_holder').jcarousel({
        auto: 12,
        wrap: 'last',
        scroll: 1,
        rtl: 1,
        initCallback: mycarousel_initCallback,
        itemVisibleInCallback: itemVisibleIn,
        itemVisibleOutCallback: itemVisibleOut,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
    
    //$('.starthide').hide();
    
    $('.throwcontact').bind('click', function() {
    		
    		$('html, body').animate({ scrollTop: 0 }, 400);
    		
    		if ($('#contactbox').is(":hidden")){
    		  
    		  $('body').animate({
    		  		"backgroundPosition" : "0 270px",
    		  		"padding-top": "270px"
    		  },  {
    		    duration: 400,
    		    complete: function() {
    		      $('#contactbox').show();
    		    }
    		  });
    		} else {
    			$('body').animate({
    		  		"padding-top": "0",
    		  		backgroundPosition : "0 0"
    		  }, 400);
    			$('#contactbox').hide();
    			
    		}
    		
    		  return false;
    });
    
    $("#contact-main").validate();
    
});
