jQuery(document).ready(function() {

	jQuery('#home-slider').cycle({
		timeout: 0,
		random: true
	});
	
	jQuery('#ads').cycle({
		fx: 'fade',
		timeout: 8000,
		delay: 4000,
		slideExpr: 'a'
	});
	
	//	jQuery('figure.gallery-item a').attr('rel','gallery');
	//	jQuery('figure.gallery-item a[rel="gallery"]').fancybox();

	jQuery(function() {
	   /* Get the window's width, and check whether it is narrower than 480 pixels */
	   var windowWidth = jQuery(window).width();
	   if (windowWidth <= 480) {
	
	      /* Clone our navigation */
	      var mainNavigation = jQuery('nav#nav-main').clone();
	
	      /* Replace unordered list with a "select" element to be populated with options, and create a variable to select our new empty option menu */
	      jQuery('nav#nav-main').html('<select class="mobile-nav"></select>');
	      var selectMenu = jQuery('select.mobile-nav');
	
	      /* Navigate our nav clone for information needed to populate options */
	      jQuery(mainNavigation).children('ul').children('li').each(function() {
	
	         /* Get top-level link and text */
	         var href = jQuery(this).children('a').attr('href');
	         var text = jQuery(this).children('a').text();
	
	         /* Append this option to our "select" */
	         jQuery(selectMenu).append('<option value="'+href+'">'+text+'</option>');
	
	         /* Check for "children" and navigate for more options if they exist */
	         if (jQuery(this).children('ul').length > 0) {
	            jQuery(this).children('ul').children('li').each(function() {
	
	               /* Get child-level link and text */
	               var href2 = jQuery(this).children('a').attr('href');
	               var text2 = jQuery(this).children('a').text();
	
	               /* Append this option to our "select" */
	               jQuery(selectMenu).append('<option value="'+href2+'">--- '+text2+'</option>');
	            });
	         }
	      });
	   }
	
	   /* When our select menu is changed, change the window location to match the value of the selected option. */
	   jQuery(selectMenu).change(function() {
	      location = this.options[this.selectedIndex].value;
	   });
	});
	
	

});


