<!--//for MSIE to work
function getElementWithId(id)
{
	if (document.getElementById)
		// this is the way the standards work
		return document.getElementById(id);
	
	else if (document.all)
	// this is the way old msie versions work
		return document.all[id];
	
	else if (document.layers)
	// this is the way nn4 works
		return document.layers[id];
	
}


function disableItem(name)
{
	getElementWithId(name).disabled="1";
}

function enableItem(name)
{
	getElementWithId(name).disabled="";
}

function hideItem(name)
{
	getElementWithId(name).style.display = "none"

/*	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(name).style;
		style2.display = "none"
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[name].style;
		style2.display = "none"
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[name].style;
		style2.display = "none"
	}*/					
}

function showItem(name)
{
	getElementWithId(name).style.display = ""

// 	if (document.getElementById)
// 	{
// 		// this is the way the standards work
// 		var style2 = document.getElementById(name).style;
// 		style2.display = ""
// 	}
// 	else if (document.all)
// 	{
// 		// this is the way old msie versions work
// 		var style2 = document.all[name].style;
// 		style2.display = ""
// 	}
// 	else if (document.layers)
// 	{
// 		// this is the way nn4 works
// 		var style2 = document.layers[name].style;
// 		style2.display = ""
// 	}					
}	

function showHideItem(name)
{
	var style = document.getElementById(name).style;
	if(style.display == "none")
		showItem(name);
	else
		hideItem(name);
}

function sortDataBy(fieldName)
{
	document.searchForm.sortDataBy.value = fieldName;
	document.searchForm.submit();
}

function listOnMouseOver(obj)
{
	obj.className = "list-mouse-over";
}

function listOnMouseOut(obj)
{
	obj.className = "list-mouse-out";
}



/*
 *function to remove leading and trailing spaces
 */
function trimStr(inString) 
{
	inString = inString.replace( /^\s+/g, "" );// strip leading
	return inString.replace( /\s+$/g, "" );// strip trailing
}

//-------------------------------------------------------------------------------
// checking Input function (Same as commonIndex's one, but those are in PHP)
//-------------------------------------------------------------------------------
	function isInteger(input)
	{
  	var filter  = /^(\d+)*$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;
  }

	function isContactNum(input)
	{
  	var filter  = /^[0-9-+ ]*$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;
	}  

	function isFloat(input)
	{
  	var filter  = /^(\d+)*\.?(\d+)*$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;
	}
	
	function isCurrency(input)
	{
  	var filter  = /^[-+]?[ ]*[$]?[ ]?(\d+)?\.?\d{0,2}$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;    
	}
  	
  function isEmail(input)
  {
  	var filter  = /^[a-zA-Z0-9]([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;
  }

	function isDate(input)
	{
  	var filter  = /^(19|20|21)\d\d([-])(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;
	}	
  
	function isDateTime(input)
	{
  	var filter  = /^(19|20|21)\d\d([-])(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) (0[0-9]|1[0-9]|2[0123]):([0-5][0-9]):([0-5][0-9])$/;
  	if(!filter.test(input)) 
  		return false;
  	return true;    	
	}	  	

/*
 * convert to two digits and currency format
 */
function convertDigitToCurrency(tmp, dollarSym)
{
	tmp = tmp * 100;
	tmp = Math.round(tmp)/100;

	tmp = tmp.toFixed(2);	

	return (dollarSym)?'S$'+tmp:tmp;

//this commented script has problem display about 1000 bucks
//     var alertbox=false;
//     var tmp;
//     tmp = tmp*100;
//     tmp = Math.round(tmp);
//     if(isNaN(tmp)) {tmp = 0.00;}
//     if(tmp>99999999999)alert("trillion is not supported - only millions.");
//     /* converts tmp to decimal cents and adds a 0 to .1 to .9 or adds .00 to 0 */
//     cen = tmp%100;
//     if(cen < 0){cen = ".00"}
//     else if(cen <10) {cen = ".0"+cen}
//     else if(cen < 100){cen = "."+cen}
//     else {cen = cen}
//     if(alertbox)alert("Cents "+cen);  /* Cents alert dialog box */
// 
//     tmp = parseInt(tmp/100);
//     hun = tmp - ((parseInt(tmp/1000)) *1000 );
//     if(hun > 0 && hun <1000) {hun = hun}
//     else {hun = ''}
//     if(alertbox)alert("Hundreds "+hun); /* Hundreds alert dialog box */
// 
//     tmp = parseInt(tmp/1000)
//     tho = tmp -((parseInt(tmp/1000)) *1000);
//     if(tho > 0 && tho < 1000) {tho = tho +","}
//     else {tho = ''}
//     if(alertbox)alert("Thousands "+tho);  /* Thousands dialog box */
// 
// 
//     tmp = parseInt(tmp/1000);
//     mil = tmp -((parseInt(tmp/1000)) *1000);
//     if(mil > 0 && mil < 1000) {mil = mil + ","}
//     else {mil = ''}
//     if(alertbox)alert("Millions "+mil); /* Millions dialog box */
//     if(alertbox)alert("$"+mil+tho+hun+cen); /* Convert tmp to Currency */
// 
// 
//     if(dollarSym)
//         return "$"+mil+tho+hun+cen;
//     else
//         return mil+tho+hun+cen;
}


//------------------------------------------------------------------------------------------------------------------------------------

function submitForm(inActionName)
{
	var formObj = document.functionForm;
	formObj.actionForm.value=inActionName;

	if(formObj.onsubmit==null) {
		formObj.submit();
	} else if(formObj.onsubmit!=null) {
		// If there is no onSubmit at the form, it will just submit
// 		if(formObj.onsubmit()) {
			formObj.submit();
// 		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------

function confirmSubmitForm(formObj, newActionFormValue, msg)
{
	var agree= true;
	if(msg!="")
	{
		agree=confirm(msg);
	}
	
	if (agree)	
	{
		if(newActionFormValue!="")
		{
			formObj.actionForm.value=newActionFormValue;
		}

    // If there is no onSubmit at the form, it will just submit
		if(formObj.onsubmit==null)
		{
		  formObj.submit();
		}
		else if(formObj.onsubmit!=null)
		{
		  // If there is no onSubmit at the form, it will just submit
  		if(formObj.onsubmit())
  		{
  		  formObj.submit();
      }
    }	
	}
	else
		return false ;				
}	

//constant value for collection method by mail
var CHARGES_VALUE_BYMAIL = 2;
var CHARGES_VALUE_BYCOURIER = 3;
var CHARGES_VALUE_BYREGISTERMAIL = 26;

function flashAlert(msg){
  alert(msg);
}

//------------------------------------------------------------------------------------------------------------------------------------

//-->

