$(document).ready(function() {
	


	   
/* ##################################################  SCROLL  ##############################################*/

			function mCustomScrollbars(){
		
			/*malihu custom scrollbar function parameters: 
			1) scroll type (values: "vertical" or "horizontal")
			2) scroll easing amount (0 for no easing) 
			3) scroll easing type 
			4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
			5) scrollbar height/width adjustment (values: "auto" or "fixed")
			6) mouse-wheel support (values: "yes" or "no")
			7) scrolling via buttons support (values: "yes" or "no")
			8) buttons scrolling speed (values: 1-20, 1 being the slowest)
			*/
			$("#mcs_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10); 
			$("#mcs2_container").mCustomScrollbar("vertical",0,"easeOutCirc",1.05,"auto","yes","no",0); 
			$("#mcs3_container").mCustomScrollbar("vertical",900,"easeOutCirc",1.05,"auto","no","no",0); 
			$("#mcs4_container").mCustomScrollbar("vertical",200,"easeOutCirc",1,"fixed","yes","no",0); 
			$("#mcs5_container").mCustomScrollbar("horizontal",500,"easeOutCirc",1,"fixed","yes","yes",20); 
		}
		
		/* function to fix the -10000 pixel limit of jquery.animate */
		$.fx.prototype.cur = function(){
		    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
		      return this.elem[ this.prop ];
		    }
		    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
		    return typeof r == 'undefined' ? 0 : r;
		}

		/* function to load new content dynamically */
		function LoadNewContent(id,file){
			$("#"+id+" .customScrollBox .content").load(file,function(){
				mCustomScrollbars();
			});
		}
		
		mCustomScrollbars();
		 /* ##################################################  SCROLL  ##############################################*/		
}); 


$(document).ready(function() {
	$("#ul-nav li ul").addClass("dropdown");
	$(function () {
		$('.dropdown').each(function () {
		    $(this).parent().eq(0).hover(function () {
			    $('.dropdown:eq(0)', this).show();
			}, function () {
			    $('.dropdown:eq(0)', this).hide();
	        });
		});
        
        $('.dropdown').hover(function(){
            $(this).show();    
        }, function(){
            $(this).hide();    
        });
    });
	
/* ############################################    ----  CUFON  ----  ################################################################## */	

	Cufon.replace('#wrap #colwrap #sidebar h2'); // Works without a selector engine
	Cufon.replace('#wrap #colwrap #sidebar #absoluted-text p'); // Requires a selector engine for IE 6-7, see above
        Cufon.replace('#villas-items')

	/* ############################################    ----  IMANES RANDOM  ----  ################################################################## */	
/*	 
	 jQuery.images_random = function(){
		   /*  $("#images-random").fadeOut("show",function(){
		    	 $(this).fadeOut(400);
		     });*/
/*		     
		   	  var images = ['ceyba-home-im2.jpg','ceyba-home-im3.jpg','ceyba-home-im4.jpg','homeslide.jpg'];
		   	  var path = 'localhost/ceyba_co/assets/images/';
		   	 
              var rango_superior = 1;  
              var rango_inferior = 4;  
              var aleatorio = Math.floor(Math.random()*(rango_superior-(rango_inferior-1))) + rango_inferior;
              /* 
             // $("#images-random").fadeIn(3000);
              $("#images-random").attr('src','http://'+path+images[aleatorio]);  */
   /*           
            // $('#images-random').cycle();
              $('slideshow').cycle({ 
            	  fx: 'custom', 
            	  cssBefore: { top: 232 }, 
            	  animIn:  { top: 0 }, 
            	  animOut: { top: -232 } 
            	}); 

             
     }    	            
     
	   setInterval('$.images_random()',5000);		
	*/
	
	$('#slideshow').cycle({
		
		speed: 5000,
		timeout: 4000
	});

/* ######################################### CLOSET DESCRIPTION ################################################### */	
	
 $('#close').bind('click', function(){
	
	   $('#description-villes').fadeOut(3000);
	   //$('#description-villes').addClass("none-description");
		return false;
	});
 
 /* ########################################## GALLERY IMAGES ##################################################*/
   $('#images-gallery a').bind('click', function(){
		
	   var image_background = $(this).attr('href');
	  // $('#images-absolud').css('display','inline');
	  
	   $('#image_home').attr("src",image_background);
	   $('#image_home').fadeIn('show');
	  
		return false;
	});
   
/* ############################################# FECLA IZQUIERDA ##################################################################### */ 
   $("#villas-items li a").bind('click', function(){
	   
	   
	   $('#villas-items li a').removeClass('select-a');   
	  
	  
	   $(this).addClass('select-a');
	  // return false;
   });
   
 /* ############################################# GALLERY VILLA AND POST ##################################################################### */ 
    
  /*  $("#images-left-large, #images-right-large").bind('click',function(){
       
        event.preventDefault();
        var ruta = $(this).attr('href');
        
        if ( $('#images-append').size() > 0 ){
            
           // $('#images-append').fadeOut('show',function(){
                
                $('#images-append').remove();
           // });
            
          
        }
        
        var div  = $('<div id="images-append"> <img src="'+ruta+'" /></div>');
            div.css({
                        'position'      :'absolute',
                        'top'           :108,
                       // 'background'    :'2px red no-repeat',
                        'width'         : 657,
                        'height'        : 450,
                        'left'          : 222
                      //  'visibility'    :'hidden'
                    });
                    
          $("body").append(div);
         
              $('#images-append').slideDown(5000); 
         
          
    }); */
   
             $("a#images-left-large,a#images-right-large").fancybox({
                                'opacity'	: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
});


