// JavaScript Document

$(document).ready(function(){
	//show-hide a pulldown menu on hover
	$(".header .navigation LI").hover(
		function () {
			$(this).css("zIndex","900");
			$(this).children('UL.pulldown').slideDown(200);
			$(this).children('.header .navigation LI A').css('background-color', '#C1002B');
			$(this).children('.header .navigation UL.pulldown A').css('background-color', '#C1002B');
		},
		function () {
			$(this).css("zIndex","100");
			$(this).children('UL.pulldown').stop(true, true).slideUp(200);
			$(this).children('.header .navigation LI A').css('background-color', '#A59890');
			$(this).children('.header .navigation UL.pulldown A').css('background-color', '#f1f0ee');
		}
	);
	$("UL.pulldown LI").hover(
		function () {
			$(this).css("zIndex","1000");
			$(this).children('UL.subpulldown').slideDown(200);
		},
		function () {
			$(this).css("zIndex","100");
			$(this).children('UL.subpulldown').stop(true, true).slideUp(200);
		}
	);


    if ($('DIV.quotes p').length == 0) {
        $('DIV.quotes').wrapInner('<p>');
    }
	
	$("DIV.quotes p").each(function(){
		$(this).prepend('<img src="/images/default/quotes.jpg" width="24" height="26" class="quote" />').append('<img src="/images/default/quotes_2.jpg" width="24" height="26" align="texttop" class="quote" />');
	});

    $(".colspan-4 P.quotes").each(function () {
        $(this).prepend('<img src="/images/default/quotes.jpg" width="24" height="26" class="quote" />').append('<img src="/images/default/quotes_2.jpg" width="24" height="26" align="texttop" class="quote" />');
    });

	$(".title IMG:not(.quote)").each(function(){
		if ($(this).attr("alt")) {
			var alt = '<p>' + $(this).attr("alt") + '</p>';
		} else {
			var alt = '';
		}
		$(this).replaceWith(
			'<div class="imagemask" style="width:' + $(this).attr("width") + 'px">' + 
				'<img src="' + $(this).attr("src") + '" width="' + $(this).attr("width") + '" height="' + $(this).attr("height") + '" border="0" />' + alt +
			'</div>');
	});

	$(".title IFRAME").each(function(){
		$(this).replaceWith('<div class="iframemask">' +
			'<iframe height="182" marginheight="0" src="' + $(this).attr("src") + '" frameborder="0" width="230" marginwidth="0" scrolling="no"></iframe>' + 
			'<p><a href="' + $(this).attr("src") + '" target="_blank">View Larger Map</a></p></div>'
		);
	});

	$(".mainContent IMG:not(.quote,.addthis)").each(function(){
		if ($(this).attr("alt")) {
			var alt = '<p>' + $(this).attr("alt") + '</p>';

			$(this).replaceWith(
			'<div class="imagemask" style="width:' + $(this).attr("width") + 'px">' + 
				'<img src="' + $(this).attr("src") + '" width="' + $(this).attr("width") + '" height="' + $(this).attr("height") + '" border="0" />' + alt +
			'</div>');
		}
		
    });
});
