//global

$(document).ready(function() {
   


$(".clear-both + h1").css("margin-top", "1em");

$("p + h3, ul + h3, .storyBox + h3").css("margin-top", "2.5em");

$('#mainColumn>.storyWrap>p + h2').css("margin-top", "3em");
$('#mainColumn>.storyWrap>a + h2').css("margin-top", "3em");
$('#mainColumn>.storyWrap>div + h2').css("margin-top", "3em");

$('#mainColumn>.storyWrap>p + dl').css("margin-top", "2em");
$('#mainColumn>.storyWrap>ul + dl').css("margin-top", "2em");


  $.localScroll({duration:300}); 



$(".round").corner("10px");


$("#mainColumn .storyWrap").corner("12px");


$(".external").append( " ", "<img src='Styles/g/icons/external.png' border='0'  title='' alt='' class='' />");




$('#mainColumn>.storyWrap>ul>li>a[href$=".pdf"]').prepend( " " + "<img src='Styles-2008/g/icons/Acrobat_icon.jpg' border='0'  title='' alt='' class='' />" + "&nbsp;");

$('#mainColumn>.storyWrap>p>a[href$=".pdf"]').prepend( " ", "<img src='Styles-2008/g/icons/Acrobat_icon.jpg' border='0'  title='' alt='' class='' />" + "&nbsp;");



// list expander




$("dl.listExpander > dd").hide ();


$("dl.listExpander>dt").toggleClass('listExpanderRight');

$("dl.listExpander >dt").click(function(){
   
            $(this).toggleClass('listExpanderRight');
          $(this).toggleClass('listExpanderDown');
     
          $(this).next().toggle('fast');
	});
































// use this to obfuscate email

$('a.email').each(function(){
			e = this.rel.replace('/','@');
                        
                         theText = "Email"
			this.href = 'mailto:' + e;
		
		});





});





// this is for our suckerfish menu
  
function mainmenu(){
$(" #sf-nav ul ").css({display: "none"}); // Opera Fix
$(" #sf-nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(300);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

 $(document).ready(function(){
	mainmenu();
});






// this will add a caption below an image 
// img class="add-caption"
// caption taken from alt


$(window).load(function(){
		$("img.add-caption").each(function(i) {
			var imgwidth = $(this).width();
			var thetext = $(this).attr("alt");
                        var thetitle = $(this).attr("title");
			$(this).wrap("<div class='image-wrap'></div>");	
			$(this).parent().width(imgwidth);

			if ((thetext != null)&&(thetext != " "))
	                if ((thetitle != null)&&(thetitle != " "))
			{
				$(this).parent().append("<p class='image-caption'>" + "<strong>" + thetitle +  "</strong>" + "&nbsp;" + thetext + "</p>");
			}	
		});	

	});
	



// This add caption floats left


$(window).load(function(){
		$("img.add-caption-left").each(function(i) {
			var imgwidth = $(this).width();
                        var thetext = $(this).attr("alt");
			var thetitle = $(this).attr("title");
                	$(this).wrap("<div class='image-wrap' style='float:left;margin:0 15px .5em 0;'></div>");
	
			$(this).parent().width(imgwidth);
                        		if ((thetitle != null)&&(thetitle != " "))
			if ((thetext != null)&&(thetext != " "))
			{
				$(this).parent().append("<p class='image-caption'>" + "<strong>" + thetitle +  "</strong>" + "&nbsp;" + thetext +  "</p>");
		           }
                           

		});	

	});
	





// This add caption floats right


$(window).load(function(){
		$("img.add-caption-right").each(function(i) {
			var imgwidth = $(this).width();
                        var thetext = $(this).attr("alt");
			var thetitle = $(this).attr("title");
                	$(this).wrap("<div class='image-wrap' style='float:right;margin-left:15px;'></div>");	
			$(this).parent().width(imgwidth);
                        	if ((thetitle != null)&&(thetitle != " "))
			if ((thetext != null)&&(thetext != " "))
			{
				$(this).parent().append("<p class='image-caption'>" + "<strong>" + thetitle +  "</strong>" + "&nbsp;" + thetext +  "</p>");
			}	
		});	

	});
	




