var popUp; 

var telform;
	//Code for tele formatting ---- By Tony

	function call_phonemask(t,keyCod){
		//alert(keyCod);
		do_phonemask_global(t.value,keyCod,telform);
	}
	function getteleformatdata(format)
	{
		telform = format;
		
	}

	//end of tele formatting

function OpenCalendar(idname, postBack)
{
	if (screen.width==1024)	
	{
		popUp = window.open('../Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value +  '&postBack=' + postBack, 
		'popupcal', 
		'width=180,height=280,left=200,top=250');
		// mahesh has changed the calendar hight due to the problem with buttton visiblity
	}
	else 
	{
		popUp = window.open('../Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value +  '&postBack=' + postBack, 
		'popupcal', 
		'width=190,height=280,left=200,top=250');
	}
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	//if (postBack)
	//__doPostBack(id,'');
}

//Fucntion to check the time
//coded by Anand
 function timeMask(t, key) {
	var timefield = t.value;
	var time1,time2;
	if(key == 8) {
	}
	else if (timefield.length==1)
	{
		if (timefield>1){
			t.value = "0" + timefield;
			timefield=t.value;
		}
	}
	if (timefield.length==2) {
		time1=timefield.substring(0,1);
		time2=timefield.substring(1,2);
		if (time1==1&&time2 >2)
			t.value=timefield.substring(0,1);
		else
			t.value = timefield + ":" ;
	}
	else if (timefield.length==4)
	{
		time1 = timefield.substring(3,4);
		if (time1>5)
			t.value = timefield.substring(0,3);
	}
	else if (timefield.length==5)
	{
		time1 = timefield.substring(0,2);
		if(time1 < 12 && time1 > 8)
			t.value = timefield + "a";
		else
			t.value = timefield + "p";
	}
	t.focus();
}//end of TimeMask


function helpwindow(filenm)
{
	window.open(filenm,"Help","height=300,width=600,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no")
}

function detailwindow(filenm)
{
	window.open(filenm,"Preview","height=450,width=700,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no")
}

function detailwindowTT(filenm)
{
	window.open(filenm,"Preview","height=450,width=700,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes")
}

function trimLeft(s)
{
  i=0;
  n= s.length;
  while((i<n)&&(s.charAt(i)==' ')) i++;
    s = s.substring(i);
   return(s);
} 

function trimRight(s)
{
 n= s.length;
 i= s.length-1;
 while((i>=0)&&(s.charAt(i)==' ')) i--;
    s = s.substring(0,i+1);
 return(s);
}

// code added by vinay

// this function counts for the number of occurences of ' (singlequote)
function checkforquote(formname,inputboxname,no)	{
	var str = eval('document.'+ formname +'.'+ inputboxname + '.value')
	var n=str.length,i=0;
	var count=0;
	while (i<n)	{
		if (str.charAt(i)=="'") count++;
	i++;
	}
	if (parseInt(count)>parseInt(no))
		return(-1);
	else
		return(1);
}


// Start of Email validation

 function  validateemail(inputboxname,formname)
 {
 
	var chkstring = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value');

	if(!strval.match(chkstring))
	 {
	//	 alert('Please Enter The Valid Email Address');	
    	 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return (-1);
	 }
	else
		  return (1);	
 }
 
// End of Email validation


// Start of website validation

 function  validateweb(inputboxname,formname)
 {
 
	var chkstring = /^([www_\.\-])+\.(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value');

	if(!strval.match(chkstring))
	 {
	//	 alert('Please Enter The Valid website Address');	
    	 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return (-1);
	 }
	else
		  return (1);	
 }
 
// End of website validation

// this function counts for the number of occurences of " (doublequote)
function checkfordblquote(formname,inputboxname,no)	{
	var str = eval('document.'+ formname +'.'+ inputboxname+'.value')
	var n=str.length,i=0;
	var count=0;
	while (i<n)	{
		if (str.charAt(i)=="\"") count++;
	i++;
	}
	if (parseInt(count)>parseInt(no))
		return(-1);
	else
		return(1);
}


	function getval(formname,inputboxname,i)	
	{
	   var i;
	   str=eval('document.'+ formname +'.'+ inputboxname+i+'.value');
	   return(str);
    }

// this function converts the <sq> tag into ' while listing
function convertsq(string)	{
	var i=1;
	quote = "<sq>";
	while(1)
	{
		string=string.replace(quote,"'");		
		i=string.indexOf(quote);
		if(parseInt(i)<=0)
			break;
	}
	return(convertdq(string));
}

// this function converts the <dq> tag into " while listing
function convertdq(string)	{
	var i=1;
	quote = "<dq>";
	while(1)
	{
		string=string.replace(quote,"\"");		
		i=string.indexOf(quote);
		if(parseInt(i)<=0)
			break;
	}
	return(string);
}

// this function converts the <sq> tag into ' while listing
function txtareaconvertsq(string)	{
	var i=1;
	quote = "<sq>";
	while(1)
	{
		string=string.replace(quote,"'");		
		i=string.indexOf(quote);
		if(parseInt(i)<=0)
			break;
	}
	return(txtareaconvertdq(string));
}

// this function converts the <dq> tag into " while listing
function txtareaconvertdq(string)	{
	var i=1;
	quote = "&quot;";
	while(1)
	{
		string=string.replace(quote,"\"");		
		i=string.indexOf(quote);
		if(parseInt(i)<=0)
			break;
	}
	return(string);
}


// code added by vinay ends here


// code by salil

/* use 
 * OnKeyUp="javascript:do_phonemask(this, event.keyCode);"
 */
function do_phonemask(t, key) {
	var phonefield = t.value;
	if(key == 8) {
	}
	else if (phonefield.length==1) {
		t.value = "(" + phonefield;
	}
	else if (phonefield.length==4) {
		t.value = phonefield + ") ";
	}
	else if (phonefield.length==9) {
		t.value = phonefield + "-";
	}
	t.focus();
}
//Start of Tony's code
function do_phonemask_global(t, key) {

	var phonefield = t.value;
	
	//alert(key);
if((key > 48 && key < 57) || (key > 96 && key < 105))
{
	if(telform == '1')
	{
	if(key == 8) {
	}
	else if (phonefield.length==1) {
		t.value = "(" + phonefield;
	}
	else if (phonefield.length==4) {
		t.value = phonefield + ") ";
	}
	else if (phonefield.length==9) {
		t.value = phonefield + "-";
	}}

	if(telform == '2')
	{
		if(key == 8) {
		}
		else if (phonefield.length==1) {
			t.value = "(" + phonefield;
		}
		else if (phonefield.length==3) {
			t.value = phonefield + ") ";
		}
		else if (phonefield.length==9) {
			t.value = phonefield + "-";
		}
	} 
	if(telform == '3')
	{
		if(key == 8) {
		}
		else if (phonefield.length==2) {
			t.value = phonefield + "(";
		}
		else if (phonefield.length==4) {
			t.value = phonefield + ") ";
		}
		else if (phonefield.length==8) {
			t.value = phonefield + "-";
		}
	} 
	if(telform == '4')
	{
		if(key == 8) {
		}
		else if (phonefield.length==1) {
			t.value = "(" + phonefield;
		}
		else if (phonefield.length==4) {
			t.value = phonefield + ") ";
		}
		else if (phonefield.length==7) {
			t.value = phonefield + "-";
		}
	} 
}
	t.focus();
}

function do_phonecheck_global(t) {
	
	if(telform == '1')
	{
		//format (546) 454-5754
		var CurRegExp = /^(\([\d]{3})\) ([\d]{3})\-([\d]{4})$/;
		
		var curfield = t.value;
		if(!CurRegExp.test(curfield) && curfield != "")	
			return true;
		else
			return false; 
	}
	if(telform == '2')
	{
		var CurRegExp = /^(\([\d]{2})\) ([\d]{4})\-([\d]{4})$/;
		var curfield = t.value;
		if(!CurRegExp.test(curfield) && curfield != "")	
			return true;
		else
			return false; 
	}
	if(telform == '3')
	{
		//format 54(5) 45-454547
		//var CurRegExp = /^(\([\d]{3})\) ([\d]{3})\-([\d]{6})$/;
		var CurRegExp = /^([\d]{2})(\([\d]{1})\)\-([\d]{6})$/;
		var curfield = t.value;
		if(!CurRegExp.test(curfield) && curfield != "")	
			return false;
		else
			return false; 
	}
	if(telform == '4')
	{
		var CurRegExp = /^(\([\d]{3})\) ([\d]{1})\-([\d]{7})$/;
		var curfield = t.value;
		if(!CurRegExp.test(curfield) && curfield != "")	
			return true;
		else
			return false; 
	}
}
//End of Tony's Code

/*  use
*   OnBlur="javascript:do_phonecheck(this);" 
*/
// this code is modified by vinay

 function do_phonemask(t, key) {
	var phonefield = t.value;
	
		
			if(key == 8) {
			}
			else if (phonefield.length==1) {
				t.value = "(" + phonefield;
			}
			else if (phonefield.length==4) {
				t.value = phonefield + ") ";
			}
			else if (phonefield.length==9) {
				t.value = phonefield + "-";
			}
	t.focus();
}


function do_phonecheck(t) {
	var CurRegExp = /^(\([\d]{3})\) ([\d]{3})\-([\d]{4})$/;
	var curfield = t.value;
	if(!CurRegExp.test(curfield) && curfield != "")	
		return true;
	else
		return false; 
}


// salil's code ends here


// raghu's code for date validaion on keyup
 
function do_datemask(t, key) {
	var datefield = t.value;
	if(key == 8) {
	}
	else if (datefield.length==2) {
		t.value = datefield + "-";
	}
	else if (datefield.length==6) {
		t.value = datefield + "-";
	}
	
	t.focus();
}

 function do_datecheck(t) {
    var CurRegExp = /^\d{2}\-[a-z]{3}-\d{4}$/;
    var curfield = t.value;
	if(!CurRegExp.test(curfield) && curfield != "")	
		return true;
	else
		return false; 
}


// raghu's code ends here

function trimAll(s)
{
 s = trimLeft(s);
 s = trimRight(s);
 return(s);
} 

function isDigit(c)
{
if((c=='0')||(c=='1')||(c=='2')||(c=='3')||(c=='4')||(c=='5')||(c=='6')||(c=='7')||(c=='8')||(c=='9'))
	return true;
else
	return false;
}

function isPosInt(s)
{
 n=s.length;
 if(n==0) return false;
 for(i=0;i<n;i++)
	if(!isDigit(s.charAt(i))) return false;
 return true;
}

// This function Modified by vinay

function isPosReal(s)
{
 s = trimAll(s);

 if(s.indexOf("-")!="-1")
	 return false;

 dot =0;
 for(i=0;i<s.length;i++)	{
	if(!isDigit(s.charAt(i))) 
		{
			if(s.charAt(i)=='.') 
				{
					dot++;
					if(i==s.length-1) return false;
					if(dot>1) return false;
				}
			else return false;	
		}
 }
 if (dot==0)
	return false;
 else
	return true;
}

// End of Modification

// Start of Email validation

 function  email(inputboxname,formname)
 {
 
	var chkstring = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value');

	if(!strval.match(chkstring))
	 {
	//	 alert('Please Enter The Valid Email Address');	
    	 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return (-1);
	 }
	else
		  return (1);	
 }
 
// End of Email validation


// Start of website validation

 function  web(inputboxname,formname)
 {
 
	var chkstring = /^([www_\.\-])+\.(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value');

	if(!strval.match(chkstring))
	 {
	//	 alert('Please Enter The Valid website Address');	
    	 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return (-1);
	 }
	else
		  return (1);	
 }
 
// End of website validation



// Date comparision

function DateDiff(start, end)
{
    var iOut = 0;
    var bufferA = Date.parse(start);
    var bufferB = Date.parse(end);
    var number = bufferB-bufferA ;
     iOut = parseInt(number / 86400000) ;
	 iOut += parseInt((number % 86400000)/43200001) ;
	 return iOut ;
}


//End of Date comparision


// Emptyfield validation

function  validatetext(inputboxname,formname)
 {		
	if(eval('document.'+ formname +'.'+ inputboxname + '.value')==0)	
		return (-1);
	else
		return (1);
 }

//Checking for Empty field and Positive Integer

function  field(inputboxname,formname)
 {		
	if(eval('document.'+ formname +'.'+ inputboxname + '.value') < 0)	
		return (-1);
	 else
		return (1);
 }



// End of Emptyfield Validations



//  Time validation

function  validatetime(inputboxname,formname)
 {
    var chkstring = /^\d{2}:\d{2}$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value')
	
	if(!validatetext(inputboxname,formname))
		 return(-1);
	else if(!strval.match(chkstring))
	 {
		 // eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return(-1);
	 }
	else if(parseInt(strval.substring(0,strval.indexOf(':')))<0 || parseInt(strval.substring(0,strval.indexOf(':')))>23 || parseInt(strval.substring(strval.indexOf(':')+1,strval.length))<0 || parseInt(strval.substring(strval.indexOf(':')+1,strval.length))>59)
	 {	
		 // eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return(-1);
	 }
	else
		  return(1);	
 }


//End of Time Validation



 //    Phone validation


function  phone(inputboxname,formname)
 {
    var chkstring1 = /^\d{4,4}\-\d{3,3}\-\d{7,11}$/;
	var chkstring2 =  /^\d{4,5}\-\d{4,9}$/;
	var strval = eval('document.'+ formname +'.'+ inputboxname + '.value');

	if(!text(inputboxname,formname))
		 return (-1);
	else if(!strval.match(chkstring1) && !strval.match(chkstring2))
	 {
		  eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		  return (-1);
	 }
	else
		  return (1);
 }

 // End of Phone Validation



 //  Date Comparision Function


function Compare_Dates(date1,date2)
{
  if(DateDiff(ConvertDate(date1),ConvertDate(date2))>=0)
		return (-1);
  else
	    return (1);
}

// End of Date Comparision 


function timecomp(vdat)
{
  var s;
  var i=vdat.indexOf(':');
  pre = trimAll(vdat.substring(0,i));
  post = trimAll(vdat.substring(i+1,vdat.length-1));

  if ( (i == 1) || (i == 2) )
	
	{
		if (!isNaN(pre) && !isNaN(post))
	
		{	inpre = parseInt(pre);
			inpost = parseInt(post);
			if (inpre > 12 || inpost > 60)
			{
				alert("Invalid time");
				return true;
			}
			return false;
		}
		else 
		{	
			alert("Invalid time");
			return true;
		}
	}
	else
	{
		alert("Invalid time");
		return true;
	}

}


//  Time Comparision Function

function Compare_Times(time1,time2)
{
  if(parseInt(time1.substring(0,time1.indexOf(':')))>parseInt(time2.substring(0,time2.indexOf(':'))))
		return (-1);
  else if((parseInt(time1.substring(0,time1.indexOf(':')))==parseInt(time2.substring(0,time2.indexOf(':')))) && (parseInt(time1.substring(time1.indexOf(':')+1,time1.length))>parseInt(time2.substring(time2.indexOf(':')+1,time2.length))))
	    return(-1);
  else
		return(1);
}

// End of Time Comparision 


// Interger number validation
/*
function  int(inputboxname,formname)
 {
    if(!isPosInt(eval('document.'+ formname +'.'+ inputboxname + '.value')))
		{
		// alert("Please Enter Positive Integer " + fieldname);
		 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		 return (-1);
		}
	else
		  return (1);
 }
*/
// End of Integer number validation


// Real number validations

function  validatereal(inputboxname,formname)
 {
	
	if(!isPosReal(eval('document.'+ formname +'.'+ inputboxname + '.value')))
		 {
//		 alert("Please Enter Positive And Real Value For " + fieldname);
		 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		 return (-1);
		}
	else	
		 return (1);
 }
// End of real number validation

// Interger number validation

function  validateint(inputboxname,formname)
 {
    if(!isPosInt(eval('document.'+ formname +'.'+ inputboxname + '.value')))
		{
		// alert("Please Enter Positive Integer " + fieldname);
		 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		 return (-1);
		}
	else
		  return (1);
 }

// End of Integer number validation



// Change Case function which will convert lower case to upper case

function change_case(formname,ctrlname)
   {
	 ctrlobject=eval('document.'+formname+'.'+ctrlname);
	 ctrlobject.value=ctrlobject.value.toUpperCase();
   }

// End of Change case function


// Maxlength validation

function maxlength(formname,inputboxname,maxlimit) 
{
  if ( eval('document.'+ formname +'.'+ inputboxname + '.value.length') > maxlimit )
  {
//    alert( ' This Text can have only '+ maxlimit +' in length.');
	eval('document.'+formname+'.'+inputboxname+'.value.length' == 0); 
	eval('document.'+formname+'.'+inputboxname+'.focus()'); 

		 return (-1);
  }
  else
		 return (1);

}

// End of Maxlength validation


// checks for valid date
 function isValidDate(strDate)
{

 strDate=trimAll(strDate);

 i1 = strDate.indexOf("/")
 if(i1<0) return (-1);
 m = strDate.substring(0,i1)
 i2= strDate.indexOf("/",i1+1)
 if(i2<0) return (-1);
 d = strDate.substring(i1+1,i2)
 y = strDate.substring(i2+1)

 if((m=="")||(d=="")||(y=="")) return (-1);
 if((m==0)||(d==0)||(y==0)) return (-1);
 if(!isPosInt(m))
 	 return (-1);
 else
 	{	
	 m = parseInt(m);
	 if(m>12) return (-1);
 	}


 if(!isPosInt(y))
 	 return (-1);
 else
	{
	 y = parseInt(y)
	 if(y>9999) return (-1);
	}

 if(!isPosInt(d))
 	 return (-1);
 else
	{
	 d = parseInt(d)
	 if (d > 31)
	 {
		 return (-1);
	 }
	 if((m==1)||(m==3)||(m==5)||(m==7)||(m==8)||(m==10)||(m==12))
		 if(d>31) return (-1);
 	 if((m==4)||(m==6)||(m==9)||(m==11))
		if(d>30) return (-1);

	 if(m==2)
		{
		 if(d>29) return (-1);
		 if((y%4)!=0) // not a leap year
		 	if(d>28) return (-1);
		}
	}

return 1;
}


 // date validate

 function  validatedate(inputboxname,formname)
  {
	var chkstr = /^\d{1,2}\-\w{3}\-\d{4}$/;
	var dateval = eval('document.'+ formname +'.'+ inputboxname + '.value')

	if(!dateval.match(chkstr))
	 {
		 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		 return (-1);
	 }	 
	else if(!isValidDate(ConvertDate(dateval)))
	{
		 eval('document.'+ formname +'.'+ inputboxname + '.focus()');
		 return (-1);
	} 	
	
	else
		 return (1);	
 }


 
// Date Converting Function

function ConvertDate(olddate)
{
  var newdate;
  var day;
  var month;
  var year;

  day=trimAll(olddate.substring(0,olddate.indexOf('-')));
  var firstdash=olddate.indexOf('-');
  
  switch(olddate.substring(firstdash+1,firstdash+4).toUpperCase())
	{
	  case "JAN":
					month=1;
					break;
	  case "FEB":	
					month=2;
					break;
	  case "MAR":	
					month=3;
					break;
	  case "APR":	
					month=4;
					break;
	  case "MAY":	
					month=5;
					break;				
	  case "JUN":	
					month=6;
					break;
	  case "JUL":
					month=7;
					break;
	  case "AUG":	
					month=8;
					break;	
	  case "SEP":	
					month=9;
					break;
	  case "OCT":	
					month=10;
					break;	
	  case "NOV":	
					month=11;
					break;	
      case "DEC":	
					month=12;
					break;	
	  default:		
					month=0;		
	}			    
  year=trimAll(olddate.substring(firstdash+5,firstdash+9));
  newdate=year+"/"+month+"/"+day;
  return(newdate);
}


// Checking whether start date should less than the end date


function  validityfromtocompare(startdate,enddate,formname)
 {
		
	if(!CompareDates(trimAll(eval('document.'+ formname +'.'+ startdate + '.value')),trimAll(eval('document.'+ formname +'.'+ enddate + '.value'))))
	 {
		alert("Validity From Date Should Be Less Than The Validity To Date");
		 eval('document.'+ formname +'.'+ startdate + '.focus()');
		 return (-1);
	 }
	else
	 	 return (1);
 }
   
// End of Checking


/*  This function is used to change the pointer color when mouse enters or leaves the 
	list of records
*/

function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
  {
    var theCells = null;

	// 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one

    //alert(theCells[0].style.backgroundColor)

	if ((currentColor == '') || (currentColor == null) || (currentColor.toLowerCase() == theDefaultColor.toLowerCase())) {
		//alert(currentColor);
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
	//Change the color
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;

		//Change the color
		
        }

    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
		//Change the color
			
    } // end 4

		
    // 5. Sets the new color...
		Set_Color(theCells,newColor,domDetect)
    return true;
} // end of the 'setPointer()' function

function Set_Color(theCells,newColor,domDetect)
{
	if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < theCells.length; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c <theCells.length; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5
}

//Code Added by Tony 

// Real number validations

// code added by vinay


function floatvalidation(p)	{
	var FloatRegExp = /^\d{0,5}(\.)\d{0,2}$/;
	var IntRegExp = /^\d{1,5}$/;
	var floatfield = p.value;

	if (!FloatRegExp.test(floatfield) && !IntRegExp.test(floatfield)) {
		return(false);
	} else {
		return(true);
	}
}
	function floatvalidequip(p)	{
		var FloatRegExp = /^\d{0,7}(\.)\d{0,2}$/;
		var IntRegExp = /^\d{1,10}$/;
		var floatfield = p.value;

		if (!FloatRegExp.test(floatfield) && !IntRegExp.test(floatfield)) 
		{
			return(false);
		} 
		else {
			return(true);
		}
	}






