$(function(){
	$(".mediumHover img").hover(function(){
		$("#preview img").attr("src",$(this).attr("src").split("/small/").join("/medium/"));
	});
});

$(function(){
	$(".largeClick img").click(function(){
		$("#preview2 a").attr("href",$(this).attr("src").split("/small/").join("/large/"));
		$("#preview2 img").attr("src",$(this).attr("src").split("/small/").join("/large/"));
		$("#preview2 p").html($(this).attr("alt"));
		return false;
	});
});

function slideSwitch(){
	var $active=$(".slideshow IMG.active");
	if($active.length==0){$active=$(".slideshow IMG:last");}
	var $next=$active.next().length?$active.next():$(".slideshow IMG:first");
	$active.addClass("last-active");
	$next.css({opacity:0}).addClass("active").animate({opacity:1},1000,function(){$active.removeClass("active last-active");});
}

$(function(){
	setInterval("slideSwitch()",5000);
});

if(jQuery().tabs) {
	//jQuery UI loaded and ready
	$(function(){  
		$('#tabs > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
	});
	$(function(){  
		$('#tabsbox > ul').tabs().tabs('rotate', 4000, false); 
	});
}

$(function(){
	$("#buynowForm form #submit").click(function(){var categoryName=$("#category").attr("value");
		var productName=$("#product").attr("value");
		var productType=$("#productType").attr("value");
		var dataString="category="+categoryName+"&product="+productName+"&productType="+productType+"&source=ajax";
		$.ajax({type:"POST",url:"/buynow.php",data:dataString,success:function(response){$("#buynowForm form").fadeOut("fast");
			$("#buynowForm").html("<div id='message'></div>");
			$("#message").fadeIn("normal",function(){
				$("#message").append("<p>"+productType+" selected - <a href='/buynow.php?category="+escape(categoryName)+"&product="+escape(productName)+"'>modify</a></p>");
			$("#message").append(response);
			});
		}});
		return false;
	});
});