function showmenu() {
     var menu = $(this);
     menu.children("ul").slideDown('fast');
   }
  
   function hidemenu() { 
     var menu = $(this);
     menu.children("ul").slideUp('fast');
   }



// remap jQuery to $
(function($){})(window.jQuery);

// function callback on hiding image
function superbgimage_hide(img) {
	$('.maintitle p').fadeOut("slow");


}

// function callback on showing image
// get title and display it
function superbgimage_show(img) {
	$(".maintitle p").html($("img.activeslide").attr("alt")).text();
	$('.maintitle p span').hide();
	$('.maintitle p').fadeIn("slow");
	$('.maintitle p span').delay(3000).fadeIn("slow");
}

/* trigger when page is ready */
$(document).ready(function (){

	$('.maintitle p').hide();
	
    // Options for SuperBGImage
    $.fn.superbgimage.options = {
        slideshow: 1, // 0-none, 1-autostart slideshow
        slide_interval: 7000, // interval for the slideshow
       speed: 'slow', // animation speed
	onShow: superbgimage_show, // function-callback show image
	onHide: superbgimage_hide // function-callback hide image
    };
 
    // initialize SuperBGImage
    $('#superbgimage').superbgimage().hide();
    
    $(function(){
	    $("#mainnav ul ul").hover(
	      function() {$(this).parent("li").addClass("active");}, 
	      function() {$(this).parent("li").removeClass("active");}
	    );
	});
		
	
	
	 $('.page_imagery').cycle({
        fx:     'fade',
        speed:  400,
        timeout: 6000,
		slideExpr: 'span'
		//next:   '#next1', 
	    //prev:   '#prev1'
	                          
    }); 
	
	$('#mid-footer .paged-fade').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 3000, 
	    pager:  '.specials.pager' 
	});
	
	$('#toggle').click(function(){
	
		var $this = $(this);
		if($this.hasClass('out') == false){
			
			$this.removeClass('in');
			$this.addClass('out');
			
			var $left = $('.slide-box');		
			$left.animate({		
				left: 0
			});
			
		} else {
			
			$this.removeClass('out');
			$this.addClass('in');
			
			var $left = $('.slide-box');		
			$left.animate({		
				left: -610
			});
			
		}
		return false;

	});
	
	if($("#contactform").length){$("#contactform").validate();}
	
	$("#mainnav ul li").hoverIntent({
     sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
     interval: 30,   // number = milliseconds for onMouseOver polling interval
     over: showmenu,     // function = onMouseOver callback (required)
     timeout: 300,   // number = milliseconds delay before onMouseOut
     out: hidemenu       // function = onMouseOut callback (required)
   });
	

});



		$(document).ready(function() {
			$("#content-master a[href$=jpg]").fancybox({

				'zoomSpeedIn'		:	500,
				'zoomSpeedOut'		:	500,
	                	'titlePosition'  : 'inside'

			});
		});

$(document).ready(function(){$("a[href$=pdf]").attr('target','_blank');});
$(document).ready(function(){$("a[href^='http']").not("[href*='renvyle.com']").attr('target','_blank');});
$(function(){
    $('a.pageedit').click(function(){
        window.open(this.href);
        return false;
    });
});
