/**********************************
          Hiding rows
***********************************/



	//alert(top.frames(4).document.body.innerHTML);
	//top.frames(4).document.body.innerHTML='';
	//top.mainframeset.cols="*,"+val+"";
	//top.frames(3).style.width='100%';
	//top.frames(4).document.body.style.display='none';




var full='';
var selectedOption;
var comboServEnabled;

function comboSelect(combo)
{
	if(comboServEnabled)
	{
		combo.selectedIndex=selectedOption;
	}
	else
	{
		selectedOption=combo.selectedIndex;
		full = "";
	}
}

function comboFind(combo)
{
	comboServEnabled=true;
	optlist='';

	if (self.event.keyCode == 38)
	{
	  full = "";
	  selectedOption = selectedOption - 1;
	  window.status=full;
	  return;
	}

	if (self.event.keyCode == 40)
	{
	  full = "";
	  selectedOption = selectedOption + 1;
	  window.status=full;
	  return;
	}

	if (event.keyCode == 27)
	{
	  combo.selectedIndex = 0;
	  full = "";
	  window.status=full;
	  return;
	}

	if (event.keyCode != 32)
	{
      if (event.keyCode < 65 || event.keyCode > 90)
         return;
	}

	full=full+String.fromCharCode(self.event.keyCode);
	window.status=full;

	for(ii=0;ii<combo.length;ii++)
	{
		if(combo.item(ii).text.substr(0,full.length).toLowerCase()==full.toLowerCase())
		{
			optlist=optlist+combo.item(ii).text;	
			selectedOption=ii;
			return;
		}
	}

	return;
}



function hideList()
{
	top.mainframeset.cols="*,0";
}

function showList()
{
	top.mainframeset.cols="*,245";
	//top.frames(3).document.body.style.display='none';
}


function number_format(dsep,tsep,scale,val)
{
	valfloor=Math.floor(val);
	valrest=val-valfloor;
	valrest=Math.round(valrest*Math.pow(10,scale))/Math.pow(10,scale);

	val=valfloor.toString();

	var valfinal='';
	for(ii=val.length;ii>0;ii--)
	{
		if((val.length-ii)%3 || valfinal=='')
			valfinal=val.substr(ii-1,1)+valfinal;
		else
			valfinal=val.substr(ii-1,1)+' '+valfinal;
	}

	if(valrest==0)
		valrest=Math.pow(10,scale).toString().substr(1);
	else
		valrest=valrest.toString().substr(2);
	
		

	valfinal=valfinal+','+valrest;

	//alert(valfinal);
	

	return valfinal;
}


function chooseTab(group)
{
	// show/hide rows
	for(ii=1;ii<document.all.tags('TR').length;ii=ii+1)
	{
		if(document.all.tags('TR')(ii).getAttribute('hide',false)==group)
			document.all.tags('TR')(ii).style.display='block';
		else
			if(document.all.tags('TR')(ii).getAttribute('hide',false)!=null)
				document.all.tags('TR')(ii).style.display='none';
	}
	
	// set tab colors
	var sNum=group.charAt(4); //type: string
	var i=0; //type:integer
	while(document.getElementById('tl'+i))
	{
		if(i==sNum)
		{
			document.getElementById('tl'+i).bgColor=_tabActiveBackgroundColor;
			document.getElementById('fl'+i).color=_tabActiveFontColor;
		}
		else
		{
			document.getElementById('tl'+i).bgColor=_tabInactiveBackgroundColor;
			document.getElementById('fl'+i).color=_tabInactiveFontColor;
		}
		i=i+1;
	}
}



function hideRows(group)
{
	var ison=0;

	for(ii=1;ii<document.all.tags('TR').length;ii=ii+1)
	{
		if(document.all.tags('TR')(ii).getAttribute('hide',false)==group)
		{
			if(document.all.tags('TR')(ii).style.display=='none')
				document.all.tags('TR')(ii).style.display='block';
			else
				document.all.tags('TR')(ii).style.display='none';
			
			ison=1;
		}
		else
		{
			if(ison==1)
				break;
		}
	}

	for(ii=0;ii<document.all.tags('INPUT').length;ii=ii+1)
	{
		if(document.all.tags('INPUT')(ii).value!='' && document.all.tags('INPUT')(ii).type!='button' && document.all.tags('INPUT')(ii).type!='submit' && document.all.tags('INPUT')(ii).type!='hidden')
			document.all.tags('INPUT')(ii).style.backgroundColor='#ffffaa';
	}

	for(ii=0;ii<document.all.tags('TEXTAREA').length;ii=ii+1)
	{
		if(document.all.tags('TEXTAREA')(ii).value!='')
			document.all.tags('TEXTAREA')(ii).style.backgroundColor='#ffffaa';
	}

	for(ii=0;ii<document.all.tags('SELECT').length;ii=ii+1)
	{
		if(document.all.tags('SELECT')(ii).value!='')
			document.all.tags('SELECT')(ii).style.backgroundColor='#ffffaa';
	}
}



/**********************************
          Floating headers
***********************************/

var startpos;
var firstrow=1;
var rowsShadow=new Array();

function toppos(item)
{
	if(item.tagName!='BODY')
		return(item.offsetTop+toppos(item.offsetParent));
	else
		return(item.offsetTop+document.body.clientTop);
}

function leftpos(item)
{
	if(item.tagName!='BODY')
		return(item.offsetLeft+leftpos(item.offsetParent));
	else
		return(item.offsetLeft+document.body.clientTop);
}


function initth()
{
	document.all.header0shadowtable.style.position='absolute';
	for(ii=1;ii<document.all.tags('TR').length;ii=ii+1)
	{
		if(document.all.tags('TR')(ii).getAttribute('h',false)!=null)
		{
			if(firstrow)
			{
				document.all.header0shadowtable.width=document.all.tags('TR')(ii).parentElement.parentElement.offsetWidth+1;
				document.all.header0shadowtable.style.pixelLeft=leftpos(document.all.tags('TR')(ii).offsetParent.offsetParent)-2;
				startpos=toppos(document.all.tags('TR')(ii));
				firstrow=0;
				document.recalc();
			}
	
			newrow=document.all.header0shadowtable.insertRow(document.all.header0shadowtable.rows.length);
			ii=ii+1;

			for(jj=0;jj<document.all.tags('TR')(ii).cells.length;jj=jj+1)
			{
				newcell=newrow.insertCell(newrow.cells.length);
				newcell.innerHTML=document.all.tags('TR')(ii).cells(jj).innerHTML;
				newcell.colSpan=document.all.tags('TR')(ii).cells(jj).colSpan;
				newcell.rowSpan=document.all.tags('TR')(ii).cells(jj).rowSpan;
				newcell.align=document.all.tags('TR')(ii).cells(jj).align;
				newcell.vAlign=document.all.tags('TR')(ii).cells(jj).vAlign;
				newcell.className=document.all.tags('TR')(ii).cells(jj).className;
				newcell.width=document.all.tags('TR')(ii).cells(jj).offsetWidth;
				newcell.bgColor=document.all.tags('TR')(ii).cells(jj).bgColor;
				newcell.background=document.all.tags('TR')(ii).cells(jj).background;
			}
			document.recalc();
		}
	}
	showth();
}

function showth()
{
	if(document.body.scrollTop>startpos)
	{
		document.all.header0shadowtable.style.display='block';
		document.all.header0shadowtable.style.background='white';
		delta=(document.body.scrollTop-document.all.header0shadowtable.style.posTop)/10;
		if(delta<1 && delta>-1)
			document.all.header0shadowtable.style.posTop=document.body.scrollTop;
		else
			document.all.header0shadowtable.style.posTop=document.all.header0shadowtable.style.posTop+delta;
	}
	else
	{
		document.all.header0shadowtable.style.display='none';
	}
	var timer=setTimeout('showth()',20);
}

function switchmenu()
{
	if(document.all.menuslim.style.display=='none')
		document.all.menuslim.style.display='block';
	else
		document.all.menuslim.style.display='none';
}


/**********************************
          PopUp Layouts
***********************************/

function ret(Val){
  opener.popUpField.value = Val;
  window.close()
}

/*********************************************************************
JavaScript 1.2 Validation Script (IE and Netscape)
	version 1.02
	by matthew frank

There are no warranties expressed or implied.  This script may be
re-used and distrubted freely provided this header remains intact
and all supporting files are included (unaltered) in the distribution:

		nn-validation.js   - this file
		nn-validation.htm  - example form
		nn-readme.htm      - directions on using this script
		(nn-validation.zip contains all files)

If you are interested in keeping up with the latest releases of this
script or asking questions about its implementation, think about joining
the eGroups discussion forum dedicated to data validation:

	http://www.egroups.com/group/validation

*********************************************************************/


function Validation()
{
	var Err=function()
	{
		var oSource  = new Object;
		var sMessage = new String;
		this.clear=function ()
		{
			oSource  = new Object;
			sMessage = new String;
		}
		this.add=function (oSrc,sMsg)
		{
			oSource  = oSrc;
			sMessage = sMsg;
		}
		this.raise=function ()
		{
			var sName = oSource.NAME;
			var sMsg  = oSource.MSG;
			
			// Alert appropriate error message
			sMsg = sMsg ? sMsg : sMessage + (sName ? " in the "+sName+" field" : "");
			alert(sMsg);
			//1.07.2003 TOMS choose tab to show oSource
			var obj = oSource;
			while(obj&&obj.tagName!='TR') 
			obj=obj.parentNode;
			if(obj && obj.hide)
				chooseTab(obj.hide);
			// Give invalid field focus
			if(oSource.focus)
				oSource.focus();
			if(oSource.select)
				oSource.select();
			// Clear the Err object
			this.clear();
		}
	}
	var getValueOf=function (oElement)
	{
		var sReturnValue = null;
		switch (oElement.type)
		{
			case "text" : case "textarea" : case "file" : case "password" : case "hidden" :
				sReturnValue = oElement.value;
				break;
			case "select-one" :
				sReturnValue=oElement.options[oElement.selectedIndex].value;
				if(sReturnValue==0)
					sReturnValue = null;
				break;
			case "select-multiple" :
				var i, iOptions = oElement.options.length;
				for(i=0; i<iOptions; i++)
					if(oElement.options[i].selected && oElement.options[i].value.toString().trim())
					{
						sReturnValue = true;
						break;
					}
				break;
			case "radio" : case "checkbox" :
				if(oElement.checked)
					sReturnValue = oElement.value ? oElement.value : true;
				break;
		}
		return sReturnValue;
	}
	this.setup=function ()
	{
		// Fan through forms on page to perform initializations
		var i,oForm,iForms=document.forms.length;
		for(i=0; i<iForms; i++){
			oForm=document.forms[i];
			if(!oForm.bProcessed)
			{
				// Capture and replace onsubmit event handler
				var fnSubmit=oForm.onsubmit;

				// Create new event handlers
				oForm.onsubmit=function ()
				{
					// Execute onbeforevalidate processing
					if(typeof this.onbeforevalidate=="function" && this.onbeforevalidate()==false)
						return false;
					var i, oElement, iElements=this.elements.length;
					// Validate individual elements
					for(i=0;i<iElements;i++)
					{
						oElement=this.elements[i];
						// Perform default validation for element
						if (!oElement.valid())
						{
							Validation.Err.raise();
							return false;
						}
					}
					// Execute onaftervalidate processing
					if(typeof this.onaftervalidate=="function" && this.onaftervalidate()==false)
						return false;

					// Perform original onsubmit event handler
					if (fnSubmit && fnSubmit()==false)
						return false;
				}
				oForm.bProcessed=true;
			}
			// Create Input methods
			var j, iElements=oForm.elements.length;
			for(j=0; j<iElements; j++)
			{
				var oElement=oForm.elements[j];
				if(!oElement.bProcessed)
				{
					oElement.valid=function ()
					{
						// Trim leading and trailing spaces
						if(this.value)
							this.value = this.value.trim();
						var sValue = getValueOf(this);
						// REQUIRED
						if(this.REQUIRED && !sValue)
						{
							Validation.Err.add(this, "Please enter a value");
					 		return false;
						}
						// REGEXP
						var oRegexp=this.REGEXP;
						if(oRegexp && oRegexp.constructor==RegExp && sValue)
						{
							
							if(!oRegexp.test(sValue))
							{
								Validation.Err.add(this, "Please enter a valid value");
								return false;
							}
						}
						// Perform onvalidate event handler
						if(typeof this.onvalidate=="function" && this.onvalidate()==false)
							return false;

						return true;
					}
					oElement.bProcessed=true;
				}
			}
		}
	}
	// Limit use of script to valid environments
	if("".replace && window.RegExp)
	{
		String.prototype.trim=function ()
		{
			return this.replace(/^\s+|\s+$/g,"");
		}

		// Form setup
		if(document.forms)
		{
			this.setup();
			this.Err=new Err;
		}
	}
}