
var cityFm = {
	
	slider : null,
	sliderClick : false,
	
	init : function()
	{
		this.initImageSlider();
		this.regSlidesPauseResume();
		
		this.initAvatarSlider('#evenimente');
		this.initAvatarSlider('#artisti');
	},
	
	initImageSlider : function()
	{
		this.regImageSliderClick();
		
		var that = this;
		
		this.slider = $('#slides').cycle({
			timeout:5000,
			speed:500,
			before:that.onBefore,
			after:that.onAfter

		});		
	},
	
	regSlidesPauseResume : function()
	{
		
		var that = this;
		
		$('#slides, #slide-desc').mouseenter(function(){
		
			that.slider.cycle('pause');
			
		});
		
		$('#slides, #slide-desc').mouseleave(function(){
		
			that.slider.cycle('resume');
			
		});
		
		
	},
	
	onBefore : function()
	{
		if ( $('#slide-desc').css('display') == 'none' ) { return false; }
		$('#slide-desc').effect('slide', { direction: 'down', mode:'hide'}, 500);
	},
	
	onAfter : function()
	{		
		if (cityFm.sliderClick === true) { cityFm.sliderClick = false; return false; }
		
		var liSel = $('#image-slider li.selected');
		var rel = 0;
		
		if (liSel.length == 0)
		{
			$('#image-slider li:first').addClass("selected");	
		}
		else
		{
			liSel.removeClass('selected');		
			var liNext = liSel.next();
			if (liNext.length > 0)
			{
				liNext.addClass('selected')
				rel = $('a', liNext).attr('rel');
			}
			else
			{
				$('#image-slider li.first').addClass('selected');
			}					
		}
		
		// Slider description
		
		$('#slide-desc > div').hide();
		$('#slide-desc > div[rel=' + rel +']').show();

		$('#slide-desc').effect('slide', { direction: 'down', mode:'show'}, 500);
		
	},
	
	regImageSliderClick : function()
	{
		var that = this;

		$('#image-slider li a').click(function(){
			
			that.sliderClick = true;
			
			var t = $(this);
			var imageIndex = parseInt(t.attr('rel'));
			that.slider.cycle(imageIndex);
			
			$('#image-slider li').removeClass('selected');
			
			t.parent('li').addClass('selected');
			
			// Slider description
			$('#slide-desc > div').hide();
			$('#slide-desc > div[rel=' + imageIndex +']').show();
			
			$('#slide-desc').effect('slide', { direction: 'down', mode:'show'}, 500);
			
			return false; //avoid event bubbling up
			
		});
		
	},
	
	initAvatarSlider : function(container)
	{
		
		var li = $(container + ' .avatar-slider > li');
		var infoBox = $(container + ' .info');
		
		
		li.hover(function(){
		
			var t = $(this);
			
			li.removeClass('selected');
			t.addClass('selected');
			
			var anchor = $('a', t);
			infoBox.html(anchor.attr('title'));
						
			return false; // avoid event bubbling up
			
		});
		
		
		
	}
	
}
$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("selected");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("selected");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append("&raquo; ");

});

$(document).ready(function() {

	
	$("a.thumb").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
	
});
 
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/
 
function slideSwitch() {
    var $active = $('.eveniment_slide DIV.active');
    if ( $active.length == 0 ) $active = $('.eveniment_slide DIV:last');
 
    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.eveniment_slide DIV:first');
 
    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
 
 
    $active.addClass('last-active');
 
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

