function erase(id)
{
	document.getElementById(id).value = '';
}

function hideTree(id)
{
	mImg = document.getElementById('img' + id);
	mSec = document.getElementById('s' + id)
	if(mSec.style.display=='none'){
		mSec.style.display='';
		mImg.className="open";
	} else {
		mSec.style.display='none';
		mImg.className="closed";
	}
}

function hideMe(id)
{
	mImg = eval("document.img" + id);
	if(document.getElementById(id).style.display=='none'){
		document.getElementById(id).style.display='';
		mImg.src="{/literal}{$srIm}{literal}_-.gif";
	} else {
		document.getElementById(id).style.display='none';
		mImg.src="{/literal}{$srIm}{literal}_+.gif";
	}
}

function hideBox(id)
{
	mImg = eval("document.img" + id);
	if(document.getElementById(id).style.display=='none'){
		document.getElementById(id).style.display='';
		mImg.src="{/literal}{$srIm}{literal}_min.gif";
	} else {
		document.getElementById(id).style.display='none';
		mImg.src="{/literal}{$srIm}{literal}_max.gif";
	}
}

function closeBox(id)
{
	document.getElementById(id).style.display='none';
}

function execute($text, $url)
{
	window.status='';
	if(!confirm($text))return;
	this.window.location=$url;
}

function executeForm($text)
{
   return confirm($text);
}

function maskKeyPress(objEvent)
{
	var iKeyCode;
	if (window.event) iKeyCode = window.event.keyCode;
	else if (objEvent) iKeyCode = objEvent.which;
	if(iKeyCode==34 || iKeyCode==37 || iKeyCode==39 || iKeyCode==8 || iKeyCode==46)return false;
	return true;
}

function maskKeyPressNumer(objEvent)
{
	var iKeyCode;
	if (window.event) iKeyCode = window.event.keyCode;
	else if (objEvent) iKeyCode = objEvent.which;
	if((iKeyCode>=48 && iKeyCode<=57) || iKeyCode==8 || iKeyCode==13 || iKeyCode==32 || iKeyCode==0)return true;
	return false;
}

function maskKeyPressFloat(objEvent)
{
	var iKeyCode;
	if (window.event) iKeyCode = window.event.keyCode;
	else if (objEvent) iKeyCode = objEvent.which;
	if((iKeyCode>=48 && iKeyCode<=57) || iKeyCode==8 || iKeyCode==13 || iKeyCode==32 || iKeyCode==46 || iKeyCode==0 || iKeyCode==44)return true;
	return false;
}

function maskKeyPressAlfaNumer(objEvent)
{
	var iKeyCode;
	
	if (window.event) iKeyCode = window.event.keyCode;
	else if (objEvent) iKeyCode = objEvent.which;
	/*alert(iKeyCode);*/
	if((iKeyCode>=48 && iKeyCode<=57) || (iKeyCode>=65 && iKeyCode<=90) || (iKeyCode>=97 && iKeyCode<=122) || iKeyCode==8 || iKeyCode==13 || iKeyCode==32 || iKeyCode==0 || iKeyCode==45 || iKeyCode==46){
		return true;
	}
	return false;
}

function maskKeyPressEmail(objEvent)
{
	var iKeyCode;
	
	if (window.event) iKeyCode = window.event.keyCode;
	else if (objEvent) iKeyCode = objEvent.which;
	if((iKeyCode>=48 && iKeyCode<=57) || (iKeyCode>=65 && iKeyCode<=90) || (iKeyCode>=97 && iKeyCode<=122) || iKeyCode==8 || iKeyCode==13 || iKeyCode==32 || iKeyCode==64 || iKeyCode==46 || iKeyCode==45 || iKeyCode==95 || iKeyCode==0)return true;
	return false;
}

function infoOn(event, text){
	mobj = document.getElementById('info');
	mobj2 = document.getElementById('iText');
	pause(200);
	if(mobj.style.display=='none'){
		mobj.style.display='';
		mobj2.innerHTML = text;
		mobj.style.left=event.clientX;
		mobj.style.top=event.clientY-30;
	} else {
		mobj.style.display='none';
		mobj2.innerHTML = '';
	}
}

function infoOff(){
	mobj = document.getElementById('info');
	mobj2 = document.getElementById('iText');
	pause(500);
	mobj.style.display='none';
	mobj2.innerHTML = '';
}

function end(){
	w = window.open("clear.php", '', 'width=0, height=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no');
}


/****************************************/

function pause(numberMillis){
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while(true){
		now = new Date();
		if (now.getTime() > exitTime)return;
	}
}
		
function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if(typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [scrOfX, scrOfY];
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function isUndefined(f) {
	return (typeof(f)=='undefined');
}

function isEmpty(f) {
	return f==null || isUndefined(f);
}

function isArray(f) {
	return typeof(f)=="object" && !isUndefined(f.length);
}

function getObj(id) {
	var o;
	if (document.getElementById)
		o = document.getElementById(id);
	else if (document.all)
		o = document.all[id];
	if (isUndefined(o))
		o = null;
	return o;
}

function showObj(id, show) {
	if (isArray(id)) {
		var i;
		for(i=0; i<id.length; i++) {
			showObj(id[i], show);
		}
		return;
	}

	var o = getObj(id);
	if (o==null)
		return false;
	if (isUndefined(show))
		show = true;
	return o.style.display = (show ? "" : "none");
}

function checkAll(field, check) {
	var i;
	if (isEmpty(field))
		return;
	if (isUndefined(field.length)) {
		field.checked = check;
	} else {
		for(i=0; i<field.length; i++)
			field[i].checked = check;
	}
}

function isChecked(field) {
	var i;
	if (isUndefined(field.length)) {
		return field.checked;
	} else {
		for(i=0; i<field.length; i++) {
			if (field[i].checked)
				return true;
		}
		return false;
	}
}

function isSelected(f, i) {
	if (isUndefined(i))
		i = 0;
	try {
		return f.options[i].selected;
	} catch(e) {
	}
	return false;
}

function clearForm(f) {
	var i, e;
	for(i=0; i<f.elements.length; i++) {
		e = f.elements[i];
		switch(e.type) {
		case "select-one":
			if (e.options.length>0)
				e.selectedIndex = 0;
			break;
		case "text":
			e.value = "";
			break;
		}
	}
}

function addBookmark(){
	var bookmarkurl = document.location;
	var bookmarktitle = document.title;

	if(window.external){
		window.external.AddFavorite(bookmarkurl, bookmarktitle);
	} 
	if(window.sidebar){
		window.sidebar.addPanel(bookmarkurl, bookmarktitle, "");
	}

	/*if(document.all){ 
		window.external.AddFavorite(bookmarkurl, bookmarktitle);
	}*/
} 
