$(document).ready(function(){
			// product grid click handler
			function setProductGridHandler(){
				$(".mList A").click(function(){
				
					var c = $.ajax({
						url: $(this).attr("href").replace('boots', 'closeup'),
						async: false
					}).responseText;
					$("#prodPopup").html(c);
					$("#prodPopup").css('z-index','9999');
					$("#prodPopup").fadeIn('fast');
					return false;
				});
			}
	
            function setEndorseeDetailsHandler(){
                $(".endorseeLink").click(function(){
                
                    var c = $.ajax({
                        url: $(this).attr("href"),
                        async: false
                    }).responseText;
                    $("#endorseePopup").html(c);
                    setProductGridHandler();
                    $("#endorseePopup").fadeIn('fast');
					setProductGridHandler();
                    return false;
                });
            }

			// search box 
			var searchTerm;
			$("#searchBox").click(function(){
				if ($(this).val() == 'Search Site') $(this).val('');
			});
	
			/*
$("#searchBtn").click(function(){
				searchTerm = $("#searchBox").val().toUpperCase();

				$.getJSON('/ajax/search&keyword='+searchTerm, function(data){
					if (data.resultCount == 1 && data.status == 2 ) {

						var html = $.get('/closeup/'+data.materialNbr,
						function(data) {
							$("#prodPopup").html(data);
							$("#prodPopup").fadeIn('fast')
							});	
							return false;							
					} 
					var html = data.html+'<br clear="all" /><br clear="all" /><br clear="all" /><br clear="all" />';
					$("#breadcrumbs").html('Search Results');
					$("#scrollpane").html(html);
					$("#scrollpane").jScrollPane({showArrows:true, scrollbarWidth:38});
		  			setProductGridHandler();
				});
				
				return false;
			});
*/
			// build the scrollpane
			$("#scrollpane").jScrollPane({showArrows:true, scrollbarWidth:38});
/*			if ($.jScrollPane.active.length > 0) {
				$("#scrollpane").append('<div id="scrolldown"><img src="/templates/nocona/images/icons/scrolldown.png" alt="Scroll down."></div>');
			}*/
			
			// start news ticker
		   /* $(function () {
		      $('#ticker marquee').marquee('pointer').mouseover(function () {
		            $(this).trigger('stop');
		        }).mouseout(function () {
		            $(this).trigger('start');
		        }).mousemove(function (event) {
		            if ($(this).data('drag') == true) {
		                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
		            }
		        }).mousedown(function (event) {
		            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
		        }).mouseup(function () {
		            $(this).data('drag', false);
		        });
   			});*/
			// position the product popup
			$("#prodPopup").css('left', $("#outer").position().left+65 );
			$("#prodPopup").css('top',32);
			
            // position the endorsees popup
            $("#endorseePopup").css('left', $("#outer").position().left+65 );
            $("#endorseePopup").css('top',32);
			
			// set hover for promo box
			$(".promo").hover(function()
				 {
					 $("#promoTop").attr('src',$("#promoTop").attr('src').replace("-off","-over"));
				 },
				 function()
				 {
				   	 $("#promoTop").attr('src',$("#promoTop").attr('src').replace("-over","-off"));
				 }
			);
			
			setProductGridHandler();
            setEndorseeDetailsHandler();
		});
