jQuery(document).ready(function() {		
	// Cart Popout
	jQuery(".mycart").click(function() {
		jQuery(".mycart-block").slideToggle('medium');
	});
	
	// Featured Products
    jQuery('#featured').jcarousel();

	// Slider Homepage
	jQuery('#slider').cycle({
        fx: 'fade',
        speed: 2000,
		timeout: 5000,
        pager: '#controls',
		slideExpr: '.panel'
    });
 	// Custom Menu
	jQuery(".category").click(function() {
		// var open = jQuery(".category").attr("rel");
		var open = this.getAttributeNode('rel').value;
		jQuery(".subcategory_" + open).slideToggle(500);
	});
    
    // Camera Filters
    //jQuery(".filter-by").hide();    
	jQuery(".show-filters").click(function() {
        var $this = jQuery(this);
        if($this.is(".active")){
            jQuery(".filter-by").slideUp(200);
            jQuery(this).html("Filter By <span>(Click to show filter options)</span><em></em>").toggleClass('active');
        }
        else{
            jQuery(".filter-by").slideDown(200);
            jQuery(this).html("Filter By <span>(Click to hide filter options)</span><em></em>").toggleClass('active');            
        }
        
	});
    
    // Custom Select Inputs
    jQuery('.customSelectBox').customStyle();
    jQuery('.optionSelect select').customStyle();
    
});

(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).change(function(){
				// selectBoxSpanInner.text($(this).val()).parent().addClass('changed');   This was not ideal
    			selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
				// Thanks to Juarez Filho & PaddyMurphy
			});
			
	  });
	  }
	}
 });
})(jQuery);
