//Global variables
var tbSelMonth; 
var tbSelYear;



function UnlockForm(frmNm)
{
	for(i=0; i < eval('document.'+frmNm+'.elements.length');i++)
	{
		eval('document.'+frmNm+'.elements.item(i).disabled = false');
	}
}
/* update*/

function CancelOnClick(frmNm)
{
	window.location.href = frmNm;
}

function replaceSpace(str) ///Used to replace multiple spaces between words
{
	var i,len=0,current="",previous=" ",retStr=""
	len = str.length;

	for(i=0;i<= len-1;i++)
	{
		current = str.charAt(i);
		if (current == " ")
		{
			if(current != previous)
			{
				retStr = retStr + current;
			}
		}
		else
		{
			retStr = retStr + current;
		}
		previous=current;
	}
	return (retStr);
}

function getErrMsg(errno)
{
	var msg;
	msg="No message";
	switch (errno)
	{
		case "1" :
			msg=" can not start with space(s).";
			break;
		case "2" :
			msg=" can not be empty.";
			break;
		case "3" :
			msg=" must be selected.";
			break;
		case "4" :
			msg=" is invalid.";
			break;
		case "5" :
			msg=" are invalid.";
			break;
		case "6" :
			msg=" cannot be duplicated.";
			break;
		case "7" :
			msg=" Sorry!!! No rows found for Selection.";
			break;
		case "8" :
			msg=" Atleast one item has to be present for delete operation.";
			break;
		case "9" :
			msg=" Do you want to delete the selected record ?";
			break;
		default :
			break;
	}
	return(msg);
}

function isnumber(str)
{
	var vtmp,string,count,x;
	string = str
	for (count=0; count<string.length; count++)
	/*checking if there is a combination of no. and alphabet.
	because paseInt is returning number if the input as  above
	*/
    {
		x = string.substring(count, count+1)
		RefString="1234567890.";
		if (RefString.indexOf (x, 0)==-1)
		{
			//alert("Invalid Number")
			return (false);
		}
    }

	vtmp =  parseInt(str);
	if ( isNaN(vtmp) || (vtmp <= 0 ) ) //checking for alphabet and zero and negative
	{
		return false;
	}
	else
	{
		return true;
	}
} //End Function function isnumber(str)


function isnumber_withdec_withzero(str)
{
	var vtmp,string,count,x;
	string = str
	for (count=0; count<string.length; count++)
	/*checking if there is a combination of no. and alphabet.
	because paseInt is returning number if the input as  above
	*/
    {
		x = string.substring(count, count+1)
		RefString="1234567890.";
		if (RefString.indexOf (x, 0)==-1)
		{
			//alert("Invalid Number")
			return (false);
		}
	}
	vtmp =  parseInt(str);
	if ( isNaN(vtmp) || (vtmp < 0 ) ) //checking for alphabet and negative
	{
		return false;
	}
	else
	{
		return true;
	}
}


function isnumber_withzero(str)
{
	var vtmp,string,count,x;
	string = str
	for (count=0; count<string.length; count++)
	/*checking if there is a combination of no. and alphabet.
	because paseInt is returning number if the input as  above
	*/
	{
		x = string.substring(count, count+1)
		RefString="1234567890.";
		if (RefString.indexOf (x, 0)==-1)
		{
			//alert("Invalid Number")
			return (false);
		}
	}

	vtmp =  parseInt(str);
	if ( isNaN(vtmp) || (vtmp < 0 ) ) //checking for alphabet and zero and negative
	{
		return false;
	}
	else
	{
		return true;
	}
}

function isnumber_nodec_nozero(str)
{
	var vtmp,string,count,x;
	string = str
	for (count=0; count<string.length; count++)
	/*checking if there is a combination of no. and alphabet.
	because paseInt is returning number if the input as  above
	*/
    {
		x = string.substring(count, count+1)
		RefString="1234567890";
		if (RefString.indexOf (x, 0)==-1)
		{
			//alert("Invalid Number")
			return (false);
		}
    }
	vtmp =  parseInt(str);
	if ( isNaN(vtmp) || (vtmp <= 0 ) ) //checking for alphabet and zero and negative
	{
		return false;
	}
	else
	{
		return true;
	}
}


function isdate(str)
{
	if(str.length != 10) {return false} //checking for the length dd/mm/yyyy

	for (count=0; count<str.length; count++)
	{
		x = str.substring(count, count+1)
		RefString="1234567890/";
		if (RefString.indexOf (x, 0)==-1)
		{
			return (false);
		}
	}
	var day = str.charAt(0) == "0" ? parseInt(str.substring(1,2)) : parseInt(str.substring(0,2));
	var month = str.charAt(3) == "0" ? parseInt(str.substring(4,5)) : parseInt(str.substring(3,5));
	var begin = str.charAt(6) == "0" ? (str.charAt(7) == "0" ? (str.charAt(8) == "0" ? 9 : 8) : 7) : 6;
	var year = parseInt(str.substring(begin, 10));

	if (day == 0) { return false }
	if (year < 1800){return false}
	if (year > 4000){return false}
	if (month == 0 || month > 12) { return false }
	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
	{
		if (day > 31) { return false }
        }
	 else
	{
		if (month == 4 || month == 6 || month == 9 || month == 11)
                {
			if (day > 30) { return false }
                }
		else
		{
			if (year%4 != 0)
			{
				if (day > 28) { return false }
                        }
			else
			{
				if (day > 29) { return false }
                        }
                }
	}
	return true;
}

function checkdoublequotes(formname)
{
	var totlen
	totlen  = eval("document."+formname+".elements.length")
	for(l=0;l<totlen;l++)
	{
		typ = eval("document."+formname+".elements[l].type")
		if(typ=="text")  //here i am checking that the element type is text or button etc.etc
		{
			a = eval("document."+formname+".elements[l].value")
			for (i=0;i<a.length;i++)
			{
				myString = new String(a)
				b = myString.charCodeAt(i)
				if (b==34)
				{
				alert("Double Quotes Are Not Allowed.  Please Change.")
				eval("document."+formname+".elements[l].focus()")
				return 0;
				}
			}
		}
	}
	return 1;
}

function isvalidemail(stremail)
{
	ctemp = stremail;
	// If stremail length less than 5 characters than return false.
	if (stremail.length < 5)
	{
		return false ;
	}
	// In stremail string no . is present
	ctemp_search = ".";
	results = ctemp.indexOf(ctemp_search);
	if (results == -1)
	{
		return false ;
	}
	// In stremail string no @ character present
	ctemp_search = "@";
	results = ctemp.search(ctemp_search);
	if (results == -1)
	{
		return false ;
	}
	// If stremail string contains any spaces than return false.
	ctemp_search = " ";
	results = ctemp.search(ctemp_search);
	if (results > -1)
	{
		return false ;
	}
	// If stremail string contains the first character as @ than return false.
	ctemp_search = "@";
	results = ctemp.search(ctemp_search);
	if (results == 0)
	{
		return false ;
	}
	myString = new String(stremail);
	splitString = myString.split("@");
	// If stremail string contains the @ character twice than return false.
	if (splitString.length > 2)
	{
		return false ;
	}
	return true ;
}

// following function for displaying the hand on buttons when (onmousemove event) take place
function displayhand_onmousemove(objname)
{
	ctemp = "document.getElementById('"+objname+"').style.cursor = 'hand'";
	//execScript(ctemp);
	eval(ctemp);
}

function displayhand_onmousemove_obj(objname)
{
	objname.style.cursor = 'hand';
}

/*
// following function for displaying the hand on buttons when (onmousemove event) take place
//And also to Display TOOL-TIP: tool tip
function displayhand_onmousemove_tooltip(button_name)
{
	//ctemp = "document.forms[0]."+button_name+".style.cursor = 'hand'";
	ctemp = "document.forms[0]."+button_name+".style.alt = 'Add New Record'";
	execScript(ctemp);
}
*/


// This function is used to make Right Click Disabled on Browser.
// This is not implemented yet in our Project due to Client Convinince.
// If you have to add this, then Just add the following line in every page.
// [ document.onmousedown = disableRightClick;  ]
function disableRightClick(btnClick)
{
	if (navigator.appName == "Netscape" && btnClick.which == 3) // check for netscape and right click
	{
		alert("Sorry !!!  This Functionality is Disabled for this Page.");
		return false;
	}
	else if (navigator.appName =="Microsoft Internet Explorer" && event.button == 2)  // for IE and Right Click
	{
		alert("Sorry !!!  This Functionality is Disabled for this Page.");
		return false;
	}
}


function convert_newline(str)
{
	//Converting the new line character with html <BR> tag.
	//the escape character for chr(10), linefeed chr(13) enter key is
	// %0D  and %0A  I am using the unescape sequence techniques to display it
	//on the screen.
	ctemp = new String(str);
	ctemp = ctemp.replace(/\r\n/g,"<br>")
	return ctemp;
}

function FieldHelp(m,i,p)
{	//m = module (e.g.= Admin)
	//i = interface (user interface)
	//p = position (label position)
	var fieldwindow = window.open('../help_window.aspx?module1='+m+'&interface1='+i+'&position1='+p,'fieldhelp','left=0,top=0,width=350,height=145,scrollbars=no,resizable=no,titlebar=no');
	//var fieldwindow = window.open('../help_window.aspx?module1='+m+'&interface1='+i+'&position1='+p,'fieldhelp','left=0,top=0');
	fieldwindow.focus();
	return false;
}

function isBlankString(str)
{
	// If str contains any spaces than return false.
	ctemp_search = " ";
	results = str.search(ctemp_search);
	if (results >= 0){return false;}else{return true;}
}

function isStartSpace(str)
{
	// If str contains any space as first character
	ctemp_search = " ";
	results = str.indexOf(ctemp_search,0);
	if (results == 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function Date_OnKeyUp(col_cur,col_next)
{
	// col_cur  = Current Column
	// col_next = Next Column
	a=event.keyCode;
	if((a!=9) && (a!=16))
	if(eval("document.all."+col_cur+".value.length") == 2) eval("document.all."+col_next+".focus()");
	return false;
}

//Following function is used for VALUE_AUTHORIZED Checked.
function add_val_auth()
{
	var oRow;
	var oCell;
	// I am inserting a row row
	oRow =  oValTable.insertRow();
	// I am inserting cell
	oCell = oRow.insertCell();
	oCell.innerHTML= "<div align='right'>Value Authorized &nbsp;<input type='checkbox' id='val_auth' name='val_auth' disabled></div>"
	return true;
}

function isValidAddress(str)
{
	//string = str;
	//if (string.indexOf("{")>0 || string.indexOf("}")>0 || string.indexOf("[")>0 || string.indexOf("]")>0 || string.indexOf("-")>0 || string.indexOf(":")>0)
	//{
	//	return false;
	//}
	//else
	//{
	//	return true;
	//}

	//Checking for Special Characters { } [ ] - : % ! # $ & * ; > "
	//I am using the S character for separator.

	string				= str;
	string_array		= "{S}S[S]S-S:S%S!S#S$S&S*S;S>";
	splitString_array	= string_array.split("S");

	for (i=0; i<splitString_array.length; i++)
	{
		if (string.indexOf(splitString_array[i]) >= 0)
		{
			alert("Special Character  " + splitString_array[i] + "  not allowed.");
			return false;
			break;
		}
	}

	if (string.indexOf('"') >= 0)
	{
		alert('Special Character  "  not allowed.');
		return false;
	}
	return true;
}

/*
function Search_Div_Validation(div_name,control_name)
{
	eval("document.all."+div_name+".style.visibility='visible'");
	//select_value = eval("document.all."+control_name+".value")
	//select_value = eval("document.all."+control_name+".value")
	select_value = document.all.div_dropdown_value.value;
	alert("select_value : " + select_value);
	tot_len = eval("document.all.item('"+control_name+"').length");
	//alert("tot_len : " + tot_len);
	for (j=0; j<tot_len; j++)
	{
		alert("loop value : " + eval("document.all.item('"+control_name+"').item(j).value"));
		if (eval("document.all.item('"+control_name+"').item(j).value") == select_value)
		{
			eval("document.all.item('"+control_name+"').item(j).selected=true");
		}
	}
}
*/

function Cancel_onclick()
{
	window.location.href = "dpsecure_main.asp"
}


var isAltKeyPressed = false;
function hotkey()
{
	if(event.keyCode == 18)
	{
		isAltKeyPressed = true;
	}
	if(event.keyCode == 66 && isAltKeyPressed) //ALT+B
	{
		isAltKeyPressed = false;
		window.location.href = "change_branch.asp"
	}
	if(event.keyCode == 67 && isAltKeyPressed)//ALT+C
	{
		isAltKeyPressed = false;
		window.location.href = "change_dp.asp"
	}
}

function checking_all_special_characters(str)
{
	//Checking for Special Characters `~!@#$%^&*()-_=+[]{};:"<>,/?\|
	//I am using the S character for separator.
	string			= str;
	string_array	= "`S~S!S@S#S$S%S^S&S*S(S)S-S_S=S+S[S]S{S}S;S:S<S>S,S/S?S\\S|";
	splitString		= string_array.split("S");
	for (j=0; j<splitString.length; j++)
	{
		if (string.indexOf(splitString[j]) >= 0)
		{
			alert("Special Character  " + splitString[j] + "  not allowed.");
			return false;
			break;
		}
	}
	if (string.indexOf('"') >= 0)
	{
		alert('Special Character  "  not allowed.');
		return false;
	}
}

function checking_special_characters(str)
{
	//Checking for Special Characters "/\
	//I am using the S character for separator.

	string			= str;
	string_array	= "/S\\";
	splitString		= string_array.split("S");

	for (j=0; j<splitString.length; j++)
	{
		if (string.indexOf(splitString[j]) >= 0)
		{
			alert("Special Character  " + splitString[j] + "  not allowed.");
			return false;
			break;
		}
	}

	if (string.indexOf('"') >= 0)
	{
		alert('Special Character  "  not allowed.');
		return false;
	}
}

function isValidSlipNo(str)
{
	string = str;
	if (string.indexOf("{")>=0 || string.indexOf("}")>=0 || string.indexOf("[")>=0 || string.indexOf("]")>=0 || string.indexOf("-")>=0 || string.indexOf(":")>=0 || string.indexOf("?")>=0 || string.indexOf("_")>=0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function DDSearch_OnChange()
{
		document.getElementById("txtSearch").value='';
}


//(Please Do not put any function in between following code until you find end)
//FOLLOWING FUNCTIONS ARE USED FOR DATE POPUP
//===========================================
//****************************************************************************
// PopCalendar 3.30, Emailware(please mail&commend me if u like it)
// Originally coded by Liming(Victor) Weng, email: victorwon@netease.com
// Release date: 2000.3.7
// Anyone may modify it to satify his needs, but please leave this comment ahead.
//****************************************************************************
var gdCtrl1 = new Object();
var gdCtrl2 = new Object();
var gdCtrl3 = new Object();
var goSelectTag = new Array();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#DDE7EC";
var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();



function fSetDate(iYear, iMonth, iDay){
  VicPopCal.style.visibility = "hidden";
  //gdCtrl.value = iMonth+"-"+iDay+"-"+iYear; //Here, you could modify the locale as you need !!!!

if(iDay <= 9)
{
   iDay = "0" + iDay;
}
if(iMonth <= 9)
{
   iMonth = "0" + iMonth;
}

  //if(GetCookieVal("DATE_FORMAT")=="DD-MM-YYYY")
  //{
    gdCtrl1.value = iDay;
    gdCtrl2.value = iMonth;
    gdCtrl3.value = iYear;
  //}
  /*if(GetCookieVal("DATE_FORMAT")=="MM-DD-YYYY")
  {
    gdCtrl1.value = iMonth;
    gdCtrl2.value = iDay;
    gdCtrl3.value = iYear;
  }*/

  for (i in goSelectTag)
  	goSelectTag[i].style.visibility = "visible";
  goSelectTag.length = 0;
}

function fSetSelected(aCell){
var tbSelMonth1 = document.getElementById('tbSelMonth');
var tbSelYear1 = document.getElementById('tbSelYear');
  var iOffset = 0;
  var iYear = parseInt(tbSelYear1.value);
  var iMonth = parseInt(tbSelMonth1.value);
  
  aCell.bgColor = gcBG;

 // with (aCell.children["cellText"]){

  with (aCell.childNodes[0]){
   var iDay = parseInt(innerHTML);
   if (color==gcGray)
  iOffset = (Victor<10)?-1:1;
 iMonth += iOffset;
 if (iMonth<1) {
  iYear--;
  iMonth = 12;
 }else if (iMonth>12){
  iYear++;
  iMonth = 1;
 }
  }
  fSetDate(iYear, iMonth, iDay);
}

function Point(iX, iY){
	this.x = iX;
	this.y = iY;
}

function fBuildCal(iYear, iMonth) {
	
  var aMonth=new Array();
  for(i=1;i<7;i++)
  	aMonth[i]=new Array(i);

  var dCalDate=new Date(iYear, iMonth-1, 1);
  var iDayOfFirst=dCalDate.getDay();
  var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
  var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
  var iDate = 1;
  var iNext = 1;

  for (d = 0; d < 7; d++)
	aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
  for (w = 2; w < 7; w++)
  	for (d = 0; d < 7; d++)
		aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
  
  return aMonth;
}

function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {
  var WeekDay = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
  var styleTD = " bgcolor='"+gcBG+"' bordercolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font:bold "+iDateTextSize+" Courier;";            //Coded by Liming Weng(Victor Won)  email:victorwon@netease.com

  with (document) {
	write("<tr>");
	for(i=0; i<7; i++)
		write("<td "+styleTD+"color:#990099' >" + WeekDay[i] + "</td>");
	write("</tr>");

  	for (w = 1; w < 7; w++) {
		write("<tr>");
		for (d = 0; d < 7; d++) {
			write("<td id=calCell "+styleTD+"cursor:pointer;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
			write("<font id=cellText name='cellText' Victor='Liming Weng'> </font>");
			write("</td>")
		}
		write("</tr>");
	}
  }
}

function fUpdateCal(iYear, iMonth) {
	

iYear = document.getElementById('tbSelYear').value;
iMonth = document.getElementById('tbSelMonth').value;


  myMonth = fBuildCal(iYear, iMonth);
  
  var cellText = document.getElementsByName('cellText');
  var i = 0;
  for (w = 0; w < 6; w++)
 for (d = 0; d < 7; d++)
  with (cellText[(7*w)+d]) {
   Victor = i++;
   if (myMonth[w+1][d]<0) {
    color = gcGray;
    innerHTML = -myMonth[w+1][d];
   }else{
    color = ((d==0)||(d==6))?"red":"black";
    innerHTML = myMonth[w+1][d];
   }
  }
		
}



function fSetYearMon(iYear, iMon){
  
  var tbSelMonth = document.getElementById('tbSelMonth');
  tbSelMonth.options[iMon-1].selected = true;
  var tbSelYear = document.getElementById('tbSelYear');
  
  for (i = 0; i < tbSelYear.length; i++)
	if (tbSelYear.options[i].value == iYear)
	tbSelYear.options[i].selected = true;
  
	
  fUpdateCal(iYear, iMon);
 
}

function fPrevMonth(){
var tbSelYear = document.getElementById('tbSelYear');
var tbSelMonth = document.getElementById('tbSelMonth');
  var iMon = tbSelMonth.value;
  var iYear = tbSelYear.value;
  
  if (--iMon<1) {
   iMon = 12;
   iYear--;
  }
  
  fSetYearMon(iYear, iMon);
}


function fNextMonth(){
var tbSelMonth = document.getElementById('tbSelMonth');
var tbSelYear = document.getElementById('tbSelYear');
  var iMon = tbSelMonth.value;
  var iYear = tbSelYear.value;
  
  if (++iMon>12) {
   iMon = 1;
   iYear++;
  }
  
  fSetYearMon(iYear, iMon);
}

function fToggleTags(){
var select = document.getElementsByTagName("SELECT");

var isIE4 = ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
if (isIE4)
{
 for (i=0; i<select.length; i++)
    if ((select[i].Victor != 'Won') && fTagInBound(select[i])){
     select[i].style.visibility = "hidden";
     goSelectTag[goSelectTag.length] = select[i];
    }

 with (document.all.tags("SELECT")){
   for (i=0; i<length; i++)
    if ((item(i).Victor!="Won")&&fTagInBound(item(i))){
     item(i).style.visibility = "hidden";
     goSelectTag[goSelectTag.length] = item(i);
    }
 }
}

}

function fTagInBound(aTag){
var VicPopCal = document.getElementById('VicPopCal');
  with (VicPopCal.style){
   var l = parseInt(left);
   var t = parseInt(top);
   var r = l+parseInt(width);
   var b = t+parseInt(height);
 var ptLT = fGetXY(aTag);
 return !((ptLT.x>r)||(ptLT.x+aTag.offsetWidth<l)||(ptLT.y>b)||(ptLT.y+aTag.offsetHeight<t));
  }
}

function fGetXY(aTag){
  var oTmp = aTag;
  var pt = new Point(0,0);
  do {
  	pt.x += oTmp.offsetLeft;
  	pt.y += oTmp.offsetTop;
  	oTmp = oTmp.offsetParent;
  } while(oTmp.tagName!="BODY");
  return pt;
}

///////////////    System Date Actually it has to come from Server Date(to be changed)

function SYSDate(){
        CurrentDate=new Date();
	SYS_DATE_DD=CurrentDate.getDate();
       	SYS_DATE_MM=CurrentDate.getMonth()+1;
       	SYS_DATE_YY=CurrentDate.getFullYear();
      	if (parseInt(SYS_DATE_DD)<=9) {SYS_DATE_DD='0'+SYS_DATE_DD;}
	if (parseInt(SYS_DATE_MM)<=9) {SYS_DATE_MM='0'+SYS_DATE_MM;}
       
	var sysdate=SYS_DATE_DD+"-"+SYS_DATE_MM+"-"+SYS_DATE_YY;
         
return 	sysdate;
}



/////////////// To check the date is less than System Date

function sysDate(dd,mm,yy){
	var result=cmpCurrentDate(dd,mm,yy);

	if(result < 0){

		return false;
	}
return true;
}


/////////////////  Comparing with SYSTEM date.

function cmpCurrentDate(T_DATE_DD,T_DATE_MM,T_DATE_YY)
		{

			var ctemp,t_ServerDate;

			t_ServerDate=SYSDate();

			//Returns 1: T_DATE Greater Than CURRENT DATE
			//Returns 0: T_DATE Equal To CURRENT DATE
			//Returns -1: T_DATE Less Than CURRENT DATE
			

			F_DATE_DD=t_ServerDate.substr(0,2);

			F_DATE_MM=t_ServerDate.substr(3,2);

			F_DATE_YY=t_ServerDate.substr(6,4);

			return cmpDate(T_DATE_DD,T_DATE_MM,T_DATE_YY,F_DATE_DD,F_DATE_MM,F_DATE_YY);
		}

/////////  comparing between two dates


function cmpDate(F_DATE_DD,F_DATE_MM,F_DATE_YY,T_DATE_DD,T_DATE_MM,T_DATE_YY)
	{

		var ctemp,t_DateFormat;
		var temp;
		t_DateFormat="DD-MM-YYYY";

		//Returns 1: F_DATE Greater Than T_DATE
		//Returns 0: F_DATE Equal To T_DATE
		//Returns -1: F_DATE Less Than T_DATE

		if(t_DateFormat=="DD-MM-YYYY")
		{
			ctemp  = F_DATE_YY+"/"+F_DATE_MM+"/"+F_DATE_DD;
			temp = T_DATE_YY+"/"+T_DATE_MM+"/"+T_DATE_DD;
		//	alert("curDate"+ctemp);
		//	alert("SysDate"+temp);
		}
		if(t_DateFormat=="MM-DD-YYYY")
		{
			ctemp  = F_DATE_YY+"/"+F_DATE_DD+"/"+F_DATE_MM;
			temp = T_DATE_YY+"/"+T_DATE_DD+"/"+T_DATE_MM;
		}

		if (ctemp > temp)
			{
				return 1;
			}
		if (ctemp == temp)
			{
				return 0;

			}
		if (ctemp < temp)
			{
				return -1;
			}
	}




//Wrap function for calling calendar dhtml row
function fPopCalendar_dhtml(dateCtrl,control){

	index = (control.parentNode.parentNode.rowIndex) - 1;
	oTblElem = (control.parentNode.parentNode.parentNode);

	var len = oTblElem.rows.length;
	if(len == 2){
		//fPopCalendar(document.getElementById(dateCtrl1),document.getElementById(dateCtrl2),document.getElementById(dateCtrl3));
		oDateCtrl1 = eval("document.forms[0]."+dateCtrl+"_DD");
		oDateCtrl2 = eval("document.forms[0]."+dateCtrl+"_MM");
		oDateCtrl3 = eval("document.forms[0]."+dateCtrl+"_YY");
		fPopCalendar(oDateCtrl1,oDateCtrl2,oDateCtrl3);
	}
	else{
		oDateCtrl1 = eval("document.forms[0]."+dateCtrl+"_DD["+index+"]");
		oDateCtrl2 = eval("document.forms[0]."+dateCtrl+"_MM["+index+"]");
		oDateCtrl3 = eval("document.forms[0]."+dateCtrl+"_YY["+index+"]");
		fPopCalendar(oDateCtrl1,oDateCtrl2,oDateCtrl3);
	}
}

// Main: dateCtrl1 is the widget beyond which you want this calendar to appear;
//       dateCtrl is the widget into which you want to put the selected date.
// i.e.: <input type="text" name="dc" style="text-align:center" readonly><INPUT type="button" value="V" onclick="fPopCalendar(dc,dc);return false">
function fPopCalendar(dateCtrl1,dateCtrl2,dateCtrl3){

  gdCtrl1 = dateCtrl1;
  gdCtrl2 = dateCtrl2;
  gdCtrl3 = dateCtrl3;

  fSetYearMon(giYear, giMonth);
  var point = fGetXY(dateCtrl1);
  with (VicPopCal.style) {
  	//left = point.x;
  	//NOTE:08/12/2003:
  	//Above code commented to adjust the Calender Right Position :
  	left = point.x - 100;
  	//alert (left);
	top  = point.y+dateCtrl1.offsetHeight+1;
	width = VicPopCal.offsetWidth;
	height = VicPopCal.offsetHeight;
	fToggleTags(point);
	visibility = 'visible';
  }
  VicPopCal.focus();
}

//------------------------------------------------------------------
//Use this name=fPopCalendar_bottom , when using Calendar at Bottom
//side of the Form for proper form alignment:
function fPopCalendar_bottom(dateCtrl1,dateCtrl2,dateCtrl3){
  gdCtrl1 = dateCtrl1;
  gdCtrl2 = dateCtrl2;
  gdCtrl3 = dateCtrl3;

  fSetYearMon(giYear, giMonth);
  var point = fGetXY(dateCtrl1);
  with (VicPopCal.style) {
  	//left = point.x;
  	//NOTE:08/12/2003:
  	//Above code commented to adjust the Calender Right Position :
  	left = point.x - 100;
  	//alert (left);

  	//Commented on 17012004:
	//top  = point.y+dateCtrl1.offsetHeight+1;
	top  = (point.y+dateCtrl1.offsetHeight+1)- 220;
	width = VicPopCal.offsetWidth;
	height = VicPopCal.offsetHeight;
	fToggleTags(point);
	visibility = 'visible';
  }
  VicPopCal.focus();
}
//------------------------------------------------------------------

function fChangeMonth(){

	iMon = document.getElementById('tbSelMonth').value; 
	iYear =  document.getElementById('tbSelYear').value; 
	
	fUpdateCal(iYear, iMon);
}

function fHideCal(){
  var oE = window.event;
  if ((oE.clientX>0)&&(oE.clientY>0)&&(oE.clientX<document.body.clientWidth)&&(oE.clientY<document.body.clientHeight)) {
	var oTmp = document.elementFromPoint(oE.clientX,oE.clientY);
	while ((oTmp.tagName!="BODY") && (oTmp.id!="VicPopCal"))
		oTmp = oTmp.offsetParent;
	if (oTmp.id=="VicPopCal")
		return;
  }
  VicPopCal.style.visibility = 'hidden';
  for (i in goSelectTag)
	goSelectTag[i].style.visibility = "visible";
  goSelectTag.length = 0;
}

var gMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

with (document) {
write("<Div id='VicPopCal' onblur='fHideCal()' onclick='focus()' style='POSITION:absolute;visibility:hidden;border:2px ridge;width:10;z-index:100;'>");
write("<table border='0' bgcolor='#4D84A0'>");
write("<TR>");
write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:20;width:20;FONT:16 Fixedsys' onClick='fPrevMonth()' onblur='fHideCal()'>");
write("&nbsp;&nbsp;<select name='tbSelMonth' id='tbSelMonth' onChange='fChangeMonth()' Victor='Won' onclick='self.event.cancelBubble=true' onblur='fHideCal()'>");
for (i=0; i<12; i++)
	write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
write("</SELECT>");
write("&nbsp;&nbsp;<SELECT name='tbSelYear' id='tbSelYear'  onChange='fChangeMonth()' Victor='Won' onclick='self.event.cancelBubble=true' onblur='fHideCal()'>");
for(i=1900;i<2054;i++)
	write("<OPTION value='"+i+"'>&nbsp;&nbsp;"+i+"&nbsp;&nbsp;</OPTION>");
write("</SELECT>");
write("&nbsp;&nbsp;<input type='button' name='PrevMonth' value='>' style='height:20;width:20;FONT:16 Fixedsys' onclick='fNextMonth()' onblur='fHideCal()'>");
write("</td>");
write("</TR><TR>");
write("<td align='center'>");
write("<DIV style='background-color:teal;'><table width='100%' border='0'>");
fDrawCal(giYear, giMonth, 18, 16);
write("</table></DIV>");
write("</td>");
write("</TR><TR><TD align='center'>");
write("<B style='cursor:pointer' onclick='fSetDate(giYear,giMonth,giDay); self.event.cancelBubble=true' onMouseOver='this.style.color=gcToggle' onMouseOut='this.style.color=0'>Today:&nbsp;&nbsp;"+gMonths[giMonth-1]+"&nbsp;"+giDay+",&nbsp;&nbsp;"+giYear+"</B>");
write("</TD></TR>");write("</TD></TR>");
write("</TABLE></Div>");
}
// End -- Coded by Liming Weng, email: victorwon@netease.com -->
//END FUNCTIONS ARE USED FOR DATE POPUP
//===========================================

/*
function GetDateFormat()
{
	txt_cookie = document.cookie;
	myString = new String(txt_cookie);
	cookie_list = myString.split(";");
	cnt=cookie_list.length;
	for(i=0;i<cnt;i++)
	{
		cookie_val = cookie_list[i];
		final_cookie_list = cookie_val.split("=");
		final_cookie_val=final_cookie_list[0];
		rexp = / /gi;
		final_cookie_val=final_cookie_val.replace(rexp,'');
		if(final_cookie_val=="DATE_FORMAT")
		{
			//alert('final value new : ' + final_cookie_list[0]);
			//alert('final value new : ' + final_cookie_list[1]);
			return final_cookie_list[1];
		}
	}
}
*/

/*
	ADDED ON: 20/04/2004
	BY: KALAI SELVAN T.
	TAKES IN DAY, MONTH, YEAR AS '01', '01', '1980'
	RETURNS : 01-JAN-1980
*/

function getDateInWordFormat(sdd, smm, syy)
{
	var mon = getMonthInWord(smm);
	return sdd+"-"+mon+"-"+syy;
}


/*
	ADDED ON: 20/04/2004
	BY: ABIN
	TAKES IN MONTH AS '01' (RANGE - '01' TO '12')
	RETURNS : 'JAN' FOR '01'...............
*/

function getMonthInWord(sVal)
{
	var mon1 = "";

	if (sVal == "01")
	{
 		mon1 ="JAN";
	}
	else if (sVal == "02")
	{
 		mon1 ="FEB";
	}
	else if(sVal == "03")
	{
 		mon1 = "MAR";
	}
	else if(sVal == "04")
	{
 		mon1 ="APR";
	}
	else if ( sVal == "05")
	{
  		mon1 ="MAY";
	}
	else if ( sVal == "06")
	{
  		mon1 ="JUN";
	}
	else if ( sVal == "07")
	{
  		mon1 ="JUL";
	}
	else if ( sVal == "08")
	{
  		mon1 ="AUG";
	}
	else if ( sVal == "09")
	{
  		mon1 ="SEP";
	}
	else if ( sVal == "10")
	{
  		mon1 ="OCT";
	}
	else if ( sVal == "11")
	{
  		mon1 ="NOV";
	}
	else if ( sVal == "12")
	{
  		mon1 ="DEC";
	}

	return mon1;
}

///////////////////







function GetCookieVal(tCookieNm)
{
	txt_cookie = document.cookie;
	myString = new String(txt_cookie);
	cookie_list = myString.split(";");
	cnt=cookie_list.length;
	for(i=0;i<cnt;i++)
	{
		cookie_val = cookie_list[i];
		final_cookie_list = cookie_val.split("=");
		final_cookie_val=final_cookie_list[0];
		rexp = / /gi;
		final_cookie_val=final_cookie_val.replace(rexp,'');
		if(final_cookie_val==tCookieNm)
		{
			//alert('final value new : ' + final_cookie_list[0]);
			//alert('final value new : ' + final_cookie_list[1]);
			return final_cookie_list[1];
		}
	}
}

/*Used to disallow characters in numeric fields ---onkeypress*/
function IntCheck()  //Valid for Numbers Only
{
    var key=event.keyCode;
    if(!((key>=48 && key<=57) || key==8))
    {
        alert('Character(s) not allowed.');
        event.keyCode=0;
    }
}

/*Used to disallow characters in numeric fields ---onkeypress*/
function IntCheck1()  //Valid for [Numbers] & [Comma] & [Decimals] Only
{
    var key=event.keyCode;
    if(!((key>=48 && key<=57) || key==44 || key==46))
    {
        alert('Character(s) not allowed.');
        event.keyCode=0;
    }
}

/*Used to disallow characters in numeric fields ---onkeypress*/
function IntCheck2()  //Valid for [Numbers] & [Decimals] Only
{
    var key=event.keyCode;
    if(!((key>=48 && key<=57) || key==46))
    {
        alert('Character(s) not allowed.');
        event.keyCode=0;
    }
}

function AmountCheck(numVar)
{
	if((parseInt(numVar.indexOf("."))>0) && (numVar.length>12))
	{
		return false;
	}
	else
	{
		return true;
	}
}
/*Used to disallow Comma's in Dynamic Dataentry Fields.---onkeypress*/
function commaCheck()
{
    var key=event.keyCode;
    if((key==44))
    {
        alert('Comma(s) not allowed.');
        event.keyCode=0;
    }
}

/*Used to disallow characters in numeric fields ---onkeypress*/
function checkPhone()  //Valid for [Numbers] & [Decimals] Only
{
    var key=event.keyCode;
    //To do not allow a-->z & A-->Z characters:
    if(((key>=65 && key<=90) || (key>=97 && key<=122)))
    {
        alert('Character(s) not allowed.');
        //alert('key pressed is' + event.keyCode);

        event.keyCode=0;
    }
}

//To converting big decimal values in to specified decimal numbers.
function fnformatNumber(cStr,cDeci)
{
	cStr = String(cStr);
	if(cStr.indexOf(".")>0)
		{
			cStr = cStr.slice(0,cStr.indexOf(".")+parseInt(cDeci)+1);
		}
	cStr = parseFloat(cStr);
	return cStr;
}

//To Convert number in two decimal number
//function FormatDecNumber(Str)
//	{
//		if (Str!=0)
//			{
//			Str=Str.toString();
//			if (Str.length-Str.lastIndexOf('.')==2)
//				{
//					Str=Str+"0";
//				}
//			else
//				if (Str.indexOf('.')<0)
//				{
//					Str=Str+".00";
//				}
//			}
//		else
//			{
//				Str=Str.toString();
//				Str=Str+".00";
//			}
//		return Str;
//	}
function FormatDecNumber(Str,Cdeci)
	{

		Str=Str.toString();
		Str=parseFloat(Str,Cdeci)
		Str=Str.toString();
		cnt=0;
		Cdeci=parseInt(Cdeci);

		if (Str.indexOf(".")>0)
			{
				cnt=Cdeci-(Str.length-Str.indexOf('.')-1);
			}
		else
			{
				if (Cdeci!=0)
					{
						Str=Str+(".")
					}
				cnt=Cdeci;
			}

		for (i=0;i<cnt;i++)
			{
				Str=Str+"0";

			}
		if (Cdeci!=0)
			{
				Str = Str.slice(0,Str.indexOf(".")+parseInt(Cdeci)+1);
			}
		return Str;
	}
/*
function cmpDate(F_DATE_DD,F_DATE_MM,F_DATE_YY,T_DATE_DD,T_DATE_MM,T_DATE_YY)
	{
		var ctemp,t_DateFormat;
		t_DateFormat=GetCookieVal("DATE_FORMAT");

		//Returns 1: F_DATE Greater Than T_DATE
		//Returns 0: F_DATE Equal To T_DATE
		//Returns -1: F_DATE Less Than T_DATE
		//if (parseInt(F_DATE_DD)<9) {F_DATE_DD='0'+F_DATE_DD;}
		//if (parseInt(F_DATE_MM)<9) {F_DATE_MM='0'+F_DATE_MM;}
		//if (parseInt(T_DATE_DD)<9) {T_DATE_DD='0'+T_DATE_DD;}
		//if (parseInt(T_DATE_MM)<9) {T_DATE_MM='0'+T_DATE_MM;}

		if(t_DateFormat=="DD-MM-YYYY")
		{
			ctemp  = F_DATE_YY+"/"+F_DATE_MM+"/"+F_DATE_DD;
			ctemp1 = T_DATE_YY+"/"+T_DATE_MM+"/"+T_DATE_DD;
		}
		if(t_DateFormat=="MM-DD-YYYY")
		{
			ctemp  = F_DATE_YY+"/"+F_DATE_DD+"/"+F_DATE_MM;
			ctemp1 = T_DATE_YY+"/"+T_DATE_DD+"/"+T_DATE_MM;
		}

		if (ctemp > ctemp1)
			{
				return 1;
			}
		if (ctemp == ctemp1)
			{
				return 0;
			}
		if (ctemp < ctemp1)
			{
				return -1;
			}
	}

function cmpCurrentDate(T_DATE_DD,T_DATE_MM,T_DATE_YY)
	{
		var ctemp,t_DateFormat;
		t_DateFormat=GetCookieVal("DATE_FORMAT");

		//Returns 1: T_DATE Greater Than CURRENT DATE
		//Returns 0: T_DATE Equal To CURRENT DATE
		//Returns -1: T_DATE Less Than CURRENT DATE
		CurrentDate=new Date();
		F_DATE_DD=CurrentDate.getDate();
		F_DATE_MM=CurrentDate.getMonth()+1;
		F_DATE_YY=CurrentDate.getFullYear();
		if (parseInt(F_DATE_DD)<9) {F_DATE_DD='0'+F_DATE_DD;}
		if (parseInt(F_DATE_MM)<9) {F_DATE_MM='0'+F_DATE_MM;}
		return cmpDate(T_DATE_DD,T_DATE_MM,T_DATE_YY,F_DATE_DD,F_DATE_MM,F_DATE_YY);
	}
*/
//NOTE:FOR #:
//When passing values in query string from 1-page to other,
//if it contains # sign then all values will not be dumped on form
//where we take values of query string using Request.querystring.
//So, restrict # entry in popUp page or like that any page,
//whose values will be taken on some other page:
//*So, below restricting # Entry also:

//CHECKING for ~, ^, | and do not allow user to enter these 3 special characters:

var isShiftKeyPressed = false;
function specialCharCheck()
{	//Here var declaration does not work, so declare it above function:
	//	var isShiftKeyPressed = false;
	//alert('code is: '+ event.keyCode);


	if(event.keyCode == 16)
	{
		isShiftKeyPressed = true;
	}
	if(event.keyCode == 54 && isShiftKeyPressed) //SHIFT+6 = ^
	{
		//event.cancelBubble =0;
		isShiftKeyPressed = false;
		alert('Special Character(s) not allowed.');
	}

	if(event.keyCode == 192 && isShiftKeyPressed) //SHIFT+` = ~
	{
		isShiftKeyPressed = false;
		alert('Special Character(s) not allowed.');
	}

	if(event.keyCode == 220 && isShiftKeyPressed) //SHIFT+\ = |
	{
		isShiftKeyPressed = false;
		alert('Special Character(s) not allowed.');
	}

	if(event.keyCode == 51 && isShiftKeyPressed) //SHIFT+3 = #
	{
		isShiftKeyPressed = false;
		alert('Special Character(s) not allowed.');
	}
}


/*
	Date: 22/04/2004 starts
	Functions for Adding and Deleting Rows dynamically in a table
*/


/*
	Adds a new row at end of a table.
	parameter: 1] array of string which is to be added inside the colume (Length of array decides the number of column).
		   2] Table name.
	Rtn Value: The index of the inserted row
*/
function addNewRowAtEnd(arrCellContent, tblname) //addNewRow(arrCellContent, tblname) start
{
	var i=0, totalCell = arrCellContent.length;
	var oRow;
	var oCell;

        /* I am inserting a new row*/
        var tabElem = document.getElementById(tblname);
        oRow = tabElem.insertRow(tabElem.rows.length);

	for(i=0;i<arrCellContent.length;i++)
	{
        	oCell = oRow.insertCell(oRow.cells.length);
		oCell.innerHTML = arrCellContent[i];
	}

	return tabElem.rows.length - 1;
} //addNewRowAtEnd(arrCellContent, tblname) end


/*

*/
function checkAllCheckBox(chkAll, chkList) //checkAllCheckBox(chkAll, chkList) starts
{
	var totlen,cnt;
	cnt=0;
	totlen  = document.form0.elements.length;
	for(m=0;m<totlen;m++)
	{
		typ = document.form0.elements[m].type
		nm  = document.form0.elements[m].name
  		if (typ=="checkbox" & nm == chkList)
		{
			cnt = cnt+1;
		}
	}
	if(cnt>0)
	{
		if(eval("document.form0."+chkAll+".checked") == true)
		{
			if(cnt==1)
			{
				eval("document.form0."+chkList+".checked = true");
			}
			else
			{
				for(i=0;i<cnt;i++)
				{
					eval("document.form0."+chkList+"[" + i + "].checked  = true");
				}
			}
		}
		else
		{
			if(cnt==1)
			{
				eval("document.form0."+chkList+".checked = false");
			}
			else
			{
				for(i=0;i<cnt;i++)
				{
					eval("document.form0."+chkList+"[" + i + "].checked  = false");
				}
			}
		}
	}
	else
	{
		alert("Sorry!!! No Rows Found for Selection.");
		eval("document.form0."+chkAll+".checked = false");
	}
	return true;
}// checkAllCheckBox(chkAll, chkList) ends


/*
	Deletes rows from the table if it contains a checkbox to select the row.
	parameter: 1] checkbox name.
		   2] Table name.
*/
function deleteCheckedRows(chkName, tblName) //deleteCheckedRows(chkname, tblname) start
{
	var i,totlength,oRow,cnt,tlen;
	cnt=0;totlength=0,tlen=0;
	var tbodyElem = document.getElementById(tblName);
	totlength = tbodyElem.rows.length - 1;
	//var chkObj = document.forms[0].item(chkName);
	var chkObj = eval("document.forms[0]."+chkName);

	if(chkObj != null)
	{
		if(isNaN(chkObj.length))
		{
			totlength = 1;
		}
		else
		{
			totlength = chkObj.length;
		}


	}
        else
		return false;

	//I am counting the no. of selection made and the no. of item present.
	//If both the are equal then I am giving a error message atleast one item has
	//to be present
	for(i=0; i<totlength; i++)
	{
		if (totlength == 1)
		{
			if (eval("document.form0."+chkName+".checked") == true)
			{
				cnt = cnt + 1;
			}
                }
		else
		{
			if (eval("document.form0."+chkName+"["+ i +"].checked") == true)
			{
				cnt = cnt + 1;
			}
                }
	}

	if (cnt<=0)
	{
		alert("Atleast One Item has to be present for Delete Operation.");
		return false;
	}

	if (confirm("Do you want to Delete the selected record ?"))
	{
        	var index;
		/* I am deletion the item which has been selected*/
		for(i=totlength-1;i>=0;i--)
		{
			if (totlength == 1)
			{
				if (eval("document.form0."+chkName+".checked") == true)
				{
					index = eval("document.form0."+chkName+".parentNode.parentNode.rowIndex");
					tbodyElem.deleteRow(index);
				}
			}
			else
			{
		  		if (eval("document.form0."+chkName+"["+ i +"].checked") == true)
		  		{
					index = eval("document.form0."+chkName+"["+ i +"].parentNode.parentNode.rowIndex");
					tbodyElem.deleteRow(index);
				}
			}
		}
	}
	return true;
} ////deleteCheckedRows(chkname, tblname) ends

/*
	To delete all rows from a table
	parameter: Table name
*/
function deleteAllRows(tblName) //deleteAllRows(tblName) starts
{
	var i,totlength,oRow,cnt,tlen;
	cnt=0;totlength=0,tlen=0;
	var tbodyElem = document.getElementById(tblName);
	totlength = tbodyElem.rows.length - 1;
	for(i=totlength;i>=1;i--)
	{
		tbodyElem.deleteRow(i);
	}
	return true;
} ////deleteAllRows(tblName) ends


///////////////////////////////////////////


/*
	To add a new at the end of a table and also sets cell attributtes
	parameter: 1] array of cellProperty. array length should equal to no of columns
		   2] array of HTML content. array length should equal to no of columns
                   3] table name
*/
function addNewRowWithCellProperty(arrCellProperty, arrCellContent, tblName)
{
	var rowIndex = addNewRowAtEnd(arrCellContent, tblName);
	setCellProperty(arrCellProperty, rowIndex, tblName);
}


/*
	To set property of cells in a row
	parameter: 1] array of cellProperty. array length should equal to no of columns
		   2] index of the row
                   3] table name
*/

function setCellProperty(arrCellProperty, rowIndex, tblName)
{
	var tabObj = document.getElementById(tblName);
	var arrRows = tabObj.rows;
	var arrCells = arrRows[rowIndex].cells;
	for(var i=0;i<arrCells.length;i++)
	{

		arrCells[i].id = arrCellProperty[i].id;
		arrCells[i].className = arrCellProperty[i].className;
		arrCells[i].align = arrCellProperty[i].align;
		arrCells[i].bgcolor = arrCellProperty[i].bgcolor;
		arrCells[i].height = arrCellProperty[i].height;
		arrCells[i].width = arrCellProperty[i].width;
		arrCells[i].colspan = arrCellProperty[i].colspan;
		arrCells[i].rowspan = arrCellProperty[i].rowspan;
		arrCells[i].valign = arrCellProperty[i].valign;
		arrCells[i].nowrap = arrCellProperty[i].nowrap;
	}

	return true;
}

/*
	JavaScript Object
*/

function cellProperty(id, className, style, bgcolor, valign, align, height, width, colspan, rowspan, nowrap)
{
	this.id = id;
	this.className = className;
	this.style = style;
	this.bgcolor = bgcolor;
	this.align = align;
	this.valign = valign;
	this.height = height;
	this.width = width;
	this.colspan = colspan;
	this.rowspan = rowspan;
	this.nowrap = nowrap;
}

/*
	Date: 22/04/2004 starts
	Adding and Deleting Rows dynamically in a table
*/


/*

This is to change the flag to Edit for all rows fetched from the dataset into the grid used for 
the Java framework developed by CMC.


*/

	function chngGridFlag2Edit(gridname){
		grd = eval(gridname + "_myData");
		grd_ln = grd.length;
		flag = 0;
		for ( i = 0 ; i < grd_ln ; i ++ ){
			inarr = grd[i];
			flag = inarr.length;
			if (flag > 0 ){
				//alert("inarr[0] : " + inarr[0]);

				myString = new String(inarr[0]);
				myValueString = getRowValue(gridname,grd, i);

				rExp = fldSetSep;
				newValueString = new String ("")
				ValueResults = myValueString.replace(rExp,newValueString)
				myValueString = ValueResults + fldSetSep + ValueResults;

				results = "<input type='hidden' name='" + gridname + "rowflag' value='E' />" + 
				"<input type='hidden' name='" + gridname + "rowvalue' value='" + myValueString + "' />"

				//alert(results);
				inarr[0]= results;
			}
		}
			
		if (flag > 0 )
		{
			obj = eval(gridname + "obj");

			obj.refresh();
		}
	}
    //added by NVKrishna
	// u just call this function on onKeyUp event.
	function checkApostrophe(feild,msg){
	str = document.getElementById(feild).value;
	for(i = 0;i<str.length;i++){
		if(str.charAt(i) =="'"){
			alert("Apostrophe is not allowed in "+msg);
			document.getElementById(feild).focus();
			document.getElementById(feild).value="";
			return false;
		}
	}
	return true;
	}
	


function iscontactnumber(str)
{
	if(str!="")
	{
		
	var vtmp,string,count,x;
	string = str
	for (count=0; count<string.length; count++)
	/*checking if there is a combination of no. and alphabet.
	because paseInt is returning number if the input as  above
	*/
    {
		x = string.substring(count, count+1)
		RefString="1234567890/";
		if (RefString.indexOf (x, 0)==-1)
		{
			//alert("Invalid Number")
			return (false);
		}
    }

	vtmp =  parseInt(str);
	if ( isNaN(vtmp) || (vtmp <= 0 ) ) //checking for alphabet and zero and negative
	{
		return false;
	}
	else
	{
		return true;
	}
	}
} //End Function function isnumber(str)


