var pureQuote;
$(function() {
$('#submit_btn').live('click', function() {

 var user = jQuery.trim($('#login').val());
 var pass = jQuery.trim($('#password').val());
var reme;
if($('#remember').is(':checked'))
  reme = '&reme=true';

 
if(user == '') {
  $('#errorMessage').text('Please enter a valid username').show();
  return false;
}

if(pass== '') {
  $('#errorMessage').text('Please enter a password').show();
  return false;
}
 var dataString = "user="+user+"&pass="+pass+reme;
  $.post('login-exec.php',
 	{
    	user: user,
        pass: pass,
		reme: reme
	},
    function(result)
    {
		
           if(result=='true')
        {
        	$('#loginArea').load('loginarea.php');
			$('.siteRight').load('rightside.php');
			$('#forumMain').load('popforum.php');
        }
        else
        {
        	$('#loginArea').load('wrongpw.php');
        }
    }
 );

 return false;
});



$('.siteLogo').mouseover(function() {
$.post('goatplay.php');
	return false;
});


$('.quoteKnapp').click(function() { 
$.ajax({
  async: false,
  type: 'post', 
  url: 'getpurepost.php',
  data: 'postid='+$(this).attr('rel'),
  cache: false,
  success: function(data) {
	pureQuote=data;
  }
});								


if($('.expand').val() == 'Write a comment...')
{
	$('.expand').val("[quote="+$(this).parents().eq(1).next('div.mainPostText').attr('rel')+"]"+pureQuote+"[/quote]\r\n");
	$('.expand').css('color', '#333');
		$('.expand').css('padding-bottom', '10px');
		$('#replyButton').show();
}
else
{
	$('.expand').val($('.expand').val() + "\r\n[quote="+ $(this).parents().eq(1).next('div.mainPostText').attr('rel')+"]"+pureQuote+"[/quote]\r\n");
}
		 $(".expand").focus();
		 	
		 

		return false; 
});


$('.editKnapp').live('click', function() { 		
$.ajax({
  type: 'post', 
  url: 'getpurepost.php',
  data: 'postid='+$(this).attr('rel'),
  cache: false,
  success: function(data) {
	$('.expand').val(data);
	 $(".expand").focus();
  }
});
	
	$('.editKnapp2').html('Edit');
	$('.editKnapp2').addClass('editKnapp');
	$('.editKnapp2').removeClass('editKnapp2');
	$("div#replyPost").appendTo("div#editPost"+$(this).attr('rel'));
	$("div#editPost"+$(this).attr('rel')).show();

	$('.expand').css('color', '#333');
	$('.expand').css('padding-bottom', '10px');
	$('#replyButton').show();
	$('.actionfield').val('edit');
	$('.postidfield').val($(this).attr('rel'));
	$(this).removeClass('editKnapp');
	$(this).addClass('editKnapp2');
	$(this).html('Abort editing');
	
	return false;
});

$('.editKnapp2').live('click', function() { 
										
	$("div#replyPost").appendTo("div#justCheckin");
	$(this).removeClass('editKnapp2');
	$(this).addClass('editKnapp');
	$(this).html('Edit');	
	$('.actionfield').val('reply');
	$('.expand').val($('.expand').attr('title'));				
	$('.expand').css('color', '#999');
	$('.expand').css('padding-bottom', '0px');
	$('#replyButton').hide(); return false;

});


});




