jQuery(function($){
	
	$('.gform_wrapper .ginput_container input, .gform_wrapper .ginput_container textarea').each(function() {
		$(this).attr('title', $(this).attr('value'));
	});
	
	$('.blink, .gform_wrapper .medium').focus(function(){
		if ( $(this).attr('value') == $(this).attr('title') ) {
			$(this).attr({ 'value': '' })
		}
	}).blur(function(){
		if ( $(this).attr('value') == '' ) {
			$(this).attr({ 'value': $(this).attr('title') })
		}
	});
	
	function change_slide(top, idx) {
		if($('.slider .slides-inner:animated').length == 0) {
			$('.slider .slides-inner').animate({'top': top + 'px'}, 500);
			$('.slider .navigation a.active').removeClass('active');
			$('.slider .navigation a:eq(' + idx + ')').addClass('active');
		}
	}
	
	var slider_total = $('.slider .slides img').length;
	var slider_h = $('.slides').height();
	
	$('.slider .controls a').click(function() {
		var top = parseInt($('.slider .slides-inner').css('top'));
		var idx = $('.slider .navigation a').index($('.slider .navigation a.active'));
		if(isNaN(top)) {
			top = 0;
		}
		if($(this).hasClass('prev')) {
			if (top == 0) {
				top = (slider_total-1)*slider_h*-1;
				idx = slider_total - 1;
			} else {
				top += slider_h;
				idx -= 1;
			}
		} else if($(this).hasClass('next')) {
			if (top == (slider_total-1)*slider_h*-1) {
				top = 0;
				idx = 0;
			} else {
				top -= slider_h;
				idx += 1;
			}
		}

		change_slide(top, idx);
		return false;
	});
	
	$('.slider .navigation a').click(function() {
		var idx = $('.slider .navigation a').index($(this));
		var current = $('.slider .navigation a').index($('.slider .navigation a.active'));
		var top = parseInt($('.slider .slides-inner').css('top'));
		if (current != idx) {
			top = idx * slider_h * -1;
		}
		change_slide(top, idx);
		return false;
	});
	
});
