// lounge slider
$j(document).ready(function() {
	
		 // rotator slider
		 $j('.rotator').eq(0).addClass('rot-first');			 
		 $j('.rotator-btn').bind('mouseup',function() {			 
			 switch_what = $j(this).index()-1;
			 switchTo();				 
			 clearInterval(switch_iv);
			 if(switch_to) {
				clearTimeout(switch_to);											
			 }
			 switch_to = setTimeout(function() { startSwitch(switch_what); },2000);
				 
		});
			 
		 var switch_what = 0;
		 var switch_iv;	
		 var switch_to;	
		 
		 function startSwitch() {
			switch_iv = setInterval(function() { switchTo(); },4000)
		 }
			 
		 function switchTo() {
								
			var rot =  $j('.rotator');
			if(rot.length == 1) return;	
			$j('.rot-on').fadeOut('fast',function() { 
				$j('.rotator').eq(switch_what).fadeIn('fast',function() { $j('.rot-on').removeClass('rot-on'); $j(this).addClass('rot-on')});
				$j('.rotator-btn').removeClass('rotbtn-on');
				$j('.rotator-btn').eq(switch_what).addClass('rotbtn-on');
			});	

			switch_what++;	
			if(switch_what == (rot.length)) {
				switch_what = 0;
			}
		 }
			
		 startSwitch();
});

function vendorSearch() {
	if($j('#vendor').val() == '' || $j('#state').val() == '') {
		alert('Please select a category and a state');
		return false;
	}
	
	document.location.href = '/vendors/' + $j('#vendor').val() + '?state=' + $j('#state').val();
}
