// JavaScript Document

$(document).ready(function() {
						   
	$('div#home div#news div#sources').cycle({	
		fx:     'fade',
		speed:  'fast',
		before: setNewsTab
	});
	
	
	$("div#home div#news ul#tabs li#m-theory-news").click( function() {
    	$('div#home div#news div#sources').cycle(0);
		$('div#home div#news div#sources').cycle('pause');
	});
	$("div#home div#news ul#tabs li#in-store-events").click( function() {
    	$('div#home div#news div#sources').cycle(1);
		$('div#home div#news div#sources').cycle('pause');
	});
	$("div#home div#news ul#tabs li#hi-speed-soul-news").click( function() {
    	$('div#home div#news div#sources').cycle(2);
		$('div#home div#news div#sources').cycle('pause');
	});
	
	$("div#home div#news").mouseover( function() {
		$('div#home div#news div#sources').cycle('pause');
	});
	
	$("div#home div#news").mouseout( function() {
		$('div#home div#news div#sources').cycle('resume');
	});
	
	function setNewsTab() {
		var showing = this.id;
		if (showing == "m-theory-news") {
			$("div#home div#news ul#tabs li#m-theory-news").addClass("active");
			$("div#home div#news ul#tabs li#in-store-events").removeClass("active");
			$("div#home div#news ul#tabs li#hi-speed-soul-news").removeClass("active");
		}
		else if (showing == "in-store-events") {
			$("div#home div#news ul#tabs li#m-theory-news").removeClass("active");
			$("div#home div#news ul#tabs li#in-store-events").addClass("active");
			$("div#home div#news ul#tabs li#hi-speed-soul-news").removeClass("active");
		}
		else if (showing == "hi-speed-soul-news") {
			$("div#home div#news ul#tabs li#m-theory-news").removeClass("active");
			$("div#home div#news ul#tabs li#in-store-events").removeClass("active");
			$("div#home div#news ul#tabs li#hi-speed-soul-news").addClass("active");
		}
	};
	
	$('div#home div#products div#featuredItems').cycle({
		fx:     'scrollHorz',
		speed:  'fast',
		timeout: 6000,
		next:   'a#next',
		prev:   'a#prev'
	});
	
	$('div#latestProducts a.item').hover(function() {
		var category = $(this).html();
		if (category == "( Vinyl )") {
			$(this).parent().addClass('vinyl');	
		} else if (category == "( CDs )") {
			$(this).parent().addClass('cd');	
		}
		//alert(category);										   
	});
	
	$('#header form#search input#search').focus(function() {
		if (this.value=='{ Search the Store }'){this.value = ''}
	});
	$('#header form#search input#search').blur(function() {
		if (this.value==''){this.value = '{ Search the Store }'}
	});
	
	//focus="if (this.value=='{ Search the Store }'){this.value = ''}"  onblur="if (this.value==''){this.value = '{ Search the Store }'}"
	
});
