
$(function(){
	$('.blink')
		.focus(function(){
			if( $(this).val() == $(this).attr('title') ) {
				$(this).val('');
			}
		})
		.blur(function(){
			if( $(this).val() == '' ) {
				$(this).val( $(this).attr('title') );
			}
		});
	
	$('#navigation li').hover(function() {
		$(this).css({ 'z-index' : 100 });
		$(this).find('> ul').show();
		$(this).find('a:eq(0)').addClass('hover');
	}, function() {
		$(this).css({ 'z-index' : 1 });
		$(this).find('> ul').hide();
		$(this).find('a:eq(0)').removeClass('hover');
	});
	
	$('.contact .field').focus(function () {
		$(this).addClass('field-h');
	}).blur(function () {
		$(this).removeClass('field-h');
	});
	
	// fader
	var fader = null;
	var counter = 0;
	$('#fader .slider').simpleFade({
		duration: 5500,
		speed: 2000,
		init: function () {
			fader = this;
		},
		onFade : function (index) {
			$('#slider-nav a').removeClass('active').eq(index).addClass('active');
			if (counter++ == 4) fader.stop();
		}
	});
	$('#slider-nav a').click(function () {
		fader.fadeTo($('#slider-nav a').index(this));
		return false;
	});
	
	$('.slider ul li:first').clone().appendTo('.slider ul');
	$('.slider ul').jcarousel({
	    scroll: 1,
	    wrap : 'both',
	    auto : 1,
	    animation: 1000,
	    buttonNextHTML: null,
	    buttonPrevHTML: null,
	    // Events
	    initCallback: function (carousel) {
	    	$('.slider-holder .prev').click(function () {
		        carousel.prev();
		        carousel.stopAuto();
		        return false;
		    });
		    $('.slider-holder .next').click(function () {
		        carousel.next();
		        carousel.stopAuto();
		        return false;
		    });
	    },
	    itemLastInCallback: function (carousel,li,pos,state) {
	    	if (!($(li).next('li').size())) {
				carousel.options.animation = 0;
				carousel.scroll(0);
				carousel.options.animation = 1000;
			} 
	    }
	});
	
	$('.s-slider-holder ul li:first').clone().appendTo('.s-slider-holder ul');
	$('.s-slider-holder ul').jcarousel({
	    scroll: 1,
	    wrap : 'both',
	    auto : 0,
	    animation: 1000,
	    buttonNextHTML: null,
	    buttonPrevHTML: null,
	    // Events
	    initCallback: function (carousel) {
	    	$('.s-slider-holder .prev').click(function () {
		        carousel.prev();
		        carousel.stopAuto();
		        return false;
		    });
		    $('.s-slider-holder .next').click(function () {
		        carousel.next();
		        carousel.stopAuto();
		        return false;
		    });
	    },
	    itemLastInCallback: function (carousel,li,pos,state) {
	    	if (!($(li).next('li').size())) {
				carousel.options.animation = 0;
				carousel.scroll(0);
				carousel.options.animation = 1000;
			} 
	    }
	});
});
