
jQuery(document).ready(function(){

  var cache = [];
  // Arguments are image paths relative to the current page.
  jQuery.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }

jQuery.preLoadImages("/wp-content/themes/ridgevalley3/images/menu-titles/careers-over.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/news-media-over.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/about-us-over.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/free-roof-assessment-over.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/what-your-roof-is-telling-y.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/contact-us-over.jpg", "/wp-content/themes/ridgevalley3/images/menu-titles/license-insurance-over.jpg");

	// jQuery("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
// jQuery("#textSide").show("slide", { direction: "left" }, 1000);


	jQuery("ul.topnav li span").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		jQuery(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		jQuery(this).parent().hover(function() {

			jQuery(this).addClass("tophover"); //When the mouse hovers out of the subnav, move it back up

			var currentImg = jQuery(this).find('img').attr('src');
			jQuery(this).find('img').attr('src', jQuery(this).find('img').attr('hover'));

		}, function(){	
			jQuery(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
			jQuery(this).removeClass("tophover"); //When the mouse hovers out of the subnav, move it back up

			var currentImg = jQuery(this).find('img').attr('default');
			jQuery(this).find('img').attr('src', jQuery(this).find('img').attr('default'));

		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
			jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			jQuery(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});


	jQuery("ul.subnav li span").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		jQuery(this).parent().find("ul.subnav2").show(); //Drop down the subnav on click

		jQuery(this).parent().hover(function() {

			jQuery(this).addClass("tophover"); //When the mouse hovers out of the subnav, move it back up


		}, function(){	

			jQuery(this).parent().find("ul.subnav2").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
			jQuery(this).removeClass("tophover"); //When the mouse hovers out of the subnav, move it back up

			var currentImg = jQuery(this).find('img').attr('default');
			jQuery(this).find('img').attr('src', jQuery(this).find('img').attr('default'));

		});



	},
	function() {
		

	});



});
