// Cufon font replacement
Cufon.replace('.page-id-2346 h2, .page-id-2325 h2, .page-id-2420 h2, .page-id-2453 h2, .page-template-page-lighthouse-subpage-php h2, #lighthouse-overlay h2');

$(function(){

    $("ul#dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul#dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

	if (ie7 == true) {
		// move overlay to right before the </body> tag in IE7 and lower; fixes mask bug
		var lo = $('#lighthouse-overlay');
		lo.detach().appendTo('body');
	}
	
	$('a[rel]').overlay({
		mask: {
			color: '#333333'
		}
	});
	
	// Abolitionist form: Attach and un-hide generated list of lighthouses
	$('#abo_state').blur(function(){	
		if ($(this).val()) {
			$.post('/wp-content/themes/960bc/query-lighthouses.php', { 'state': $('#abo_state').val() }, function(data){
				var lh = $('#lighthouse-holder');
				// remove existing select menus
				$('#lighthouse-holder span.wpcf7-form-control-wrap.abo_lighthouse').remove();
				// append new select menus
				lh.append(data);
				// detach lighthouse holder and append to end of form
				lh.detach();
				lh.appendTo('.half.right').fadeIn();
				
				// add "no lighthouses found" option if no options were appended in query-lighthouses
				if (!$('#lighthouse-holder select option').length) {
					$('#lighthouse-holder select').append('<option value="none">No Lighthouses Found in Your Area</option>');
				}
			})
		}
		if ($('#lighthouse-holder').length > -1) {
			var lh = $('#lighthouse-holder');
			
		}
	});
});
