// JQuery Ajax Function

// JQ Playlist Functions
function jqDeletePlaylistVideo(obj, pl_id, pl_vid) {
	if (pl_id != "" && pl_vid != "") {
		if (confirm('ยืนยันการลบ วีดีโอ?')) {
			//xajax_ajx_removePlaylistVideo(pl_id, pl_vid);
			//document.getElementById(divID).innerHTML =  "<span class=\"success\">ลบเรียบร้อยแล้วค่ะ</span>";
			$.ajax({
				type: 'POST',
				url: baseurl+'/jquery/jq_playlist.php',
				data: 'method=delete_playlist_video&pl_id='+pl_id+'&pl_vid='+pl_vid,
				success: function(result) { $('#'+obj).html('<span style="font-size: 12px;">'+result+'</span>'); }
			});
		}
	} else {
		alert("ไม่สามารถทำรายการได้");
	}
}

function jqUpdatePlaylistThumb(obj, pl_id, pl_vid) {
	if (pl_id != "" && pl_vid != "") {
		//xajax_ajx_updatePlaylistThumb(pl_id, pl_vid);
		//document.getElementById(divID).innerHTML =  "<span class=\"success\">ตั้งเรียบร้อยแล้วค่ะ</span>";
		$.ajax({
			type: 'POST',
			url: baseurl+'/jquery/jq_playlist.php',
			data: 'method=update_playlist_thumb&pl_id='+pl_id+'&pl_vid='+pl_vid,
			success: function(result) { $('#'+obj).html('<span style="font-size: 12px;">'+result+'</span>'); }
		});
	} else {
		alert("ไม่สามารถทำรายการได้");
	}
}

function jqVotePlaylist(objh, obj, objThank, pl_id, score) {
	hideMe(objh)
	$.ajax({
		type: 'POST',
		url: baseurl+'/jquery/jq_playlist.php',
		data: 'method=vote_playlist&pl_id='+pl_id+'&score='+score,
		success: function(result) {
			outDataArr = result.split("|");
			$('#'+obj).html(outDataArr[0]);
			if (outDataArr[1] != "") {
				$('#'+objThank).html(outDataArr[1]);
			}
		}
	});
}

function jqCommentPlaylist(obj, frm) {
	comment_value = frm.addcomment.value;
	comment_length = comment_value.length;
	if (comment_value == '') {
		alert('กรุณาใส่ข้อความด้วยค่ะ !!');
	} else {
		if (comment_length > 2000) {
			alert('ข้อความยาวเกินไปค่ะ!! ใส่ได้ไม่เกิน 2000 ตัวอักษรค่ะ');
		} else {
			$('#'+obj).html =  "ระบบกำลังทำงาน กรุณารอซักครู่...";
			$.ajax({
				type: 'POST',
				url: baseurl+'/jquery/jq_playlist.php',
				data: 'method=comment_playlist&comment='+comment_value+'&pl_id='+frm.pl_id.value,
				success: function(result) { $('#'+obj).html('<span style="font-size: 12px;">'+result+'</span>'); }
			});
		}
	}		
}

function jqViewPlaylistComment(obj, pl_id, page, limit, com_num) {
	$.ajax({
		type: 'POST',
		url: baseurl+'/jquery/jq_playlist.php',
		data: 'method=view_playlist_comment&pl_id='+pl_id+'&page='+page+'&limit='+limit+'&com_num='+com_num,
		success: function(result) { $('#'+obj).html('<span style="font-size: 12px;">'+result+'</span>'); }
	});
}

// End JQuery Ajax Function
