/* CONFIG FOR JS */
var _path = '/';

function isset(varname)
{
	if(typeof( window[ varname ] ) != "undefined") return true;
	else return false;
}

function sure()
{
	var ask = confirm('Are you sure?');
	if (ask == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function check_newtopic()
{
	var title = $('#topic_title').val();
	var select = $('#select-category').val();
	var post = $('#topic_content').val();

	if ( title == '' )
	{
		alert('You must enter a title');
		return false;
	}

	if ( select == '' )
	{
		alert('You must select a category');
		return false;
	}

	if ( post == '' )
	{
		alert('You must write your post');
		return false;
	}

	//check lengths
	if (title.length < 5)
	{
		alert('Title must be atleast 5 character long');
		return false;
	}

	if ( post.length < 10)
	{
		alert('Your post is too short.');
		return false;
	}
	
	return true;
}

function process_quickreply()
{
	var post = $("#reply_post").val();

	if (post == '')
	{
		alert('Please write a proper reply before submitting.');
		return false;
	}

	if (post.length < 10)
	{
		alert('Your reply is too short.');
		return false;
	}

	//serialize data
	 var data = $("#form_reply input,textarea").serialize();

	 var html = '';
	 var html = $.ajax({
					   type: "POST",
					   url: "/newreply.php?ajax=1",
					   data: data,
					   async: false
					 }).responseText;
	
	var check = html.search(/<div/);
	
	//tade error
	if (check != -1)
	{
		$("#anchor_reply").before().append(html);

		$(".posts:last").hide();
		$(".posts:last").fadeIn();
		$("#reply_post").val(" ");
	}
	else
	{
		alert(html);
		//alert('An error has occurred');
	}

	return false;
	//return true;
}

function fastreply(id)
{
	if (loggedin == 0)
	{
		alert('You must be logged in to post a reply');

		return false;
	}
	//$("#fastreply").slideDown('slow', function(){ 
	
		var targetOffset = $("#fastreply").offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 500);

	//});
	
	$("#reply_id").val(id);
	
	

	return false;
}