
		jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = 
			function ( oSettings, iDelay ) { 
				iDelay = (iDelay && (/^[0-9]+$/.test(iDelay))) ? iDelay : 500; 
				var $this = this, oTimerId; 
				var anControl = $( 'div.dataTables_filter input:text' ); 
				anControl.unbind( 'keyup' ).bind( 'keyup', function() { 
					var $$this = $this; 
					window.clearTimeout(oTimerId); 
					oTimerId = window.setTimeout(function() { 
					$$this.fnFilter( anControl.val() ); 
				}, iDelay); 
			}); 
			return this; 
		}
//----------------------------------------------------------------------

		$(document).ready(function() {
			getDeviceList();
		});	
//----------------------------------------------------------------------

	var device_list = undefined;

	function getDeviceList() {
		if(typeof(device_list) == 'undefined')
		{
			device_list = $('#solar_table').dataTable( {
					"bJQueryUI": true,
					"bProcessing": true,
          "bServerSide": true,
          "sAjaxSource": "resource/data/load_devices.php",
          "bPaginate": true,
					"bStateSave": true,
					"bFilter": true,
					"bSort": true,
					"bInfo": true,
					"bLengthChange": true,
					"iDisplayLength": 25,
					//"aLengthMenu": [20, 40, 60, 100],
          "sPaginationType": "full_numbers",
					"oLanguage": {
						"sLengthMenu": "<span id=\"_show\">&nbsp;</span> _MENU_ <span id=\"entries_on_page\">&nbsp;</span>",
						"sZeroRecords": "<span id=\"no_entry\">&nbsp;</span>",
						"sInfo": "<span id=\"showing\">&nbsp;</span> _START_ <span id=\"do\">&nbsp;</span> _END_ <span id=\"z\">&nbsp;</span> _TOTAL_ <span class=\"records\">&nbsp;</span>",
						"sInfoEmpty": "<span id=\"zero_show\">&nbsp;</span>",
						"sInfoFiltered": "(<span id=\"filtering\">&nbsp;</span> _MAX_ <span class=\"records\">&nbsp;</span>)",
						"sSearch": "<span id=\"search\">&nbsp;</span>",
						"oPaginate": 
						{
							'sNext': '&gt;',
							'sLast': '&gt;&gt;',
							'sFirst': '&lt;&lt;',
							'sPrevious': '&lt;'
						}			
					},
					"fnDrawCallback": function(oSettings, json) {
						locIndex();
					},
					"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
						$('td:eq(1)', nRow).html('<a href="resource/fve.php?id=' + aData[0] + '&dev=' + aData[2] + '&link=' + aData[7] + '">' + aData[2] + '</a>');
						$('td:eq(6)', nRow).html(((aData[5] > 0) ? Math.round((aData[6] / aData[5])*100, 0) : '0') + '%'); 
            $('td:eq(7)', nRow).html('<img src="'+ aData[8] + '" title="' + aData[11] + '" alt="" />');
						var state = '<img src="' + aData[1] + '" title="' + aData[9] + '" alt="" border="0">';
						if (aData[10] != 1)
						{	
							$('td:eq(0)', nRow).html( state );						
							$('td:eq(1)', nRow).html('<a href="#" onclick="document.loginForm.action=\'index.php\';return document.loginForm.submit();">' + aData[2] + '</a>');
							$('td:eq(3)', nRow).html('---');
							$('td:eq(4)', nRow).html('---');
							$('td:eq(5)', nRow).html('---');
						}
						else
							$('td:eq(0)', nRow).html( ((aData[7]) ? '<a target="_blank" href="http://'+aData[7]+'">'+state+'</a>' : state ));
						
						return nRow;
					},
					"aoColumns": [  
						{"bVisible": false},
						{"bSortable": false, "sClass": "center", "sWidth": "0px"},
						{"sClass": "left", "sWidth": "250px"},
						{"sClass": "center", "sWidth": "145px"},
						{"bSortable": sorted, "sClass": "center","sWidth": "140px"},
						{"bSortable": sorted, "sClass": "center","sWidth": "140px"},
						{"bSortable": sorted, "sClass": "center", "sWidth": "140px"},
						{"bVisible": false },
						{"bVisible": false },
						{"bVisible": false },
						{"bVisible": false },
						{"bVisible": false },
						{"bSortable": false, "sClass": "center", "sWidth": "0px"},					
						{"bSortable": false, "sClass": "center", "sWidth": "0px"}
					]
				} ).fnSetFilteringDelay();
			}
			else
			{
				device_list.fnSettings().sAjaxSource = "resource/data/load_devices.php";
				device_list.fnDraw();
			}
	}
//----------------------------------------------------------------------
	
	function locIndex() {		
		$.localise('js/localisation', {language: readCookie("language") , loadBase: true});	
		$("#device").text(device);
		$(".update").text(update);
		$(".act_power").text(act_power + " [kW]");
		$(".inst_vykon").text(ins_vykon + " [kW]");
		$("#produced").text(produced);
    $('#name').text(jmeno);
    $("#pass").text(heslo);  
    $(".login input:submit").val(prihlasit);
		$("#invalid_login").text(invalid_login);
		$("#logout").text(logout);
		$("#settings").text(settings);

		$("#_show").text(_show);
		$("#entries_on_page").text(na_stranu);
		$("#no_entry").text(no_entry);
		$("#search").text(search);
		$("#zero_show").text(zero_show);
		$("#showing").text(showing);
		$("#do").text(_do);
		$("#z").text(_z);
		$(".records").text(records);
	}
//----------------------------------------------------------------------																									
	
																						



