	$(document).ready(function(){
		$('div.textbox').click(function(){
			$('input',this).focus();
		});
		$('div.textarea').click(function(){
			$('textarea',this).focus();
		});
		$('#say-hello').click(function(){
			show_contact();		   
		});		

		$('.list-parent').focus(function(){show_the_list()});
		$('.list-parent').click(function(){show_the_list()});
		$('input').focus(function(){hide_the_list()});
		$('.send-button').focus(function(){hide_the_list()});
		$('body').click(function(){hide_the_list()});

		$('.le-click').click(function(evt){ 
			evt.stopImmediatePropagation();
			hide_the_list();
			var the_row = $(this).parents('tr');
			if($('#contact_frame:visible').size() > 0){
				$('#contact_frame .list-parent:eq(0)').html($('td:first',the_row).html());
				$('#contact_frame .list-parent:eq(1)').html($('td:last',the_row).html());
				$('#contact_frame #mood').val($('td:first',the_row).html());
			}else{
				$('#contact_form2 .list-parent:eq(0)').html($('td:first',the_row).html());
				$('#contact_form2 .list-parent:eq(1)').html($('td:last',the_row).html());
				$('#contact_form2 #mood').val($('td:first',the_row).html());
			}
		});
	});

	function show_the_list(){
		if($('.send-button:visible').size() > 0){
			if($('#contact_frame:visible').size() > 0){
				var pos = $('#contact_frame .list-parent:eq(0)').offset();
			}else{
				var pos = $('#contact_form2 .list-parent:eq(0)').offset();
			}
			$('#list-pop').css({left:pos.left+'px',top:(pos.top+5)+'px'}).fadeIn('fast');
		}
	}
	function hide_the_list(){
		$('#list-pop').fadeOut('fast');
	}

	function validate_form(blah){
		if(!blah){blah = ''}
		if($.trim(jQuery('#contact_form'+blah+' #name').val()) == ''){
			show_dialog('Please enter your name','Something is not quite right');

		}else if(!validate_email(jQuery('#contact_form'+blah+' #email').val())){
			show_dialog('Please enter a valid Email Address','Something is not quite right');

		}else if($.trim(jQuery('#contact_form'+blah+' #comment').val()) == ''){
			show_dialog('Please enter a comment','Something is not quite right');

		}else{
			$('.send-button').hide();
			$('input').attr('readonly','readonly');
			$('textarea').attr('readonly','readonly');
			var the_form = jQuery('#contact_form'+blah)[0];
			the_form.onsubmit = '';
			the_form.action = 'contact_send.php';
			$('#contact_form'+blah+' #form_type').val('contact_form');
			the_form.submit();
		}
	
	}
