
//These are the main functions for the Clearwater Toolbox

function popup(URL) {
    var windowprops = "left=100,top=20,width=800,height=650,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
    var win = window.open(URL,"graphic",windowprops);
	return;
}
function RTrim(field){
	while(''+field.value.charAt(field.value.length-1)==' ')
		field.value=field.value.substring(0,field.value.length-1);
	return;
}
function getElementFromId(tID) {
	var eID = tID;
	if (document.getElementById){
		// this is the way the standards work
		var elem = document.getElementById(eID);
	}else if (document.all){
		// this is the way old msie versions work
		var elem = document.all[eID];
	}else if (document.layers){
		// this is the way nn4 works
		var elem = document.layers[eID];
	}
	return elem;
}
function toggleLayer(eID){
	obj = getElementFromId(eID);
	obj.style.display = (obj.style.display=="block")? "none":"block";
	return;
}
function openTip(tID){
	var eID = tID;
	if(eval("tip_"+eID+"_show == 1")){
		toggleTip(eID,1);
		eval("matchSize('tip"+eID+"_content','tipIframe"+eID+"');");
		eval("tip_"+eID+"_show = 0;");
	}
	//alert("btip_"+eID+"_show = "+eval("tip_"+eID+"_show == 1")+";");
	return;
}
function closeTip(tID){
	var eID = tID;
	toggleTip(eID,0);
	eval("tip_"+eID+"_show = 0");
	//alert("tip_"+eID+"_show = "+eval("tip_"+eID+"_show"));
	return;
}
function toggleTip(tID,show){
	var eID = tID;
	obj = getElementFromId('tip'+eID);
	if(show==1 || show==0){
		obj.style.display = (obj.style.display=="block" || !show)? "none":"block";
	}else{
		obj.style.display = (obj.style.display=="block")? "none":"block";
	}
	matchSize('tip'+eID+'_content','tipIframe'+eID);
	return;
}
function matchSize(source_id,resize_id){
	var source = getElementFromId(source_id);
	var resize = getElementFromId(resize_id);
	if (document.layers){
        //alert('width = ' + source.document.width + ' height = ' + source.document.height);
        resize.style.width = source.document.width+2;
		resize.style.height = source.document.height+2;
    }else{
        //alert('width = ' + source.clientWidth + ' height = ' +  source.clientHeight);
        resize.style.width = source.clientWidth+2;
		resize.style.height = source.clientHeight+2;
	}
	return;
}