function inputMaxLen(field, maxlimit) { 
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit); 
}

function toggleDisplay(id1,id2) {
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'block'
		document.getElementById(id2).style.display = 'none'
	} else {
		document.getElementById(id1).style.display = 'none'
		document.getElementById(id2).style.display = 'block'
	}
	return false;
}

function toggleDisplayInline(id1,id2) {
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'inline'
		document.getElementById(id2).style.display = 'none'
	} else {
		document.getElementById(id1).style.display = 'none'
		document.getElementById(id2).style.display = 'inline'
	}
	return false;
}

function jqCheckAll( id, name, flag )
{
   if (flag == 0)
   {
      $("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', false);
   }
   else
   {
      $("form#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', true);
   }
   return false;
}

function showDiv( id, flag ) {
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (flag == 1) {
		document.getElementById(id).style.display = 'inline'
	} else {
		document.getElementById(id).style.display = 'none'
	}
	return true;
}

function ChangeOptions(array)
{
	this.array = array; 
	this.indexName = '';
	this.obj = '';   
    this.subSelectChange = function(selectName1, selectName2)
	{
		var obj1 = document.getElementById(selectName1);
		var obj2 = document.getElementById(selectName2);
		var objName = this.toString();
		var me = this;
		obj1.onchange = function()
		{
			
			me.optionChange(this.options[this.selectedIndex].value, obj2.id)
		}
	}

	this.firstSelectChange = function(indexName, selectName)  
	{
		this.obj = document.getElementById(selectName);
		this.indexName = indexName;
		this.optionChange(this.indexName, this.obj.id)
	}

	this.optionChange = function(indexName, selectName)
	{
		var obj1 = document.getElementById(selectName);
		var me = this;
		obj1.length = 0;
		obj1.options[0] = new Option("---", '');
		for(var i = 0; i < this.array.length; i++)
		{	

			if(this.array[i][1] == indexName)
			{
				obj1.options[obj1.length] = new Option(this.array[i][2], this.array[i][0]);
			}
		}
	}
}