// JavaScript Document
var pBuild = function (olutid) {
	pTable = $('#pointscontent').dataTable( { 
		"bAutoWidth": false,
		"iDisplayLength": 25,
		"bJQueryUI": true,
		"bProcessing": false,
		"sAjaxSource": "http://olutopas.info/inc/oo/dt_points2.php?id=" + olutid,
		"aaSorting": [[1,'desc']],
		"oLanguage": {
			"sUrl": "http://olutopas.info/inc/dt/fi_FI.txt"
		},
		"aoColumns": [
			{ "sTitle": "Ts-Aika", "sType": "numeric", "bSearchable": false, "bVisible": false },
			{ "sTitle": "Aika", "sType": "fi-date", "iDataSort": 0 },
			{ "sTitle": "Käyttäjä", "sType": "html" },
			{ "sTitle": "Pisteet", "sType": "html" }
		]
	} );
}

var dBuild = function (olutid,e,g,a) {
	dTable = $('#datacontent').dataTable( { 
		"bAutoWidth": false,
		"iDisplayLength": 10,
		"bJQueryUI": true,
		"bProcessing": false,
		"sAjaxSource": "http://olutopas.info/inc/oo/dt_bdata2.php?id=" + olutid + "&e=" + e + "&g=" + g + "&a=" + a,
		"aaSorting": [[1,'desc']],
		"oLanguage": {
			"sUrl": "http://olutopas.info/inc/dt/fi_FI.txt"
		},
		"aoColumns": [
			{ "sTitle": "Pakkaus, l", "sType": "numeric-comma", "bSearchable": false },
			{ "sTitle": "Annoksia", "sType": "numeric-comma", "bSearchable": false },
			{ "sTitle": "Valmispizzoja", "sType": "numeric-comma", "bSearchable": false }
		]
	} );
}

var sBuild = function (olutid) {
	sTable = $('#saatcontent').dataTable( { 
		"bAutoWidth": false,
		"iDisplayLength": 50,
		"bJQueryUI": true,
		"bProcessing": false,
		"sAjaxSource": "http://olutopas.info/inc/oo/dt_avail3.php?id=" + olutid,
		"aaSorting": [[5,'asc']],
		"oLanguage": {
			"sUrl": "http://olutopas.info/inc/dt/fi_FI.txt"
		},
		"aoColumns": [
			{ "sTitle": "l" },
			{ "sTitle": "Pakkaus" },
			{ "sTitle": "Myyntipaikka", "sType": "html" },
			{ "sTitle": "Kunta", "sType": "html" },
			{
				"sTitle": "€",
				"sClass": "center",
				"sType": "numeric-comma",
				"bUseRendered": false,
				"fnRender": function(obj) {
					var sReturn = obj.aData[ 4 ];
					if ( sReturn == "0,00" ) {
						sReturn = "<span class=\"bullet ico ico-blueball-question\"></span>";
					} else {
						if ( obj.aData[ 7 ] > 180 ) {
							sReturn = "<span style=\"color: #F00\">" + sReturn + "</span>";
						}
					}
					return sReturn;
				}
			},
			{
				"sTitle": "€/l",
				"sClass": "center",
				"sType": "numeric-comma",
				"bUseRendered": false,
				"fnRender": function(obj) {
					var sReturn = obj.aData[ 5 ];
					if ( sReturn == "0,00" ) {
						sReturn = "<span class=\"bullet ico ico-blueball-question\"></span>";
					} else {
						if ( obj.aData[ 7 ] > 180 ) {
							sReturn = "<span style=\"color: #F00\">" + sReturn + "</span>";
						}
					}
					return sReturn;
				}
			},
			{ "sTitle": "Tila", "sClass": "center" },
			{ "sTitle": "Ikä, vrk", "sClass": "center", "sType": "numeric" }
		]
	} );
}

var cBuild = function (olutid,reg) {
	cTable = $('#userccontent').dataTable( { 
		"bAutoWidth": false,
		"iDisplayLength": 10,
		"bJQueryUI": true,
		"bProcessing": false,
		"sAjaxSource": "http://olutopas.info/inc/oo/dt_comms3.php?id=" + olutid + "&reg=" + reg,
		"aaSorting": [[1,'desc']],
		"oLanguage": {
			"sUrl": "http://olutopas.info/inc/dt/fi_FI.txt"
		},
		"aoColumns": [
			{ "sTitle": "Ts-Aika", "sType": "numeric", "bSearchable": false, "bVisible": false },
			{ "sTitle": "Aika", "sType": "fi-date", "iDataSort": 0 },
			{ "sTitle": "Käyttäjä", "sType": "html" },
			{ "sTitle": "Kommentti", "sType": "text", "bSortable": false }
		]
	} );
}

var rBuild = function (olutid,reg) {
	rTable = $('#userrcontent').dataTable( { 
		"bAutoWidth": false,
		"sDom": '<"r_text"t>rflpi',
		"iDisplayLength": 10,
		"bJQueryUI": true,
		"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
			$('td:eq(0)', nRow).addClass( 'r_row' );
			return nRow;
		},
		"bProcessing": false,
		"sAjaxSource": "http://olutopas.info/inc/oo/dt_ratings3.php?id=" + olutid + "&reg=" + reg,
		"aaSorting": [[0,'desc']],
		"oLanguage": {
			"sUrl": "http://olutopas.info/inc/dt/fi_FI.txt"
		},
		"aoColumns": [
			{ "sTitle": "Ts-Aika", "sType": "numeric", "bSearchable": false, "bVisible": false },
			{ "sTitle": "Karma", "sType": "numeric", "bSearchable": false, "bVisible": false },
			{ "sTitle": "Käyttäjä", "sType": "html", "bSearchable": false, "bVisible": false },
			{ "sTitle": "Pisteet", "sType": "numeric", "bVisible": false },
			{ "sTitle": "Pisteet = Tuoksu + ulkonäkö + maku + suutuntuma + yleisvaikutelma", "sType": "text", "bSortable": false }
		]
	} );
	$("#bpiccontent").load("/inc/oo/be_bpic_html3.php", { 'id': olutid, 'reg': reg } );
}

var dAjax = function (olutid) {
	$("#datacontent").load("/inc/oo/be_bdata_html.php", { 'id': olutid } );
}

var dAistit = function (olutid) {
	$("#aistijat").load("/inc/oo/be_aistijat_html.php", { 'id': olutid } );
}

