jQuery.noConflict();

/*
 * General DOM ready statemenets
 * 
 */
jQuery(function($) {
	
	//IE6
	if (($.browser.msie) && ($.browser.version <= 6)) {
		$('.thumb').find('a').hover(
			function(){
				$(this).attr('id','over');
			}
			,
			function(){
				$(this).attr('id','');
			}
		);
	}
	
	//Nav effects
	$('#nav li').each(function(){
		var $navHover = $(this).children('.nav-hover');
		if (!$(this).is('.active')) {
			$(this)
				.mouseenter(				
					function(){
						if(!$navHover.is(':animated')){
							$navHover.fadeIn();
						}
					})
				.mouseleave(
					function(){
						$navHover.fadeOut();
					});
		}
	});
	
	
	
	//Cycle
	if (document.getElementById('home')) {	
		$('#column1 .csc-textpic-imagewrap')
		.cycle({ 
			random: 1,
			timeout: 6000
		});
		$('#column2 .csc-textpic-imagewrap')
		.cycle({ 
			delay: 2000,
			timeout: 6000,
			random: 1
		});
		$('#column3 .csc-textpic-imagewrap')
		.cycle({
		    delay: 4000,
		    timeout: 6000,
		    random: 1
		});
	}
	
	//Arhivă
	$('#archive').insertAfter('#main');
	
	//Colectii switch images
	var $side = $('#side');
	$('#colectie').find('.csc-textpic-imagewrap')
		.click(function(event){
			if ($(event.target).is('.img-overlay')) {
				var $newImg = $(event.target).siblings('img').clone();
				$side.empty().append($newImg);
			} 				
		})		
	.end()	
	.find('img')
		.mouseenter(function(){
			if ($(this).is('img')) {
				var $overlay = $('<div class="img-overlay" />').insertAfter($(this));
				$overlay.mouseleave(function(){
					$overlay.remove();
				});
			}
		})		
	.filter(':first').mouseenter().siblings('.img-overlay').click().mouseleave();
	
	//Galerii
	$('#galerie dt').parent().parent().css({
		'height': 113,
		'margin-bottom': 0
	});
	
	$('#galerie .csc-textpic-imagewrap').each(function(){
		$(this)
			.attr('rel','group')
			.attr('href',$(this).find('img')[0].src)
			.attr('title',$(this).find('.csc-textpic-caption').text());
		
	}).fancybox({
		cyclic : true,
		type : 'image'
	});
	
	
	//Showroom
	if (document.getElementById('showroom')){
		var $titles = $('#main h1');
		var $side = $('#side');
		var $extra = $('#extra');
		
		$titles.click(function(){
			$titles.removeClass('active').filter($(this)).addClass('active');
			
			var $wrap = $(this).parent().parent();
			var $images = $('img', $wrap).clone();
			var $text = $('.csc-textpic-text', $wrap).clone();
			
			$side.empty().append($images).find('img').each(function(){ $(this).wrap('<div />'); });
			$extra.empty().append($text);
			
			//Applying events
			$('#showroom #side img').each(function(){
				$(this)
					.attr('rel','group')
					.attr('href',this.src);
			}).fancybox({
				cyclic : true,
				type : 'image'
			});			
			
		}).filter(':first').click();
	}
	
		
	//Scrollbars
	$('.news-list-container, #colectii #main, #colectie .csc-textpic-text, #galerie #main, #noutati #main-content')
		.jScrollPane({
			showArrows: true
		});

});





