
var parfumMarket = {
	
	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').mouseenter(function(){
		
			that.slider.cycle('pause');
			
		});
		
		$('#slides').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 (parfumMarket.sliderClick === true) { parfumMarket.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; ");

});

// REGISTER FORM
/*jQuery(document).ready(function() {
  jQuery('#show_livrare').click(function() {
										 
   if (this.checked) {
	 //po.sameform();  
    this.checked=jQuery('#livrare').removeClass('hidden');
   } else {
      jQuery('#livrare').addClass('hidden');
     }
  });
  jQuery('#show_facturare').click(function() {
   if (this.checked) {
    this.checked=jQuery('#facturare').removeClass('hidden');
   } else {
      jQuery('#facturare').addClass('hidden');
     }
  });  
});*/

			$(document).ready(function(){
			//To switch directions up/down and left/right just place a "-" in front of the top/left attribute

				//Vertical Sliding

				$('.boxgrid.slidedown').hover(function(){

					$(".cover", this).stop().animate({top:'-290px'},{queue:false,duration:300});

				}, function() {

					$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});

				});

				//Horizontal Sliding

				$('.boxgrid.slideright').hover(function(){

					$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});

				}, function() {

					$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});

				});

				//Diagnal Sliding

				$('.boxgrid.thecombo').hover(function(){

					$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});

				}, function() {

					$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});

				});

				//Partial Sliding (Only show some of background)

				$('.boxgrid.peek').hover(function(){

					$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});

				}, function() {

					$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});

				});

				//Full Caption Sliding (Hidden to Visible)

				$('.boxgrid.captionfull').hover(function(){

					$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});

				}, function() {

					$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});

				});

				//Caption Sliding (Partially Hidden to Visible)

				$('.boxgrid.caption').hover(function(){

					$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});

				}, function() {

					$(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});

				});

				$('img#one').click(function () {				

					$('ul#one').slideToggle('medium');

		    	});

				$('img#two').click(function () {				

					$('ul#two').slideToggle('medium');

		    	});

				$('img#three').click(function () {				

					$('ul#three').slideToggle('medium');

		    	});

			});

 
