// JQuery Functions for YarnLady.com Website
// by BarefootChris.net. Copyright 2010

$(document).ready(function(){

	//Hide (Collapse) the toggle containers on load
	$(".submenu").hide(); 

	//Switch the "Open" and "Close" state per click
	//$("h2.main").toggle(function(){
		//$(this).addClass("active");
		//}, function () {
		//$(this).removeClass("active");
	//});

	//Slide up and down on click
	$("h2.main").click(function(){
		$(this).next(".submenu").slideToggle("slow").siblings(".submenu:visible").slideUp("slow");
		$(this).siblings("h2").removeClass("active");
		$(this).toggleClass("active");
	});
	

	

/* CONFIG */
		xOffset = 10;
		yOffset = 30;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	

$("#minicart").hover(function() { //Hover over event on list item
		$(this).find("#minicart_exp").show('300'); //Show the subnav
	} , function() { //on hover out...
		$(this).css({ 'border-bottom' : '2px solid black'}); //Ditch the background
		$(this).find("#minicart_exp").hide('300'); //Hide the subnav
	});


});
