// JavaScript Document

$(document).ready(function() {
	  // for the see price in cart there is another close button
 	$('#quickViewTop img').live("click", function() {
 		tb_remove();
 	});
 
// 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: 300, // number = milliseconds for onMouseOver polling interval    
				 over: menuHoverOver, // function = onMouseOver callback (REQUIRED)    
				 timeout: 200, // number = milliseconds delay before onMouseOut    
				 out: menuHoverOut // function = onMouseOut callback (REQUIRED)    
		};
		$("#menuBar li:has(div)").hoverIntent(config);
		// menu dropdown end

		if ($("#slider-range").length !== 0)	{
			$("#slider-range").slider({
				range: true,
				min: 0,
				max: 150,
				values: [1, 125],
				step: 5,
				change: function(event,ui) {
				 			$("#lnForm").ajaxSubmit(options);							
					},
				slide: function(event, ui) {
					$("#amount").val('$' + ui.values[0] + ' - $' + ui.values[1]);
				}
			});
			$("#amount").val('$' + $("#slider-range").slider("values", 0) + ' - $' + $("#slider-range").slider("values", 1));
		}
													 
		// for the daily deals arrow buttons when clicked
		// the previous arrow
		function scrollPrevClick(event){
			var prodContainer = $(this).parent().siblings("div:visible").children("div.allScrollingProdContainer");
			var that = $(this);
			
			var location = prodContainer.position().left;
			var newLocation = location + event.data.elementWidth;
			$(this).unbind('click');
			
			// we stop it from going to the previous one if there is no previous
			if (location < 0){
				prodContainer.stop('true', 'true').animate({left: newLocation}, 'slow', '', function(){
					that.bind('click', event.data, scrollPrevClick);
					});
			} else {
					that.bind('click', event.data, scrollPrevClick);
			}
			return false;
		}

$("input[type='text'][name!=kword][id!=email-addy][id!=footer-newsletter-box][id!=shipping_zip][id!=shipping_address2][id!=billing_zip][id!=billing_address2][id!=GCAMOUNT][id!=cart-zip][id!=qty-input], input[type='password']").css({'background':'url(/images/field_l.gif) 0 0px no-repeat','font-size': '12px','color': '#6C6C6C','width':'225px','z-index':'50','height':'29px','display':'block','float':'left','border':'0px','padding':'2px 5px 0px 2px'});

		$("#login").validate();
		$("#create_account").validate({
		rules: {
		    passwrd: {required: true,minlength: 6},
			confirm_password: {required: true,minlength: 6,equalTo: "#passwrd"}
		  },
		messages: {

			passwrd: {
				required: "<img src='/images/invalid.gif' alt='error' style='width: 13px; height: 7px; vertical-align: middle;' /> Please provide a password",
				minlength: jQuery.format(" <img src='/images/invalid.gif' alt='error' style='width: 13px; height: 7px; vertical-align: middle;' /> Password must be {0} characters or more")
			},
			confirm_password: {
				required: "<img src='/images/invalid.gif' alt='error' style='width: 13px; height: 7px; vertical-align: middle;' /> Repeat your password",
				minlength: jQuery.format("<img src='/images/invalid.gif' alt='error' style='width: 13px; height: 7px; vertical-align: middle;' /> Password must be {0} characters or more"),
				equalTo: "<img src='/images/invalid.gif' alt='error' style='width: 13px; height: 7px; vertical-align: middle;' /> Your passwords do not match!"
			}
		}
		});
});
