


function html_lock_screen(htmlCode){

}



function form_getElementValue(id){
	var obj = document.getElementById(id);
	if(obj!=null){
		switch(obj.tagName){
			case "TEXTAREA":
			case "INPUT":{
				if(typeof(obj.value)!="undefined"){
					return obj.value;
				}
			}
			case "SELECT":{
				return select_getValue(id);
			}
			default:{
				alert("Provided element is not supported by method [form_getElementValue]");
				return false;
			}
		}
	}
	return null;
}




function html_clearElement(obj){
	var obj = dojo.byId(obj);
	while(obj.firstChild!=null){obj.removeChild(obj.firstChild);}
	return obj;
}

//TABLE
function JsTable(parent, id,isLast)
{
	this.tBody;
	this.tHead;
	this.parent = parent;
	this.table = document.createElement('table');
	this.table.id = id;
	if(typeof(isLast)=="undefined"){
		this.parent.appendChild(this.table);
	}else{
		if(isLast){
			this.parent.appendChild(this.table);
		}else{
			this.parent.insertBefore(this.table,this.parent.firstChild);
		}
	}
	this.tBody = document.createElement('tbody');
	this.tHead = document.createElement('thead');

	this.table.appendChild(this.tBody);
	this.table.appendChild(this.tHead);

	this.getTable = _JsTableGetTable;
	this.getTableBody = _JsTableGetTableBody;
	this.getTableHead = _JsTableGetTableHead;
	this.getParent = _JsTableGetParent;
	this.addRow = _JsTableAddRow;
	this.getRowById = _JsTableGetRowById;
	this.removeRow = _JsTableRemoveRow;
	this.removeRowById = _JsTableRemoveRowById;
	this.removeAllRows = _JsTableRemoveAllRows;
	this.clearRow = _JsTableClearRow;
	this.clearRowById = _JsTableClearRowById;
	this.addCell = _JsTableAddCell;
	this.addCellToRow = _JsTableAddCellToRow;
	this.removeCell = _JsTableRemoveCell;
	this.removeCellById = _JsTableRemoveCellById;
}

	function _JsTableInitialize(parent, table)
	{
		this.parent = parent;
		this.table = table;
		this.parent.appendChild(this.table);
		this.tBody = document.createElement('tbody');
		this.tHead = document.createElement('thead');

		this.table.appendChild(this.tBody);
		this.table.appendChild(this.tHead);

	}
	function _JsTableGetTable()
	{
		return this.table;
	}

	function _JsTableGetTableBody()
	{
		return this.tBody;
	}

	function _JsTableGetTableHead()
	{
		return this.tHead;
	}

	function _JsTableGetParent()
	{
		return this.parent;
	}

	function _JsTableAddRow(id)
	{
		var row = document.createElement('tr');
		row.id = id;
		this.tBody.appendChild(row);

		return row;
	}

	function _JsTableGetRowById(id)
	{
		for (var i in this.tBody.childNodes)
		{
			child = this.tBody.childNodes[i];
			if (child.id == id)
			{
				return child;
			}
		}

		return false;
	}

	function _JsTableRemoveRow(row)
	{
		return this.tBody.removeChild(row);
	}

	function _JsTableRemoveRowById(id)
	{
		var result = this.getRowById(id);

		if (result)
		{
			this.tBody.removeChild(result);
		}

		return result;
	}

	function _JsTableRemoveAllRows()
	{
		while (this.tBody.firstChild != null)
		{
			this.tBody.removeChild(this.tBody.firstChild);
		}
	}

	function _JsTableClearRow(row)
	{
		while (row.firstChild != null)
		{
			row.removeChild(row.firstChild);
		}
	}

	function _JsTableClearRowById(rowId)
	{
		var result = this.getRowById(rowId)

		if (result)
		{
			this.clearRow(result);
		}
		else
			return false;
	}

	function _JsTableAddCell(row, cellId)
	{
		var cell = document.createElement('td');
		cell.id = cellId;

		row.appendChild(cell);

		return cell;
	}

	function _JsTableAddCellToRow(rowId, cellId)
	{
		var result = this.getRowById(rowId);

		if (result)
		{
			return this.addCell(result, cellId);
		}
		else
			return false;
	}

	function _JsTableRemoveCell(cell)
	{
		cell.parentNode.removeChild(cell);
	}

	function _JsTableRemoveCellById(cellId)
	{
		for (var i in this.tBody.childNodes)
		{
			child = this.tBody.childNodes[i];
			for (var j in child.childNodes)
			{
				cell = child.childNodes[j];

				if (cell.id == cellId)
				{
					child.removeChild(cell);
					return cell;
				}
			}
		}
	}



	function isObject(obj){
		return typeof obj == "object" && obj!=null;
	}


	
	
	function array_contains(obj,value){
		if(array_indexOf(obj,value)>-1){
			return true;
		}
	}
	
	function array_indexOf(obj,value){
		if(isObject(obj)){
			for(var i in obj){
				if(value == obj[i]){
					return i;
				}
			}
		}
		return -1;
	}	
	
	
	
	
	
	
	




function select_chooseItem(selBox,selectedItem){
	selBox = dojo.byId(selBox);
	for(var i in selBox.options){
		if(selBox.options[i]!=null){
			if(selBox.options[i].value == selectedItem){
				selBox.options.selectedIndex = i;
				return true;
			}
		}
	}
	return false;
}

function select_getValue(optBox){
	optBox = dojo.byId(optBox);
	if(optBox.selectedIndex==-1){return false;}
	return optBox.options[optBox.selectedIndex].value;
}

function select_getSelected(optBox){
	optBox = dojo.byId(optBox);
	var selected = new Array();
	var index = 0;
	for (var intLoop=0; intLoop < optBox.length; intLoop++) {
		if (optBox[intLoop].selected) {
			index = selected.length;
			selected[optBox[intLoop].value] = optBox[intLoop].text;
		}
	}
	return selected;	
}



function select_clear(selBox){
	selBox = dojo.byId(selBox);
	//opener.console.log("SELECT BOX");
	//opener.console.dir(selBox);
	if(selBox!=null&& typeof selBox == "object"){
		if(selBox.options!=null&& typeof selBox.options == "object"){
			var count = selBox.options.length;
			for(var i=count-1;i>=0;i--){
				selBox.options[i] = null;
			}
		}
	}
}

function select_toArray(selBox){
	selBox = dojo.byId(selBox);
	
}

function select_addOptions(selBox,items){
	selBox = dojo.byId(selBox);
	var count = selBox.options.length;
	for(var i=0;i<items.length;i++){
		selBox.options[i+count] = new Option(items[i].text,items[i].value);
	}
}

function select_setOptions(selBox,items){
	select_clear(selBox);
	select_addOptions(selBox,items);
}

function select_fillFromArray(selBox,arr){
	selBox = dojo.byId(selBox);
	var nInst = new Array();
	for(var i in arr){
		var tmpInst = new Object();
		tmpInst.text = arr[i];
		tmpInst.value = i;
		nInst.push(tmpInst);
	}
	select_setOptions(selBox,nInst);
}

function select_getContent(selBox){
	selBox = dojo.byId(selBox);
	var reply = new Array();
	for(var i=0;i<selBox.options.length;i++){
		reply [selBox.options[i].value] = selBox.options[i].text;
	}
	return reply;
}

function select_swapItems(fromIndex,toIndex,selBox){
	selBox = dojo.byId(selBox);

	if(toIndex>=selBox.options.length){ return false;}
	if(toIndex<0){return false;}
	
		var fText  = selBox.options[fromIndex].text;
	    var fValue = selBox.options[fromIndex].value;
	    
	    //make first = second
	    selBox.options[fromIndex].text  = selBox.options[toIndex].text;
	    selBox.options[fromIndex].value = selBox.options[toIndex].value;  
	    
	    //make second = first
	    selBox.options[toIndex].text = fText;
	    selBox.options[toIndex].value = fValue;
	    
	    //amke new one be selected
	    selBox.options[toIndex].selected = true;  
	    
	return true;  
}

function select_getOrder(selBox){
	selBox = dojo.byId(selBox);
	var reply = new Array();
    for (i = 0; i <= selBox.options.length-1; i++){   
        reply.push(selBox.options[i].value);
    }	
    return reply;
}


