var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
	} else if (document.all)  {
		this.obj = document.all[name];
	} else if (document.layers)  {
		this.obj = document.layers[name];
	}
	return this.obj;
}

function objExist(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
	} else if (document.all)  {
		this.obj = document.all[name];
	} else if (document.layers)  {
		this.obj = document.layers[name];
	}
	if(this.obj) 
		return true;
	else 
		return false;
}


function divDsp(hideThis,dspState)
{
	if (!DHTML) return;
	var x = new getObj(hideThis);
	x.style.display = (dspState)? (dspState=='inline'?'':dspState) : (x.style.display=='inline'||x.style.display=='') ? 'none' : '';
}


function popup(href,width,height,win_name) {
	    if (!win_name) win_name = 'none';
	    var window_features = "height="+height+",width="+width+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,dependent=1,top=100,left=100";
		win = window.open(href,win_name,window_features);
		if(win) {win.focus();}
		return false;
}

function selectAll(selectBox){
	for(var i=0;i<selectBox.options.length;i++){
		selectBox.options[i].selected = true;
	}
	return;
}

function unSelectAll(selectBox){
	for(var i=0;i<selectBox.options.length;i++){
		selectBox.options[i].selected = false;
	}
	return;
}

function selectAllChecked(selectBox){
	for(var i=0;i<selectBox.length;i++){
		selectBox[i].checked = true;
	}
	return;
}

function unSelectAllChecked(selectBox){
	for(var i=0;i<selectBox.length;i++){
		selectBox[i].checked = false;
	}
	return;
}

function numOnly(el) {
	return el.value=el.value.replace(/[^0-9.]/g,'');
}

function Highlight(j,color) {
	if(!color) color 	= "#FFF8CB";
	var n 				= null;
	if (j.parentNode && j.parentNode.parentNode) {
		n = j.parentNode.parentNode;
	}
	else if (j.parentElement && j.parentElement.parentElement) {
		n = j.parentElement.parentElement;
	}
	if (n) {
		n.style.backgroundColor = color; //if (n.className == "row-color") {  } //E3F1FF //C1DDF2 //F4F6D3
	}
}

function Unhighlight(j) {
    var n = null;
	if (j.parentNode && j.parentNode.parentNode) {
		n = j.parentNode.parentNode;
	}
	else if (j.parentElement && j.parentElement.parentElement) {
		n = j.parentElement.parentElement;
	}
	if (n) {
		n.style.backgroundColor=n.getAttribute('bgcolor'); //if (n.className == "row-color") {  }
	}
}

function CheckRow(j,color) {
	if (j.checked) {
	    Highlight(j,color);
	} else {
	    Highlight(j,"#ffffff");
	}
}

function DrawMenu(obj,event) {

	thisObj 	= 'toolbar-menu';

	if (!objExist(thisObj)) return;
	var x = new getObj(thisObj);
	
	if (!(x.style.display=='inline' || x.style.display=='')) {
		x.style.display = 'inline';
	}
	
	x.style.position	= "absolute";
	x.style.zIndex 		= obj.style.zIndex + 1;
	
	if (navigator.appName=="Netscape") {
		showX = (event.pageX);
		showY = (event.pageY);
	} else {
		showX = (event.clientX);
		showY = (event.clientY);
	}
	newX = document.body.clientWidth-showX;
	x.style.right = newX;
	x.style.top = showY;
	
	obj.className = 'toolbar-hover';
}

function closeMenu() {
	thisObj 	= 'k-link';
	
	if (!objExist(thisObj)) return;
	var x = new getObj(thisObj);
	x.className = '';
	
	divDsp('toolbar-menu','none');
}
var timer;
function timeoutMenu() {
	timer = setTimeout("closeMenu()",800);
}

function clearMenuTimeout(){
		clearTimeout(timer);
}

function hoverDiv(t,classN) {
	t.className = classN;
}

/*
function InstallTimeout() {
		var sessionTimeout =  (1000*60)*180; //1000*10;
		timer = setTimeout('TimeOut()',sessionTimeout);
	}
	function TimeOut() {
		popLayer('','visible',350,110,80,screen.width,screen.height,'#000000','hidden'); 
		var sessionTimeout =  (1000*60)*5;
		timer2 = setTimeout('location.href=\'?action=do_logout&msg=inactive\'',sessionTimeout);

	}
*/
