jQuery(document).ready(function(){
	jQuery("#topslide").hide();
	jQuery("#wufoo").hide();
	jQuery("#tell").hide();
	jQuery("#save").hide();
	
	jQuery("#wufoo iframe").height(321);
	jQuery('.topbutton').mouseover(function(){
		jQuery(this).stop();
		jQuery(this).animate({height:"77px"}, 300);
	});
	jQuery('.topbutton').mouseout(function(){
		jQuery(this).stop();
		jQuery(this).animate({height:"65px"}, 300);
	});
	
	jQuery('.topbutton').click(function() {
		var what = jQuery(this).attr("rel");
		slideThisDown(what);
	});
	
	jQuery('.closebtn').click(function() {
		jQuery(".top_frame").fadeOut("fast", function() {
			jQuery("#topslide").slideUp("slow");
			jQuery("#topslide").removeAttr("rel");
		});
		return false;
	});
	
	if(jQuery.flash.hasVersion('8.0.0')){
		// #flash-example-1 is the selector
		jQuery('#design_by_am').html("");
		jQuery('#design_by_am').flash({
			// test.swf is the flash document
			swf: '/am_spinning_logo.swf',
			height: '20px',
			width: '71px',
			wmode:"transparent"
		});
		
		jQuery('#noflash').css("display", "none");
		jQuery('#flash_container').flash({
			// test.swf is the flash document
			swf: '/Y2011_home.swf',
			quality: "high",
			scale: "noscale",
			height:"100%",
			width:"100%",
			wmode:"window",
			bgcolor: "#111111"
		});
		if(jQuery("#flash_container").is(":visible")) {
			swffit.fit("flash_container", 980, 575);
		}
		if(jQuery("#sub")) {
			jQuery('#sub_flash').flash({
				// test.swf is the flash document
				swf: '/Y2011_subheader.swf',
				flashvars: {
					headerText: jQuery('#page_title').text(),
					headerImage: "/images/sub_header_img.jpg"
				},
				height: '350px',
				width:"100%",
				wmode:"opaque"
			});
		}
	}
	
	jQuery("#send_btn").click(function() {
		jQuery("#response").hide();
		jQuery("#response").load("/email.script.php", {
			share_name: jQuery("#share_name").val(), 
			share_email: jQuery("#share_email").val(), 
			friend_name: jQuery("#share_friend_name").val(), 
			friend_email: jQuery("#share_friend_email").val(), 
			subject: jQuery("#share_friend_subject").val(), 
			text_to_send: jQuery("#share_text_to_send").val()
			}, function(){
				jQuery("#send_btn").fadeOut("slow", function() {
					jQuery("#response").fadeIn("fast", function() {
						jQuery("#response").animate({marginLeft: "0px"}, 2000, function () {
							jQuery("#response").fadeOut("slow", function() {
								jQuery("#send_btn").fadeIn("fast");
							});
						});
					});	
				});
				
		});
		
		
		return false;
	});
	
	jQuery("#page_container h2").each(function() {
		jQuery(this).before("<span class='h2_arrow'><!-- --></span>");
		jQuery(this).after("<span class='clear'><!-- --></span>");	
	});
});
	
function slideThisDown(what) {
	var elem_height = jQuery(".top_frame[rel="+what+"]").css("height");
	if (jQuery("#topslide").is(":visible")) {
		if(what == jQuery("#topslide").attr("rel")) {
			jQuery(".top_frame").fadeOut("fast", function() {
				jQuery("#topslide").slideUp("slow");
				jQuery("#topslide").removeAttr("rel");
			});
		} else {
			jQuery(".top_frame").hide();
			jQuery("#topslide").animate({height: elem_height}, "slow");
			jQuery("#topslide").attr("rel",what);
			jQuery("#topslide .top_frame[rel="+what+"]").fadeIn("slow");
		}
	} else {
		jQuery("#topslide").attr("rel",what);
		jQuery("#topslide").height(elem_height);
		jQuery("#topslide").slideDown("slow");
		jQuery("#topslide .top_frame[rel="+what+"]").fadeIn("slow");
	}
}