$(function(){
	$('#rating_section').draggable({ appendTo: 'body' });
	$("#add_comment").die("click");
	$("#add_comment").live("click",function(){
		var imgid = $("#imgid").val();
		var subject = $("#comment_subject").val();
		var comment = $("#comment_comment").val();
		var author = $("#comment_name").val();
		sendComment(imgid,subject,comment,author);
	});
});
function rateItem(item_id,rating){
		var data = new Object();
		data['itemid']=item_id;
		data["rating"]=rating;
		var data = 'action=rateItem&json='+JSON.stringify(data);
		postIt(data);
	}
function tag_dialog(){
$('#tag_dialog').css({top: ($(window).height() - $('#tag_dialog').height() ) / 2+$(window).scrollTop() + "px",left:'50%',margin:'-'+($('#tag_dialog').height() / 2)+'px 0 0 -'+($('#tag_dialog').width() / 2)+'px'});
	$('#tag_dialog').draggable();
	$("#tag_dialog").fadeIn();
}
function do_tag(a){
	sendTag(a,$("#imgid").val());
	$("#tag_dialog").css("display","none");
	$("#tag_dialog").fadeIn("fast");
}
function sendTag(tagg,imgid){
	var data =  new Object();
	data['tag']=encodeURI(tagg);
	data['itemid']=imgid;
	var data = 'action=tagItem&json='+JSON.stringify(data);
	postIt(data);
}
function sendComment(imgid,subject,comment,author){
	if(subject=='Subject'||comment=='Comment'||author=='Name'){
		alert("Please Enter a Name, Subject, And Comment!");
		return false;
	}
	var data =  new Object();
	data['subject']=encodeURI(subject);
	data["comment"]=encodeURI(comment);
	data["author"]=encodeURI(author);
	data["itemid"]=imgid;
	var data = 'action=commentItem&json='+JSON.stringify(data);
	postIt(data);
}
function flagPic(itemid){
	var data =  new Object();
	data['itemid']=itemid;
	var data = 'action=flagItem&json='+JSON.stringify(data);
	postIt(data);
}
function add_comment(){
	$("#comment_input").show();
}
