/*************
Stock Message Color
**********/
jQuery(document).ready(function(){
     jQuery('.stockMsg').each(function() {
        if (this.innerHTML == "Out of Stock")
        {
	jQuery(this).addClass('stockOut');
        }
     });
});

/*
 * this is to expand out the menus on the left hand nav
 * c. lee 5/4/2011
 */ 
jQuery(document).ready(function(){
	jQuery(".expand-menu").click(function(){
		//jQuery(this).prev(".collapse").slideToggle(600);
		jQuery(this).prev(".collapse").toggleClass('expanded', "slow");
		//write code to toggle the text. 
		jQuery(this).children(":first").text(jQuery(this).children(":first").text() == 'View All \u25BC' ? 'View Less \u25B2' : 'View All \u25BC'); 
	});
});

/*
 * This script changes the Item Detail page.
 * Adds alternating color to every other row of Additional Product Description div with the id "Item_More_Info".
 */
if(typeof jQuery === 'undefined'){}
else{jQuery(document).ready(function(){
	if (document.getElementById("Item_More_Info") != null){
		jQuery("#Item_More_Info ul li:even").addClass("alternate");
	}
});} 

/*
 * Image preview script  *
 * clee 5/11/11 */

  
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 50;
		yOffset = -375;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
		
	/* END CONFIG */
	
	jQuery("a.preview").hover(function(e){	
	
		this.t = this.title;
		//this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		jQuery("body").append("<p id='preview'><img src='"+ this.id +"' alt='Image preview' /></p>");								 
		jQuery("#preview")
			//.css("top",(e.pageY - xOffset) + "px")
			.css("bottom", "0px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#preview").remove();
    });	
	jQuery("a.preview").mousemove(function(e){
		jQuery("#preview")
			//.css("top",(e.pageY - xOffset) + "px")
			.css("bottom", "0px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
jQuery(document).ready(function(){
	jQuery("a.preview").each(function () {
	    if(jQuery(this).find("img").length) {
			var src = jQuery(this).find("img").attr('src').replace('170x214', '343x432');
			jQuery(this).attr('id', src);
			var title = jQuery(this).find("img").attr('alt');
			jQuery(this).attr('title', title);
		}
	});
	imagePreview();
});
