jQuery.noConflict();

jQuery(document).ready(function(){
	var widthIndexCatalogField = jQuery('#catalog_index_container').width();
	var innerIndexCatalogTable = jQuery('#catalog_index_container table');
    innerIndexCatalogTable.css('margin-left', 0);

    /*jQuery('body').append('<div id="overlay_rect"></div>');
    jQuery('#overlay_rect').css({position:'absolute', backgroundColor: '#000', opacity:'0.2', display: 'none', zIndex: 1});
    jQuery('#content_left').css({zIndex: 10});  */

	jQuery('#arrow_right').mousedown(function(){
		if (parseInt(innerIndexCatalogTable.css('margin-left')) > widthIndexCatalogField - innerIndexCatalogTable.width()){
			innerIndexCatalogTable.animate({marginLeft: parseInt(innerIndexCatalogTable.css('margin-left'))-200}, 500);
		}
		return false;
	});
	
	jQuery('#arrow_left').mousedown(function(){
		if (parseInt(innerIndexCatalogTable.css('margin-left')) < 0){
			innerIndexCatalogTable.animate({marginLeft: parseInt(innerIndexCatalogTable.css('margin-left'))+200}, 500);	
		}
		return false;
	});	
	
	jQuery('#clients input.text').click(function(){
		jQuery(this).val('');
	});	

	/*jQuery('#catalog_categories a.active').each(function(){
		jQuery(parseId(this.href)).addClass('active');		
	});*/
	
	var slideMaxHeight = 0;
	var slideMaxWidth = 0;
	
	jQuery('#slides .slide').each(function(){		
		if (jQuery(this).height() > slideMaxHeight){
			slideMaxHeight = jQuery(this).outerHeight();
		}
		jQuery(this).attr('margin', slideMaxWidth);
		slideMaxWidth += jQuery(this).outerWidth();
		jQuery(this).css({float: 'left', overflow: 'hidden', width: jQuery(this).outerWidth()});		
	});
	
	jQuery('#slides').css({overflow: 'hidden', height: slideMaxHeight+100});
	jQuery('#slides_wrapper').css({float: 'left', width: slideMaxWidth});

	jQuery('#catalog_categories a').click(function(){
		jQuery('#catalog_categories a.active').each(function(){
			jQuery(this).removeClass('active');				
		});
		jQuery('#slides_wrapper').animate({marginLeft: -jQuery(parseId(this.href)).attr('margin')}, 800);
		jQuery(this).addClass('active');
		return false;
	});

    /*jQuery('#catalog_index_container img').hover(function(){
        jQuery('#overlay_rect').width(jQuery(this).width());
        jQuery('#overlay_rect').height(jQuery(this).height());
        var offset = jQuery(this).offset();
        jQuery('#overlay_rect').css({top: offset.top, left: offset.left});
        jQuery('#overlay_rect').show();
    }); */
});

function parseId(id)
{
	var match = id.match(/#.*$/g);
	return match[0];
}
