// JavaScript Document


	function NewWindow(mypage, myname, w, h, scr) {
//			var q = mypage.indexOf("?");
			var name = mypage.substr(0, 5);
			if( myname == 'name') myname = name;
			if( myname == 'name') myname = 'name';
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition;
		if(scr) settings = settings + ', scrollbars=yes';
		var win = window.open(mypage,myname,settings); win.focus();
		return false;
	}
	var dhtmlwin;
	function NewWindow_dhtml(url, name, width, height) {
	 dhtmlwin=dhtmlwindow.open("editbox", "iframe", url, " ", "width="+width+"px,height="+height+"px,resize=1,scrolling=1,center=1", "recal");
	}
	
	

	
	function getTable(table_id) {
		return document.getElementById(table_id);
	}
	
	function clearTable(table) {
		while(table.rows.length > 2) {	// excluding the header
			table.deleteRow(2);
		}
	}

	function clearTableEx(table, row_index) {
		while(table.rows.length > row_index) {	// excluding the header
			table.deleteRow(row_index);
		}
	}
	
	function addCell(row) {
		return row.insertCell(row.cells.length);
	}

	function addCells(row, count) {
		var cells = new Array();
		for(i = 0; i <  count; i++) {
			cells[i] = addCell(row);
		}
		return cells;
	}
	
	
	function addRow(tbl, color, row_id) {
			
			var lastRow = tbl.rows.length;
			var row = tbl.insertRow(lastRow);
			row.setAttribute("Bgcolor",  color);
			row.bgColor = color;
			row.id = row_id;
		return row;	  
	}
	
	function addBoldText(txt) {
		var bold = document.createElement("B");
		bold.innerHTML = txt;
		return bold;
	}
	function addText(txt) {
		var bold = document.createElement("span");
		bold.innerHTML = txt;
		return bold;
	}
		
	function addPopupLink(txt, url, w, h) {
		var linkNode = document.createElement('A');
		//var txtNode = document.createTextNode(txt);
		linkNode.innerHTML = txt;
		linkNode.href = '#';
		linkNode.onclick = function() { NewWindow(url, 'name', w, h, true); return false; }; 
		//linkNode.appendChild(txtNode);
		return linkNode;
	}

	function addLink(txt, url) {
		var linkNode = document.createElement('A');
		linkNode.href = url;
		linkNode.innerHTML=txt;
		return linkNode;
	}
		
	function addCheckBox(name, value, checked) {
			  var input = document.createElement('input');
			  input.name = name;
			  input.value = value;
			  input.type = 'checkbox';
		return input;
	}

	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}


	function ro(who, how) {
		if (how) who.style.backgroundColor='#E6E4D9'; else who.style.backgroundColor='#ffffff';		
	}
	
	function $$(element_id) {
		var element = document.getElementById(element_id);
		return element;
	}
	
	function restoreSearchBox() {
		if(getCookie('show_contractors_div') == 1) showHideSrch('contractors_div');
		if(getCookie('show_clients_div') == 1) showHideSrch('clients_div');
		if(getCookie('show_users_div') == 1) showHideSrch('users_div');
	
	}
	

	function hideDiv(element) { 
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(element).style.visibility = 'hidden'; 
			document.getElementById(element).style.display = 'none'; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.element.visibility = 'hidden'; 
				document.element.display = 'none'; 
			} 
			else { // IE 4 
				document.all.element.style.visibility = 'hidden'; 
				document.all.element.style.display = 'none'; 
			} 
		} 
	} 

	function showDiv(element) { 
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(element).style.visibility = 'visible'; 
			document.getElementById(element).style.display = 'block'; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.element.visibility = 'visible'; 
				document.element.display = 'block'; 
			} 
			else { // IE 4 
				document.all.element.style.visibility = 'visible'; 
				document.all.element.style.display = 'block'; 
			} 
		} 
	}

