			$(document).ready(function(){

				// for the menu dropdown
				function menuHoverOver(){
						$(this).children("div:has(ul)").show(5);
				}
				
				function menuHoverOut(){
						$(this).children("div:has(ul)").hide(5);
				}
				var config = {    
						 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
						 interval: 100, // number = milliseconds for onMouseOver polling interval    
						 over: menuHoverOver, // function = onMouseOver callback (REQUIRED)    
						 timeout: 500, // number = milliseconds delay before onMouseOut    
						 out: menuHoverOut // function = onMouseOut callback (REQUIRED)    
				};
				$("#menuList li:has(div)").hoverIntent(config);
				// menu dropdown end
					
				$("#productsSwatchesHolder img").hover(
						function() {
							$("#currentSwatch").text($(this).attr("alt"));
						},
						function() {
							$("#currentSwatch").text("");
					});
					
				$("#productsSwatchesHolder img").click(function()
					{
						var idValue = $(this).attr('id');
						$("#selectedSwatch option[value='" + idValue + "']").attr("selected", "selected");
					}
					);
				

				$("#swatchLeft img").click(function()
					{
						$("#swatchRight img").attr("src", "/images/swatches/" + $(this).attr("id") + "_L.jpg");
						$("#swatchLeft p span").text($(this).attr("alt"));
						$(this).parent().siblings().children().removeClass("highlightImage");
						$(this).addClass("highlightImage");
					});
					
				$("#swatchForm").submit(function()
					{
						var selectElement = $("#swatchForm :input");
						if (selectElement[0].value == "") {
							alert("Please Select a " + $(this).attr("name"));
							return false;
						}
					}
				);
				
				// this is for the registry button on the little castle pages and all the pages with combined styles. 
				//what i am doing is changing the action of the form if they click add to registry.
				$("#swatchRegistry").click(function(){
					var $swatch = $("#swatchForm")
					$swatch.attr("action", $swatch.attr("action").replace("cart", "registry/AddToRegistry"));
				});
					
			function limitChars(textid, limit, infodiv)
			{
				var text = $('#'+textid).val();	
				var textlength = text.length;
				if(textlength > limit)
				{
					$('#' + infodiv).html('You have 0 characters left.');
					$('#'+textid).val(text.substr(0,limit));
					return false;
				}
				else
				{
					$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
					return true;
				}
			}
			
				$('#giftComments').keyup(function(){
					limitChars('giftComments', 100, 'charlimitinfo');
});

});
			
			// used for magic zoom so the alt image will be displayed in the magic zoom
			function changeZoomImage() {
			
			// Step 1
			// Stop Magic Zoom
			MagicZoom_stopZooms();
			
			
			// Step 2
			// Re-initialize Magic Zoom
			MagicZoom_findZooms();
			}

