	var tableWidget_okToSort = true;
	var tableWidget_arraySort = new Array();
	tableWidget_tableCounter = 1;
	var activeColumn = new Array();
	var currentColumn = false;
	
	function sortNumeric(a,b){
		
		a = a.replace(/,/,'.');
		b = b.replace(/,/,'.');
		a = a.replace(/[^\d\.\/]/g,'');
		b = b.replace(/[^\d\.\/]/g,'');
		if(a.indexOf('/')>=0)a = eval(a);
		if(b.indexOf('/')>=0)b = eval(b);
		return a/1 - b/1;
	}
	

	function sortString(a, b) {

	  if ( a.toUpperCase() < b.toUpperCase() ) return -1;
	  if ( a.toUpperCase() > b.toUpperCase() ) return 1;
	  return 0;
	}
		
	function sortTable()
	{
		if(!tableWidget_okToSort)return;
		tableWidget_okToSort = false;
		var obj = this;
		var indexThis = 0;
		while(obj.previousSibling){
			obj = obj.previousSibling;
			if(obj.tagName=='TD')indexThis++;		
		}
		
		if(this.getAttribute('direction') || this.direction){
			direction = this.getAttribute('direction');
			if(navigator.userAgent.indexOf('Opera')>=0)direction = this.direction;
			if(direction=='ascending'){
				direction = 'descending';
				this.setAttribute('direction','descending');
				this.direction = 'descending';	
			}else{
				direction = 'ascending';
				this.setAttribute('direction','ascending');		
				this.direction = 'ascending';		
			}
		}else{
			direction = 'ascending';
			this.setAttribute('direction','ascending');
			this.direction = 'ascending';
		}
		
		var tableObj = this.parentNode.parentNode.parentNode;
		var tBody = tableObj.getElementsByTagName('TBODY')[0];
		
		var widgetIndex = tableObj.getAttribute('tableIndex');
		if(!widgetIndex)widgetIndex = tableObj.tableIndex;
		
		if(currentColumn)currentColumn.className='';
		document.getElementById('col' + widgetIndex + '_' + (indexThis+1)).className='highlightedColumn';
		currentColumn = document.getElementById('col' + widgetIndex + '_' + (indexThis+1));

			
		var sortMethod = tableWidget_arraySort[widgetIndex][indexThis]; // N = numeric, S = String
		if(activeColumn[widgetIndex] && activeColumn[widgetIndex]!=this){
			if(activeColumn[widgetIndex])activeColumn[widgetIndex].removeAttribute('direction');			
		}

		activeColumn[widgetIndex] = this;
		
		var cellArray = new Array();
		var cellObjArray = new Array();
		for(var no=1;no<tableObj.rows.length;no++){
			var content= tableObj.rows[no].cells[indexThis].innerHTML+'';
			cellArray.push(content);
			cellObjArray.push(tableObj.rows[no].cells[indexThis]);
		}
		
		if(sortMethod=='N'){
			cellArray = cellArray.sort(sortNumeric);
		}else{
			cellArray = cellArray.sort(sortString);
		}
		
		if(direction=='descending'){
			for(var no=cellArray.length;no>=0;no--){
				for(var no2=0;no2<cellObjArray.length;no2++){
					if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
						cellObjArray[no2].setAttribute('allreadySorted','1');	
						tBody.appendChild(cellObjArray[no2].parentNode);				
					}				
				}			
			}
		}else{
			for(var no=0;no<cellArray.length;no++){
				for(var no2=0;no2<cellObjArray.length;no2++){
					if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
						cellObjArray[no2].setAttribute('allreadySorted','1');	
						tBody.appendChild(cellObjArray[no2].parentNode);				
					}				
				}			
			}				
		}
		
		for(var no2=0;no2<cellObjArray.length;no2++){
			cellObjArray[no2].removeAttribute('allreadySorted');		
		}

		tableWidget_okToSort = true;
		
		
	}
	function initSortTable(objId,sortArray)
	{
		var obj = document.getElementById(objId);
		obj.setAttribute('tableIndex',tableWidget_tableCounter);
		obj.tableIndex = tableWidget_tableCounter;
		tableWidget_arraySort[tableWidget_tableCounter] = sortArray;
		var tHead = obj.getElementsByTagName('THEAD')[0];
		var cells = tHead.getElementsByTagName('TD');
		for(var no=0;no<cells.length;no++){
			if(sortArray[no]){
				cells[no].onclick = sortTable;	
			}else{
				cells[no].style.cursor = 'default';	
			}
		}		
		/*for(var no2=0;no2<sortArray.length;no2++){
			if(sortArray[no2] && sortArray[no2]=='N')obj.rows[0].cells[no2].style.textAlign='right';
		}	*/	
		
		tableWidget_tableCounter++;
	}

	
	
	
	
	
	
	
	
	
function show_hide_div(state,object) {
//alert(object);
if(state) { object.style.display="block"; }
else { object.style.display="none"; }
}


function show_hide_div_id(state,object_id) {
var object = document.getElementById(object_id);
if(state) { object.style.display="block"; }
else { object.style.display="none"; }
}

function show_hide_div_id_inline(state,object_id) {
var object = document.getElementById(object_id);
if(state) { object.style.display="inline"; }
else { object.style.display="none"; }
}


function check_show_hide_div(object_id) {
//alert(object_id);
var object = document.getElementById(object_id);
//alert(object);
var current_display = object.style.display;
if (current_display=='block') { object.style.display="none"; }
else { object.style.display="block"; }
}

function check_show_hide_div1(object_id) {
var object = document.getElementById(object_id);
var current_display = object.style.display;
if (current_display=='block') { object.style.display="none"; }
else { object.style.display="none"; }
}

	
	
	
	
	
	
	
		
	
function open_new_window(url,w,h,scrollbars) {
winLeft = (screen.width-800)/2; 
winTop = (screen.height-720)/2; 
new_window = window.open(url,'my_window','scrollbars='+scrollbars+',toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width='+w+',height='+h+',left='+winLeft+',top='+winTop);
}
function go_to_delete(text,url) { if (confirm(text)) { location = url; } }
function checkAll(formId,cName,check) { for (i=0,n=formId.elements.length;i<n;i++) if (formId.elements[i].className.indexOf(cName) !=-1) formId.elements[i].checked = check; }
function uncheck_both(cislo) {
reject = eval("document.muj.reject_" + cislo);
approve = eval("document.muj.approve_" + cislo);
approve.checked = false; reject.checked = false;
}
function show_hide_div(state,object) {
//alert(object);
if(state) { object.style.display="block"; }
else { object.style.display="none"; }
}



function preview_window(url)
{ newwindow=window.open(url,'preview_window','width='+(screen.availWidth-150)+',height='+(screen.availHeight-150)+',left=10,right=10,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,location=yes');
  newwindow.focus();
}

