/*
$(document).ready(function() {
	var item_total =$('.slide').length;
	$('#number_total').text(item_total);
	var item_width = $('#gallery li.slide').outerWidth() * (-1); 
	$('#slide_next').click(function() {
									
		if ( parseInt($('#gallery ul').css('left')) > item_width * (item_total - 1))
		{ var left_indent = parseInt($('#gallery ul').css('left')) + item_width;          
		$('#gallery ul').animate({'left' : left_indent}, 500); }
		else { returnfalse; }
		});         
		
	$('#slide_previous').click(function() {  
		var item_width = $('#gallery li.slide').outerWidth()										
		var left_indent = parseInt($('#gallery ul').css('left')) + item_width;           
		if (parseInt($('#gallery ul').css('left')) < 0 )
		{ $('#gallery ul').animate({'left' : left_indent}, 500); }
		else {
		return false; }
		});
	});
*/

function post_comment()
{
	var eventid = $('#eventid').val();
	var email = $('#txcomment_email').val();
	var comment = $('#txcomment_name').val()+'|'+ $('#txcomment').val();
	var userid = $('#userid').val();
	var uname = $('#txcomment_name').val();

	$.ajax({
		url: '/ajax/post_comment.php',
		type: 'POST',
		dataType: 'json',
		data:
		{
			eid: eventid,
			em: email,
			cm: comment,
			uid: userid,
			uname: uname
		},
		success: posted_comment
	});
}

function posted_comment(resp)
{
	if (resp.ERROR)
	{
		alert(resp.ERROR);
		return;
	}
	$('.feedback_box > div').hide();
	$('.feedback_box #fb').show();
	$('#fb').html('<p><strong>Your comment has been sent.</strong></p>');
}
function post_feedback(type)
{
	var t = type.toUpperCase()[0];

	if ($('#userid').val() == "")
		var uid = 0;
	else
		var uid = $('#userid').val();

//	if (type == "comment")
//		var comm = $('#txcomment').val()+"|eventid:"+$('#eventid').val()+"|name:"+$('#txcomment_name').val()+"|email:"+$('#txcomment_email').val();

	if (type == "idea")
	{
		var em = $('#txidea_email').val();
		var nm = $('#txidea_name').val();
		var tx = $('#txidea').val();
	}
	else if (type == "question")
	{
		var em = $('#txquestion_email').val();
		var nm = $('#txquestion_name').val();
		var tx = $('#txquestion').val();
	}
	else if (type == "praise")
	{
		var em = $('#txpraise_email').val();
		var nm = $('#txpraise_name').val();
		var tx = $('#txpraise').val();
	}

	$.ajax({
		url: '/ajax/post_feedback.php',
		type: 'POST',
		dataType: 'json',
		data:
		{
			userid:uid,
			mtype:t,
			email:em,
			name:nm,
			txt:tx
		},
		success: create_feedback
		
	});
}

function create_feedback(resp)
{
	if (resp.ERROR)
	{
		alert(resp.ERROR);
		return;
	}
	$('.feedback_box > div').hide();
	$('.feedback_box #fb').show();
	$('#fb').html('<p><strong>Your feedback has been received.</strong></p>');
}

