        function PriceFilter(form){
            var preChar;
            var PriceMin;
            var PriceMax;
            var URLparam;
            
        //Shorten variable in order to have a clear code
            PriceMin = form.PriceMin.value;
            PriceMax = form.PriceMax.value;
            
        //Replace comma by point (for some cities like France ;))
            PriceMin = PriceMin.replace(",", ".");
            PriceMax = PriceMax.replace(",", ".");

        //The default value of the input is "Price Min." or "Price Max.", if the default values are still there then the variable will be empty
            PriceMin = (PriceMin == "<?php echo Mage::helper('catalog')->__('£') ?>") ? "" : PriceMin;
            PriceMax = (PriceMax == "<?php echo Mage::helper('catalog')->__('£') ?>") ? "" : PriceMax;

        //if one of the two field is filled then...
            if((PriceMin) || (PriceMax)) {
                //if the one of them is not filled we fill them manually
                //if there is only the Price Max which is filled the Price Min is 0 
                //if there is only the Price Min which is filled the Price Max is 1000000 (changeable below) 
                PriceMin = !(PriceMin) ? 0 : PriceMin;
                PriceMax = !(PriceMax) ? 1000000 : PriceMax; //can be changed
                
                //Verify is there are numbers. Yes, I think we could do this verification before. But here is good for me.
                if(!isNaN(PriceMin) && !isNaN(PriceMax)){
                    //We look if the URL contains parameter (color, manufacturer...), if Yes we give preChar "&", if No "?" 
                    URLparam = location.href.indexOf("?");
                    preChar = (URLparam>0) ? "&" : "?";
                    location.href += preChar + "price=" + (PriceMax/(PriceMax - PriceMin)) + "," + (PriceMax - PriceMin);
                }
            }
        }
        
        
        function hideBubble() {
        	jQuery('#messages').css("display","none");
        	jQuery('#messages_product_view').css("display","none");
        }
        
        function displayBubble() {
        	jQuery('#messages_product_view').css("display","block");
        }
        
        function hideBubbleTimeout() {
        	setTimeout(function() {
        		hideBubble();
        	}, 8000);
        }
         
        function initPriceSlider() {
        	 $slider = jQuery("#price_slider");//Caching slider object
             $amount_min = jQuery("input.amount_min");//Caching amount object
             $amount_max = jQuery("input.amount_max");//Caching amount object
             $slider.slider({
                 range: true, // necessary for creating a range slider
                 min: 0, // minimum range of slider
                 max: 1500, //maximimum range of slider
                 values: [0, 1500], //initial range of slider
                 slide: function(event, ui) { // This event is triggered on every mouse move during slide.
                     $amount_min.val(ui.values[0]);//set value of  amount span to current slider values
                     $amount_max.val(ui.values[1]);//set value of  amount span to current slider values
                 }
             });
             $amount_min.val($slider.slider("values", 0));
             $amount_max.val($slider.slider("values", 1));
         }
        
         jQuery(function() { //jquery view.phtml tab functionality
        	 var cookie = jQuery( "#tabs" ).tabs( "option", "cookie" );
        	 jQuery( "#tabs" ).tabs({ cookie: { expires: 30 } });
         });
         

         jQuery(function() {
        	 jQuery(".pCarouselWrapper").jCarouselLite({
        		 btnNext: ".pCarouselNext",
        		 btnPrev: ".pCarouselPrev",
        		 visible: 5
        	 });
         });
         
          
     	function ajaxloader(link) {
     		var enabledisable = 0;
     		if(enabledisable == 0) {
     			window.location = link;
     		} else {
	        	jQuery('div.ajax-loader-main').css("display","block");
	        	jQuery('div.col-main').css({'opacity' : '0.2', 'filter' : 'alpha(opacity=20)'});
	        	jQuery('div.block-layered-nav').css({'opacity' : '0.2', 'filter' : 'alpha(opacity=20)'});
	    		var temp = jQuery.get(link, function(data) {
	    			var start = data.indexOf('<!-- AJAX START -->');
	    			var end = data.indexOf('<!-- AJAX END -->');
	    			var update = data.substring(start,end);	
	    			var startmenu = data.indexOf('<!-- start MENUAJAX -->');
	    			var endmenu = data.indexOf('<!-- end MENUAJAX -->');
	    			var updatemenu = data.substring(startmenu,endmenu);
	    			jQuery('div.col-main').html(update);
	    			jQuery('div.block-layered-nav').html(updatemenu);
	    			jQuery('#slider-wrapper').remove();
	    			jQuery('div.ajax-loader-main').css("display","none");
	            	jQuery('div.col-main').css({'opacity' : '1', 'filter' : 'alpha(opacity=100)'});
	            	jQuery('div.block-layered-nav').css({'opacity' : '1', 'filter' : 'alpha(opacity=100)'});
	            	initPriceSlider();
	            	amshopby_start();
	            	Custom.init();
	            	parent.location.hash = link;
	    		});
     		}
    	}
     	
     	function getProductCount() {
     		var productAmount = jQuery('#productNumber').attr('title');
     		return productAmount;
     	}
     	
     	//Event.observe(window, 'load', function() {
     	//	var params = location.hash.replace(/^#/, '?');
     	//	var link = location.protocol + location.host + location.pathname + params;
     	    //ajaxloader(location.protocol + location.host + location.pathname + params);
     	//    console.log(link);
     	//});
     	
     	function pageInit() {
         	jQuery('.text-more').click(function() {
         		//jQuery('.more-content').slideToggle('fast', function() { });
         		//jQuery('.more-content').css('display','block');
         		jQuery(".more-content").toggle();  
         	});
        	initPriceSlider();
        	Custom.init();
        	if(getProductCount() >= 8 && getProductCount() <= 200) {
        		//jQuery('.featured_container').slideDown('slow', function() { } ); /* Not working in IE7 */
        		jQuery('.featured_container').css('display','block');
        	}
        	if(!getProductCount() && !jQuery('.cms-home')) {
        		jQuery('.text_wrapper').css('display','none');
        	}
            jQuery('.toolbar-bottom a').click(function() {
            	jQuery('html, body').animate({scrollTop:0}, 'slow');
            });
     	}
     	
        jQuery(document).ready(function() {
        	pageInit();
        });
