// BEGIN DOM
$(document).ready(function()
{
	
	// Any link with the rel of backlink will go back history -1
	$('a[rel="backlink"]').click( function() {
		parent.history.back(-1);		
        return false;
    });
	
	// Any External Link will open up a new window.
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	
	// Will handle any PDF to open up without sending you to a new page	
	$("a[href*=.pdf]").click(function()	{
		$(this).attr({"target":"_self"});
		return false;
	});

	// Any External Link will open up a new window.
	$('A[rel="confirm"]').click(confirmTheClick);
	
	// Checks when the input is clicked inside and erases the default value
	$("#firstname").focus(function(){
		if($(this).val() == "First Name")
		{
			var newValue = ""
			$(this).val(newValue);
		}
	});
	
	// When you get off the input, it checks to see if the value is EMPTY, if its empty, it puts the default back.
	$("#firstname").blur(function(){
		var newValue = ""
		if($(this).val() == newValue)
		{
			$(this).val("First Name");
		}			
	});
	
	// Checks when the input is clicked inside and erases the default value
	$("#lastname").focus(function(){
		if($(this).val() == "Last Name")
		{
			var newValue = ""
			$(this).val(newValue);
		}
	});
	
	// When you get off the input, it checks to see if the value is EMPTY, if its empty, it puts the default back.
	$("#lastname").blur(function(){
		var newValue = ""
		if($(this).val() == newValue)
		{
			$(this).val("Last Name");
		}			
	});
	
	// Checks when the input is clicked inside and erases the default value
	$("#email").focus(function(){
		if($(this).val() == "Email Address")
		{
			var newValue = ""
			$(this).val(newValue);
		}
	});
	
	// When you get off the input, it checks to see if the value is EMPTY, if its empty, it puts the default back.
	$("#email").blur(function(){
		var newValue = ""
		if($(this).val() == newValue)
		{
			$(this).val("Email Address");
		}			
	});
	
	// When the user clicks the submit button, remove all default items
	$("#submit_email").click(function(){
			if($("#firstname").val() == "First Name")
			{
				$("#firstname").attr("value","");
			}
			if($("#lastname").val() == "Last Name")
			{
				$("#lastname").attr("value","");
			}
			if($("#email").val() == "Email Address")
			{
				$("#email").attr("value","");
			}
		});
	
	// Facebox scripts
    $('a[rel*=facebox]').facebox();	
	
	// Validate the form in the footer
	$("#email_form").validate({
		rules: {
			firstname: "required",
			lastname: "required",
			email: {
				required: "#email",
				email: true
			}
		},
		messages: {
			firstname:"[Required:] Please Enter Your First Name",
			lastname:"[Required:] Please Enter Your Last Name",
			email:"[Required:] Please Enter Your Email Adress"
		}
	});
	
	

}); // END DOM


// Confirm the click...to make sure that there are no mistakes
function confirmTheClick()
{
	var agree="Are you sure you wish to perform this action?\nCheck your work!";
	if ( confirm( agree ) )
		return true;
	else
		return false;
}

