$(document).ready(function () {
	$('#filter_keyword').keydown(function(e) {
		if (e.keyCode == 13) {
			moduleSearch();
		}
	});
	

	$('.showprice').click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		if($(this).hasClass('on'))
			return;
			
		$('.showprice').removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
			//ADD THE ON CLASS TO THE BUTTON
		$(this).addClass('on');
		  
		//calcprice($(this).attr("pwidth"), $(this).attr("pheight"));
		$('#width').val($(this).attr("pwidth"));
		$('#height').val($(this).attr("pheight"));
		$('#listprice').html($(this).attr("price"));
		$('#total').html('Price:'+$(this).attr("discountprice"));
		
	 });
	  
	
	/*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	//ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
	$('.showprice').mouseover(function() {
		$(this).addClass('over');
		
	//ON MOUSEOUT REMOVE THE OVER CLASS
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	
	$(".relatescroll").scrollable();
	$(".scrollable").scrollable({ next: '.navnext', prev: '.navprev' });
	$(".scrollable2").scrollable({ next: '.navnext2', prev: '.navprev2' });
	$(".scrollable3").scrollable({ next: '.navnext3', prev: '.navprev3' });
	/*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	
	/********************************************************************************************************************
	CLOSES ALL S ON PAGE LOAD
	********************************************************************************************************************/	
});

	function moduleSearch() {
		url = 'index.php?route=product/search';
		
		var filter_keyword = $('#filter_keyword').attr('value');
		
		if (filter_keyword) {
			url += '&keyword=' + encodeURIComponent(filter_keyword);
		}
		
		var filter_category_id = $('#filter_category_id').attr('value');
		
		if (filter_category_id) {
			url += '&category_id=' + filter_category_id;
		}
		
		location = $("base").attr("href")+url;
	}
	
   function convertTime(seconds) {
		var sec = seconds % 60;
		var val = Math.floor(seconds/60);
		var min = val % 60;
		var hour = Math.floor(val/60);
		return (hour < 10 ? "0" + hour : hour) + ':' + (min < 10 ? "0" + min : min) + ':' + (sec < 10 ? "0" + sec : sec);
   }
   function showRemainTime() {
		var seconds = $('#remain').val();
		seconds = seconds - 1;
		$('#remain').val(seconds);
		$('#remaintime').html(convertTime(seconds));
		if (seconds <= 0) {
			window.clearInterval(timeid);
		}
   }
   function switchSizes() {
		if ($('#switchSize').html() == 'Show More Sizes'){
			$('#switchSize').html('Show Less Sizes');
			$('.more').slideDown('normal');
		}
		else {
			$('#switchSize').html('Show More Sizes');
			$('.more').slideUp('normal');
		}
   }

