var hasdropdown

function mainmenu(){
$("ul#topnav ul ").css({display: "none"}); // Opera Fix
$("ul#topnav li").hover(function(){
hasdropdown = 0;
hasdropdown = $(this).find('ul:first').find('li').size();
if(hasdropdown > 0) { $(this).addClass('active'); }
$(this).find('ul:first').css({visibility: "visible",display: "none", "z-index":"5000"}).slideDown(300);
},function(){
hasdropdown = $(this).find('ul:first').find('li').size();
if(hasdropdown > 0) { $(this).removeClass('active'); }
$(this).find('ul:first').css({visibility: "hidden"});
});
}

jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};

$(function() {
	mainmenu();
	
	$('#footer .top ul li:last').css({"paddingRight":"0px", "border":"none"});
	
	$('#topbar .children li.page_item:last-child').addClass("last");
	$('#sidebar1 .widget:last').addClass("last");
	$('#sidebar2 .widget:last').addClass("last");
	
	jQuery.each(["page-item-108", "page-item-110", "page-item-91", "page-item-113", "page-item-124"], function(index, value) { 
            jQuery("."+value+" a:first").click(function(event){ event.preventDefault();});
            jQuery("."+value+" a:first").addClass("noLink");
    });
	
    var galleries = $('#gallery').adGallery({
  loader_image: '/wp-content/themes/lewisburgPA/slider/loader.gif',
  width: 1400,
  height: 490,
  start_at_index: 0,
  animate_first_image: false, // Should first image just be displayed, or animated in?
  animation_speed: 800, // Which ever effect is used to switch images, how long should it take?
  display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
  scroll_jump: 1, // If 0, it jumps the width of the container
  slideshow: {
    enable: true,
    autostart: true,
    speed: 5000,
    start_label: 'Start',
    stop_label: 'Pause',
    countdown_prefix: '(', // Wrap around the countdown
    countdown_sufix: ')',
    onStart: function() {
      // Do something wild when the slideshow starts
      $(".ad-slideshow-start").hide();
      $(".ad-slideshow-stop").show();
    },
    onStop: function() {
      // Do something wild when the slideshow stops
      $(".ad-slideshow-start").show();
      $(".ad-slideshow-stop").hide();
    }
  },
  effect: 'fade', // or 'slide-vert', 'resize', 'fade', 'none' or false
  enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?
  cycle: true // If set to false, you can't go from the last image to the first, and vice versa
  // All callbacks has the AdGallery objects as 'this' reference
	});
	
	$(".scrollable").scrollable();
	
	$("#mc_mv_EMAIL").DefaultValue("Enter your email address");
	
});
