$(function(){
	$('#mainMenu').superfish({
		animation:   {height:'show'},
		autoArrows:    false
	});

	$('#slideshow')
		.before('<div id="controls">') 
		.cycle({
			fx: 'fade',
			delay: ss_delay,
			timeout: ss_timeout,
			speed: ss_speed,
			pager: '#controls'
	});
	
	
	$(window).hashchange( function() {checkHash();} );
	
	
	function checkHash() {
		var hash=location.hash;
		
		//Events page hash changes
		if (hash == '#uroborosEvents' || hash == '#industryEvents') {
			changeEventList(hash);
		}		

	}
	
	checkHash();

});


function changeEventList(hash) {
	if (hash == '#industryEvents') {
		$('#eventsLists #head1').css('display','none');
		$('#eventsLists #list1').css('display','none');
		$('#eventsLists #head2').css('display','block');
		$('#eventsLists #list2').css('display','block');
	} else {
		$('#eventsLists #head2').css('display','none');
		$('#eventsLists #list2').css('display','none');
		$('#eventsLists #head1').css('display','block');
		$('#eventsLists #list1').css('display','block');
	}
}



$(function() {
	$('a.read_more').colorbox({
		transition:"fade",
		speed:500,
		opacity:.35	,
		width:"600px",
		height:"500px",
//		initialWidth:"550px",
//		initialHeight:"430px"
		initialWidth:"40px",
		initialHeight:"50px",
		iframe:true
	});
	
	// create custom animation algorithm for jQuery called "bouncy"
	$.easing.bouncy = function (x, t, b, c, d) {
		var s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	}
	
	// create custom tooltip effect for jQuery Tooltip
	$.tools.tooltip.addEffect("bouncy",
	
		// opening animation
		function(done) {
			this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show();
		},
	
		// closing animation
		function(done) {
			this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  {
				$(this).hide();
				done.call();
			});
		}
	);
	
//	$('.thumb_item_product img[title]').tooltip({effect: 'bouncy'});
	$('.thumb_item_product img[title]').tooltip();	//no effect

});


function submitSearch() {
	var search_key = $("#search_key")[0].value;
	$.get("search.php",{'key':search_key}, 
		function(data){
			if (data == -1) {
				alert("We could not find a product for the code you entered.  Please try again.");
			} else {
				$("#search_results a").attr("href","product_detail.php?id="+data);
				$("#search_results a").click();
			}
		}
	);	
}

$(function() {
	$(".product_list_row").bind("mouseover", 
		function() {
			$(this).addClass("over");
		}
	);
	$(".product_list_row").bind("mouseout", 
		function() {
			$(this).removeClass("over");
		}
	);

	$('a.product_list_row').colorbox({
		transition:"elastic",
		speed:500,
		opacity:.35	,
		width:"554px",
		height:"660px",
		initialWidth:"40px",
		initialHeight:"50px",
		iframe:true
	});
	
	$('a.product_thumb').colorbox({
		transition:"elastic",
		speed:500,
		opacity:.35	,
		width:"554px",
		height:"660px",
		initialWidth:"40px",
		initialHeight:"50px",
		iframe:true
	});
		
	/* Artist Gallery Popups */
	$('#art_gallery a[rel="gallery"]').colorbox({
		transition:"elastic",
		speed:500,
		opacity:.65,
		height:"760px",
		width:"835px",
		iframe:true
	});
		
	/* About vid Popups */
	$('#aboutVideos a').colorbox({
		transition:"elastic",
		speed:500,
		opacity:.65,
		height:"500px",
		width:"502px",
		iframe:true
	});
		
	/* Event detail Popups */
	$('.eventList a').colorbox({
		transition:"elastic",
		speed:500,
		opacity:.65,
		height:"500px",
		width:"680px",
		iframe:true
	});
		



});


	/* Retail map */
	function setMapOver(index) {
		$("#retailerMapOverlay").removeClass();
		$("#retailerMapOverlay").addClass('over_'+index);
	}
	function setMapActive(index) {
		$("#retailerMap").removeClass();
		$("#retailerMapOverlay").removeClass();
		$("#retailerMap").addClass('active_'+index);
		
		$(".retailerCollection").css('display','none');
		$("#region_"+index).css('display','block');

		$(".retailerResultDisplay h1").css('display','block');
		$(".retailerResultDisplay h1 span").html($("#region_"+index).attr('title'));

//		$(".retailerResultDisplay h1").focus();
	}
	function restoreMapActive(index) {
		$("#retailerMapOverlay").removeClass();
	}


