$(document).ready(function() {


//--slaider on main page--------
$('#slider_main').cycle({
				speed:1000,
				before: hideTitle,
				after: showTitle,
				timeout:5000,
				cleartypeNoBg:true,
				pager:'#slider_nav', 
				pagerAnchorBuilder: function(idx, slide) { 					
					return '#slider_nav li:eq(' + idx + ') a'; 
				},
				pauseOnPagerHover: true,
				fx: 'scrollRight' 
			});
			
			function hideTitle () {
			$('div.slide div.content h1').hide();	
			$('.slider_nav_bg').hide();	
			}
			function showTitle () {	
			$('.slider_nav_bg').show();	
			$(this).find('h1').fadeIn("slow");
			}
//--END slaider on main page--------

		$('.top_menu').corner();
		$('#cartlink').corner();
		$('.slider_cntr').corner();
		$('.round_input').corner("round 4px");
		$('.slider_nav_bg').corner( "top");
		
		$('#small_pic img').click(function () {
			$('#view').attr("src",($(this).attr("rel")));
			});
			
	$('#login').hover(function () {
		$('a.cab').toggleClass("active");
        $('.login').toggle();
    });
	$('#fast').hover(function () {
		$('a.fast').toggleClass("active");
        $('.fast_container').toggle();

    });
	$('.printit').click(function () {
		$(this).parent().printElement();
    });

	$('.bottom_menu li ul li:last').addClass('last');
	$('.bottom_menu li').has('ul').hover(function () {
		$(this).toggleClass("active");
        $(this).find('ul').toggle();

    });
	$('.left_menu li').find('ul').has('a.current').toggle().parent('li').find('span:first').addClass('minus');
	$('a.current').prev().addClass('minus').parent().find('ul:first').show();
	$('.left_menu li span').click(function () {
		$(this).parent().find('ul:first').toggle();
		$(this).parent().has('ul').find('.expand:first');
		$(this).toggleClass('minus');	
		return false;
    });
	
	//$('.dillers_container:first').addClass('active_container').find('.dillers').slideToggle('slow');
	$('.dillers_container .arrow_').click(function () {
		if ($(this).parent().is('.active_container')) {
			$(this).parent().removeClass('active_container').find('.dillers').slideUp('slow')
		}
		else
		if (!$(this).parent().is('.active_container')){
		$('.active_container').removeClass('active_container').find('.dillers').slideToggle('slow');
		$(this).parent().addClass('active_container').find('.dillers').slideToggle('slow');
		}
		return false;
		});
		$('.dillers_container .title').click(function () {
		if ($(this).parent().is('.active_container')) {
			$(this).parent().removeClass('active_container').find('.dillers').slideUp('slow')
		}
		else
		if (!$(this).parent().is('.active_container')){
		$('.active_container').removeClass('active_container').find('.dillers').slideToggle('slow');
		$(this).parent().addClass('active_container').find('.dillers').slideToggle('slow');
		}
		return false;
		});
	$('.exp_all').click(function () {
		$('.exp_all').hide();
		$('.fold_all').css('display', 'block');;		
		$('.dillers_container').addClass('active_container')
		$('.dillers_container .dillers').slideDown('slow').addClass('active')
		$('.dillers div').slideDown('slow').addClass('active');
		return false;
		});
	$('.fold_all').click(function () {
		$('.fold_all').hide();
		$('.exp_all').show();
		$('.dillers_container').removeClass('active_container')
		$('.dillers_container .dillers').slideUp('slow').removeClass('active')
		$('.dillers div').slideUp('slow').removeClass('active');
		return false;
		});
	$('.dillers span').click(function () {
	if (!$(this).parent().is('.active')) {
		$('.dillers .active div').slideUp('slow', function(){
			$(this).parent().removeClass('active');
		});
		
		$(this).next().slideDown('slow', function(){
			$(this).parent().addClass('active');
		});
	}
	else
	$(this).next().slideUp('slow', function(){
			$(this).parent().removeClass('active');
		});
  		return false;
    });
	$('.dillers .arrow').click(function () {
	if (!$(this).parent().is('.active')) {
		$('.dillers .active div').slideUp('slow', function(){
			$(this).parent().removeClass('active');
		});
		
		$(this).next().next().slideDown('slow', function(){
			$(this).parent().addClass('active');
		});
	}
	else
	$(this).next().next().slideUp('slow', function(){
			$(this).parent().removeClass('active');
		});
  		return false;
    });
	
	$('.sap .arrow').click(function () {
	$(this).parent().toggleClass('active');
	$(this).next().slideToggle('slow');
  	return false;
    });
	
	$(function() {
		var originalSizes = new Array();
		$('#pane1').jScrollPane({showArrows: true});
		$('.jspContainer').corner();
		$('.jspDrag').corner();
		$('.filter').corner();
	});
	$('#parent_section_id').change(function(){
		var select = $('#section_id');
		select.find('option:not(:first-child)').remove();
		if(this.value){
			select.append(arCategorySystems[this.value]);
			// for (var i=0; i < arCategorySystems[this.value].length;i++){
				// select[0].options[ select[0].options.length ] = arCategorySystems[this.value][i];
			// }
		}
	});
	
	
	$('#cat_filter_form').submit(function(){
		var $txt = $(this).find('input[type="text"]');
		var $hdn = $(this).find('input[type="hidden"]');
		var params = "";
		var $select1 = $('#parent_section_id');
		var $select2 = $('#section_id');
		
		$txt.each(function(){
			params += (params.length ? "&" : "") + this.name + "=" + (this.value==this.title?"":this.value);
		});
		if($select2.attr("value")){
			params += (params.length ? "&" : "") + $select2.attr("name") + "=" + $select2.attr("value");
		}else{
			params += (params.length ? "&" : "") + $select1.attr("name") + "=" + $select1.attr("value");
		}
		$hdn.each(function(){
			params += (params.length ? "&" : "") + this.name + "=" + this.value;
		});
		window.location = this.action+"?"+params;
		return false;
	});	
	
	

		
	
});

