// JavaScript Document

var h1;

$(document).ready(function(){ 
	//$(document).pngFix(); 


	$("h1").each( function(i) {
			
			if( $(this).parent().attr("id") != "rightcontent" )
			{
				h1 = $(this).html();
				$(this).empty();
				h1 = h1.replace(" ","%20");
				$(this).prepend('<img src="include/dynamic_image/header.php?text='+h1+' />');
			
	    	}
	   }
	);

	
	$(".topnavimage").hover( function() {
									  $(this).css("border-color","rgb(114,155,200)");
									  },
							  function() {
								  		$(this).css("border-color","#eee");
							  		  });




$("#leftmenu ul li a").click( function() {
									   if( $(this).parent().attr("class") != "subnav" && $(this).attr("target") != "_blank" )
									   {
											var goto = $(this).attr("href");
											location.href = goto;
									   }
			});

/*
	$("#leftmenu ul li").click( function() {
										 	$("#leftmenu ul li").each( function(i) {
																		if( $(this).find(".subnav").css("display") != "none" )
																		{
																			 $(this).find(".subnav").hide("slide", { direction: "up"},500);
																		}
											 
																	} );
											 $(this).find(".subnav").show("slide", { direction: "up"},500);
											 //$(this).find(".subnav").show();
										});
*/

/*
	$("#leftmenu ul li").hover( function() {
										 if( $(this).attr("class") != "active" && $(this).find(".subnav").css("display") == "none" )
										{
											 $(this).find(".subnav").show("slide", { direction: "up"},500);
											 //$(this).find(".subnav").show();
										}
										},
								function() {
										//alert( "#"+$(this).attr('class')+"#" );
										if( $(this).attr("class") != "active" )
										{
											$(this).find(".subnav").hide("slide", { direction: "up"},500);
											//$(this).find(".subnav").hide();
										}
											//$(this).find("div").animate( { height: "0px" }, 1000 );
								});
	*/
}); 


function submitForm()
{
	
	var formdata = $("#contactform").serialize();

	$.ajax({
		url: "submitform.php",
		type: "GET",
		data: formdata,
		cache: false,
		error: function(html){
		},
		success: function(html){
			$("#form").css("display","none");
			$("#success").css("display","block");
			replaceHeaders();
	  }
	});
	
}

function loadEvent( id )
{
	$.ajax({
		url: "include/getevent.php",
		type: "POST",
		data: "id="+id,
		cache: false,
		error: function(html){
		},
		success: function(html){
			$("#content").empty();
			$("#content").append('<div id="clear"></div>');
			$("#content").append(html);
			replaceHeaders();
	  }
	});
}

function loadPressRelease( id )
{
	$.ajax({
		url: "include/getpressrelease.php",
		type: "POST",
		data: "id="+id,
		cache: false,
		error: function(html){
		},
		success: function(html){
			$("#content").empty();
			$("#content").append(html);
			replaceHeaders();
	  }
	});
}

function loadAllPressReleases()
{
	$.ajax({
		url: "include/news_releasesAll.php",
		type: "POST",
		data: "",
		cache: false,
		error: function( err ){
		},
		success: function( press ){
			$("#content").html( '<div id="clear"></div>' );
			$("#content").append( press );
			replaceHeaders();
	  }
	});
}

function replaceHeaders()
{

	$("h1").each( function(i) {
		
			h1 = $(this).html();
			$(this).empty();
			h1 = h1.replace(" ","%20");
			$(this).prepend('<img src="include/dynamic_image/header.php?text='+h1+' />');
		
			  }
	);
	
}

function showHide( year )
{
	
	$(".pressrelease").each( function( press ) { 
		$(this).css("display","none");
	});
	
	$("#"+year).css("display","block");
}
