$(document).ready(function () {
						
	$('.tab-content').hide();
	$('.tab-content:eq(0)').show();
	$('.tabs a').click(function () {
		
		$('.tabs a').removeClass('active');
		$(this).addClass('active');
		$('.tab-content').hide();
		$('.tab-content').eq($('.tabs a').index(this)).show();
		return false;
	});
	
	// action
	$('.action .row .item').hover(function () {
		$(this).find('.image').height($(this).height()-22);
		$(this).addClass('item-hover');
		return false;
	}, function () {
		$(this).removeClass('item-hover');
		return false;
	});
	
	$("#navigation ul li").hover(function() {
		$(this).css({ 'z-index' : 100 });
		$(this).find("> .dd-h").show();
		$(this).find("a:eq(0)").addClass('hover');
	}, function() {
		$(this).css({ 'z-index' : 1 });
		$(this).find("> .dd-h").hide();
		$(this).find("a:eq(0)").removeClass('hover');
	});

	$('.blink')
		.focus(function(){
			if( $(this).val() == $(this).attr('title') ) {
				$(this).val('');
			}
		})
		.blur(function(){
			if( $(this).val() == '' ) {
				$(this).val( $(this).attr('title') );
			}
		});
	
	$('.link-to-value').change(function() { 
		  window.location = $(this).val(); 
	}); 

	
	// added new image part for carousel
	$('.slider-img').jcarousel( {
		auto: 11,
		wrap: 'both',
		initCallback: slider_initCallback,
		itemFirstInCallback: slider_firstInCallback,
		scroll: 1,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	
	/*
	$('.slider').jcarousel( {
		auto: 11,
		wrap: 'both',
		initCallback: slider_initCallback,
		itemFirstInCallback: slider_firstInCallback,
		scroll: 1,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	*/
	
	$('.slider2').jcarousel( {
		initCallback: slider_initCallback2,
		itemFirstInCallback: slider_firstInCallback2,
		scroll: 4,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	
	$('.slider3').jcarousel( {
		initCallback: slider_initCallback3,
		itemFirstInCallback: slider_firstInCallback3,
		scroll: 4,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	 
	$('.carousel-img-slides').show();
});


function slider_initCallback (jc, state) {
	if (state == 'init') { 
	  jc.startAutoOrig = jc.startAuto; 
	  jc.startAuto = function() { 
		if (!jc.paused) { 
		  jc.startAutoOrig(); 
		} 
	  } 
	  
	  jc.pause = function() { 
		$('#play-pause-button').css("background-image","url(/images/play.png)");
	
		jc.paused = true; 
		jc.stopAuto(); 
	  }; 
	  
	  jc.play = function() { 
		$('#play-pause-button').css("background-image","url(/images/pause.png)");
	  
		jc.paused = false; 
		jc.startAuto(); 
	  }; 
	  
	  $('#play-pause-button').bind('click', function() {
		   if (jc.paused) { 
			  jc.play(); 
			} else { 
			  jc.pause(); 
			} 
	  });
	} 

	// Disable autoscrolling if the user clicks the prev or next button.
    jc.buttonNext.bind('click', function() {
        jc.startAuto(0);
    });

    jc.buttonPrev.bind('click', function() {
        jc.startAuto(0);
    });
	
	$('.box-slide .slider-nav a:not(#play-pause-button)').bind('click', function() {
		jc.scroll($.jcarousel.intval($(this).attr('rel')));
		return false;
	});
	
    jc.play(); 
}

function slider_firstInCallback(carousel, item, idx, state) {
	$('.slider-nav a').removeClass('active');
	$('.slider-nav a').eq(idx-1).addClass('active');
}

function slider_initCallback2 (carousel) {
	$('.box-slide2 .slider-nav a').bind('click', function() {
		carousel.scroll($.jcarousel.intval($(this).attr('rel')));
		return false;
	});
}

function slider_firstInCallback2(carousel, item, idx, state) {
	$('.box-slide2 .slider-nav a').removeClass('active');
	var index = 0;
	switch (idx) {
		case 1: index = 0; break;
		case 5: index = 1;break;
		case 9: index = 2;break;
	}
	$('.box-slide2 .slider-nav a').eq(index).addClass('active');
}
function slider_initCallback3 (carousel) {
	
	$('.box-related .slider-nav a').bind('click', function() {
		carousel.scroll($.jcarousel.intval($(this).attr('rel')));
		return false;
	});
}

function slider_firstInCallback3(carousel, item, idx, state) {
	$('.box-related .slider-nav a').removeClass('active');
	$('.box-related .slider-nav a').eq(idx-1).addClass('active');
}
