jQuery(document).ready(function(){
	jQuery('.page_item').each(function(i, v){
		
		var el = jQuery(v);
		var children = el.children('ul');
		if (children.size()) {
			//console.log(el);//background:;
			el.css('background','transparent url(/wp-content/themes/eco/images/arrow-down.gif) no-repeat scroll right 7px');
			el.mouseover(function(){
				children.show();
			})
			.mouseout(function(){
				children.hide();
			})
			;
		}
	});
	
	jQuery('#allproducts').tabs();
	
	//if (jQuery('.page_item').children('ul').size()
	Prod.init();
});

Prod = {};
Prod.current=1;
Prod.init = function() {
	jQuery('.listing .page a').click(function(){
		Prod.showPage(jQuery(this));
		return false;
	});
	
	jQuery('.prev a').click(function(){
		if(Prod.current==1) {
			return false;
		}
		
		if(Prod.current<=9) {
			var page = Prod.current-1;
			Prod.showPage(null,page);
			return false;
		}
	});
	
	jQuery('.next a').click(function(){
		if(Prod.current==9) {
			return false;
		}
		
		if(Prod.current<9) {
			var page = Prod.current+1;
			Prod.showPage(null,page);
			return false;
		}
	});
	
};

Prod.showPage = function(elem,pid) {

	if(pid) {
		id = pid;
		elem = jQuery('#l-'+id);
	} else {
		id = elem.attr('id').split('-')[1];
	}
	
	if(jQuery('#p-'+id).attr('id')) {
		
		jQuery('.rightblock').hide();
		jQuery('.page a').removeClass('current');
		
		jQuery('#p-'+id).show();
		elem.addClass('current');
		Prod.current = id;
	}
	
}




