$(document).ready(function(){
	defaultValues = new Array();
	var inputSelectors = 'input.search-normal'; //, #search-input-wide input';

	$(inputSelectors).each(function(i){
		defaultValues[i]=$(this).val();
		$(this).focus(function(){
			if(defaultValues[i] == $(this).val()) {
				$(this).val('');
				
			}			
		});
		$(this).blur(function(){
			if($(this).val()=='' || $(this).val()==undefined) {
				$(this).val(defaultValues[i]);
			}
		});	
	});
	$('#header-search-button').click(function(){
		var input = $('#header-search-input .search-normal');
		if( input.attr('title') != input.val() ) {
			$('#header-search-form').submit();
		}
	});
	$('.pick-a-category, #theme-selector select').change(function(){
		var url = 'http://www.rainbow.fi/?id='+$(this).val();
		setTimeout(function(){
			window.location.href = url;
		}, 0);
	});
	

	/* Theme slider */
	$('.pick-items li').mouseover(function(){
		var moveTo = ($(this).index()+1) * -230;
		$('.theme-slide-row').stop().animate({top: moveTo+'px'}, 200);
		$('.pick-items li').removeClass('current');
		$(this).addClass('current');
	});
	$('.theme-image').mouseleave(function(){
		var moveTo = 0;
		$('.theme-slide-row').stop().animate({top: moveTo+'px'}, 200);
		$('.pick-items li').removeClass('current');
	});

	/* cool-checkboxes */
	$('.cool-checkboxes input[type="radio"]').change(function(){
		$('.cool-checkboxes input[type="radio"]').next('label').removeClass('checked');
		$('.cool-checkboxes input[type="radio"]:checked').next('label').addClass('checked');
	});
	
	$('.cool-checkboxes input[type="radio"]').trigger('change');
	
	$('#submit-on-change').change(function(){
		window.location='http://www.rainbow.fi/?id=73696&s='+$(this).val();
	});
});
