//KaushikP | 20041102
//Following code blocks the script error
function blockError(){return true;}
window.onerror = blockError;

//JunedM | 20050420
//This function will disable the right click on every page of PowerWEB.
function General_RightClickDisable()
			{
				if (event.button ==2)
				{
					ShowAlert("You can't use right click on this page")			
					return false	
				}
			}
document.onmousedown=General_RightClickDisable;
//alert(window.frameElement.style)
//window.frameElement.style="BACKGROUND-POSITION: center center; BACKGROUND-IMAGE: url(/PowerWEB/ICONS/loading.gif); BACKGROUND-REPEAT: no-repeat"


/*
	VipulP | CRF#16941 | 12/15/2005
	Declared vairable for storing the cookie value of Medical Necesssity.
	If GLO_Cookies_ABN = 1 -->Check Medical Necessity.
	else  --> Do not Check Medical Necessity. 
	CABN-->CHECK ABN
*/
var GLO_Cookies_ABN="CABN"	

/*
	NilayM | CRF#27385 | 20060919
	Declared Global variables for "ALL PATIENT" and "ACTIVE PATIENT"
	Declared this variables of 'Request Type' for AJAX Implementation.
*/

var GLO_NextRequest = "NextSearch"
var GLO_PrevRequest = "PrevSearch"
var GLO_DateLessRequest = "DateLess"
var GLO_DateSearchRequest = "DateSearch"
var GLO_ParameterXML = "<?xml version='1.0' encoding='windows-1252' ?><ROOT>"
var GLO_ParameterXMLEnd = "</ROOT>"


/*
JunedM | 20050407
This is the global variable used for storing section Expand/Collaps in New Order page.
*/
var GLO_Cookies_Section="NS"

/*
JunedM | 20050407
This is the global variable used for storing section Expand/Collaps in New Patient page.
*/
var GLO_Cookies_PatientSection="PS"

var LOC_Open="1"
var LOC_Close="0"
/*	NilayM | CRF#26163 | 20060823
	This Message is used by Today_StandingOrder.aspx page
	This Variable is also used in PWModule.vb file
	so Whenever you change this variable at that time change here also
*/
var GLO_FACILITY_ERROR_MESSAGE = "This ability not provided to you (OR) Session has expired"
// Vipul 200511 | |CRF#
//Deleted but again copied because required in DelteOldCookie function on TodayPage
var LOC_BillingSection="BillingSection"
var LOC_OrderingSection="OrderingSection"
var LOC_DiagnosisSection="DiagnosisSection"
var LOC_SpecimenSection="SpecimenSection"
var LOC_TestProfileSection="TestProfileSection"
var LOC_PrintOptionSection="PrintOptionSection"
var LOC_NotesCollection="NotesOptionSection"
var LOC_ExtraReportSection="ExtraReportSection"

// Vipul 200515 | |CRF#
//Variable for section expand collapse for NewPatient. 
var LOC_BillingSectionNewPatient="BillingSectionNewPatient"
var LOC_MiscSection="MiscelleneousSection"
var LOC_NotesSection="NotesSection"

//Vipul CRF#16443 20050407
//Varibles for Settings Cookies 

var LOC_TodaySettings="SToday"

 //XMLForCustomize="Property.xml"
 //Validation rule.//
 // B- Field Can not be Blank
 // S- Field Can not enter any Special Character.
 // E- Field is an E-mail Field
 // N- Field can Enter only Numeric.
 // C- Field can Enter only Character.
 // D- Date Field. 
 // P- Space not Allowed.

//Cookies variables
var CookiesFolder="/"
var PrintCopies="printcopies"
var LabelCookiesName="firstname"
var e_HistoLogisSettingCookies="SetHistoOrder"
var e_CookiesUserID_TimeOut="CookiesUserID_TimeOut"
var e_CookiesSessionID_TimeOut="CookiesSessionID_TimeOut"

/*
	DevangM | CRF#21277 | 20051214
	This equate is declared to specify the no format error.
*/
var e_NoFormat_Error = "There is some problem in format \nPlease contact LAB administrator and relogin to PowerWEB."

/*
	DevangM | CRF#25840 | 20060513
	This equate is declared to specify Font Downloade completion message
*/

var e_FontDownloadMsg = "Required font(s) are downloaded, it is recommended to restart your system."

/*
	DevangM | CRF#21264 | 20060705
	This is Equate is added for Error message to be displayed for Validation failure of Requisition No
	In Ordering Page
*/
var e_ConfirmAccessionNoWithMaxLength = ReplacePropertyString("Accession is already created for specified requisition and newly generated requisition number has length more than 20 characters. So keeping the field blank.")
var e_OrdClinicReqNoMsg = ReplacePropertyString("Due to some reason Ordering Clinic found blank/inactive.") + "\n" + ReplacePropertyString("Please Logoff and try to create accession again.")
var e_OrdFacErrMsg = ReplacePropertyString("The selected/entered Ordering Clinic doesn't exist or is inactive.") + "\n" +  ReplacePropertyString("Please select/enter correct Ordering Clinic.")
var e_RptClinicErrMsg = ReplacePropertyString("The selected/entered Reporting Clinic doesn't exist or is inactive.") + "\n" +  ReplacePropertyString("Please select/enter correct Reporting Clinic.")
var e_ConfirmAccessionNo = ReplacePropertyString("Accession is already created for specified requisition.") + "\n" + ReplacePropertyString("Are you sure to create new accession with next valid requisition number?")

/*
  VipulP | CRF#21357 | 20051118
  Declare the cookie variable to store Shipment Report Option.
*/
var e_CookiesShipmentOption="Shi_Opt"

/*
   VipulP CRF#23748 20060710
   This equate will be used in case if we do not need to search for messages through property.xml
*/
var e_NoCheck="NoCheck"

/*
		   VipulP | CRF#25111 | 20060808
		   Below equates passed to setMsg function to indicate
		   wheter Report DisplyMode fullscreen or not.		   
*/
		
		var e_FullScreenYes= "YES"
		var e_FullScreenNo= "NO"

/*Method common is used to check the following detail from the any form
    1> Check the validation as per given in the form
 		2> Check the size of control box
 		Following Validation is to be done on any Control of any form
 		 	B - Field Can not be Blank
	 		S - Field Can not enter any Special Character.
 			A - Field Can be Only Alpha Numberic Field and can contain Space
 			E - Field is an E-mail Field
  			N - Field can Enter only Numeric.
  			C - Field can Enter only Character.
			D - Field is a Date Field
			F - Field is an Float Datatype Field
*/ 	
/*
	******************************************
	DevangM | CRF#23191 | 20060217
	The Message Section Starts here
	******************************************
*/
//#########################################################################################

/*Constant for message to be dispalyed while saved report is getting some error*/	
//var e_Message_SaveError="";
var e_Message_SaveError=ReplacePropertyString("Due to one of the following reason, you are not able to open the report.") + "\n"  + "\n"
e_Message_SaveError=e_Message_SaveError +  ReplacePropertyString("1. Report is not saved properly")  + "\n" 
e_Message_SaveError=e_Message_SaveError +  ReplacePropertyString("2. You are not having proper rights to open this file")  



var e_CollectionDateEmpty = 'Please enter Collection Date.'
var e_ScheduleDateEmpty = 'Please enter Schedule Date.'
//Message Section Ends
//#########################################################################################
/*
	DEvangM | CRF#25490 | 20060406
	The Singature is changed to include the Null format string to Compare zero string
*/
function common(formIndex,obj_ary,obj_chk,obj_size,obj_zerostr)
{
for(i=0;i<obj_ary.length;i++)
 {//for loop of object array loop
   		var display=obj_ary[i];
   		/*
   			DEvangM | CRF#25490 | 20060406
   			Get the Format String 
   		*/
   		/*
   		   DevangM  |CRF#26174 | 20060531
   		   Added try catch block
   		*/
   	    try{	
   			 var LOC_ZeroStr = obj_zerostr[i]
   		   }
   		   catch(exception)	
   		   {
   		   
   		   }
			var idx=display.indexOf('|');
			//Retrieve the Display Value of Control box if specified
			if(idx!=-1) 
			 {
				  display=display.substring(idx+1);
				  obj_ary[i]=obj_ary[i].substring(0,idx);
			 }
   		var s1=document.forms[formIndex].elements[obj_ary[i]];
//   		if(s1.name==obj_ary[i])
//   	 	 {//if both control is matched
			 //check for sizefield
			 //alert(i);
			 //alert(obj_ary[i]);
			 	if(!sizeField(s1,obj_size[i],display))
   	 	 	   return false;
   	 	 	for(var k=0;k<obj_chk[i].length;k++)
   	 	 	{//access list for loop
   	 	 	  var chk=obj_chk[i].substring(k,k+1);
   	 	 	  //check for Blank Condition
   	 	 	  if(chk=='b' || chk=='B')
   	 	 	   {
   	 	 	   	  removeblank(s1);
   	 	 	   	   /*
   	 	 	   		DEvangM | CRF#25490 | 20060406
   	 	 	   		Pass the Format string in following function
   	 	 	   		to validate whehter it should be blank or not.
   	 	 	   	  */	
   	 	 	   	  try
   	 	 	   		{
   	 	 	   	  if(!blankField(s1,display,LOC_ZeroStr))
   	 	 	   	      return false;
   	 	 	   	    }
   	 	 	   	    catch(exception)  
   	 	 	   	    {
   	 	 	   	    }
   	 	 	   }//End of Blank Field Checking Condition
   	 	 	   //check for Number Field
   	 	 	   else if(chk=='n' || chk=='N')
   	 	 	   {
   	 	 	   	  if(!numberField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Number Field Checking Condition
   	 	 	   //check for Float Field
   	 	 	   else if(chk=='f' || chk=='F' )
   	 	 	   {
   	 	 	   	  if(!floatField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Float Field Checking Condition
   	 	 	   //check for Character Field
   	 	 	   else if(chk=='c' || chk=='C')
   	 	 	   {
   	 	 	   	  if(!charField(s1,display))
   	 	 	   	    return false;
   	 	     }//End of Character Field Checking Condition
   	 	     //check for Date Field
   	 	     else if(chk=='d' || chk=='D')
   	 	 	   {
   	 	 	   	  if(!check_date(s1.value,s1,display))
   	 	 	   	    {    return false;}
   	 	 	   	    
   	 	 	   }//End of Character Field Checking Condition
   	 	 	   //check for E-mail Field
   	 	 	   else if(chk=='e' || chk=='E')
   	 	 	   {
   	 	 	   	  if(!emailField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Email Field Checking Condition
  	 	 	   //check for Special Characters
  	 	 	   else if(chk=='s' || chk=='S')
   	 	 	   {
   	 	 	   	  if(!specialField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Special Character Checking Condition
 	 	       //check for Alphanumeric Characters
 	 	       else if(chk=='a' || chk=='A')
   	 	 	   {
   	 	 	   	  if(!nameField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Alphanumeric Checking Condition
  		 	//check for Space
 	 	       else if(chk=='p' || chk=='P')
   	 	 	   {
   	 	 	   	  if(!spaceField(s1,display))
   	 	 	   	    return false;
   	 	 	   }//End of Space Checking Condition
   	 	 	}//End of For loop for separting each Checking- access list
//   	 	 }//End of If condition for matching object
//   	}//End of for loop of elements of form
 }//End of for loop of passing array objects
return true;
}//End of function


//Function specialField is used check weather the field
//contains any Special Characters or not.
function specialField(formCtrl,display)
{
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == " ") || 
			(str.charAt(x) == "@"))
		{
			ShowAlert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//End of specialField function

//Function nameField is used check that field should
//contains only alphanumeric characters and blank space
function nameField(formCtrl,display)
{
 var str = formCtrl.value;
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || 
			(str.charAt(x) == "@"))
		{
			ShowAlert("Special Characters are not allowed")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}
	}
  return true;
}//end of nameField method

//Function emailField is used check the validation of normal email id
function emailField(formCtrl)
{
 var str = formCtrl.value;
 var len=str.length;
 var apos=str.indexOf('@');	
 var dotpos=str.lastIndexOf('.');	
 var lastpos=str.length-1;
  if(len>0)
  { //if length condition
  if(apos<1 || dotpos-apos<2 || lastpos-dotpos<2)
	{
		ShowAlert('Please Enter Email Address in Proper Format');
		formCtrl.select();
		formCtrl.focus();
		return false;
	}
	for(x = 1; x <= str.length; x++)
    {
		if((str.charAt(x) == "~") || (str.charAt(x) == "`")  || (str.charAt(x) == "#") || 
			(str.charAt(x) == "$") || (str.charAt(x) == "%") || (str.charAt(x) == "^") || 
			(str.charAt(x) == "&") || (str.charAt(x) == "*") || (str.charAt(x) == "(") || 
			(str.charAt(x) == ")") || (str.charAt(x) == "+") || (str.charAt(x) == "?") || 
			(str.charAt(x) == "<") || (str.charAt(x) == ">") || (str.charAt(x) == "/") || 
			(str.charAt(x) == "|") || (str.charAt(x) == "{") || (str.charAt(x) == "}") || 
			(str.charAt(x) == "[") || (str.charAt(x) == "]") || (str.charAt(x) == " "))
		 {
			ShowAlert("Please enter valid E-mail")
			formCtrl.select();
			formCtrl.focus();
			return false;
		}//End of if condition
	}//End of for loop
}//end of length if condition
return true;
}	//end of emailField method

//function blakField used to check whether the field is blank or not
//DEvangM | CRF#25490 | 20060406
function blankField(formCtrl,display,zeroStr)
{
//alert(formCtrl.value.length+' length');
try
 {
if(formCtrl.value.length==0)
 {
	ShowAlert(display+' should not be blank');
	formCtrl.select();
	formCtrl.focus();
	formCtrl.className='RequiredFields';
	return false;
 }
 else
 {
	/*
	   DEvangM | CRF#25490 | 20060406
	   We will check whete format string and entered string
	   are identical or not. if they are same we should prompt
	   user to enter the respective field value.			
	*/
	
	if(trimX(formCtrl.value)==zeroStr)
	{
		ShowAlert("Please enter valid " + display);
		formCtrl.select();
		formCtrl.focus();
		formCtrl.className='RequiredFields';
		return false;
	}
	formCtrl.className='TextBox';
 }
return true; 
}
catch(exception)
{
}
}//End of blankField method


/****************************************************************
 DevangM| 20051108 | CRF#21127
 SSN was sent with spaces which resulted in some extra junk character in reply
 Previous Trim could not remove all white spaces
******************************************************************/
function trimX(sString) 
{ 
	try
	{  
		var sTrimmedString1 = ""; 
		if (sString != "") 
		{ 
			var iStart = 0; 
			var iEnd = sString.length - 1; 
			while(CheckWhiteSpace(sString.charAt(iStart))==true)
			{     
			iStart++; 
			if (iStart > iEnd) 
			break; 
			} 
		    
		// If the string not just whitespace 
			if (iStart <= iEnd) 
			{ 
				while(CheckWhiteSpace(sString.charAt(iEnd))==true)
					iEnd--; 
			} 
		 
		 
			sTrimmedString1 = sString.substring(iStart,++iEnd);  
		}
		return sTrimmedString1;
	}catch(exception)
	{
	
	}
}


/***********************************************************************
 DevangM| 20051108 | CRF#21127
 This Function Checks if the given character is Whitespace or not.
************************************************************************/
 
 function CheckWhiteSpace(p_Char)
 {
	switch (p_Char)
	{
		case " ":
		case "\t":
		case "\f":
		case "\n":
		case "\r":
		case "\v":
			return(true);
			break;
		default:
			return(false);
	}
 }
 
//***********************************************************************************************


//function blakField used to check whether the field is blank or not
function blankField11(formCtrl,display)
{
//alert(formCtrl.value.length+' length');
if(formCtrl.value.length==0)
 {
	ShowAlert(display+' should not be blank');
	formCtrl.select();
	formCtrl.focus();
	formCtrl.className='RequiredFields';
	return false;
 }
 else
 {	
	formCtrl.className='TextBox';
 }
return true; 
}//End of blankField method


function spaceField(formCtrl,display)
{
str=formCtrl.value;
if(str.indexOf(' ')!=-1)
 {
	ShowAlert(display+' Can not Contain Space');
	formCtrl.select();
	formCtrl.focus();
	return false;
 }
return true; 
}//End of spaceField method


//function numberField is used to check that field
//should contain only number .
function numberField(formCtrl,display)
{
if(isNaN(formCtrl.value))
 {
	ShowAlert(display+' contains only Numbers ');
	formCtrl.select();
	formCtrl.focus();
	return false;
 }
return true; 
}//end of numberField method


//function charField is used to check that field
//should contain only character.
function charField(formCtrl,display)
{
if(!isNaN(formCtrl.value))
 {
	ShowAlert(display+' contains only Characters');
	formCtrl.select();
	formCtrl.focus();
	return false;
 }
return true; 
}//end of charField method

//function numberField is used to check that field  length
//should satisfies it's maximum length 
function sizeField(formCtrl,size,display)
{
//       alert(formCtrl.value);
       str=formCtrl.value;

        if(str.length>size)
 	{	
 		ShowAlert('The Maximum Limit of '+display+' is '+size+' characters' ); 
		formCtrl.select();
		formCtrl.focus();
  		return false;
  	}
  	return true;
}//end of sizeField method

//function numberField is used to check that field
//should contain only float type .
function floatField(formCtrl,display)
{
	str = formCtrl.value;
	len=str.length;
  //alert(str.length); 
  flag=1
  for(x=0;x<len;x++)
  {
  	//alert(str.charAt(i)); 
  	if(!(str.charAt(x)=='.' || !isNaN(str.charAt(x))))
  	  flag=0; 
  }
	if(flag)
		return true;
	else {
		ShowAlert('Not Valid Number Format' ); 
		formCtrl.select();
		formCtrl.focus();
		return false;
	}	
}//End of floatField method

//function numberField is used to check that field
//should valid date .
function check_date(frmNmCtl,frmFocus,display)
{
	var ls_date, li_yy, li_mm, li_dd, ld_date;
	
	ls_date = frmNmCtl;

	if(ls_date.length == 0)return true;
	else{
	if(ls_date.length != 10)
	{ ShowAlert("Error in length of Date");
		frmFocus.select();
		frmFocus.focus();
		return false;
	}
	else
	{	if ((ls_date.charAt(2) != "/") || (ls_date.charAt(5) != "/"))
		{	ShowAlert("Please use slash to seperate day, month and year. ");
		  frmFocus.select();
		  frmFocus.focus();
			return false;
		}
		else
		{	li_yy = 9999;
			li_mm = 99;
			li_dd = 99;
			li_dt = ls_date.split("/");
			li_yy = li_dt[2];
			li_mm = li_dt[1];
			li_dd = li_dt[0];

			if(isNaN(li_yy)){
				ShowAlert("Year Entered Contains Non Numeric Character");
				frmFocus.select();
				frmFocus.focus();
				return false;	
			}

			if(isNaN(li_mm)){
				ShowAlert("Month Entered Contains Non Numeric Character");
				frmFocus.select();
				frmFocus.focus();
				return false;	
			}

			if(isNaN(li_dd)){
				ShowAlert("Date Entered Contains Non Numeric Character");
				frmFocus.select();
				frmFocus.focus();
				return false;	
			}

			if ((li_yy < 1850) || (li_yy > 3050))
			{	ShowAlert("Year entered is either less than 1850 or greater than 3050.");
				frmFocus.select();
				frmFocus.focus();
				return false;
			}
			if ((li_mm > 12) || (li_mm < 1))
			{	ShowAlert("Entered month does not fall between 1 to 12.");
				frmFocus.select();
				frmFocus.focus();
				return false;
			}
			if ((li_mm == 1) || (li_mm == 3) || (li_mm == 5) || (li_mm == 7) || (li_mm == 8) || (li_mm == 10) || (li_mm == 12))
			{
				if (li_dd > 31)
				{	
					ShowAlert("Entered Date does not fall in this month.");
					frmFocus.select();
					frmFocus.focus();
					return false;
				}
			}
			if ((li_mm == 4) || (li_mm == 6) || (li_mm == 9) || (li_mm == 11))
			{	
				if (li_dd > 30)
				{	
					ShowAlert("Entered date does not fall in this month.");
					frmFocus.select();
					frmFocus.focus();
					return false;
				}
			}
			if (li_mm == 2) //leap year
			{
     		if (li_yy % 4 != 0)
         {if (li_dd > 28) {ShowAlert("Days cannot be greater than 28"); frmFocus.select(); frmFocus.focus; return false;}}
     		else if  (li_yy % 400 == 0)
         {if (li_dd > 29) {ShowAlert("Days Cannot be greater than 29."); frmFocus.select(); frmFocus.focus;  return false;}}
     		else if (li_yy % 100 == 0)
         {if (li_dd > 28) {ShowAlert("Days cannot be greater than 28.");  frmFocus.select(); frmFocus.focus;  return false;}}
       else
         {if (li_dd > 29) {ShowAlert("Days Cannot be greater than 29."); frmFocus.select();frmFocus.focus;  return false;}}
			}
			return true;
		}
	}
 }
}//End of dateField method


function removeblank(field)
{
//alert(field.value);
//var j = field.value.length;
//alert(j);

var newstr=field.value;
var j=newstr.length;
    for(var i=0;i<j;i++)
      {
      if(i==0 && newstr.charAt(0)==' ')
          {
	          newstr=newstr.substring(1,j+1);
	          j=newstr.length;
	          i--;
         	}
       }
		field.value=newstr;
		j=newstr.length;
		for(var k=0;k<j;k++)
			{
				var m=k+1;
				if(newstr.charAt(k)==newstr.charAt(k+1)&&newstr.charAt(k+1)==' ')
					{
						newstr=newstr.substring(0,m-1) + newstr.substring(m,j+1);
						j=newstr.length;
						k--;	
					}
			}
field.value=newstr;
}


function DateComparison(formindex,d1,d2)
{
	return 1;
	var sdate =document.forms[formindex].elements[d2].value;
	var fdate= document.forms[formindex].elements[d1].value;

	fyy = fdate.substring(6,10);
	fmm = fdate.substring(3,5);
	fdd = fdate.substring(0,2);	


	syy = sdate.substring(6,10);
	smm = sdate.substring(3,5);
	sdd = sdate.substring(0,2);	


	if(fyy>syy)
		{
			return 1;
		}

	else if(fyy < syy)
				{
				return 2;
				}
	else
	{
		if(fmm>smm)
			{
				return 1;
			}		
		else if(fmm < smm)
			{
				return 2;
			}
		else
		{
			if(fdd > sdd)
				{
					return 1;
				}
			else if(fdd < sdd )
				{
					return 2;
				}
			else
				{
					return 0;
				}	
		}
	}	
}




function InitList(sName)
{
	var len = sName.options.length;
	if (len < 1)
	    return;
		
	for (i=0; i<=len; i++)
	{
	
			sName.options[0]=null;
	}
	
}

function fillSkill(sName, sObj,sHid)
{
  
	index = 0;
	var opt;
	var selcat;
	var s;
	var sId;	
	var objstr;
	InitList(sName);
	
	sObjIndex = sObj.options.selectedIndex;
	if(sObjIndex !=-1) {
	sId = sObj.options[sObjIndex].value;
	if ((sId!=0)|| sId=="")
	{
	if (sHid=="M") {
		objstr="document.forms[0].t1";
	}
	if (sHid=="O"){
		objstr="document.forms[0].t1" + sId;
		}
	s = (eval(objstr).value);

	do
		{
			c = s.indexOf("#",0);
			s = s.substring(c+1);
			cat = s.substring(0,s.indexOf("#",1));
			catId = cat.substring(0,cat.indexOf("_",1));
			cat = cat.substring(cat.indexOf("_",1)+1);
			skill = cat.substring(0,cat.indexOf("_",1));
			skilldesc = cat.substring(cat.indexOf("_",1)+1);
			if (sHid=="M"){
			//opt	= new Option('(Select One )', 0);
			}
			if(sHid=="O"){
			opt	= new Option('(Select a Object)', 0);
			}
			//sName.options[0] = opt;	


			if (catId == sId)
			{	
				selcat = catId;	
				opt	= new Option(skilldesc,skill);
				sName.options[index] = opt;				
				index++;
			}

			if (selcat != null) {
				if (selcat != sId) {
					c = -1;
				}
			}
		
		}
		

		while (c != -1);
		//sName.options[0].selected = true;		
	
		//history.go(1);
	}	
			if (sHid=="M"){
			//opt	= new Option('N.A', 1);
			}
			if(sHid=="O"){
			opt	= new Option('N.A', 31);
			}
			//sName.options[index] = opt;	

 }
}

function checkComboTotal(formIndex,cmb)
{
	var idx=cmb.indexOf('|');
	var display=cmb;
	if(idx!=-1) 
	{
	   display=display.substring(idx+1);
	   cmb=cmb.substring(0,idx);
	}
	var obj=document.forms[formIndex].elements[cmb];
	if(obj.length==0)
	{
		ShowAlert(display+'  Should not be Null ');
		return false;
	}
	return true;
}



function CheckAll(obj_name)
{
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e = document.forms[0].elements[i];
		if ((e.name == obj_name) && (e.type=='checkbox') && (e.name != 'allbox'))
		{
		  if (!e.checked)
		    e.checked=true
		  else
		      e.checked=false
		}//end of if    
	}//end of for
}//end of function



function dateGreater(dateFrom,dateTo)
{



var From = new Date(dateFrom); 
var day = From.getYear();
var month = From.getMonth();


var FromDate = new Date(From.getMonth() + "-" + From.getDate() + "-" + From.getYear());


var To = new Date(dateTo);

var ToDate = new Date(To.getYear(),To.getMonth(),To.getDate(),0,0,0);

if ( FromDate > ToDate ){ ShowAlert("To Date should be Greater than From Date");return false;}
return true;
}





/*******************************************************************************************
		Function to convert the number in text format
******************************************************************************************/

function convertText(num,cur)
{
 i1=num.indexOf(".");
 var pon="";
 if(i1!=-1)
 {
   pon=num.substring(i1+1);
   num=num.substring(0,i1);
 }
 var str="";
 var	des1=new Array('',' One',' Two',' Three',' Four',' Five',' Six',' Seven',' Eight',' Nine');
 var	des2=new Array('',' Eleven',' Tweleve',' Thirteen',' Fourteen',' Fifteen',' Sixteen',' Seventeen',' Eighteen ',' Nineteen ');
 var	des3=new Array('',' Ten',' Twenty',' Thirty',' Fourty',' Fifty',' Sixty',' Seventy',' Eighty',' Ninety');
 var	des4=new Array(' Ten',' Hundread',' Thousand',' Lakh',' Crore');
 
var flag=false;



if (parseInt(num)==0)
str="Zero"
else
{
for(i=1;i<=num.length;i++)
 {
 	digit=num.substring(i-1,i);
 	if(flag)
 	{
 		flag=false;
 		if (num.length-i==2 && digit!="0")
			str=str+des4[1]; 	
		if (num.length-i==3 && digit!="0")
			str=str+des4[2]; 	
		if (num.length-i==5 && digit!="0")
   			str=str+des4[3]; 	
	   if (num.length-i==7 && digit!="0")
			str=str+des4[4]; 	
 		continue;
 	}	
   if (num.length-i==1 || num.length-i==4 || num.length-i==6 || num.length-i==8 )
   {
		if(digit=="1")
		{
			if(num.charAt(i)=="0") 
			{
			  str=str+des3[digit]; 
			}
			else
			{
			str=str+des2[num.charAt(i)];
			flag=true;
			continue;
			}
		}	
		else
			str=str+des3[digit]; 	
			if(num.charAt(i)=="0")
			{
			  if(num.length-i==4)
				str+=des4[2];
			  else if(num.length-i==6)
				str+=des4[3];
			  else if(num.length-i==8)
				str+=des4[4];			
			}
	}	
	else
		str=str+des1[digit]; 	

   if (num.length-i==2 && digit!="0")
		str=str+des4[1]; 
   if (num.length-i==3 && digit!="0")
		str=str+des4[2]; 	
   if (num.length-i==5 && digit!="0")
   		str=str+des4[3]; 	
   if (num.length-i==7 && digit!="0")
		str=str+des4[4]; 	

 }//end of for
 
 }
 
 
  if(i1!=-1)
  {
   str=cur+" "+str+" and " + convertText(pon,'');
  } 
  else
   str=cur+" "+str;


  return str;

}//end of function





// function to round off a number to some precesion
// val is the textfield object of which the round off has to be done
// posi is the position to which the round off to be donw
function doRound(val1,posi)
{

	val1 = ''+val1;
	var finVal = -1;
	if(isNaN(val1))
	{
		ShowAlert(val1+" " + ReplacePropertyString('is not a number'));
		return val1;
	}
	
	var appnd = '';
	for(var i=0;i<posi ;i++)
	{
		appnd = appnd + '0';
	}
	if(val1.indexOf(".") == val1.length-1)
	{
		finVal = val1 + appnd;
	}
	else 
	{
		if(val1.indexOf(".")>-1)
		{

			var deci = val1.substring(val1.indexOf(".")+1);

			if(deci.length < parseInt(posi))
			{
				deci = deci + appnd.substr(0,parseInt(posi)-deci.length);
			}			
			var newStr = deci.substring(0,parseInt(posi)) + "." + deci.substring(parseInt(posi));
			newStr = Math.round(newStr);
			
			if((newStr+'').length > parseInt(posi))
			{
				finVal = parseInt(val1.substr(0,val1.indexOf(".")))+1;
				finVal = finVal+''+'.'+appnd ; 
			}
			else
				{		
				newStr = ''+newStr;
				if(newStr.length < parseInt(posi))
						newStr = appnd.substr(0,parseInt(posi)-newStr.length) + newStr;
				finVal = val1.substr(0,val1.indexOf(".")+1)+newStr;
				}
		}
		else
		{
			finVal =  val1 + '.' + appnd;
		}
	}
	if(finVal.indexOf(".00")>=0) 
	{ 
		//alert('Not equal');
	   finVal=finVal.substring(0,finVal.indexOf(".00"));
	}
	return finVal;
}


//*********************************************************************************************
//	                  Trim function	(String)
//**********************************************************************************************

// Removes all whitespace characters 
// from start and end of a string 
function trim(sString) 
{ 
   
	sTrimmedString1 = ""; 
	if (sString != "") 
	{ 
		var iStart = 0; 
		var iEnd = sString.length - 1; 
		//var sWhitespace = " \t\f\n\r\v"; 
		var ArrForXMLDetail=new Array()
		
		/*THIS ARRAY WAS ADDED KEEPING IN MIND THE FOLLOWING SCENERIO
		IF USER INSERT "v" THEN THIS FUNCTION WILL REMOVE "v" CHARACTER.
		TO REMOVE THIS LIMITATION, I HAVE MADE THIS ARRAY AND INDIVIDUALLY CHECKING EACH SPECIAL CHARACTER.	
		CODER:JUNED.
		*/
		ArrForXMLDetail[0]=" "
		ArrForXMLDetail[1]="\t"
		ArrForXMLDetail[2]="\f"
		ArrForXMLDetail[3]="\n"
		ArrForXMLDetail[4]="\r"
		ArrForXMLDetail[5]="\v"
      for(trimIndex=0;trimIndex < ArrForXMLDetail.length;trimIndex++) //FOR LOOP IS ADDED TO CHECK  EACH CHARACTER FOR e.g."\t" ONE BY ONE
      {
			sWhitespace=ArrForXMLDetail[trimIndex]
			
			while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) 
			{ 
				iStart++; 
				if (iStart > iEnd) 
				break; 
			    } 
      
			// If the string not just whitespace 
			    if (iStart <= iEnd) 
			{ 
				while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1) 
				iEnd--; 
				sTrimmedString1 = sString.substring(iStart,++iEnd); 
			} 
			 } 
	 }
        return sTrimmedString1; 100
} 

/****************************************************************
	DevangM| 20051108 | CRF#21127
	SSN was sent with spaces which resulted in some extra junk character in reply
	Previous Trim could not remove all white spaces
******************************************************************/
function trimX(sString) 
{ 
   
	var sTrimmedString1 = ""; 
	if (sString != "") 
	{ 
		var iStart = 0; 
		var iEnd = sString.length - 1; 
		while(CheckWhiteSpace(sString.charAt(iStart))==true)
		{ 				
			iStart++; 
			if (iStart > iEnd) 
			break; 
		} 
    
		// If the string not just whitespace 
		if (iStart <= iEnd) 
		{ 
			while(CheckWhiteSpace(sString.charAt(iEnd))==true)
				iEnd--; 
		} 
	
	
	    sTrimmedString1 = sString.substring(iStart,++iEnd);  
 }
        return sTrimmedString1;
} 
	
	
/***********************************************************************
	DevangM| 20051108 | CRF#21127
	This Function Checks if the given character is Whitespace or not.
************************************************************************/
	
	function CheckWhiteSpace(p_Char)
	{
		switch (p_Char)
		{
			case " ":
			case "\t":
			case "\f":
			case "\n":
			case "\r":
			case "\v":
				return(true);
				break;
			default:
				return(false);
		}
	}

//***********************************************************************************************


//***********************************************************************************************


//***********************************************************************************************


//***********************************************************************************************
//                             Validation of Date (mm/dd/yyyy)
//***********************************************************************************************

//Check Date Format with (mm/dd/yyyy)

function isValidDate(dateStr) 
{ 
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; 
	
	if(dateStr.length == 0 )
		return true;

	var matchArray = dateStr.match(datePat); // is the format ok? 
	
	if (matchArray == null) 
	{ 
		/*
			NilayM | CRF#28009 | 20061102
			showing date(s) for single or multiple dates.
		*/
		ShowAlert("Please enter the date(s) using this format - mm/dd/yyyy ") 
		return false; 
	} 
	
	month = matchArray[1]; // parse date into variables 
	day = matchArray[3]; 
	year = matchArray[4]; 

	if (month < 1 || month > 12)
	{ // check month range 
		ShowAlert("Month must be between 1 and 12."); 
		return false; 
	} 

	if (day < 1 || day > 31)
	{
		ShowAlert("Day must be between 1 and 31."); 
		return false; 
	} 
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{
		ShowAlert(ReplacePropertyString("Month ") +month + " " + ReplacePropertyString("doesn't have 31 days!"),e_NoCheck); 
		return false; 
	} 
	
	if (month == 2)
	 { // check for february 29th 
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); 
		
		if (day>29 || (day==29 && !isleap)) 
		{ 
			ShowAlert(ReplacePropertyString("February ") + year + " " + ReplacePropertyString("doesn't have") + " "  + day + ReplacePropertyString(" days!"),e_NoCheck); 
			return false; 
		} 
	}

	// NOTE : -
	// If the year is of 2 digit then remove following comments
	/*
	if(year > 99 ){//check date for no of degits 
	alert("Year must be of 2 digits");
	return false;
	}
	*/

	if (year < 1000  || year > 9999 )
	{
		alert("Year must be of 4 digits");
		return false;
	}
 
	return true; // date is valid 
} 
//End Date Validation Function



//***************************************************************************************************************************
//                                     Convert String Into Proper Format (i.e= First Charcter is Capital  patient ==Patient)
//***************************************************************************************************************************

function properString(obj)
{
	var LOC_String = new String();	
	var LOC_FirstString = new String();	
	LOC_String=obj.value;	
	LOC_FirstString=LOC_String.charAt(0);	
	obj.value = (LOC_FirstString.toUpperCase() + LOC_String.substr(1));
}
//End of Function Proper String



//***********************************************************************************************
//                             Validation of Time (hh:mmAM/PM)
//***********************************************************************************************

//Check Time Format with (hh:mmAM/PM)


function checkTime(textTime) 
{  
	if(textTime =="")
	{
		return true;
	} 
	
	//var timeExpression = /^(\d{2}):(\d{2})\s{1}([AP]M)$/;
	var timeExpression = /^(\d{2}):(\d{2})\s{0}([AP]M)$/;
	var valresult = textTime.match(timeExpression);
	if (valresult==null) 
	{		
		return false;	
	}
	
	hour = valresult[1];
	minute = valresult[2];	
	ampm = valresult[3];
	
	
	if (hour <= 0  || hour > 12) 
	{
		ShowAlert("Hour must be between 1 and 12");
		return false;
	}
	
	if (minute<0 || minute > 59) 
	{
		alert ("Minute must be between 0 and 59");
		return false;
	}
	
	if (ampm = "")
	{
		ShowAlert("You must specify AM or PM");
		return false;
	}
	return true;
	
}

//*******************************************************************************************
//Purpose  :  Inserts "/" in proper places in date entry(i.e after first 2 and 5 digits)
//Called From : on keypress event of Any Date Fields
//*******************************************************************************************
function formatDateEntry(textField)
{	
	var textValue = textField.value;	
	if(textValue.length == 2 || textValue.length == 5)
	{
		textField.value = textField.value + "/";
	}
	
	return true;		

}	
/*
	Called from locator textbox onkeypress event
	code :juned
	purpose : To trap enter key and disable it
*/
function OnEnterForLookUp()
{
	if (event.keyCode==13 )
	{
		event.keyCode =0
	}
}
//*******************************************************************************************
//Purpose  :  To remove double click problem while loading page
//Called From : every page where report is shown.
//Coder		  : Juned
//*******************************************************************************************
function OnObjectLoad(fullscreen, pagename)
{
	
	if (fullscreen!="YES")
	{
		switch(pagename)
		{
			
			case "newresult" :
				try{
					top.defaultmain.right.right_top.document.topform.ButtonForAdd.click()	
				}catch(exception)
				{
				}
				break;	
			case "requisition" :
				try{
					top.defaultmain.right.right_top.document.topform.ButtonForShow.click()	
				}catch(exception)
				{
				
				}
				break;	
			case "previewrequisition" :
				try{
					top.right_top.document.topform.ButtonForShow.click()	
				}catch(exception)
				{
				
				}
				break;	
			case "catalog" :
				try{
					top.right_top.document.topform.ButtonForAdd.click()	
				}catch(exception)
				{
				
				}
				break;	
			case "shiplist" :
				try{
					top.defaultmain.right_top.document.topform.ButtonForAdd.click()	
				}catch(exception)
				{
				
				}
				break;	
			default:
				return false	
		}
	}else{
		switch(pagename)
		{
			case "newresult"  :
				try{
					top.right_top.document.topform.ButtonForAdd.click()
				}catch(exception)
				{
				}
				break;	
			case "requisition" :
				
				try{
					top.right_top.document.topform.ButtonForShow.click()
				}catch(exception)
				{
				}
				break;	
			case "previewrequisition" :

			case "catalog" :
			
			case "shiplist" :
				try{
					top.right_top.document.topform.ButtonForAdd.click()	
				}catch(exception)
				{
				
				}
				break;	
			default:
				return false	
		}
	}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXCUSTOMIZATIONXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//JUNED 20030205 CRF 6794

//xxxxxxxxxxxxxxThis variables are used in all below function for customizationxxxxxxxxxxxx
var PCount=0
var ACount=0
var FramesetCount=0
var FrameCount=0
var IMGCount=0
var DivCount=0
var HRCount=0
var BodyCount=0
var FormCount=0
var FONTCount=0
//DevangM|CRF#20552|20051015 
//To Customize SELECT tag
//START
var SELECTCount
//END
var LICount=0
var RadioName=""
var RadioCount=0
var StyleTag="style"
var PropertyTag="property"
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//====This variables are assigned value from main.asp in which a .js file is called and XML is loaded========= 
	myXmlFile=top.window.XMLFile
	XMLForCustomizeAns=top.window.XMLStatus
//============================================================================================================
 /*Vipul CRF# 20050512
    This function will return 0/1 to validate contact 
  1-To validate the Contatc details
  0-To do not validate contact details*/
function SetValidationForContactDetails()
{
 try
  {
   var LOC_ValidateContact='';
   if (XMLForCustomizeAns)
	{			
		var myRoot = myXmlFile.documentElement;				
     try{     
		 var LOC_ValidateContactTag = myRoot.getElementsByTagName("VALIDATE_CONTACT")		
		 LOC_ValidateContact=LOC_ValidateContactTag.item(0).text				
		}
     catch(excetption)
       { 
         LOC_ValidateContact=1;	         
         return LOC_ValidateContact	         
       }
	}	
	return LOC_ValidateContact	
 }
 catch(exception)
 {
 }
}
	
/*
  SATISHD | CRF#17689 | 20050726
  ADDED FUNCTION TO MAKE  SSN FIELD Mandatory.
  FUNCTION RETURNS -- 1 THEN VALIDATE SSN
                 -- 0 THEN OPTIONAL
  REQUIREMENT OF DBML CLIENT.
*/
function SetSSNMandatory()
{
 try
  {
   var LOC_ValidateSSN='';
   if (XMLForCustomizeAns)
	{			
		var myRoot = myXmlFile.documentElement;	
		try
		{     
		 var LOC_ValidateSSNTag = myRoot.getElementsByTagName("VALIDATE_SSN")		
		 LOC_ValidateSSN=LOC_ValidateSSNTag.item(0).text
		}
        catch(exception)
       {
		  LOC_ValidateSSN=0;	         
         return LOC_ValidateSSN	         
       }
	}	
	return LOC_ValidateSSN;
 }
 catch(exception)
 {
 }
}
//----END CHANGES MADE BY SATISHD

function GetClientName()
{
  try
	{
	var LOC_CLIENT='';
	if (XMLForCustomizeAns)
		{			
			var myRoot = myXmlFile.documentElement;				
		try{     
			var LOC_CLIENTTag = myRoot.getElementsByTagName("CLIENT")		
			LOC_CLIENT=LOC_CLIENTTag.item(0).text				
			}
		catch(excetption)
		{ 
			LOC_CLIENT="";	         
			return LOC_CLIENT
		}
		}	
		return LOC_CLIENT
	}
	catch(exception)
	{
	}
}

function IsUpickOn()
{
  try
	{
	    var LOC_ALLOW_UPICK="";
	    try{
			myXmlFile = new ActiveXObject("Microsoft.XMLDOM");
			myXmlFile.async = "false";
			/* 
				NilayM | CRF#29313 | 20070226
				Property.xml file is shifted to HomePages Folder so Path is changed.
			*/
			ans = myXmlFile.load("/PowerWEB/HomePages/property.xml");
			var LOC_XmlChildObject = myXmlFile.getElementsByTagName("ALLOW_UPICK")		
			LOC_ALLOW_UPICK= LOC_XmlChildObject.item(0).text
		   }catch(exception)
		   {
		    LOC_ALLOW_UPICK=0
		    return LOC_ALLOW_UPICK
		   }		   
		   return LOC_ALLOW_UPICK
	}
	catch(exception)
	{
	  
	}
}

function LocateUpick(FormObjectLocateTextBox)
{  
  try{     
     if(FormObjectLocateTextBox.value!="")
        {
				var LOC_Tr = document.all.tags("tr");  
				for(i = 0;i<LOC_Tr.length;i++ )
				{				   
					var ChkObj=LOC_Tr[i].getElementsByTagName("INPUT")     
					for(ChkCounter=1;ChkCounter < ChkObj.length;ChkCounter++)
							{
							    
								if(ChkObj[ChkCounter].type=="checkbox")
								{ 																
									var treeValue=ChkObj[ChkCounter].value				  								
								    var LOC_ArrTree									  								
								    //LOC_ArrTree[7] will contain the code which we will compare with the filled Array
							    	LOC_ArrTree=treeValue.split("~")								
									var index=0;				 				
									var LocateValue=FormObjectLocateTextBox.value
									var LOC_TreeTestName = LOC_ArrTree[8].toUpperCase()			
									if (FormObjectLocateTextBox.value=="")	
									   {
									     return false //it will not go in infinite loop
									   }
									//Loop through our filled array from TextProfile page and if found make check box on									
									if(LOC_TreeTestName.indexOf(LocateValue.toUpperCase()) == 0)		                              
										{															
										try{   	
										       	ChkObj[ChkCounter].checked=true //Make checkbox on if found										
												FormObjectLocateTextBox.value=""
												ChkObj[ChkCounter].onclick()												
												return false
											}	
										catch(exception)	  
											{
												//If checkbox is already clicked and disabled then
												//It might rasie the exception
											}
										}					
							
								  
								}								
							}		
						}
		  }								
     
     }catch(exception) 
     {}
}

	
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThis is a main function called from ever page on on load of bodyxxxxxxxxxxxxxx
function getAtt(currentform,pagename,AppendMode)
{
	
	
	if(AppendMode=="true")
	{
		createXML(currentform,pagename)
	}
	//Userfull-- alert("juned" + pagename) 
	
	if (XMLForCustomizeAns)
	{	
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxLoading root objectxxxxxxxxxxxxxxxxxxxxxxxxx
		var myRoot = myXmlFile.documentElement;
		
		var LOC_PageName = ""
		if(myRoot!=null)
		{
			LOC_PageName=myRoot.getElementsByTagName(pagename)			//Loading the pagename object of XML
		}else
		{
			return true
		}
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
		
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxVariablexxxxxxxxxxxxxxxxxxxxxxxxxxxx
		var TableCount=0
		var RowCount=0
		var ColCount=0
		var CurrPointerOfXml=0
		var LOC_ControlName=""
		var ControlName=""
		var BodyTagORFrameTagNumber=0
		var FrameCols=""
		var FrameRows=""
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
		
		if (LOC_PageName.length > 0)
		{
			//Started of Page
			for (LOC_ToTryBodyTag=0; LOC_ToTryBodyTag < (currentform.length);LOC_ToTryBodyTag++)
			{
				if(currentform(LOC_ToTryBodyTag).tagName=="BODY")
				{
					currentform(LOC_ToTryBodyTag).style.visibility="hidden"
					BodyTagORFrameTagNumber=LOC_ToTryBodyTag
					break
				}
				
			}
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxStarting a Loop for all document Controlsxxxxxxxxxxxxxxxxxxxxxxxxx
			
			for (CurrPointerOfXml=0; CurrPointerOfXml < (currentform.length);CurrPointerOfXml++)
			{
				var ConTagName=currentform(CurrPointerOfXml).tagName
				var TypeName=currentform(CurrPointerOfXml).type
				/*
				  DevangM|CRF#20552|20051011
				  Added DIV in following If Condition expression To Process DIV tags
				*/
				
				if(ConTagName=="HR" || ConTagName=="LI" || ConTagName=="FORM" || ConTagName=="BODY" || ConTagName=="OBJECT" || ConTagName=="IMG" || ConTagName=="TEXTAREA" || ConTagName=="FRAME" || ConTagName=="FRAMESET" || ConTagName=="SELECT" || ConTagName=="TABLE" || ConTagName=="TD" || ConTagName=="TR" || ConTagName=="INPUT" || ConTagName=="P" || ConTagName=="A" || ConTagName=="FONT" || ConTagName=="DIV")
				{
					if(currentform(CurrPointerOfXml).tagName=="TABLE")
					{
							if (currentform(CurrPointerOfXml).tagName=="TABLE")
							{
								TableCount=eval(TableCount) + 1
								
								/*DevangM|CRF#20552|20051011
								  -- The changes were made to identify the tags with id.
								  -- Following code sets the tagname for table, "TABLE" + id of the table if
								     the table is given an id.
								  -- If the table is not given an id then the tagname for table is "TABLE" + Tablecount
					     		  start	
				                */
								if (currentform(CurrPointerOfXml).id=="")
								{
									ControlName	="TABLE" + TableCount
								}
								else
								{
									ControlName = "TABLE" + currentform(CurrPointerOfXml).id //We Append id for tables with ID 
								}
								//end DevangM|CRF#20552|20051011
							}
				
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxCalling a function to parse Tablexxxxxxxxxxxxxxxxxxxxxxxx
							
							CurrPointerOfXml=TableParsing(ControlName,CurrPointerOfXml,LOC_PageName,currentform)
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
										
					}else{
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxCalling a function to parse control other than Tablexxxxxxxxxxxxxxxxxxxxxxxx
							
							CurrPointerOfXml=ProcessByTag(ConTagName,TypeName,currentform,CurrPointerOfXml,LOC_PageName)
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
					}		
				}
				else
				{
					//Nothing Should be wriite over here
				}
			}//CurrPointerOfXml
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		}//LOC_PageName.length Ends
	 }  
try{
	currentform(BodyTagORFrameTagNumber).style.visibility="visible"
}catch(exception)
{

}

}
var TableToApllyCss=0
var CssStringTobeAppliedOnTable
function TableParsing(ControlName, CurrPointerOfXml,LOC_PageName,currentform)
{
	//xxxxxxxxxxxxxxxxxxxxxxxxxxStoring conrols object into variablexxxxxxxxxxxxxxxxxxxxxxxxx
	
	LOC_ControlName = LOC_PageName.item(0).getElementsByTagName(ControlName)
	
	
	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
		if (LOC_ControlName.length > 0)
		{
			//xxxxxxxxxxxxxxxxxStoring tables attributesxxxxxxxxxxxxx
			
			var TableAtt=LOC_ControlName(0).attributes	
			
			//xxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxTo know whether table should be consider row or notxxxxxxxxxxxxxxxxxxx
			var ConsiderRow=""
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			var NoOfRow=0			//To count number of row
			var NoOfCol=0			//To count number of column
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTo process the tables Attributrexxxxxxxxxxxxxxxxxxxxxxxxx
			if (TableAtt.length > 0 )	
			{
				var cssStr=""
				var specialCondition=""
				
					for (l=0;l<TableAtt.length;l++)
					{
						if (TableAtt(l).name!="ConsiderRow" && TableAtt(l).name!="Indentification")
						{
							var attName=TableAtt(l).name
							var attValue=TableAtt(l).value
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAssiging styles and propertyxxxxxxxxxxxxxxxxxxxxxxxxxxxx
							switch (attName)
							{
								case "accessKey" :
									currentform(CurrPointerOfXml).accessKey=attValue
									break
								default :
									if (cssStr == "")
									{
										cssStr=attName + ":" + attValue
									}else
									{
										cssStr=cssStr + ";" + attName + ":" + attValue
									}
									break
							}
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
							
						}
						else
						{
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAssiging styles and propertyxxxxxxxxxxxxxxxxxxxxxxxxxxxx
							
							ConsiderRow=TableAtt(l).value		
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						}
					}
				if (cssStr!="")
				{
					CssStringTobeAppliedOnTable=cssStr
					TableToApllyCss=CurrPointerOfXml
					//alert(ControlName + "==" + cssStr + "==" + currentform(CurrPointerOfXml).tagName)
					currentform(CurrPointerOfXml).style.cssText=cssStr
					cssStr=""
				}
			}
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd of process the tables Attributrexxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxProcess for finding Row and Coulumnxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var RowOfTable=currentform(CurrPointerOfXml).innerHTML
			RowOfTable=RowOfTable.toUpperCase()
			
			do 
			{
				RowOfTable =RowOfTable.replace("<TR"," ");
				NoOfRow =eval(NoOfRow) + 1
			}
				while(RowOfTable.indexOf("<TR") > -1)
				
			do 
			{
				RowOfTable =RowOfTable.replace("<TD"," ");
				NoOfCol =eval(NoOfCol) + 1
			}
					while(RowOfTable.indexOf("<TD") > -1)
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
					
			
			//xxxxxxxxxxxNow deciding upon that the table should be process according to Consider Row or Notxxxxxxxxxxxx
			
			if (ConsiderRow=="true")
			{
			
				//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxIf Consider Row is truexxxxxxxxxxxxxxxxxxxxxxxxxxxx
				
				CurrPointerOfXml=ProcessTableByRow(LOC_ControlName,currentform,CurrPointerOfXml,LOC_PageName,NoOfRow,ControlName,NoOfCol)
				
				//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			}else
			{
				//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxProcess for finding column to be customizedxxxxxxxxxxxxxxxxxxxxxxxxxx
				
				var TD=0
				var TR=0	
				for (col=CurrPointerOfXml+1; col < (currentform.length) && TR <= NoOfRow;col++)
				{
					if(currentform(col).tagName=="TABLE")
					{
						return CurrPointerOfXml
					}
					if (currentform(col).tagName=="TR")
					{
						TD=0
						TR=TR + 1
					}else
					{
						if (currentform(col).tagName=="TD" || currentform(col).tagName=="TH")
						{
							TD=TD  + 1
							var ColID="COL-" + TD
							var ColTag=LOC_ControlName(0).getElementsByTagName(ColID)

							if (ColTag.length > 0)
							{
								//xxxxxxxxxxxxxxxxxxFinding the Attributesxxxxxxxxxxxxxxxxxx
								
								//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
								var AttLength=ColTag.item(0).childNodes.length
								//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
								
								var cssStr=""
								var specialCondition=""
								//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
								if (ColTag.length > 0)
								{
									
									var LOC_ContolStyle=0
									LOC_ContolStyle=ColTag.item(0).getElementsByTagName(StyleTag)
									var LOC_ContolProperty=0
									
									LOC_ContolProperty=ColTag.item(0).getElementsByTagName(PropertyTag)
									if (LOC_ContolStyle.length > 0)
									{
										CurrPointerOfXml=OtherTag(currentform(col).tagName,col,LOC_PageName,currentform,ControlName,LOC_ContolStyle,StyleTag)
									}
									if(LOC_ContolProperty.length > 0)
									{
										CurrPointerOfXml=OtherTag(currentform(col).tagName,col,LOC_PageName,currentform,ControlName,LOC_ContolProperty,PropertyTag)
									}
								}
								//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
																
								
								//xxxxxxxxxxxxxxxxxxxxxxAs there is no end tag of <TR> This is writtenxxxxxxxxxxxxxxxxx
								if (TR==NoOfRow && TD==NoOfCol)
								{
									TR=TR + 1  //This is because After last TR it doesn't increaemnt TR as no TR will be found thats 
											   // So this has to be written.
								}		
								//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxendxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
							}
						}else
						{
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxCalling other tag than Tablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
							
							if(currentform(col).tagName=="!" || currentform(col).tagName!="B") //currentform(col).tagName!="FONT"--20030131
							{
								CurrPointerOfXml=ProcessByTag(currentform(col).tagName,currentform(col).type,currentform,col,LOC_PageName)
							}
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						}
					}
				}	
		    }//Consider Row
		}else
		{
				
		}
			
	if(CssStringTobeAppliedOnTable!="" && currentform(TableToApllyCss).tagName=="TABLE")
	{
		//alert("AfterTABLEL:  " + TableToApllyCss + "==" + CssStringTobeAppliedOnTable)
		//currentform(TableToApllyCss).style.cssText=CssStringTobeAppliedOnTable
	}
	
	return CurrPointerOfXml
}


function ProcessTableByRow(LOC_ControlName,currentform,CurrPointerOfXml,LOC_PageName,NoOfRow,ControlName,NoOfCol)
{
	var TD=0
	var TR=0	
	
	//xxxxxxxxxxxxxxxxxxxxxxLooping the document's element from point where this table is foundxxxxxxxxxxxxxxxxxxxxx
	
	for (col=CurrPointerOfXml+1; col < (currentform.length) && TR <= NoOfRow;col++)
	{
		
		//xxxxxxxxxxxxxxxxxxxxif immediate TABLE is foundxxxxxxxxxxxxxxxxxxxxxxxxxxx
		if(currentform(col).tagName=="TABLE")
		{
			return CurrPointerOfXml
		}
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

		
		if (currentform(col).tagName=="TR")
		{
			TD=0
			TR=TR + 1
		}else
		{
			if (currentform(col).tagName=="TD")
			{
				TD=TD  + 1
				var RowID="ROW-" + TR
				var ColID="COL-" + TD
				var RowTag=LOC_ControlName.item(0).getElementsByTagName(RowID)
				
				if (RowTag.length >  0)
				{
					var ColTag=RowTag.item(0).getElementsByTagName(ColID)
					//UseFul-alert("cOLUMN" + ColTag.item(0).text)
					if (ColTag.length > 0)
					{
						//xxxxxxxxxxxxxxxxxxFinding the Attributesxxxxxxxxxxxxxxxxxxx
						
						var AttLength=ColTag.item(0).childNodes.length
						
						var cssStr=""
						var specialCondition=""
											
						//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						
						if (ColTag.length > 0)
						{
									
							var LOC_ContolStyle=0
							LOC_ContolStyle=ColTag.item(0).getElementsByTagName(StyleTag)
							var LOC_ContolProperty=0
									
							LOC_ContolProperty=ColTag.item(0).getElementsByTagName(PropertyTag)
							if (LOC_ContolStyle.length > 0)
							{
								CurrPointerOfXml=OtherTag(currentform(col).tagName,col,LOC_PageName,currentform,ControlName,LOC_ContolStyle,StyleTag)
							}
							if(LOC_ContolProperty.length > 0)
							{
								CurrPointerOfXml=OtherTag(currentform(col).tagName,col,LOC_PageName,currentform,ControlName,LOC_ContolProperty,PropertyTag)
							}
						}
						
						//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						
						
						
						//xxxxxxxxxxxxxxxxxxxxxxxxxAs there is no end tag for <TR>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						if (TR==NoOfRow && TD==NoOfCol)
						{
							TR=TR + 1  //This is because After last TR it doesn't increaemnt TR as no TR will be found thats 
									   // So this has to be written.
						}		
						//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
					}else //else of colTag check
					{
						
					}
				}
			}else
			{
				
				//xxxxxxxxxxxxxxxIf there is some other control between table tag then this will go other functionxxxxxxxxxxxxxxxxxx
				
				if(currentform(col).tagName!="!" || currentform(col).tagName!="TBODY") //20030121-->currentform(CurrPointerOfXml).tagName!="A" //currentform(col).tagName!= "FONT" 20030131
				{
					CurrPointerOfXml=ProcessByTag(currentform(col).tagName,currentform(col).type,currentform,col,LOC_PageName)
				}
				
				//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			}
		}
	}
	
	return CurrPointerOfXml
}

function ProcessByTag(ConTagName,TypeName,currentform,CurrPointerOfXml,LOC_PageName)
{
	var LOC_TagName = 0
	
	//xxxxxxxxxxxxxxxxxxxxxxDefining Tag name according to type and tag name and finding that in XML filexxxxxxxxxxxxxxxxxxxxx
	//DevangM||20552|20051015 In the Following conditions ConTagName=="SELECT" added to customize SELECT tag
	if (ConTagName=="HR" || ConTagName=="LI" || ConTagName=="FORM" || ConTagName=="A" || ConTagName=="P" || ConTagName=="BODY" || ConTagName=="FRAME" || ConTagName=="FRAMESET" || ConTagName=="IMG" || ConTagName=="DIV" || ConTagName=="FONT" || ConTagName=="SELECT")
	{
		//xxxxxxxxxxxxxxxxxxxxFind the TagName object in XML e.g. <P>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		LOC_TagName=LOC_PageName.item(0).getElementsByTagName(ConTagName)
		///alert("InIf : TagName " + LOC_TagName)
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
	}else
	{
		
		try{
		
			//xxxxxxxxxxxxxxxxxxxxFind the type name  object in XML e.g. <button> or xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			if(ConTagName=="OBJECT")
			{
				TypeName="object"
			}
		
		   
			LOC_TagName=LOC_PageName.item(0).getElementsByTagName(TypeName)
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
		}catch(exception)
		{		
				//if There is any error then it will be thrown
		}
	}

	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	
	//alert(LOC_TagName.length)
	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFinding control under the tag name or type name object in XML filexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	if (LOC_TagName.length > 0)
	{	
		
		//xxxxxxxxxxxxxxxxxxxxSome tag does not have any name sp we have to give them namexxxxxxxxxxxxxxxxxxxxxxx
		//DevangM||20552|20051015 In the Following conditions ConTagName=="SELECT" added to customise SELECT tag
		if(ConTagName=="HR" || ConTagName=="LI" || ConTagName=="FORM" || ConTagName=="BODY" || ConTagName=="FONT" || ConTagName=="A" || ConTagName=="IMG" || ConTagName=="FRAMESET" || ConTagName=="FRAME" || ConTagName=="P" || ConTagName=="TD" || ConTagName=="TR"  || ConTagName=="DIV" || ConTagName=="TBODY" || ConTagName=="OPTION" ||ConTagName=="SELECT" || ConTagName=="INPUT")
		{
			
			ControlName=ConTagName + "1"
			switch (ConTagName)
			{
				case "P" :
					PCount=PCount +1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for P, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "P" + Pcount	
					  start	
				    */
				    ControlName = GetControlName("P",currentform(CurrPointerOfXml).id,PCount)
					//end DevangM|CRF#20552|20051011
					break
				case "FRAMESET" :
					FramesetCount=FramesetCount + 1
					ControlName	="FRAMESET" + FramesetCount
					break
				case"FRAME" :
					FrameCount=FrameCount + 1
					ControlName	="FRAME" + FrameCount
					break
				case"IMG" :
					IMGCount=IMGCount + 1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for IMG, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "IMG" + IMGcount	
					
					  start	
				    */
				    
				    ControlName = GetControlName("IMG",currentform(CurrPointerOfXml).id,IMGCount)
					//END DevangM|CRF#20552|20051011
					
					break
				case "DIV" :
					DivCount=DivCount + 1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for DIV, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "DIV" + Divcount	

					  start	
				    */
				    ControlName = GetControlName("DIV",currentform(CurrPointerOfXml).id,DivCount)
					//END DevangM|CRF#20552|20051011
					
					break
				case "A" :
					ACount=ACount + 1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for A, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "A" + Acount	

					  start	
				    */
				    ControlName = GetControlName("A",currentform(CurrPointerOfXml).id,ACount)
					//END DevangM|CRF#20552|20051011					
					break
				case "FONT" :
					FONTCount=FONTCount + 1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for FONT, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "FONT" + FONTcount	

					  start	
				    */
					ControlName = GetControlName("FONT",currentform(CurrPointerOfXml).id,FONTCount)
					//end DevangM|CRF#20552|20051011
					break
				case "INPUT" :				   
				try{
					if (currentform(CurrPointerOfXml).type=="text" || currentform(CurrPointerOfXml).type=="password" || currentform(CurrPointerOfXml).type=="checkbox")
				    { 				      
				      ControlName = GetControlName("INPUT",currentform(CurrPointerOfXml).id,0)	
				    }
				    }
				    catch(exception)					
				    {
				      //alert(exception.description)
				    }
				break
				case "BODY" :
					BodyCount=BodyCount + 1
					ControlName	="BODY" + BodyCount
					break
				case "FORM" :
					FormCount=FormCount + 1
					ControlName	="FORM" + FormCount
					break	
				case "LI" :
					LICount=LICount + 1
					/*DevangM|CRF#20552|20051011
						-- The changes were made to identify the tags with id.
						-- Following code sets the tagname for LI, id of the tag if
							the tag is given an id.
						-- If the tag is not given an id then the tagname "LI" + LIcount	

					  start	
				    */
				    ControlName = GetControlName("LI",currentform(CurrPointerOfXml).id,LICount)
					//END DevangM|CRF#20552|20051011
					break	
				case "HR" :
					HRCount=HRCount + 1
					ControlName	="HR" + HRCount
					break
				//DevangM|20552|20051015 Added to customize select count	
				case "SELECT" :
					SELECTCount = SELECTCount + 1
					try{
					
					ControlName = GetControlName("SELECT",currentform(CurrPointerOfXml).name,SELECTCount)
					
					
					}catch(exception)
					{
						
					}
					break;
			}
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd of giving Namexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
		}else
		{
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDeciding ControNamexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			if (currentform(CurrPointerOfXml).type=="radio")
			{
				//xxxxxxxxxxxxxxxRadio button has many control under one name so this logic is writtenxxxxxxxxxxxxxxx
				if(RadioName==currentform(CurrPointerOfXml).name)
				{
					RadioCount=RadioCount +1	
				}else
				{
					RadioCount=1	
				}
				RadioName=currentform(CurrPointerOfXml).name
				ControlName	=currentform(CurrPointerOfXml).name + "-" + RadioCount
				//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd naming radio buttonsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
				
			}else{
				
				if(ConTagName=="OBJECT")
				{
					ControlName	=currentform(CurrPointerOfXml).id
				}else
				{
					ControlName	=currentform(CurrPointerOfXml).name
				}
			}
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd of naming Controlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
		}
		
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNow searching that contro in XMLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
					
		var LOC_ControlName=0		
		
		try{
			   
			   LOC_ControlName = LOC_TagName.item(0).getElementsByTagName(ControlName)
			 
		    }catch(exception)
			{
			  //If there is any error, then it will be thrown	
		    }
		
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
		
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAfter finding ControlName in XMLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		
			
		if (LOC_ControlName.length > 0 && typeof(ControlName)!="undefined")
		{			
			var LOC_ContolStyle=0
			LOC_ContolStyle=LOC_ControlName.item(0).getElementsByTagName(StyleTag)
			
			var LOC_ContolProperty=0			
			LOC_ContolProperty=LOC_ControlName.item(0).getElementsByTagName(PropertyTag)
			if (LOC_ContolStyle.length > 0)
			{			   
				CurrPointerOfXml=OtherTag(ConTagName,CurrPointerOfXml,LOC_PageName,currentform,ControlName,LOC_ContolStyle,StyleTag)
			}
			if(LOC_ContolProperty.length > 0)
			{
				CurrPointerOfXml=OtherTag(ConTagName,CurrPointerOfXml,LOC_PageName,currentform,ControlName,LOC_ContolProperty,PropertyTag)
			}
		}
		
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd finding controlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	}
	
	return CurrPointerOfXml
   
}


function OtherTag(ConTagName,CurrPointerOfXml,LOC_PageName,currentform,ControlName,LOC_ControlName,mode)
{

	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFinding the attributesxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	var AttLength=LOC_ControlName.item(0).childNodes.length
	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	
	var cssStr=""
	for (l=0;l<AttLength;l++)
	{
		var attName=LOC_ControlName.item(0).childNodes.item(l).tagName
		var attValue=LOC_ControlName.item(0).childNodes.item(l).text
			
		//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDeciding that the control style should be assigned or Propertyxxxxxxxxxxxx
		
		if (mode==StyleTag)				//Changing Style
		{
			if (cssStr == "")
			{
				cssStr=attName + ":" + attValue
			}else
			{
				cssStr=cssStr + ";" + attName + ":" + attValue
			}
			//alert(cssStr)
		}else{							//Changing Property	
		
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAssigning Propertyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			switch (attName)
			{
				case "text-value" : 
					attValue=attValue.replace("[","<u>")
					attValue=attValue.replace("]","</u>")
					
					if(ConTagName=="LI" || ConTagName=="P" ||ConTagName=="A" || ConTagName=="FONT" || ConTagName=="TH" || ConTagName=="TD")
					{
						
						//xxxxxxxxxxxxxxxxxxxxxFor Replacing Text P,A and FONTxxxxxxxxxxxxxxxxxx
						
						var TextAtt=LOC_ControlName.item(0).childNodes.item(l).attributes	
						var ChangeText=""
						if (TextAtt.length > 0 )
						{
							ChangeText=TextAtt(0).value
						}
						if(ChangeText!="")
						{
							var ControlHTML=currentform(CurrPointerOfXml).innerHTML
							ControlHTML =ControlHTML.replace(ChangeText,attValue);	
							currentform(CurrPointerOfXml).innerHTML=ControlHTML
						}else
						{
							currentform(CurrPointerOfXml).innerHTML=attValue
						}
						
						//xxxxxxxxxxxxxxxxxxxxxEnd For Replacing Text P,A and FONTxxxxxxxxxxxxxxxx
						
					}else{
						currentform(CurrPointerOfXml).value=attValue
					}
					break			
				case "accessKey" :
					switch (ConTagName)
					{
						case "A" :
							currentform(CurrPointerOfXml).accessKey=attValue
							break
						default :
							currentform(CurrPointerOfXml).accessKey=attValue
							break
					}
					break
				case "value"	:
					currentform(CurrPointerOfXml).value=attValue
					break
				case "accessKey"	:
					currentform(CurrPointerOfXml).accessKey=attValue
					break
				case "title"	:
					currentform(CurrPointerOfXml).title=attValue
					break
				case "align" : 
					currentform(col).align=attValue
					break
				case "valign" : 
					currentform(col).valign=attValue
					break				
				case "title"	:
					currentform(CurrPointerOfXml).title=attValue
					break
				case "src"	:
					currentform(CurrPointerOfXml).src=attValue
					break
				case "cols"	:
					currentform(CurrPointerOfXml).cols=attValue
					break
				case "rows"	:
					currentform(CurrPointerOfXml).rows=attValue
					break
				case "checked"	:
				    try
				    {
						/*
						   NilayM |  CRF# | 20070321
						   Make the working Checkbox customization
						*/
						
						if (attValue.toUpperCase() == "TRUE") 
							{
								currentform(CurrPointerOfXml).checked=true
							}
							else
							{
							    currentform(CurrPointerOfXml).checked=false
							}	
					}
					catch(exception)
					{
					}
					break;
					
				case "selected"	:
					currentform(CurrPointerOfXml).selected=attValue
					break
				case "name"	:
					currentform(CurrPointerOfXml).name=attValue
					break
				case "id"	:
					currentform(CurrPointerOfXml).id=attValue
					break
				case "action"	:
					currentform(CurrPointerOfXml).action=attValue
					break
				case "background"	:
					currentform(CurrPointerOfXml).background=attValue
					break
				case "innerText" :
					currentform(CurrPointerOfXml).innerText=attValue
					break
				case "OPTION"	:
					//xxxxxxxxxxxxxxxxxxxxxxxProcess of adding options to comboxxxxxxxxxxxxxxxxxxxx
					
					var LenSelect=currentform(CurrPointerOfXml).length
					var Pos=attValue.indexOf("~")
					var optionText=attValue.substring(0,Pos);
					var optionValue=attValue.substring(eval(Pos)+1,attValue.length);
					var SecPos=attValue.indexOf("~",Pos+1)
					var SelectStr=""
					if (SecPos > -1)
					{
						SelectStr=attValue.substring(SecPos+1,attValue.length);
					}
					if (SelectStr=="select")
					{
						NewOption=Option.create(optionText,optionValue,true,true)
					}else
					{
						NewOption=Option.create(optionText,optionValue)
					}
									
					currentform(CurrPointerOfXml).add(NewOption)
									
					break
					
					//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			}
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd for assigning Propertiedxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		}
	}
	
	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAssigning css String to controlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	
	if (cssStr!="")
	{	
		if(currentform(CurrPointerOfXml).tagName!="!" || currentform(CurrPointerOfXml).tagName!="TBODY") //20030121-->currentform(CurrPointerOfXml).tagName!="A" // currentform(CurrPointerOfXml).tagName!= "FONT" 20030131
		{
			currentform(CurrPointerOfXml).style.cssText=cssStr
		}
		cssStr=""
	}
	
	//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
				
	return CurrPointerOfXml
}

function GetMainFrameRow()
{
	var RowForMain=""
	if (XMLForCustomizeAns)
	{	
		var myRoot = myXmlFile.documentElement;
		var MainFramePage = myRoot.getElementsByTagName("Main")
		if(MainFramePage.length > 0)
		{
			FrameSetLen=MainFramePage(0).childNodes.length
			for(i=0;i < FrameSetLen;i++)
			{
				var FrametNode = MainFramePage(0).childNodes.item(i).text
				RowForMain=FrametNode
				//alert(RowForMain)
			}
		}else
		{
			RowForMain="127,*"
		}
	}
	
	return RowForMain
}

//ArrForFont stores font name to be downloaded to local system from server.
ArrForFont=new Array()

/*
	DevangM | CRF#25840 | 20060513
	The Array stores the name field to be added in the registry
*/
var ArrForFontValue = new Array()
function FontsTobeInstalled()
{
  try{
			if (XMLForCustomizeAns)
			{	
				var myRoot = myXmlFile.documentElement;
				
				var LOC_FontToBeInstalled = myRoot.getElementsByTagName("FONTFROMOCX")
				if (LOC_FontToBeInstalled.length > 0 )
				{
					var LOC_NumberOfFonts=LOC_FontToBeInstalled(0).childNodes.length
					//JUNED 20030311
					for(FontSequence=0;FontSequence<LOC_NumberOfFonts;FontSequence++)
					{
						var FontName=LOC_FontToBeInstalled.item(0).childNodes.item(FontSequence).text
						ArrForFont[FontSequence]=FontName
						/*
							DevangM | CRF#25840 | 20060513
							The Value for Font registry entry is added here
						*/
						var FontValue=""
						try{
							 FontValue =LOC_FontToBeInstalled.item(0).childNodes.item(FontSequence).attributes.item(0).value
						   }
						   catch(exception)	 
						   {
						   }						
						ArrForFontValue[FontSequence]=FontValue
						
					}
				}
			}
			return LOC_NumberOfFonts
	}
	catch(exception)		
	{
	 // alert("Fontsinstall " + exception)
	}
}


//==================
/*if(ConTagName=="SELECT")
{
	var LOC_ContolOptionTex=0
	LOC_ContolOptionText=LOC_ControlName.item(0).getElementsByTagName(OptionTextTag)
	var LOC_ContolOptionValue=0
	LOC_ContolOptionValue=LOC_ControlName.item(0).getElementsByTagName(OptionValueTag)
	if (LOC_ContolAdd.length > 0)
	{
		//Useful--alert("style" + "==" + LOC_ContolStyle.length)
		CurrPointerOfXml=OtherTag(ConTagName,CurrPointerOfXml,LOC_PageName,currentform,ControlName,LOC_ContolAdd,PropertyTag)
	}
	if(LOC_ContolAppend.length > 0)
	{
		//Useful--alert(LOC_ContolStyle.length)
		CurrPointerOfXml=OtherTag(ConTagName,CurrPointerOfXml,LOC_PageName,currentform,ControlName,LOC_ContolAppend,PropertyTag)
	}
}*/
//===============

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWriting Filexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
function createXML(currentform,pagename)
{
			var TableCount=0
			
			var XMLString="<?xml version='1.0' encoding='ISO-8859-1'?><ROOT>" + "\n" 
			XMLString=XMLString + "<" + pagename + ">" + "\n"
			//==============
			var PCount=0
			var ACount=0
			var FORMCount=0
			var FramesetCount=0
			var FrameCount=0
			var IMGCount=0
			var DivCount=0
			var FONTCount=0
			var RadioName=""
			var RadioCount=0
			var LICount=0
			
			
			//Start DevangM|CRF#20552|20051015	To Include Select Tag
			var SELECTCount=0
			//End DevangM|CRF#20552|20051015	To Include Select Tag
			
			//=============
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagInput = document.all.tags("input");
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var buttonTagStr="\t" + "<button>" + "\n"
			var buttonTagXML=""
			
			var submitTagStr="\t" + "<submit>" + "\n"
			var submitTagXML=""
			
			var textTagStr="\t"  + "<text>" + "\n"
			var textTagXML=""
			
			var radioTagStr="\t"  + "<radio>" + "\n"
			var radioTagXML=""
			
			var PasswordTagStr="\t"  + "<password>" + "\n"
			var PasswordTagXML=""
			
			var checkboxTagStr="\t" + "<checkbox>" + "\n"
			var checkboxTagXML=""			
			
			var selectoneTagStr="\t" + "<select-one>" + "\n"
			var selectoneTagXML=""
			var ControlName=""
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			for(i=0;i < TagInput.length; i++)
			{
				switch(TagInput(i).type)
				{
					case "button" :
						buttonTagXML=buttonTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
					case "submit" :
						submitTagXML=submitTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
					case "text" :
						textTagXML=textTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
				   case "password" :
						PasswordTagXML=PasswordTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
					case "radio" :
						//xxxxxxxxxxxxxxxRadio button has many control under one name so this logic is writtenxxxxxxxxxxxxxxx
						if(RadioName==TagInput(i).name)
						{
							RadioCount=RadioCount +1	
						}else
						{
							RadioCount=1	
						}
						RadioName=TagInput(i).name
						ControlName	=TagInput(i).name + "-" + RadioCount
						//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEnd naming radio buttonsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						
						radioTagXML=radioTagXML + CreateOtherTag(ControlName,TagInput(i).title)
						break
					case "select-one" :
						selectoneTagXML=selectoneTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
					case "checkbox" :
						selectoneTagXML=selectoneTagXML + CreateOtherTag(TagInput(i).name,TagInput(i).title)
						break
					
				}
				
			}
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAdding end Tagxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			buttonTagStr=buttonTagStr + buttonTagXML + "\t" + "</button>" + "\n"
			submitTagStr=submitTagStr + submitTagXML + "\t" + "</submit>" + "\n"
			textTagStr=textTagStr + textTagXML + "\t" + "</text>"  + "\n"
			PasswordTagStr=PasswordTagStr + PasswordTagXML + "\t" + "</password>"  + "\n"			
			radioTagStr=radioTagStr + radioTagXML + "\t" + "</radio>" + "\n"
			checkboxTagStr=checkboxTagStr + checkboxTagXML + "\t" + "</checkbox>" + "\n"
			selectoneTagStr=selectoneTagStr + selectoneTagXML + "\t" + "</select-one>" + "\n"
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxProcessing Other Tagxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxForm TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var TagFORM = currentform.tags("FORM");
			var formTagStr=""
			formTagStr="\t" + "<FORM>" + "\n"
			//alert(TagFORM.length +  "==" + pagename)
			for(i=0;i< TagFORM.length; i++)
			{
				FORMCount=FORMCount + 1
				ControlName	="FORM" + FORMCount			
				formTagStr=formTagStr + CreateOtherTag(ControlName,TagFORM(i).action)
			}
			formTagStr=formTagStr + "\t" + "</FORM>" + "\n"
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Form IMG TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxIMG TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var TagIMG = currentform.tags("IMG");
			var imgTagStr=""
			imgTagStr="\t" + "<IMG>" + "\n"
			//alert(TagIMG.length +  "==" + pagename)
			for(i=0;i< TagIMG.length; i++)
			{
				IMGCount=IMGCount + 1
				/*DevangM|CRF#20552|20051011
					-- The changes were made to identify the tags with id.
					-- Following code sets the tagname for IMG, id of the tag if
						the tag is given an id.
					-- If the tag is not given an id then the tagname "IMG" + IMGcount	

				  start	
				*/
				ControlName = GetControlName("IMG",TagIMG(i).id,IMGCount)
				//END DevangM|CRF#20552|20051011
				imgTagStr=imgTagStr + CreateOtherTag(ControlName,TagIMG(i).src + " " + ControlName,TagIMG(i).title)
			}
			imgTagStr=imgTagStr + "\t" + "</IMG>" + "\n"
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx END IMG TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTEXT AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var TagTEXTAREA = currentform.tags("textarea");
			var textareaTagStr=""
			textareaTagStr="\t" + "<textarea>" + "\n"
			for(i=0; i < TagTEXTAREA.length; i++)
			{
				textareaTagStr=textareaTagStr + CreateOtherTag(TagTEXTAREA(i).name,TagTEXTAREA(i).title)
			}
			textareaTagStr=textareaTagStr + "\t" + "</textarea>" + "\n"
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTEXT AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxOBJECT TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var TagOBJECT = currentform.tags("object");
			var objectTagStr=""
			objectTagStr="\t" + "<object>" + "\n"
			for(i=0; i < TagOBJECT.length; i++)
			{
				objectTagStr=objectTagStr + CreateOtherTag(TagOBJECT(i).id,TagOBJECT(i).title)
			}
			objectTagStr=objectTagStr + "\t" + "</object>" + "\n"
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxOBJECT AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
						
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAME AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagFRAME = currentform.tags("FRAME");
			var frameTagStr=""
			frameTagStr="\t" + "<FRAME>" + "\n"
			for (i=0; i < TagFRAME.length; i++)
			{
				FrameCount=FrameCount + 1
				ControlName	="FRAME" + FrameCount
				frameTagStr=frameTagStr + CreateOtherTag(ControlName,TagFRAME(i))
			}
			frameTagStr=frameTagStr + "\t" + "</FRAME>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAME AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAMESET AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagFRAMESET = currentform.tags("FRAMESET");
			var framesetTagStr=""
			framesetTagStr="\t" +  "<FRAMESET>" + "\n"
			for(i=0; i < TagFRAMESET.length; i++)
			{
				FramesetCount=FramesetCount + 1
				ControlName	="FRAMESET" + FramesetCount
				framesetTagStr=framesetTagStr + CreateOtherTag(ControlName,TagFRAMESET(i))
			}
			framesetTagStr=framesetTagStr + "\t" + "</FRAMESET>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAMESET AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			var TagSELECT = currentform.tags("SELECT");
			var selectTagStr=""
			selectTagStr="\t" +  "<SELECT>" + "\n"
			//Start DevangM|CRF#20552|20051015	To Include Select Tag
			for(i=0;i < TagSELECT.length; i++)
			{
				SELECTCount = SELECTCount + 1
				//For Select we have selected name because names are already given
				ControlName = GetControlName("SELECT",TagSELECT(i).name,SELECTCount)
				selectTagStr = selectTagStr  + CreateOtherTag(ControlName,TagSELECT(i).innerText)
			}
			selectTagStr=selectTagStr + "\t" + "</SELECT>" + "\n"
			//End DevangM|CRF#20552|20051015	To Include Select Tag
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAMESET AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagP = currentform.tags("p");
			var pTagStr=""
			pTagStr="\t" + "<P>" + "\n"
			//alert(TagP.length + "==" + pagename)
			for(i=0;i < TagP.length; i++)
			{
				PCount=PCount +1
				/*DevangM|CRF#20552|20051011
					-- The changes were made to identify the tags with id.
					-- Following code sets the tagname for P, id of the tag if
						the tag is given an id.
					-- If the tag is not given an id then the tagname "P" + Pcount	

				start	
				*/
				ControlName = GetControlName("P",TagP(i).id,PCount)
				//END DevangM|CRF#20552|20051011
				pTagStr=pTagStr + CreateOtherTag(ControlName,TagP(i).innerText)
			}
			pTagStr=pTagStr +  "\t" + "</P>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFRAMESET AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA AREA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagA = currentform.tags("A");
			var aTagStr=""
			aTagStr="\t" +  "<A>" + "\n"
			for(i=0; i < TagA.length; i++)
			{
				ACount=ACount + 1
				
				/*DevangM|CRF#20552|20051011
					-- The changes were made to identify the tags with id.
					-- Following code sets the tagname for A, id of the tag if
						the tag is given an id.
					-- If the tag is not given an id then the tagname "A" + Acount	

				start	
				*/
				ControlName = GetControlName("A",TagA(i).id,ACount)
				//END DevangM|CRF#20552|20051011
				aTagStr=aTagStr + CreateOtherTag(ControlName,TagA(i).innerText + " " + TagA(i).href)
			}
			aTagStr=aTagStr + "\t" + "</A>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFONT TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagFONT = currentform.tags("FONT");
			var fontTagStr=""
			fontTagStr="\t" + "<FONT>" + "\n"
			for(i=0; i < TagFONT.length; i++)
			{
				FONTCount=FONTCount + 1
				/*DevangM|CRF#20552|20051011
					-- The changes were made to identify the tags with id.
					-- Following code sets the tagname for FONT, id of the tag if
						the tag is given an id.
					-- If the tag is not given an id then the tagname "FONT" + FONTcount	

				start	
				*/
				ControlName = GetControlName("FONT",TagFONT(i).id,FONTCount) 
				//END DevangM|CRF#20552|20051011
				fontTagStr=fontTagStr + CreateOtherTag(ControlName,TagFONT(i).innerText)
			}
			fontTagStr=fontTagStr + "\t" + "</FONT>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFONT TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDIV TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			var TagDIV = currentform.tags("DIV");
			var divTagStr=""
			divTagStr="\t" + "<DIV>" + "\n"
			for(i=0;i < TagDIV.length; i++)
			{
				DivCount=DivCount + 1
				/*DevangM|CRF#20552|20051011
					-- The changes were made to identify the tags with id.
					-- Following code sets the tagname for DIV, id of the tag if
						the tag is given an id.
					-- If the tag is not given an id then the tagname "DIV" + Divcount	

				start	
				*/
				ControlName = GetControlName("DIV",TagDIV(i).id,DivCount)
				//END DevangM|CRF#20552|20051011
				divTagStr=divTagStr + CreateOtherTag(ControlName,TagDIV(i).innerText)
			}
			divTagStr=divTagStr +  "\t" + "</DIV>" + "\n"
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDIV TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxLI TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			var TagLI = currentform.tags("LI");
			var liTagStr=""
			liTagStr="\t" + "<LI>" + "\n"
			//alert(TagFORM.length +  "==" + pagename)
			for(i=0;i< TagLI.length; i++)
			{
				LICount=LICount + 1
				/*DevangM|CRF#20552|20051011
				start	
				*/
				ControlName = GetControlName("LI",TagLI(i).id,LICount)
				//END DevangM|CRF#20552|20051011
				
				liTagStr=liTagStr + CreateOtherTag(ControlName,TagLI(i).innerText)
			}
			liTagStr=liTagStr + "\t" + "</LI>" + "\n"
			

			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx LI TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTABLE TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
			for (CurrPointerOfXml=0; CurrPointerOfXml < (currentform.length);CurrPointerOfXml++)
			{
				var ConTagName=currentform(CurrPointerOfXml).tagName
				var TypeName=currentform(CurrPointerOfXml).type
				var ControlName=""
					/*DevangM|CRF#20552|20051011
					  In Following code redundent if condition removed	
					*/
					if(currentform(CurrPointerOfXml).tagName=="TABLE")
					{
					
							TableCount=eval(TableCount) + 1
							/*DevangM|CRF#20552|20051011
						    	-- The changes were made to identify the tags with id.
								-- Following code sets the tagname for table, "TABLE" + id of the table if
								    the table is given an id.
								-- If the table is not given an id then the tagname for table is "TABLE" + Tablecount
					
							  start	
							*/
							if (currentform(CurrPointerOfXml).id=="")
							{
								ControlName	="TABLE" + TableCount
							}
							else
							{
								ControlName="TABLE" + currentform(CurrPointerOfXml).id
							}
							//end DevangM|CRF#20552|20051011
							
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxCalling a function to parse Tablexxxxxxxxxxxxxxxxxxxxxxxx
							var NoOfRow=0			//to count number of row
							var NoOfCol=0			//to count number of column
							
							var RowOfTable=currentform(CurrPointerOfXml).innerHTML
							RowOfTable=RowOfTable.toUpperCase()
			
							do 
							{
								RowOfTable =RowOfTable.replace("<TR"," ");
								NoOfRow =eval(NoOfRow) + 1
							}
								while(RowOfTable.indexOf("<TR") > -1)
								
							do 
							{
								RowOfTable =RowOfTable.replace("<TD"," ");
								NoOfCol =eval(NoOfCol) + 1
							}
							while(RowOfTable.indexOf("<TD") > -1)
							NoOfCol=(eval(NoOfCol) ) /  ( eval(NoOfRow) )
							try{
								XMLString=XMLString + "\t" + "<" + ControlName + " Indentification="  + "'" + currentform(CurrPointerOfXml +2 ).innerText +"'" + ">" + "\n"
							}catch(exception)
							{
								XMLString=XMLString + "\t" + "<" + ControlName + " Indentification="  + "'" + currentform(CurrPointerOfXml).innerText +"'" + ">" + "\n"
							}
							var Pos=0
							var OtherTableFound=""
							for(i=1;i <= NoOfRow; i++)
							{
								Pos=Pos  +1
								try{
									if(currentform(CurrPointerOfXml + Pos).tagName=="TABLE")
									{
										break
									}
								}catch(exception)
								{
									break
								}
								var RowTag="ROW-" + i
								XMLString=XMLString + "\t" + "\t" + "<" + RowTag + ">" + "\n"
								for(j=1;j <= NoOfCol; j++)
								{
									Pos=Pos  +1
									try{
										if(currentform(CurrPointerOfXml + Pos).tagName=="TABLE")
										{
											i = NoOfRow + 1
											break
										}
									}catch(exception)
									{
									}
									var ColTag="COL-" + j	
									XMLString=XMLString + "\t" +"\t" +"\t" + "<" + ColTag + ">" + "\n"
										XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "<style>" + "\n"
											//XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "\t" + "<Indentification>" + currentform(CurrPointerOfXml +2 ).innerText + "</Indentification>" +  "\n"
										XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "</style>" + "\n"								
										XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "<property>" + "\n"
										XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "</property>" + "\n"	
									XMLString=XMLString + "\t" +"\t" +"\t" +"</" + ColTag + ">" + "\n"
								}	
								XMLString=XMLString + "\t" +"\t" + "</" + RowTag + ">" + "\n"
							}
							XMLString=XMLString + "\t" + "</" + ControlName + ">" + "\n"
					
							//alert(XMLString)
							//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxEndxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
										
					}	
			}//CurrPointerOfXml
			//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTABLE TAGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
		XMLString=XMLString + formTagStr
		XMLString=XMLString + PasswordTagStr
		XMLString=XMLString + buttonTagStr
		XMLString=XMLString + submitTagStr
		XMLString=XMLString + textTagStr
		XMLString=XMLString + radioTagStr
		XMLString=XMLString + checkboxTagStr
		XMLString=XMLString + frameTagStr
		XMLString=XMLString + textareaTagStr
		XMLString=XMLString + frameTagStr
		XMLString=XMLString + framesetTagStr
		XMLString=XMLString + selectTagStr //DevangM|20552|20051015 
		XMLString=XMLString + pTagStr
		XMLString=XMLString + aTagStr
		XMLString=XMLString + fontTagStr
		XMLString=XMLString + divTagStr
		XMLString=XMLString + imgTagStr
		XMLString=XMLString + objectTagStr
		XMLString=XMLString + liTagStr
			
		XMLString=XMLString + "</" + pagename + ">" + "\n"
		XMLString=XMLString + "</ROOT>"
		fso = new ActiveXObject("Scripting.FileSystemObject");
		var XMLfilename="c:\\AspPages\\" + pagename + ".xml"
		var a = fso.CreateTextFile(XMLfilename, true);
		a.writeLine (XMLString)
		a.close()
		//alert(XMLString)
	
		return true
	
	}
	
/* DevangM|CRF#20552|20051011
	Following function is written to return the tagname to store in XML	
	-- The changes were made to identify the tags with id.
	-- Following code sets the tagname for tag, id of the tag if
		the tag is given an id.
	-- If the tag is not given an id then the tagname TAGName + TAGCount	
   start
*/	
function GetControlName(TAGName,Id,TAGCount)
{
	if(Id == "")
	{
		return(TAGName + TAGCount)
	}
	else
	{
		return(Id)
	}	

}
//end DevangM|CRF#20552|20051011
function CreateOtherTag(ControlName, Identity)
{
		var XMLString=""		
		//alert(ControlName)
		
		//ControlName)
		XMLString=XMLString + "\t" +"\t" + "<" + ControlName + " Indentification=" + "'" + Identity + "'" + ">" + "\n"
		XMLString=XMLString + "\t" +"\t" +"\t" + "<style>" + "\n"
		//XMLString=XMLString + "\t" +"\t" +"\t" + "\t" + "<Indentification>" + Identity + "</Indentification>" + "\n"
		XMLString=XMLString + "\t" +"\t" +"\t" + "</style>" + "\n"								
		XMLString=XMLString + "\t" +"\t" +"\t" + "<property>" + "\n"
		XMLString=XMLString + "\t" +"\t" +"\t" + "</property>" + "\n"	 
		XMLString=XMLString + "\t" +"\t" +"</" + ControlName + ">" + "\n"
		
	//alert(XMLString)
	return XMLString
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXEND CUSTOMIZATIONXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
//Following fuctions are called from file where there are set of records.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXMAKING KEYBOARD AND MOUSE OVER WORKING ON SET OF RECORDSXXXXXXXXXXXXXXXXXXXXXX
//CRF		:	7266-20030227
//Coder		:	Juned 
//CRF		:   7224 20030407
//To trap if Keyupevent is occured or not.
var KeyUpEvent=""
function MoveRecord(row,ObjPreviousButton,ObjNextButton)
{   
    
	//return false
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	var ar = document.all.tags("tr");	
	    
	var CurrentRowNumber=0
	var focusOnTable=""
	for(i = 0; i<ar.length;i++)
	{
		if(ar[i].id == "DataTableChangeRow")
		{
			CurrentRowNumber=i
			focusOnTable="true"
		}
	}
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
	
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx	
	if(event.keyCode==40)
	{
		if(focusOnTable=="true")
		{
			try
			{
				KeyUpEvent="true"
				if (ar[CurrentRowNumber].recordNumber==9)						
					 {
					    try{
								//ObjNextButton.fireEvent("onClick")		
								ObjNextButton.onclick()
						   }
						catch(exception)   		
						   {
						      //NileshT | Commented below message
						      //alert("40 : " + exception.description)
						   }
					 }
				ar[CurrentRowNumber+1].onclick()								
			}catch(exception)
			{			   
		
			}
			/*ar[CurrentRowNumber].id="DataTableRow"
			ar[CurrentRowNumber+1].id="DataTableChangeRow"*/
		}
		
	}
	//alert(Param_rownumber)
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
	
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	if(event.keyCode==38)
	{
		if(focusOnTable=="true")
		{
			try{
				KeyUpEvent="true"
				if (ar[CurrentRowNumber].recordNumber==0)						
						   {
								try{
									 //ObjPreviousButton.fireEvent("onClick")      
									 ObjPreviousButton.onclick()
								   }
								catch(exception)    	 
								   {
								      //NileshT | Commented below message
								      //alert("38 : " + exception.description)
								   }
						   }
				ar[CurrentRowNumber-1].onclick()				
			}catch(exception)
			{
			  	
			}
		}
	}
	if(event.keyCode==34)
	  {
	     	 try{
						//ObjNextButton.fireEvent("onClick")		
			    	ObjNextButton.onclick()
			    				    	
				 }
			catch(exception)   		
			   {
		    	      //NileshT | Commented below message
		    	      //alert("34 : " + exception.description)
		       }
	  }
	if(event.keyCode==33)  
	  {
	    	try{
				  //ObjPreviousButton.fireEvent("onClick")      
				 ObjPreviousButton.onclick()			 
				 
			    }
			catch(exception)    	 
			   {
			      //NileshT | Commented below message
			      //alert("33 : " + exception.description)
			      
			   }
	  }
	  
	//alert(row.rowIndex)
	//alert(row.recordNumber)
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
KeyUpEvent="false"
}

function AssignRowRecordNumber(Param_recordNumber,Param_row)
{
  //alert(Param_row.recordNumber)
try{
	 //Param_row.recordNumber=Param_recordNumber
   }
   catch(exception)
   {
	 //NileshT | Commented below message
     //alert("ExceptionRaised: " + exception.description)
   }

}
/*  
VipulP | CRF# | 9/21/2005
This function Will call from the OnClick event of row
Parameters => RowNumbere->Numbere of the clicked row
           => ObjNextButton->Object of NextButton
           => ObjPreviousButton-> Objecto of Previous button
*/
function MovePreviousNextSet(RecordNumber,ObjNextButton,ObjPreviousButton) 
{
  //alert(event.keyCode)
  try
  {
   if (RecordNumber==9)
    {
		if (event.keyCode==40)
			{
                  //alert('done')  
			}
	}		
    //ObjNextButton.onClick()
  }
  catch(exception) 
  {
	//NileshT | Commented below message
    //alert(exception.description)
  }
  //alert("RecordNumber: " + RecordNumber + "Next : " + ObjNextButton + "Previous : " + ObjPreviousButton)
  //alert("NameNext" + ObjNextButton.title)
   /*try
   {
      if(RecordNumber==0)
		{
		 ObjPreviousButton.onClick()
		}
       
      if(RecordNumber==9) 		
        {
         alert('above')
         ObjNextButton.Click()
         alert('clicked')
        }
   }
   catch(exception)
   {
   }*/
}
function ProcessOnEnter(Control)
{
	return false
	if(event.keyCode==13)
	{
		Control.onclick()
		return false
		
	}
}
function ChangeRowColorOnMouseOver(row)
{
	//return false
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	var ar = document.all.tags("tr");
	var CurrentRowNumber=0
	var focusOnTable="true"
	for(i = 0; i<ar.length;i++)
	{
		if(ar[i].id == "DataTableChangeRow")
		{
			CurrentRowNumber=i
			focusOnTable="true"
		}
	}
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
	
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	if(focusOnTable=="true")
	{
		/*try
		{
			ar[CurrentRowNumber].onclick()
		}catch(exception)
		{
				
		}
		document.form1.button1.style.borderStyle="solid"*/
		
		if(row.id != "DataTableChangeRow")
		{
			/*Coder:juned
			We have stopped firing on click event on mouse over 
			*/
			
			//row.onclick()
			row.id="DataTableChangeRowMouseOver"
			try{
				ar[CurrentRowNumber].id="DataTableChangeRow"
			}catch(exception)
			{
			}	
		}else
		{
			
		}
		/*ar[CurrentRowNumber].="DataTableRow"
		ar[CurrentRowNumber+1].id="DataTableChangeRow"*/
	}
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
}
function ChangeRowColorOnMouseOut(row)
{
	
	//return false
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	var ar = document.all.tags("tr");
	var CurrentRowNumber=0
	var focusOnTable="true"
	for(i = 0; i<ar.length;i++)
	{
		if(ar[i].id == "DataTableChangeRow")
		{
			CurrentRowNumber=i
			focusOnTable="true"
		}
	}
	//xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxxx
	
	//xxxxxxxxxxxxxxSTARTxxxxxxxxxxxxxxxxxxx
	if(focusOnTable=="true")
	{
		/*try
		{
			ar[CurrentRowNumber].onclick()
		}catch(exception)
		{
				
		}*/
		if(row.id != "DataTableChangeRow")
		{
			row.id="DataTableChangeRowMouseOut"
			try{
				/*Coder:juned
				We have stopped firing on click event on mouse over 
				*/
				//ar[CurrentRowNumber].onclick()
			}catch(exception)
			{
				//error
			}	
		}
	}
} 
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXENDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//CRF : 7541 JUNED-20030331
//This function will get back the user to patient page with previous page
/*function GoBack(pageName)
{
	for(GoBackTotalPage=0; GoBackTotalPage < top.defaultmain.history.length-1; GoBackTotalPage++)
	{
		
		
		if(top.defaultmain.location.pathname!=pageName)
		{
			top.defaultmain.history.back(1)		
		}else
		{
			top.defaultmain.history.forward(1)		
			break
		}
		
	}
}*/

/*****************************************************************************************
CRF 5298 AjayB 2003/04/10
To check the current value of the resultpage and toggle PREVIOUS & NEXT button accordingly
*****************************************************************************************/
function CheckPrevNextButtonStatus(totalPages,currentPage){
if (currentPage==1 && totalPages==1)
	return 0;
if (currentPage==1 && currentPage<totalPages)
	return 1;
if (currentPage==totalPages && totalPages>1)
	return 2;
if (currentPage<totalPages && currentPage>1)
	return 3;
}
function SetButtonStatus(ButtonObject,Type,TotalPages,CurrentPage){
/*
	NilayM | CRF#27982 | 20061031
	if any value in string then we are converting string value to integer in TotalPages and CurrentPage
*/
TotalPages=eval(TotalPages)
CurrentPage=eval(CurrentPage)
var ButtonStatus;
ButtonStatus=CheckPrevNextButtonStatus(TotalPages,CurrentPage);
if (ButtonStatus==0){	
	ButtonObject.disabled=true;
	return 0;
}
if (ButtonStatus==3){
	ButtonObject.disabled=false;
	return 1;
}
if (ButtonStatus==1)

	if (Type==0){
	ButtonObject.disabled=true;
	return 0;
	}
	else
	{
	ButtonObject.disabled=false;
	return 1;
	}
if (ButtonStatus==2)
	if (Type==0){
	ButtonObject.disabled=false;
	return 1;
	}
	else{
	ButtonObject.disabled=true;
	return 0;
	}
	
	/*This block has been written on 20031218
	coder:juned.
	when no result is dispalyed on newresult right page and error was given. To over come the error we hav
	writte the try block
	*/
	try{
		ButtonObject.disabled=false;
	}catch(exception)
	{
	
	}
return 0;
}
function ButtonCheck(PrevButtonObject,NextButtonObject,totalPages,currentPage)
{
/*
	NilayM | CRF#27982 | 20061031
	if any value in string then we are converting string value to integer in TotalPages and CurrentPage
*/
totalPages = eval(totalPages)
currentPage = eval(currentPage)
if (currentPage==1 && totalPages==1)
{
	PrevButtonObject.disabled=true;
	NextButtonObject.disabled=true;
}
if (currentPage==1 && currentPage<totalPages)
{
	PrevButtonObject.disabled=true;
	NextButtonObject.disabled=false;
}
if (currentPage==totalPages && totalPages>1)
{
	PrevButtonObject.disabled=false;
	NextButtonObject.disabled=true;
}
if (currentPage<totalPages && currentPage>1)
{
	PrevButtonObject.disabled=false;
	NextButtonObject.disabled=false;
}
}
//************************END OF CHANGE*******************************************
var Printer_Cookies_Name="Printer_Name"
/*
		Purpose:To set the value to cookie
		Coder : Juned
	*/
	function GeneralfixDate(date) 
	{
	  var base = new Date(0);
	  var skew = base.getTime();
	  if (skew > 0)
	    date.setTime(date.getTime() - skew);
	}
	//KaushikP 20041126
	//Add extra argument SaveCookie in function GeneralsetCookie
	function GeneralsetCookie(name,cookiesval,SaveCookie) 
	{
		var now = new Date();
		GeneralfixDate(now);
		now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
		var expires = now;
		
		var curCookie
		//KaushikP : 20041126
		//If SaveCookie == true then save the cookie so that it can be used after browser close
		if( SaveCookie == true )
		{
			curCookie = name + "=" + escape(cookiesval) +
			((expires) ? "; expires=" + expires.toGMTString() : "");
		}
		else
		{
			curCookie = name + "=" + escape(cookiesval)
		}
	    /*CRF:10551	CODER:JUNED
		We have not specified any expiry date, so this cookies will expire after the session is closed(Browser is closed)
		path is given as "/powerweb" that means cookies will be available to Powerweb folder
		*/
		document.cookie = curCookie + ";path=" + CookiesFolder
		
	}
	/*
		Purpose:To get the cookie value
		Coder : Juned.
	*/
	function GeneralgetCookie(name) 
	{
	  var dc = document.cookie;
	  var prefix = name + "=";2
	  var begin = dc.indexOf("; " + prefix);
		  
	  if (begin == -1)
	   {   
	    begin = dc.indexOf(prefix);
		  
	    if (begin != 0) return null;
		    
	  } 
	  else
	    begin += 2;
	  var end = document.cookie.indexOf(";", begin);
		  
	  if (end == -1)
	    end = dc.length;
	  return unescape(dc.substring(begin + prefix.length, end));
	}
	
	/*
	JunedM | 20050211
	This function will "delete" the supplied cookie from the browser by setting the cookie's expiry date 
	to one second in the past.
	*/
	function delete_cookie (cookie_name)
	{
		var cookie_date = new Date ( );  // current date & time
		cookie_date.setTime ( cookie_date.getTime() - 1 );
		document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
	}



/*CRF:10551
CODER:JUNED
THIS FUNCTION WILL SET THE PRINTER NAME AS TITLE OF PRINT BUTTON.
*/
function SetTitleForPrinter(fullscreen)
{
	try{
		var Loc_PrinterNameToolTip1=GeneralgetCookie(Printer_Cookies_Name)
		var Loc_PrinterNameToolTip2=GeneralgetCookie(Printer_Cookies_Name)
		if (Loc_PrinterNameToolTip1== null || Loc_PrinterNameToolTip1=="" || Loc_PrinterNameToolTip1== "null")
		{
			Loc_PrinterNameToolTip1="Click here to print current page of this report"
			Loc_PrinterNameToolTip2="Click here to print this report"
		}
		if (fullscreen=="YES")
		{
			top.right_top.document.topform.Current_Print.title=Loc_PrinterNameToolTip1
			top.right_top.document.topform.LOC_Print.title=Loc_PrinterNameToolTip2
		}else
		{
			top.defaultmain.right.right_top.document.topform.Current_Print.title=Loc_PrinterNameToolTip1
			top.defaultmain.right.right_top.document.topform.LOC_Print.title=Loc_PrinterNameToolTip2
		}
	}catch(exception)
	{
	}

}
/*Vipul CRF#17716 20050615
 This function will encode the querystring values
*/
function Sys_HTMLEncoder_New(sString)
{
  /*
		Vipul | 20050610 |CRF#17720
		Put the procedure in try catch block.
 */				
  try{	
      	if (sString != "") 
			{ 	
				var ArrForSpecialchar=new Array()
				var ArrForSpecialcharEncode=new Array()
				
				//ArrForSpecialchar[2]="%"
				ArrForSpecialchar[0]="!"				
				ArrForSpecialchar[1]="#"
				ArrForSpecialchar[2]="&"				
				ArrForSpecialchar[3]="?"
				ArrForSpecialchar[4]='"'
				ArrForSpecialchar[5]="'"
				
				
				//ArrForSpecialcharEncode[2]="%25"
				ArrForSpecialcharEncode[0]="%21"				
				ArrForSpecialcharEncode[1]="%23"
				ArrForSpecialcharEncode[2]="%26"				
				ArrForSpecialcharEncode[3]="%3F"
				ArrForSpecialcharEncode[4]="&quot;"
				//Vipul 20050621 CRF#17931
				//Changed from &#39; to %27
				ArrForSpecialcharEncode[5]="%27" 
		
				/*
				Vipul | 20050610 |CRF#17720
				Replace function not replacing all the occrences of special character
				so we have put it in the do loop
				*/
				var index=0;
				for(index=0;index<ArrForSpecialchar.length;index++)
				{
						do{
						    sString = sString.replace(ArrForSpecialchar[index],ArrForSpecialcharEncode[index]);								
						 
						   }while(sString.indexOf(ArrForSpecialchar[index]) > -1)
				}	
				return sString
			}else
			{
				return ""
			}	
	}catch(exception)		
	{
			return ""
	}
}

/*
CRF:11777
CODER:JUNED.
REPLACING THE SPECIAL CHARACTER WITH URL ENCODER
*/
function Sys_URLEncoder(sString)
{
	if (sString != "") 
	{ 
		var ArrForSpecialchar=new Array()
		var ArrForSpecialcharEncode=new Array()
		/*THIS ARRAY WAS ADDED KEEPING IN MIND THE FOLLOWING SCENERIO
		IF USER INSERT "v" THEN THIS FUNCTION WILL REMOVE "v" CHARACTER.
		TO REMOVE THIS LIMITATION, I HAVE MADE THIS ARRAY AND INDIVIDUALLY CHECKING EACH SPECIAL CHARACTER.	
		CODER:JUNED.
		% %25
		! %21
		" %22
		# %23
		& %26
		' %27
		? %3F
		*/
		
		ArrForSpecialchar[0]="%"
		ArrForSpecialchar[1]="!"
		ArrForSpecialchar[2]=""
		ArrForSpecialchar[3]="#"
		ArrForSpecialchar[4]="&"
		ArrForSpecialchar[5]="'"
		ArrForSpecialchar[6]="?"
		ArrForSpecialchar[7]="+"
		
		
		
		ArrForSpecialcharEncode[0]="%25"
		ArrForSpecialcharEncode[1]="%21"
		ArrForSpecialcharEncode[2]="%22"
		ArrForSpecialcharEncode[3]="%23"
		ArrForSpecialcharEncode[4]="%26"
		ArrForSpecialcharEncode[5]="%27"
		ArrForSpecialcharEncode[6]="%3F"
		ArrForSpecialcharEncode[7]="%2B"
		
		
		
		var StrSpecialCharacter=sString
		var lenStr=StrSpecialCharacter.length
		var ArrayElement=0
		var LastFound=0
		var StrForFinalString="" //new Array()
		for(SpecIndex=0;SpecIndex< ArrForSpecialchar.length;SpecIndex++) //FOR LOOP IS ADDED TO CHECK  EACH CHARACTER FOR e.g."\t" ONE BY ONE
		{
				var StrForFinalString=""
				var CharReplaced=0
				for(SpecialcharArrIndex=0;SpecialcharArrIndex<lenStr;SpecialcharArrIndex++)
				{
					var CharAtSpecialString=StrSpecialCharacter.charAt(SpecialcharArrIndex)
					if(CharAtSpecialString==ArrForSpecialchar[SpecIndex])
					{
						StrForFinalString=StrForFinalString + ArrForSpecialcharEncode[SpecIndex]
						CharReplaced=ArrForSpecialcharEncode[SpecIndex].length
					}else
					{
						StrForFinalString=StrForFinalString + CharAtSpecialString			
					}	
				}
				StrSpecialCharacter=StrForFinalString
				var lenStr=StrSpecialCharacter.length
		}
        return StrSpecialCharacter
 
	}	
}
function Sys_HTMLEncoder(sString)
{
	
	if (sString != "") 
	{ 
		var ArrForSpecialchar=new Array()
		var ArrForSpecialcharEncode=new Array()
		/*THIS ARRAY WAS ADDED KEEPING IN MIND THE FOLLOWING SCENERIO
		IF USER INSERT "v" THEN THIS FUNCTION WILL REMOVE "v" CHARACTER.
		TO REMOVE THIS LIMITATION, I HAVE MADE THIS ARRAY AND INDIVIDUALLY CHECKING EACH SPECIAL CHARACTER.	
		CODER:JUNED.
		% %25
		! %21
		" %22
		# %23
		& %26
		' %27
		? %3F
		*/
		
		ArrForSpecialchar[0]='"'
		ArrForSpecialchar[1]="'"
		//ArrForSpecialchar[2]="<"
		//ArrForSpecialchar[3]=">"
		//ArrForSpecialchar[4]="#"
		//ArrForSpecialchar[5]="\"
	//	ArrForSpecialchar[6]="!"
	//	ArrForSpecialchar[7]="@"
	//	ArrForSpecialchar[8]="$"
	//	ArrForSpecialchar[9]="%"
	//	ArrForSpecialchar[10]="^"
	//	ArrForSpecialchar[11]="*"
	//	ArrForSpecialchar[12]="("
	//	ArrForSpecialchar[13]=")"
	//	ArrForSpecialchar[14]=":"
	//	ArrForSpecialchar[15]="?"
	//	ArrForSpecialchar[16]=","
	//	ArrForSpecialchar[17]="."
				
		ArrForSpecialcharEncode[0]="&quot;"
		ArrForSpecialcharEncode[1]="&#39;"
		//ArrForSpecialcharEncode[2]="&lt;"
		//ArrForSpecialcharEncode[3]="&gt;"
		//ArrForSpecialcharEncode[4]="&#35;"
		//ArrForSpecialcharEncode[5]="&#92;"
	//	ArrForSpecialcharEncode[6]="&#33;"
	//	ArrForSpecialcharEncode[7]="&#64;"
	//	ArrForSpecialcharEncode[8]="&#36;"
	//	ArrForSpecialcharEncode[9]="&#37;"
	//	ArrForSpecialcharEncode[10]="&#94;"
	//	ArrForSpecialcharEncode[11]="&#42;"
	//	ArrForSpecialcharEncode[12]="&#40;"
	//	ArrForSpecialcharEncode[13]="&#41;"
	//	ArrForSpecialcharEncode[14]="&#58;"
	//	ArrForSpecialcharEncode[15]="&#63;"
	//	ArrForSpecialcharEncode[16]="&#44;"
	//	ArrForSpecialcharEncode[17]="&#46;"
		
		var StrSpecialCharacter=sString
		var lenStr=StrSpecialCharacter.length
		var ArrayElement=0
		var LastFound=0
		var StrForFinalString="" //new Array()
		for(SpecIndex=0;SpecIndex< ArrForSpecialchar.length;SpecIndex++) //FOR LOOP IS ADDED TO CHECK  EACH CHARACTER FOR e.g."\t" ONE BY ONE
		{
				var StrForFinalString=""
				var CharReplaced=0
				for(SpecialcharArrIndex=0;SpecialcharArrIndex<lenStr;SpecialcharArrIndex++)
				{
					var CharAtSpecialString=StrSpecialCharacter.charAt(SpecialcharArrIndex)
					if(CharAtSpecialString==ArrForSpecialchar[SpecIndex])
					{
						StrForFinalString=StrForFinalString + ArrForSpecialcharEncode[SpecIndex]
						CharReplaced=ArrForSpecialcharEncode[SpecIndex].length
						
					}else
					{
						StrForFinalString=StrForFinalString + CharAtSpecialString			
					}	
				}
				StrSpecialCharacter=StrForFinalString
				var lenStr=StrSpecialCharacter.length
		}
        return StrSpecialCharacter
	}else
	{
		return ""
	}	
}
function Sys_HTMLDecoder(sString)
{
  /*
		Vipul | 20050610 |CRF#17720
		Put the procedure in try catch block.
 */				
  try{	
      	if (sString != "") 
			{ 	
				var ArrForSpecialchar=new Array()
				var ArrForSpecialcharEncode=new Array()
				
				ArrForSpecialchar[0]='"'
				ArrForSpecialchar[1]="'"
				
				ArrForSpecialchar[2]="<"
				ArrForSpecialchar[3]=">"
				ArrForSpecialchar[4]="#"
				//ArrForSpecialchar[5]="\"
				ArrForSpecialchar[6]="!"
				ArrForSpecialchar[7]="@"
				ArrForSpecialchar[8]="$"
				ArrForSpecialchar[9]="%"
				ArrForSpecialchar[10]="^"
				ArrForSpecialchar[11]="*"
				ArrForSpecialchar[12]="("
				ArrForSpecialchar[13]=")"
				ArrForSpecialchar[14]=":"
				ArrForSpecialchar[15]="?"
				ArrForSpecialchar[16]=","
				ArrForSpecialchar[17]="."
				
						
				ArrForSpecialcharEncode[0]="&quot;"
				ArrForSpecialcharEncode[1]="&#39;"
				
				ArrForSpecialcharEncode[2]="&lt;"
				ArrForSpecialcharEncode[3]="&gt;"
				ArrForSpecialcharEncode[4]="&#35;"
				//ArrForSpecialcharEncode[5]="&#92;"
				ArrForSpecialcharEncode[6]="&#33;"
				ArrForSpecialcharEncode[7]="&#64;"
				ArrForSpecialcharEncode[8]="&#36;"
				ArrForSpecialcharEncode[9]="&#37;"
				ArrForSpecialcharEncode[10]="&#94;"
				ArrForSpecialcharEncode[11]="&#42;"
				ArrForSpecialcharEncode[12]="&#40;"
				ArrForSpecialcharEncode[13]="&#41;"
				ArrForSpecialcharEncode[14]="&#58;"
				ArrForSpecialcharEncode[15]="&#63;"
				ArrForSpecialcharEncode[16]="&#44;"
				ArrForSpecialcharEncode[17]="&#46;"		
				/*
				Vipul | 20050610 |CRF#17720
				Replace function not replacing all the occrences of special character
				so we have put it in the do loop
				*/
				var index=0;
				for(index=0;index<ArrForSpecialcharEncode.length;index++)
				{
						do{
						sString = sString.replace(ArrForSpecialcharEncode[index],ArrForSpecialchar[index]);
						/*sString = sString.replace(ArrForSpecialcharEncode[1],ArrForSpecialchar[1]);
						sString = sString.replace(ArrForSpecialcharEncode[2],ArrForSpecialchar[2]);
						sString = sString.replace(ArrForSpecialcharEncode[3],ArrForSpecialchar[3]);
						sString = sString.replace(ArrForSpecialcharEncode[4],ArrForSpecialchar[4]);
						//sString = sString.replace(ArrForSpecialcharEncode[5],ArrForSpecialchar[5]);
						sString = sString.replace(ArrForSpecialcharEncode[6],ArrForSpecialchar[6]);
						sString = sString.replace(ArrForSpecialcharEncode[7],ArrForSpecialchar[7]);
						sString = sString.replace(ArrForSpecialcharEncode[8],ArrForSpecialchar[8]);
						sString = sString.replace(ArrForSpecialcharEncode[9],ArrForSpecialchar[9]);
						sString = sString.replace(ArrForSpecialcharEncode[10],ArrForSpecialchar[10]);
						sString = sString.replace(ArrForSpecialcharEncode[11],ArrForSpecialchar[11]);
						sString = sString.replace(ArrForSpecialcharEncode[12],ArrForSpecialchar[12]);
						sString = sString.replace(ArrForSpecialcharEncode[13],ArrForSpecialchar[13]);
						sString = sString.replace(ArrForSpecialcharEncode[14],ArrForSpecialchar[14]);
						sString = sString.replace(ArrForSpecialcharEncode[15],ArrForSpecialchar[15]);
						sString = sString.replace(ArrForSpecialcharEncode[16],ArrForSpecialchar[16]);
						sString = sString.replace(ArrForSpecialcharEncode[17],ArrForSpecialchar[17]);*/		
						}while(sString.indexOf(ArrForSpecialcharEncode[index]) > -1)
				}	
				return sString
			}else
			{
				return ""
			}	
	}catch(exception)		
	{
			return ""
	}
}
function GeneralCheckAll(ChildCheckBox,MasterCheckBox)
{
	try{
		var ChildCheckBoxLen=ChildCheckBox.length
		if (ChildCheckBoxLen > 0)
		{
			for(ChildCheckBoxIndex=0;ChildCheckBoxIndex<ChildCheckBoxLen;ChildCheckBoxIndex++)
			{
				if (MasterCheckBox.checked)
				{
					ChildCheckBox[ChildCheckBoxIndex].checked=true
				}else
				{
					ChildCheckBox[ChildCheckBoxIndex].checked=false
				}
			}
		}else
		{
			if (MasterCheckBox.checked)
			{
				ChildCheckBox.checked=true		
			}else
			{
				ChildCheckBox.checked=false
			}
		}
	}catch(exception)
	{
	}
}
/*
This function is called on up and down arrow button for preffered items
*/
function MoveUp(TableControl)
{
	var LOC_Tr=TableControl.getElementsByTagName("tr") 
	for(i = 0; i<LOC_Tr.length;i++)
		{
			if(LOC_Tr[i].id == "DataTableChangeRow")
			{
				if ((i-1)!=0)
				{
					TableControl.moveRow(i,i-1) 
				}
				break	
			}
		}
}
function MoveDown(TableControl)
{
	var LOC_Tr=TableControl.getElementsByTagName("tr") 
	for(i = 0; i<LOC_Tr.length;i++)
		{
			if(LOC_Tr[i].id == "DataTableChangeRow")
			{
				if ((i+1)!=LOC_Tr.length)
				{
					TableControl.moveRow(i,i+1) 
				}
				break	
			}
		}
}

//This function will added row into the Prefered table.
//This function will added row into the Prefered table.
//NilayM | CRF#26898 |20060726
//Adding one more parameter for Focus on CheckBox
function AddRowToPreferedTable(All_RadioControl, All_CheckBoxControl,All_HiddenName,Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl,Prefered_Mode)
{
   
	var CheckedInsuranceHTMLString=""
	var XMLStringADD=""
	var CodeFound=0
	var LOC_MsgString =" " + ReplacePropertyString("is already added")
	try{
	
		if(All_RadioControl.length>0)
		{
			
			for(i=0;i< All_RadioControl.length;i++)
			{
				
				if (All_CheckBoxControl[i].checked)
				{
					
					var LOC_Code=""
					var LOC_Name=""
					
					if (Prefered_Mode=="D") //If preferred doctor.
					{
						/*For preferred doctor, we are showing doctor code first and then name
						and for every other pereferred we are showing name first and then code.
						*/
						//DevangM | CRF#16971 | 20051201
						LOC_Code=All_HiddenName[i].value	  //All_CheckBoxControl[i].value
						LOC_Name=All_CheckBoxControl[i].value //All_HiddenName[i].value
						
						
					}else
					{
						
						LOC_Code=All_CheckBoxControl[i].value 
						LOC_Name=All_HiddenName[i].value
						
					}
					
					CodeFound=0
					//=======================================
					try{
				
						if (Prefered_RadioControl.length > 0)
						{
							
							for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
							{
								
								if (Prefered_Mode=="D") //If preferred doctor.
								{
								
									/*  NilayM | CRF# 26898 | 20060726
										Doctor is already in the Preferred Doctor Window or not
										that is checked by DoctorCode 									   
									*/
									if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
									{
										//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
										/*
											NilayM | CRF#26046 | 20061031
											Show alert message with Code and Name
										*/
										ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
										
										CodeFound=1
									}
								}else
								{
									
									if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
									{
										//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
										/*
											NilayM | CRF#26046 | 20061031
											Show alert message with Code and Name
										*/
										ShowAlert(LOC_Code +" : " + LOC_Name + LOC_MsgString)
										
										CodeFound=1
									}
								}
								
							}
						}else
						{
							if (Prefered_Mode=="D") //If preferred doctor.
							{
								
								/*  NilayM | CRF# 26898 | 20060726
									Doctor is already in the Preferred Doctor Window or not
									that is checked by DoctorCode 									   
								*/
								if(LOC_Code==Prefered_CheckBoxControl.value)
								{
									//document.Form_PreferedTest.Radio_TestCode.click()
									/*
										NilayM | CRF#26046 | 20061031
										Show alert message with Code and Name
									*/
									ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
									CodeFound=1
								}
							}else
							{
								
								if(LOC_Code==Prefered_CheckBoxControl.value)
								{
									//document.Form_PreferedTest.Radio_TestCode.click()
									/*
										NilayM | CRF#26046 | 20061031
										Show alert message with Code and Name
									*/
									ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
									CodeFound=1
								}
							}	
						}
					}catch(exception)
					{
						//alert(exception)
					}
					
					if (CodeFound==0)
					{
						All_CheckBoxControl[i].checked=false
						//If user is doctor then change Code and LOC_Name sequence
						if (Prefered_Mode=="C") //If preferred doctor.
						{
							InsertCodeRow(LOC_Code,LOC_Name,Prefered_TableControl,Prefered_Mode)
						}else
						{
							InsertCodeRow(LOC_Name,LOC_Code,Prefered_TableControl,Prefered_Mode)
						}
					
						
						/*XMLStringADD=XMLStringADD + "<PROCEDUR>"
						XMLStringADD=XMLStringADD + "<ALPHA>"
						XMLStringADD=XMLStringADD + LOC_TestCode
						XMLStringADD=XMLStringADD + "</ALPHA>"
						XMLStringADD=XMLStringADD + "</PROCEDUR>"*/
					}
					
				}
			}
		}else
		{
			
			//20040925 | Juned
			/*Comment the below line and 
			if (All_CheckBoxControl[i].checked)*/
			if (All_CheckBoxControl.checked)
			{
				var LOC_Code=""
				var LOC_Name=""
				
				if (Prefered_Mode=="D") //If preferred doctor.
				{
					/*For preferred doctor, we are showing doctor code first and then name
					and for every other pereferred we are showing name first and then code.
					*/
					//Juned | 20040928
					/*
						DevangM | CRF#16971 | 20051201
						The changes were made 
					*/
					LOC_Code=All_HiddenName.value //All_CheckBoxControl.value 
					LOC_Name=All_CheckBoxControl.value  //All_HiddenName.value
					
				}else
				{
					LOC_Code=All_CheckBoxControl.value 
					LOC_Name=All_HiddenName.value
				}
				
				CodeFound=0
				//=======================================
				try{
					if (Prefered_RadioControl.length >0)
					{
						//alert(Prefered_RadioControl.length)
						for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
						{
							if (Prefered_Mode=="D") //If preferred doctor.
							{
								/*  NilayM | CRF# 26898 | 20060726
									Doctor is already in the Preferred Doctor Window or not
									that is checked by DoctorCode 									   
								*/
								if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
								{
									//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
									/*
										NilayM | CRF#26046 | 20061031
										Show alert message with Code and Name
									*/
									ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
									
									CodeFound=1
								}
							}
							else
							{
								if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
								{
									//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
									/*
										NilayM | CRF#26046 | 20061031
										Show alert message with Code and Name
									*/
									ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
									
									CodeFound=1
								}	
							}
							
						}
					}else
					{
						if (Prefered_Mode=="D") //If preferred doctor.
						{
							/*  NilayM | CRF# 26898 | 20060726
									Doctor is already in the Preferred Doctor Window or not
									that is checked by DoctorCode 									   
							*/
							if(LOC_Code==Prefered_CheckBoxControl.value)
							{
								//document.Form_PreferedTest.Radio_TestCode.click()
								/*
									NilayM | CRF#26046 | 20061031
									Show alert message with Code and Name
								*/
								ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
								
								CodeFound=1
							}
						}else
						{
							if(LOC_Code==Prefered_CheckBoxControl.value)
							{
								//document.Form_PreferedTest.Radio_TestCode.click()
								/*
									NilayM | CRF#26046 | 20061031
									Show alert message with Code and Name
								*/
								ShowAlert(LOC_Code + " : " + LOC_Name + LOC_MsgString)
								
								CodeFound=1
							}
						}
					}
				}catch(exception)
				{
					//alert(exception)
				}
				
				if (CodeFound=="0")
				{
					All_CheckBoxControl.checked=false
					//If user is doctor then change Code and LOC_Name sequence
					if (Prefered_Mode=="C") //If preferred doctor.
					{
						InsertCodeRow(LOC_Code,LOC_Name,Prefered_TableControl,Prefered_Mode)
					}else
					{
						InsertCodeRow(LOC_Name,LOC_Code,Prefered_TableControl,Prefered_Mode)
					}
					
					/*XMLStringADD=XMLStringADD + "<PROCEDUR>"
					XMLStringADD=XMLStringADD + "<ALPHA>"
					XMLStringADD=XMLStringADD + LOC_TestCode
					XMLStringADD=XMLStringADD + "</ALPHA>"
					XMLStringADD=XMLStringADD + "</PROCEDUR>"*/
				}
			}//if checked.
		}
	}catch(exception)//All_RadioControl
	{
		
		//exceptional
	}	
}
function InsertCodeRow(Name,Code,Prefered_TableControl,Prefered_Mode)
{
  
		var RowRecord=Prefered_TableControl.insertRow(Prefered_TableControl.rows.length);
		var aRows=Prefered_TableControl.rows;
		RowRecord.id="DataTableRow"
		RowRecord.attachEvent("onclick", function ()
			{
				var LOC_Tr=Prefered_TableControl.getElementsByTagName("tr") 
					for(i = 0; i<LOC_Tr.length;i++)
						{
						if(LOC_Tr[i].id == "DataTableChangeRow")
						LOC_Tr[i].id = "DataTableRow";
						}
					
					RowRecord.id='DataTableChangeRow'
			} )
		var CellRecord=RowRecord.cells;
					
		var CellRecord_CheckBox=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);	
		var CellRecord_Name=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		var CellRecord_Code=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		if (Prefered_Mode=="C") //If preferred doctor.
		{
			CellRecord_CheckBox.innerHTML="<input type=checkbox name='Checkbox_PreferedCode' value='" + Sys_HTMLEncoder(Name) + "' >"
		}
		else
		{
			CellRecord_CheckBox.innerHTML="<input type=checkbox name='Checkbox_PreferedCode' value='" + Sys_HTMLEncoder(Code) + "' >"
		}
		
		var NameStr="<p class='DataTableRowMargin'>"
		//KaushikP 20040907
		//Add substring function to extract first 21 character from name string
		//NameStr=NameStr + "<Input type=text title='" + Sys_HTMLEncoder(Name) + "' readonly size=35 class='ReadOnlyDataTable' name='ReadOnly_PreferedName' value='" + Sys_HTMLEncoder(Name.substring(0,21)) + "' height='100%'>"
/*
		   Vipul CRF#19226 20050809
		   Commented the above line.Replace the textbox with font
		   as font will not get the focus.
		*/
		NameStr=NameStr + "<font title='" + Sys_HTMLEncoder(Name) + "' readonly size=35 class='ReadOnlyDataTable' name='ReadOnly_PreferedName' height='100%'>" + Sys_HTMLEncoder(Name.substring(0,21)) + "</font>"				
		NameStr=NameStr + "<input type='radio' style='visibility:hidden; height:0px; width:0px' value = '" + Sys_HTMLEncoder(Name) + "' name='Radio_PreferedName' onClick='ChangeRowColorForAddedRow(" + RowRecord.rowIndex + ")' ></p>"
		CellRecord_Name.innerHTML=NameStr
		if (Prefered_Mode=="C") //If preferred doctor.
		{
			CellRecord_Code.innerHTML="<p class='DataTableRowMargin'>" + Sys_HTMLEncoder(Code.substring(0,21)) + "</p>"
		}
		else
		{
			CellRecord_Code.innerHTML="<p class='DataTableRowMargin'>" + Sys_HTMLEncoder(Code.substring(0,21)) + "</p>"
		}
		
}

//This will delete the selected row
function ProcessDeletedPrefered(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
{
	try{
		if (Prefered_RadioControl.length >0)
		{
				var CheckBoxLen=Prefered_RadioControl.length
				for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
				{
						if(Prefered_CheckBoxControl[LOC_Prefered].checked)
						{
							Prefered_TableControl.deleteRow(LOC_Prefered+1)
							LOC_Prefered=LOC_Prefered -1	
						}
				}
		}else
		{
			if(Prefered_CheckBoxControl.checked)
			{
				Prefered_TableControl.deleteRow(1)
			}
		}	
	}catch(exception)
	{
		
	}	
}

//====================================
/*
	JunedM | 20040927 
	Locate mode says that locate will display on code or name
*/
/*	NilayM | #CRF26898 |20060727
	to Focus on Checkbox, Added one more parameter in PreferedlocateValue() function.
*/					
function PreferedlocateValue(LocateObj,Prefered_RadioControl,Prefered_HiddenName,Prefered_CheckBoxControl,LocateMode)
{
	
	var myVal=LocateObj.value
	var LOC_Tr = document.all.tags("tr");
	if(trim(myVal)== "")
	{
		return false;
	}
	var recordTrack=-1;
	try{
		var foundFlag=0;
		for(count=0;count< Prefered_RadioControl.length;count++)
		{
			var LOC_String=Prefered_RadioControl[count].value
			//Vipul CRF#19226 20050910
			//added trim() function.
			LOC_String=trim(LOC_String.toUpperCase())
			if(LOC_String.indexOf(trim(myVal.toUpperCase() ))==0)
			{
				recordTrack = count;	
				foundFlag=1	
				break;	
			}
		}
			if(Prefered_RadioControl.length>0)
			{
				if(foundFlag==1)
				{
					
					if(recordTrack==-1)
					{		
						if (LocateMode=="C")
						{
							Prefered_RadioControl[0].click();
							Prefered_RadioControl[0].checked=false;
						}else
						{
							Prefered_RadioControl[0].click();
						}
						/*	NilayM | CRF#26898 | 20060727
							to focus on Checkbox for Selected Prefered Doctor/Clinic/Test/Diagnosis/Insurance 	
						*/
						try
						{
						Prefered_CheckBoxControl[0].focus();
						}
						catch(exception)
						{
						}
						Prefered_HiddenName[0].focus()
							
					}		
					else	 
					{
						if (LocateMode=="C")
						{
							
							Prefered_RadioControl[recordTrack].click();
							Prefered_RadioControl[recordTrack].checked=false;
							/*Vipul CRF#19226 20050910
							Incase of Cinic User we are having 
							Prefered_RadioControl==>CheckBox and Prefered_HiddenName==>Radio Control.
							Problem : Last line in above else block was raising the exception and focus was 
									  not set to the checkbox. 
						    So Added below line which will set the focus to the checkbox in case of Clinic User
							*/
							Prefered_RadioControl[recordTrack].focus();
						}else
						{
							Prefered_RadioControl[recordTrack].click();
						}
						
						/*	NilayM | CRF#26898 | 20060727
							to focus on Checkbox for Selected Prefered Doctor/Clinic/Test/Diagnosis/Insurance 	
						*/						
						try
						{
						  Prefered_CheckBoxControl[recordTrack].focus();	
						}
						catch(exception)
						{}						
						Prefered_HiddenName[recordTrack].focus()
						
					}
				}
				else
				{
					
				}
			}else
			{
				//document.Form_PreferedInsurance.Radio_InsuranceCode.click();	
				//document.Form_PreferedInsurance.ReadOnly_PreferedInsurance.focus()	
			}
	}catch(exception)
	{
		//Error
	}				
	
	LocateObj.value=""
	return false
		
		
}

 function Check_Uncheck_Process(CheckControl,CheckText,CheckButton,UncheckControl,UncheckText,UncheckButton)
 {
	/*Here try is written twice for precaution base if any control which doesn't exist is pass
	to the function, then we can catch it.
	*/
		try{
			if (UncheckControl.length > 0)
			{
				for (ControlIndex=0;ControlIndex<UncheckControl.length;ControlIndex++)
				{
					UncheckControl[ControlIndex].checked=false
				}	
			}else
			{
				UncheckControl.checked=false
			}		
			UncheckText.disabled=true
			UncheckText.value=""
			UncheckButton.disabled=true
			
		}catch(exception)
		{
			//alert("Error")
			try{
				UncheckControl.checked=false
			}catch(exception)
			{
				//alert("Inner Error")
			}
		}
	
	
	
		try{
			CheckText.disabled=false
			CheckButton.disabled=false
		}
		catch(exception)
		{
			//alert("error1")
		}	

	
 }
 function SelectedColor(iframecontrol, index)
 {
	try{
		var LOC_Font = iframecontrol.all.tags("font");
		for(i = 0; i<LOC_Font.length;i++)
			{
			if(LOC_Font[i].id == "SelectedFont")
			LOC_Font[i].id = "NotSelectedFont";
			}
		LOC_Font[index].id = 'SelectedFont';	
	}catch(exception)
	{
		try{
			LOC_Font[0].id = 'SelectedFont';	
		}catch(exception)
		{
		}
	}
 }
 
 function UnSelectedColor(Control)
 {
	var LOC_Font = Control.all.tags("font");
	for(i = 0; i<LOC_Font.length;i++)
			{
			if(LOC_Font[i].id == "SelectedFont")
			LOC_Font[i].id = "NotSelectedFont";
			}
 }
 
function MakeReadOnlyTextBold(Index, HiddenTestName)
{
	try{
		var LOC_TotalRow=HiddenTestName.length
		if (LOC_TotalRow > 0)
		{
			for(i=0;i<LOC_TotalRow;i++)
			{
				HiddenTestName[i].className="ReadOnlyNotSelected"
			}

			HiddenTestName[Index].className="ReadOnlySelected"
		
		}else
		{
			HiddenTestName.className="ReadOnlySelected"
		}
	}catch(exception)
	{
		try{
			HiddenTestName.className="ReadOnlySelected"
		}
		catch(exception)
		{
		
		}	
	}
} 
//================================CSM===========================================
//This function will added row into the Prefered table.
//IN BELOW FUNCTION, VARIABLES ARE NAME AS PREFERRED, SO DONT BE MISSED GUIDED BY THAT AS THIS FUNCTION
//IS COPIED FROM PREFERRED SECTION
/*NileshT | CRF# 24823 | 20060406
 Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
function AddRowToTable(All_RadioControl, All_CheckBoxControl,All_HiddenName,Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl,Prefered_Mode,All_Qty,All_Notes,Item_Qty,Item_Notes,NoOfItemInserted,Item_Form,PARA_GLO_WEBSERVERURL)
{
	var CheckedInsuranceHTMLString=""
	var XMLStringADD=""
	var CodeFound=0
	var LOC_NoOfSelectedItem=NoOfItemInserted
	try{
		if(All_RadioControl.length>0)
		{
			for(i=0;i< All_RadioControl.length;i++)
			{
				
				if (All_CheckBoxControl[i].checked)
				{
					var LOC_Code=""
					var LOC_Name=""
					var LOC_Qty=""
					var LOC_Notes=""
					
					if (Prefered_Mode=="D") //If preferred doctor.
					{
						/*For preferred doctor, we are showing doctor code first and then name
						and for every other pereferred we are showing name first and then code.
						*/
						LOC_Code=All_HiddenName[i].value
						LOC_Name=All_CheckBoxControl[i].value 
						LOC_Qty=All_Qty[i].value
						All_Qty[i].value=""
						LOC_Notes=All_Notes[i].value
						All_Notes[i].value=""
					}else
					{
						LOC_Code=All_CheckBoxControl[i].value 
						LOC_Name=All_HiddenName[i].value
						LOC_Qty=All_Qty[i].value
						All_Qty[i].value=""
						LOC_Notes=All_Notes[i].value
						All_Notes[i].value=""
					}
					
					CodeFound=0
					//=======================================
					try{
						if (Prefered_RadioControl.length >0)
						{
							//alert(Prefered_RadioControl.length)
							for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
							{
								if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
								{
									//Prefered_CheckBoxControl[LOC_Prefered].checked=true
									/*
										JunedM | 20050217
										Now According to new UI, we are not deleting the duplicate item inserted but instead of that
										we will show message.
									*/
									//ProcessDeleted(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
									//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
									alert(LOC_Code + " already inserted")
									CodeFound=1
									break
								}
								else
								{
									CodeFound=0
								}
							}
						}else
						{
							if(LOC_Code==Prefered_CheckBoxControl.value)
							{
								//Prefered_CheckBoxControl.checked=true
								//ProcessDeleted(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
								//document.Form_PreferedTest.Radio_TestCode.click()
								ShowAlert(LOC_Code + " already inserted")
								CodeFound=1
							}else
							{
								CodeFound=0
							}
						}
					}catch(exception)
					{
						//alert("Exception")
					}
					
					if (CodeFound==0)
					{
						All_CheckBoxControl[i].checked=false
						/*NileshT | CRF# 24823 | 20060406
						Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
						InsertRow(LOC_Name,LOC_Code,Prefered_TableControl,LOC_Qty,LOC_Notes,LOC_NoOfSelectedItem,Item_Form,PARA_GLO_WEBSERVERURL)
						
						LOC_NoOfSelectedItem=LOC_NoOfSelectedItem + 1
						
						/*XMLStringADD=XMLStringADD + "<PROCEDUR>"
						XMLStringADD=XMLStringADD + "<ALPHA>"
						XMLStringADD=XMLStringADD + LOC_TestCode
						XMLStringADD=XMLStringADD + "</ALPHA>"
						XMLStringADD=XMLStringADD + "</PROCEDUR>"*/
					}
					
				}
			}
		}else
		{
				if (All_CheckBoxControl.checked)
				{
					var LOC_Code=""
					var LOC_Name=""
					var LOC_Qty=""
					var LOC_Notes=""
					
					if (Prefered_Mode=="D") //If preferred doctor.
					{
						/*For preferred doctor, we are showing doctor code first and then name
						and for every other pereferred we are showing name first and then code.
						*/
						LOC_Code=All_HiddenName.value
						LOC_Name=All_CheckBoxControl.value 
						LOC_Qty=All_Qty.value
						LOC_Notes=All_Notes.value
					}else
					{
						LOC_Code=All_CheckBoxControl.value 
						LOC_Name=All_HiddenName.value
						LOC_Qty=All_Qty.value
						LOC_Notes=All_Notes.value
					}
					
					CodeFound=0
					//=======================================
					try{
						//alert(3)
						if (Prefered_RadioControl.length >0)
						{

							//alert(Prefered_RadioControl.length)
							for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
							{
								if(LOC_Code==Prefered_CheckBoxControl[LOC_Prefered].value)
								{
									//Prefered_CheckBoxControl[LOC_Prefered].checked=true
									//ProcessDeleted(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
									//document.Form_PreferedTest.Radio_TestCode[LOC_PreferedTest].click()
									ShowAlert(LOC_Code + " already exists as preffered")
									CodeFound=1
									break
								}else
								{
									CodeFound=0
								}
							}
						}else
						{
							//alert(1)
							if(LOC_Code==Prefered_CheckBoxControl.value)
							{
								//Prefered_CheckBoxControl.checked=true
								//ProcessDeleted(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
								//document.Form_PreferedTest.Radio_TestCode.click()
								ShowAlert(LOC_Code + " already exists as preffered")
								CodeFound=1
							}else
							{
								CodeFound=0
							}
						}
					}catch(exception)
					{
						
						
					}
					//alert("6")
					if (CodeFound=="0")
					{
						All_CheckBoxControl.checked=false
						/*NileshT | CRF# 24823 | 20060406
						Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
						InsertRow(LOC_Name,LOC_Code,Prefered_TableControl,LOC_Qty,LOC_Notes,0,Item_Form,PARA_GLO_WEBSERVERURL)
						/*XMLStringADD=XMLStringADD + "<PROCEDUR>"
						XMLStringADD=XMLStringADD + "<ALPHA>"
						XMLStringADD=XMLStringADD + LOC_TestCode
						XMLStringADD=XMLStringADD + "</ALPHA>"
						XMLStringADD=XMLStringADD + "</PROCEDUR>"*/
					}
			}//if checked.
		}
	}catch(exception)//All_RadioControl
	{
		//exceptional
	}	
}	

//=============================================================================
/*NileshT | CRF# 24823 | 20060406
  Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
function InsertRow(Name,Code,Prefered_TableControl,Qty,Notes,InsertRowIndex,Item_Form,PARA_GLO_WEBSERVERURL)
{
		
		var RowRecord=Prefered_TableControl.insertRow(Prefered_TableControl.rows.length);
		var aRows=Prefered_TableControl.rows;
		RowRecord.id="DataTableRow"
		var CurrentRowIndex=""
		RowRecord.attachEvent("onclick", function ()
			{
				var LOC_Tr=Prefered_TableControl.getElementsByTagName("tr") 
					for(i = 0; i<LOC_Tr.length;i++)
						{
						if(LOC_Tr[i].id == "DataTableChangeRow")
						LOC_Tr[i].id = "DataTableRow";
						}
						CurrentRowIndex=RowRecord.rowIndex-1
						RowRecord.id='DataTableChangeRow'
			} )
		var CellRecord=RowRecord.cells;
					
		var CellRecord_CheckBox=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);	
		var CellRecord_Name=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		var CellRecord_Code=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		var CellRecord_RequiredQuantity=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		var CellRecord_Notes=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		var CellRecord_NotesContain=aRows(RowRecord.rowIndex).insertCell(CellRecord.length);
		
		CellRecord_CheckBox.innerHTML="<input type=checkbox name='Checkbox_ItemCode' value='" + Sys_HTMLEncoder(Code) + "' >"
		var NameStr="<p class='DataTableRowMargin'>"
		NameStr=NameStr + "<Input type=text readonly class='ReadOnlyDataTable' name='ReadOnly_PreferedName' value='" + Sys_HTMLEncoder(Name) + "' height='100%'>"
		NameStr=NameStr + "<input type='radio' style='visibility:hidden; height:0px; width:0px' value = '" + Sys_HTMLEncoder(Name) + "' name='Radio_ItemName' onClick='ChangeRowColorForAddedRow(" + RowRecord.rowIndex + ")' ></p>"
		CellRecord_Name.innerHTML=NameStr  
		CellRecord_Code.innerHTML="<p class='DataTableRowMargin'>" + Sys_HTMLEncoder(Code) + "</p>"
		CellRecord_RequiredQuantity.innerHTML="<Input type=text class='TextBox' size=2 value='" + Qty + "'onkeyup='General_CheckNumeric(this)' name='TextBox_Quantity' height='100%'>"
		CellRecord_Notes.innerHTML="&nbsp;<a name='Lnk_Notes' href='' align='right'><img src='../../Icons/notes.gif' Style = 'BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none' width='18' height='17' ></a>"
		CellRecord_NotesContain.innerHTML="<textarea  style='visibility:visible;WIDTH: 0px; HEIGHT: 10px' rows='1' name='Textarea_ItemNote'>" + Notes + "</textarea>"
		CellRecord_Notes.attachEvent("onclick", function ()
			{
				var LOC_CurrentRowIndex=""
				//var Form_Object=document.Form_InsertedItem 
				var WinFeatures="dialogWidth:22;dialogHeight:10;scrolling:0;status=no"
				RowRecord.click()
				LOC_CurrentRowIndex=CurrentRowIndex
				var Table_Rows=Prefered_TableControl.rows.length
				/*NileshT | CRF# 24823 | 20060406
				Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
				showModalDialog(PARA_GLO_WEBSERVERURL + "/Powerweb/code/csm/Requisition_Item_Notes.aspx?Table_Rows=" + Table_Rows + "&rowIndex=" + LOC_CurrentRowIndex,Item_Form,WinFeatures)
				//window.open("/Powerweb/code/csm/Requisition_Item_Notes.aspx?Table_Rows=" + Table_Rows + "&rowIndex=" + rowIndex )
				return false
				
			} )
		
	
}
//This will delete the selected row
function ProcessDeleted(Prefered_RadioControl, Prefered_CheckBoxControl, Prefered_TableControl)
{
	try{
		if (Prefered_RadioControl.length >0)
		{
				var CheckBoxLen=Prefered_RadioControl.length
				for(LOC_Prefered=0;LOC_Prefered<Prefered_RadioControl.length;LOC_Prefered++)
				{
						if(Prefered_CheckBoxControl[LOC_Prefered].checked)
						{
							Prefered_TableControl.deleteRow(LOC_Prefered+1)
							LOC_Prefered=LOC_Prefered -1	
						}
				}
		}else
		{
			if(Prefered_CheckBoxControl.checked)
			{
				Prefered_TableControl.deleteRow(1)
			}
		}	
	}catch(exception)
	{
		
	}	
}

//For replacing specila character for notes
 function General_ReplaceSpecialChar(TextAreaObj)
 {
	var TempValue = ""
	TempValue=TextAreaObj.value; 
			
	do 
	{
		TempValue =TempValue.replace("¤"," ");
	}
		while(TempValue.indexOf("¤") > -1)
		TextAreaObj.value = TempValue
					
				
	do 
	{
		TempValue =TempValue.replace("®"," ");
	}
		while(TempValue.indexOf("®") > -1)
		TextAreaObj.value = TempValue
					
					
			
	do 
	{
		TempValue = TempValue.replace("&","and");
					
	}
		while(TempValue.indexOf("&") > -1)
		TextAreaObj.value = TempValue
					
			
			
	do 
	{
		TempValue = TempValue.replace(">"," ");
					
	}
		while(TempValue.indexOf(">") > -1)
		TextAreaObj.value = TempValue
					
					
					
	do 
	{
		TempValue = TempValue.replace("<"," ");
					
	}
		while(TempValue.indexOf("<") > -1)
		TextAreaObj.value = TempValue
					
		
	do 
	{
		TempValue =TempValue.replace("*"," ");
	}
		while(TempValue.indexOf("*") > -1)
		TextAreaObj.value = TempValue
					
	do 
	{
		TempValue =TempValue.replace("||"," ");
	}
		while(TempValue.indexOf("||") > -1)
		TextAreaObj.value = TempValue
					
					
	do 
	{
		TempValue =TempValue.replace(":"," ");
	}
		while(TempValue.indexOf(":") > -1)
		TextAreaObj.value = TempValue
		
	do 
	{
		TempValue = TempValue.replace("\r\n","~_~");
	}
		while(TempValue.indexOf("\r\n") > -1)
		TextAreaObj.value = TempValue			
	return TextAreaObj.value
}
/*CODER:JUNED
CHECKING VALUE ENTER AS A PRITNER COPIES.
WE WILL CHECK THAT THE ENTER VALUE IS NUMERIC AND IT IS GREATED THAN 0
*/
function General_CheckNumeric(Control)
{
	var Valresultdata=trim(Control.value)
	
	if (isNaN(Valresultdata))
	{
		ShowAlert("Please enter Numeric value");
		Control.value=""
		Control.focus();
		return false;
	}else
	{
		if(Valresultdata < 1 && Valresultdata !="")
		{
			ShowAlert("Please enter value greater than zero");
			Control.value=""
			Control.focus();
			return false;
		}	
	}
}

/*
This function is called on up and down arrow button for preffered items
*/
function MoveRow(TableControl,NewLocation)
{
	var LOC_Tr=TableControl.getElementsByTagName("tr") 
	for(i = 0; i<LOC_Tr.length;i++)
		{
			if(LOC_Tr[i].id == "DataTableChangeRow")
			{
				if ((i-1)!=0)
				{
					TableControl.moveRow(i,NewLocation) 
				}
				break	
			}
		}
}
//KaushikP : 20041021
//Folllowing function Expxnd and collapse Notes
function OpenCloseQuickHelp()
{
	if (TableNotes.style.visibility ==  "hidden" )
	{
		TableNotes.style.visibility =  "visible" 
		TableBottomHelpLink.style.visibility =  "hidden" 
		TableTopHelpLink.style.visibility = "visible" 			
	}
	else
	{
		TableNotes.style.visibility =  "hidden" 
		TableBottomHelpLink.style.visibility =  "visible" 
		TableTopHelpLink.style.visibility = "hidden"
	}
}


//***********************************************************************************************
//   Function added for the imgx control on 20050223 by sunils
//  sunils 20050223 crf# 15962
//***********************************************************************************************
	     	function zoomin(reportstr)
			{
				reportstr.mousetool=5
			}
			
			function zoomout(reportstr)
			{
				reportstr.mousetool = 6
				//top.defaultmain.Bottom.document.form1.imgxocxreport.mousetool = 6
			}
			
			function zoomarea(reportstr)
			{
				reportstr.mousetool = 3
				//top.defaultmain.Bottom.document.form1.imgxocxreport.mousetool = 3
			}
			
			function magnifier(reportstr)
			{
				reportstr.magnifierwidth = 200
				reportstr.magnifierheight = 100
				reportstr.mousetool = 12
				//top.defaultmain.Bottom.document.form1.imgxocxreport.mousetool = 12
			}
			function normal(reportstr)
			{
				reportstr.mousetool = 0
				//top.defaultmain.Bottom.document.form1.imgxocxreport.mousetool = 0
			}
			function Imgxrotate(reportstr)
			{
			  ////  alert ("in the rotate"+ reportstr)
			    reportstr.mousetool = 0
			    reportstr.effects.rotate(90)
			}
			function handtool(reportstr)
			{
			  reportstr.mousetool = 2
			}
		// commented code of scanning on 20050311 by sunils for scanning
			// ADDED FUNCTION FOR THE SCANNER OPTION WITH IMGX
			// SUNILS| 20050310
			//function scanimage(reportstr,scanstr)
		//	{
		//		  alert ('in the image scan'+ scanstr)
		//		  alert ('in the report scan' + reportstr)
		//		  imgxscanner.Acquire,imgxocxreport.hwnd
				  //scanstr.Acquire , reportstr.hwnd
				//ImgXTwain.Acquire , ImgX.hWnd
		//	}
			//function ImgXTwain_ImageAcquired(Image)
		//	{
		//	    ImgX.Images.Replace ImgX.Support.GetImageFromVariant(Image), False
		 //   }

			// addition for the scanner support ends here
			function fittosize(reportstr)
			{ 
    		   // auto zoom should be false for normal dispaly and also the zoom property should be 1 as follows
    			reportstr.autozoom = false
    			reportstr.zoom = 1
    			reportstr.mousetool = 0
    			//top.defaultmain.Bottom.document.form1.imgxocxreport.autozoom = false
				//top.defaultmain.Bottom.document.form1.imgxocxreport.zoom = 1
	    		// for making mouse pointer to be normal 
    			//top.defaultmain.Bottom.document.form1.imgxocxreport.mousetool = 0
			}

			// function added by sunils for crf 15962 ends here on 20050223
			
			/*
				JunedM | 20050223 | CRF#
				This function will install required font into the local system.
				Which font to be installed information will be taken from property file.
			*/
			function InstallFonts(PrintControl,SitePath)
			{
			
			 try{
			   
				var FontPath=SitePath
				////alert ("in the installation fonts")
				//===================Getting font number from Geenral.js====================
				/*JunedM | 20050227
				  FontsTobeInstalled will take the value from property.xml
				*/
				var TotalFont=FontsTobeInstalled()
				PrintControl.FontDownloadCompleteMsg = e_FontDownloadMsg			
				for(NoOfFont=0;NoOfFont < TotalFont; NoOfFont++)
				{
					var FinalFontPath=FontPath + "/" + ArrForFont[NoOfFont]
					//alert(FinalFontPath)
					
					/*
						DevangM | CRF#25840 | 30060513
						Here if the Name is not given for font registry entry then the pare is not passed
					*/
					if (ArrForFontValue[NoOfFont]=='')
					{
						
						PrintControl.AddFontToClient(FinalFontPath, ArrForFont[NoOfFont] , "FONT" +  NoOfFont)
					}
					else
					{
						
						PrintControl.AddFontToClient(FinalFontPath, ArrForFont[NoOfFont] , "FONT" +  NoOfFont,ArrForFontValue[NoOfFont] )
					}
				}
				
			   }
			   catch(exception)
			   {
				  //alert("InstallFonts" + exception)
			   }

			}
			
		
			//If Mode is 1 then it has been called from some page
			//or else it would be called from commonfunction.ascx file
			function GeneralOpenReloginWindow(Mode)
				{
					/*
					JunedM | 20050211
					We will get user id from javascript.
					*/
					CookiesUserIDVal=GeneralgetCookie(e_CookiesUserID_TimeOut) 
					CookiesSessionIDVal=GeneralgetCookie(e_CookiesSessionID_TimeOut) 
					GeneralsetCookie(e_CookiesUserID_TimeOut,"")
					var WinFeatures="dialogWidth:25;dialogHeight:16;scrolling:0;status=no;scroll=no"
					var LOC_WebUserURL=GetWebUserURL()
					var PageName=""
					
					if (LOC_WebUserURL!="")
					{
						PageName=LOC_WebUserURL + "/" + "Login_SessionTimeOut.aspx?UserID_Logout=" + CookiesUserIDVal + "&SessionID_Logout=" + CookiesSessionIDVal
					}
					else
					{
						
					}
					
					showModalDialog(PageName,window,WinFeatures) 		
					
					if (Mode!="1")
					{
						if (window.parent.name=="")
						{
							Font_Message.innerText="Please close this window and try again."
						}
					}
					
					CookiesUserIDVal=GeneralgetCookie(e_CookiesUserID_TimeOut) 
					if (CookiesUserIDVal==null || CookiesUserIDVal=="NULL" || CookiesUserIDVal=="")
					{
						top.window.close()
					}else
					{
						window.location.reload()		
					}
					
					
					try
					{
						top.defaultmain.main.document.body.style.cursor ='default';
					}catch(exception)
					{
										
					}
				}
				
				//This function will return the WEBSERVERURL
				function GetWebUserURL(filepath)
				{
				
					myConfiXmlFile = new ActiveXObject("Microsoft.XMLDOM");				//Creates Object of Microsoft.XMLDOM
					myConfiXmlFile.async = false;		
					var LOC_ConfigFilePath=window.location.protocol + "//" + window.location.hostname + "/configuration.xml"
					LOC_ConfigFileLoaded=myConfiXmlFile.load(LOC_ConfigFilePath)  
					
					if (LOC_ConfigFileLoaded)
					{	
						var myRoot = myConfiXmlFile.documentElement;
						
						var LOC_WebUserURL = myRoot.getElementsByTagName("WEBSERVERURL")
						//alert("LOC_WebUserURL:" + LOC_WebUserURL)
						//alert("LOC_WebUserURL.length:" + LOC_WebUserURL.length)
						if (LOC_WebUserURL.length > 0 )
						{
							var LOC_WebUserURLStr=LOC_WebUserURL.item(0).text
							//alert(LOC_WebUserURLStr)
							return LOC_WebUserURLStr
						}
					}
					return ""
				}
				
		   
			/*
				VipulP CRF#20901 20051029
				When User FirstTime LoggedIn And Search using any 
				Criterial this function will save its setting in the
				cookies and on every page visit we will get the value
				from the cookie and we will set focus to that particualr crieteria
				We will use two functions.    
				For Savingvalues in the coookie--> SaveSearchSettings()
				For Gettingvalues from the cookie --> GetSearchSettings()
			*/	
			//Cookie Name for Patient Search Criteria
			var LOC_PatSearchSeettings="PSearch"
			
			//Save Patient Search Criteria in cookie
			function SaveSearchSettings(LOC_PatName,LOC_PatID,LOC_SSN,LOC_ClinicPatID)
			{
			    try{   
			        
			        var LOC_SearchCookieVal;
			        //Patient Name
			        if (LOC_PatName.value!="")
			        {
			          LOC_SearchCookieVal=1;
			        }
			        //PowerLAB ID
			        else if(LOC_PatID.value!="")
			        {
			          LOC_SearchCookieVal=2;
			        }
			        //SSN
			        else if(LOC_SSN.value!="")
			        {
			          LOC_SearchCookieVal=3;
			        }
			        //Clinic Patient ID
			        else if(LOC_ClinicPatID.value!="")
			        {
			          LOC_SearchCookieVal=4;
			        }
					GeneralsetCookie(LOC_PatSearchSeettings,LOC_SearchCookieVal,true)
				  }
				  catch(exception)	
				  {
				    //alert("SaveSettings: " + exception)
				  }
			}			  	
				
			//Get Patient Search Criteria from cookie	
			function GetSearchSettings(LOC_PatName,LOC_PatID,LOC_SSN,LOC_ClinicPatID)
		    {
		       try{		            
		             var LOC_SearchCookieVal=GeneralgetCookie(LOC_PatSearchSeettings)		            
		             if(LOC_SearchCookieVal!=null)
		             {
		             
		                 switch (LOC_SearchCookieVal)
							{
							    //Patient Name
								case "1" :
										LOC_PatName.focus()
										break;
								//PowerLAB ID												
								case "2" :
										LOC_PatID.focus()
										break;	
								//SSN		
								case "3" :
										LOC_SSN.focus()
										break;
								//Clinic Patient ID		
								case "4" :								        						
										LOC_ClinicPatID.focus()
										break;		
							}	                
		             }else
		             {	
							//If cookies is blank then first field will get the focus.
							LOC_PatName.focus()
		             }
		          }
		          catch(exception)
		          {
		             //alert("SearchSetting: " + exception)
		          }
		     }     
		          
		//JunedM | CRF#21579 | 20051130
		//Below function will return the current time in proper format.
		function GetCurrentTime()
		{
			var LOC_theTime; 
			var LOC_Time;
			var LOC_Hour;
			var LOC_Min;
			var Min;
			LOC_theTime=new Date();	
			Min = LOC_theTime.getMinutes();
			if (Min < 10)
			{
				LOC_Min = "0" + Min;		
			} 
			else
			{
				LOC_Min = Min;
			}		

			if(LOC_theTime.getHours() >= 12)
			{			
				if (LOC_theTime.getHours() != 12) 
				{
					LOC_Hour = LOC_theTime.getHours() - 12;	
				}
				else
				{
					LOC_Hour =LOC_theTime.getHours();				
				}
				
				if(LOC_theTime.getHours() <=21 && LOC_theTime.getHours()!=12)
				{
					LOC_Time = "0" + LOC_Hour + ":" + LOC_Min + " PM"				
				}
				else
				{
					LOC_Time = LOC_Hour + ":" + LOC_Min + " PM"	
				}
							
			}
			else
			{	
						
				if(LOC_theTime.getHours() < 10)
					{	
						if (LOC_theTime.getHours() == 0 )
						{
						LOC_Time = 12 + ":" + LOC_Min + " AM"
						}
						else
						{
						LOC_Time = "0" + LOC_theTime.getHours() + ":" + LOC_Min + " AM"
						}
					}
				else
					{
						LOC_Time = LOC_theTime.getHours() + ":" + LOC_Min + " AM"
					}  	
			}	
			
			return LOC_Time
		}			
		
		
		
		
	/*
	*********************************************************************************
	DevangM | CRF#21277 | 20051212
	The Function formats the given string(for number) as per specified format.
	
	Parameters:
		1)PARA_Format -> The format to which the Given string is to be converted in
						 e.g.: (000) 000-0000
		2)PARA_String -> String to be formatted
	******************************************************************************
	*/
	function FormatNumbers(PARA_Format,PARA_String)
	
	{
	 
		//alert('FormatNumbers\PARA_Format\:'+ PARA_Format )
		//alert('FormatNumbers\PARA_String\:'+PARA_String )
		try
		{
			//alert(PARA_String)
			var LOC_ResultString = new String()
			var LOC_indxFormat = 0
			var LOC_indxParaString = 0
			
			var LOC_FinalStrPointer = 0
			var LOC_Digit
			// Traverse the Format String uptil the end
			for(LOC_indxFormat=0;LOC_indxFormat< PARA_Format.length;LOC_indxFormat++)
			{
				//To store current character of the formatstring being processed
				var LOC_CurrentChar
				//To store the Current Character of the Result string Being processed
				var LOC_ParaStringChar
				//alert(LOC_indxFormat)
				LOC_CurrentChar = PARA_Format.charAt(LOC_indxFormat)
				//alert("LOC_CurrentChar1: " + LOC_CurrentChar + " : " + LOC_indxFormat )
				/*
					if the Parameter string is shorter than the format string and 
					The current charactor of the format string is well passed the length of the
					Parameter string then only separators in the remaining format string are 
					to be appended to the result string.
				*/
				if(LOC_indxParaString < PARA_String.length)
				{ 
					LOC_ParaStringChar = PARA_String.charAt(LOC_indxParaString)
				}
				else
				{
					LOC_ParaStringChar = ''
				}
				/*
					if the current formatstring charactor is a digit then append the current
					charactor of the parameter string to the Result string
					
					else if the current Format string character is a separator and the current formatstring 
					character is not separator then after appending the current character of the Format string
					append the Current charactor of the Parameter string.  
				*/
				//alert("LOC_CurrentChar2: " + LOC_CurrentChar + " : " + LOC_indxFormat )
				if (LOC_CurrentChar == '0')
				{
					//alert("LOC_CurrentChar2: " + LOC_CurrentChar + " : " + LOC_indxFormat )
					if(LOC_indxParaString < PARA_String.length)
					{
						//alert(LOC_ParaStringChar)
						//alert(LOC_CurrentChar)
						LOC_ResultString = LOC_ResultString + LOC_ParaStringChar
						LOC_indxParaString = LOC_indxParaString + 1
					}
				}
				else
				{
					
					LOC_ResultString = LOC_ResultString + LOC_CurrentChar
					
					if(LOC_indxParaString < PARA_String.length )
					{
						
						if (LOC_ParaStringChar.match(/^\d$/)==null)
						{
							
							if(LOC_ParaStringChar != LOC_CurrentChar)
							{
								
								LOC_ResultString = LOC_ResultString + LOC_ParaStringChar
								
							}
							LOC_indxParaString = LOC_indxParaString + 1
						}
						
					}
				}
			}
			//if(LOC_indxFormat <  PARA_String.length
			//The Parameter string is longer than the Format string 
			//Then append the remaining characters in the Result string
			for(;LOC_indxParaString <  PARA_String.length;LOC_indxParaString++)
			{
				
				LOC_ResultString = LOC_ResultString + PARA_String.charAt(LOC_indxParaString)
			}
			//alert(LOC_ResultString)
			return(LOC_ResultString)
		
		}
		catch(exception)
		{
			//alert(exception)
			return('-1')
		}
	}	
	
	
	/*
	*****************************************************************************************************
	DevangM | CRF#21277 | 20051212
	The Function Validates the value of given Control with the given format
	
	Parameters:
		1)PARA_Control -> Control to be validated.
		2)PARA_RegularExpression -> Regular expression that validates the control as per the given format
		3)PARA_Format            -> The format to which the Given string is to be converted in
									e.g.: (000) 000-0000
		4)PARA_BlankFlag         -> Gives 'B' if the Blank flag is included in the PowerLAB Format 
		5)PARA_ErrorMsg          -> Error message to dislay when the Validation Fails  
	******************************************************************************************************
	*/
	function ValidateControls(PARA_Control,PARA_RegularExpression,PARA_Format,PARA_BlankFlag,PARA_ErrorMsg)
	{
	
		
		try
		{		
			
			var LOC_FormatString
			/*
				If the Format String is blank then the format is for string. In this case we
				Just Validate it with the regular expression
			*/
			
			if (PARA_Format=='')
			{
				//alert('Here')
				LOC_FormatString = PARA_Control.value
			}
			else
			{
			
				//If the Value is blank and blank flag is on then return the ZeroFormat string
				//B character indicates that if text is blank then it has to be left as blank or we have to 
				//replace with zero string for.e.g. 0000-000-00 according to the format. 
				if (PARA_Control.value=='')
				{
					if (PARA_BlankFlag =='B')
					{
						return true;
					}
					else
					{
						PARA_Control.value = PARA_Format;
						return true;
					}
				}
			}
			
			//Format the parameter string according to the given format.
			//FormatNumbers function will convert the entered value in given format.
			var LOC_FormatString = new String(FormatNumbers(PARA_Format,PARA_Control.value));
			PARA_Control.value = LOC_FormatString
			//alert('LOC_FormatString: ' + LOC_FormatString)
			if(LOC_FormatString.match(PARA_RegularExpression))
			{
				
				return(true);
			}
			else
			{
				
				//Show the alert invalid Message
				/***************************************************************************** 
					DevangM | CRF#23447 | 20060221
					The code bellow is modified to display proper message for Format Violation 
					for format @S
				******************************************************************************
				*/
				if(PARA_Format == '')
				{
					// The @S format is there
					
					
					var LOC_arr = PARA_RegularExpression.source.split(',')
					var LOC_Element = LOC_arr[LOC_arr.length-1]
					//var LOC_ErrMessage = 'Please specify maximum ' + LOC_Element.substring(0,LOC_Element.length-2) + ' characters.'
					ShowAlert(PARA_ErrorMsg + ' Specify maximum ' + LOC_Element.substring(0,LOC_Element.length-2) + ' characters.')
					//alert(LOC_ErrMessage)
				}
				else
				{
					ShowAlert(PARA_ErrorMsg);
				}
				//**************************************************************************
				//Set the Focus
				
				PARA_Control.className='GotFocus'
				PARA_Control.focus();
				return(false);
			}
		
		}
		catch(exception)
		{
		 //alert('validate error')
		}
	}
	
	/*
	  VipulP | CRF#22265 | 20051227
	  This will open the dialogue box with information reagarding clinic patient ID
	  on click event of information icon.
	*/
	function OpenClinicPatIDDialog(PARA_GLO_WEBSERVERURL)                                             
	{
	  try{
			var WinFeatures="top:100;left:100;dialogWidth:15;dialogHeight:10;scrolling:0;status=no"
			/*NileshT | CRF# 24823 | 20060406
			Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
			showModelessDialog(PARA_GLO_WEBSERVERURL + "/Powerweb/ClinicPatIDInfo.htm",window,WinFeatures);
		 }
	  catch(exception)
	     {
	     }	
	}
	
	/*
	  VipulP | CRF#23413 | 20060211
	  Below function will return true if the textbox contains only
	  single character
	  Used From --> NewOrder/Quick Order Patient Search
				--> AllPatient/Active Patient 
				--> Standing Order
	*/
	var PatientSearchMessage="Please specify minimum two characters for patient name search"
	function Allow_PatientSearchByName(Obj_TextBox)
	{
	  try
	  {
	    var LOC_Value=trimX(Obj_TextBox.value)
		if (LOC_Value.length == 1)
		   {
		     Obj_TextBox.value=LOC_Value
		     return false
		   }
		else
		   {
		      return true
		   }   
	  }
	  catch(exception)
	  {
	  }
	}    
	
	/*
	  VipulP | CRF#23413 | 20060211
	  This will open the dialogue box with information reagarding patient search.
	  on click event of information icon.
	*/
	
	function OpenPatSearchInfo(PARA_GLO_WEBSERVERURL)                                             
	{
	  try{
			var WinFeatures="top:100;left:100;dialogWidth:15;dialogHeight:11;scrolling:0;status=no"
			/*NileshT | CRF# 24823 | 20060406
			Added GLO_WEBSERVERURL variable in URL so that PowerWEB can als work with virtual directory */
			showModelessDialog(PARA_GLO_WEBSERVERURL + "/Powerweb/PatientSearchInfo.htm",window,WinFeatures);
		 }
	  catch(exception)
	     {
	     }	
	}
	
	/*
	  VipulP | CRF#23097 |20060215
	  This function will check the <VALIDATE_INSURANCE> tag in Property.xml
	  and if it found as 1 then , PowerWEB will not make it Optional.
	*/
	
	function SetInsuranceOptional()
	{
	
	  try{
	       	var LOC_ValidateIns=0;		
			if (XMLForCustomizeAns)
			{
				var myRoot = myXmlFile.documentElement;				
				try
				{
					var LOC_ValidateInsTag = myRoot.getElementsByTagName("VALIDATE_INSURANCE")						
					LOC_ValidateIns=LOC_ValidateInsTag.item(0).text										
				}
				catch(exception)
				{ 
					LOC_ValidateIns= 0;	  				
					return LOC_ValidateIns	         
				}
			}
			return LOC_ValidateIns;
	     }
	     catch(exception)
	     {
	     
	     }
	
	}

	
		/*
		    VipulP | CRF#23097 | 20060216
		    Hiding/Displaying the * sign for Insurance when it is not mandatory
		*/		
		function SetMandatorySign(Para_Obj_Font)
		{
		  try
		     {
					var LOC_ValidateInsJS = SetInsuranceOptional()			
		            var Obj_Font = Para_Obj_Font
					if (LOC_ValidateInsJS==1)
						{
						  Obj_Font.innerText=""
						}
					else
						{
						  Obj_Font.innerText="*"
						}
						
			}
			catch(exception)	
			{
			}		
		}
		
		
		/*
			DevangM | CRF#23191 | 20060217
			This Procedure is there to check if the Time Textbox is not empty then 
			The Date Text box should not be empty
		*/
		
		function CheckEmptyTimeDate(PARA_Date,PARA_Time)
		{
			//Check if the Time field is empty
			
			try
			{
				if (PARA_Time.value != '')
				{
					//alert('timetrue')
					//If the Date field is empty then return true
					if(PARA_Date.value == '')
					{
						
						return(true)
					}
				}
				//Means the required conditions are not specified
				return(false)
			}catch(exception)
			{
				//alert('Error in script')
			}
		}
		
		
		
		
	/*================================Customize messages===========================================*/
		/*
    		VipulP CRF#23748 20060626
    		Below functions are defined for enabling facility of showin Customize Alert Messages
		*/


		/*
			This function Displays the Alert()
			It will search in Property.xml for finding the matching string passed in the parameter
			if it found , customized message will be displayed in the alert to the user.    
		*/	 
           
		   function ShowAlert(Para_MSG,Para_ProcessFlag) 
		  	 {		  	
		  			try
		  			{  
		  						ProcessCustomizeMessages(Para_MSG,"0",Para_ProcessFlag)
		  			}
		  			catch(exception)
		  			{
				  	   
		  			}
			  	
		  		}
	
			/*
				This function Search in the property.xml and if it found the matched string it will
				replace the string with customized string.
			*/	  	
				  	
		  	function ReplacePropertyString(Para_MSG,Para_ProcessFlag)
		  	{
		  		try
		  		{
		  			return ProcessCustomizeMessages(Para_MSG,"1",Para_ProcessFlag)
		  		}
		  		catch(exception)
		  		{
		  		}
		   	}


			/*
				This function will return process the propert.xml file and returns
				CustomizeMessageAlert/CustomizeMessgeString
			    
				Para_MSG--> Message to be search in the Property.xml
				Para_ReplaceStringFlag --> 1-> Do not display the alert but replace the String from found in property.xml
																0-> Diplay the alert.	         
				Para_ProcessFlag --> Incase do not need to check for Customize message routing pass value of this parameter as "NoCheck"											  
													so that it will no further process and check the routine of customize message.
			*/
	    	
	    	function ProcessCustomizeMessages(Para_MSG,Para_ReplaceStringFlag,Para_ProcessFlag)
			{
				try{	
					
						/*
								If the Passed Last Parameter's value is "NoCheck" then do not process for the Property.xml	
								and returns/displays original alert/string
						*/
						if (Para_ProcessFlag==e_NoCheck)
						   {
								//Return the original string or Display original message.
								if (Para_ReplaceStringFlag == "1")
								  {
								    return  Para_MSG;
								  }
								  else
								  {
										alert(Para_MSG);
								  }
						     
						     return true
						   }
						   
						//Check If Property.XML loaded properly or not
						if (XMLForCustomizeAns)
						{
						  
							var myRoot = myXmlFile.documentElement;	
							var LOC_CustomizeMsgTagName="MSG_CUSTOMIZE"			
							var LOC_CustomizeMsgTag = myRoot.getElementsByTagName(LOC_CustomizeMsgTagName)
							var LOC_CustomizeMsgChildNodeTag=myRoot.getElementsByTagName(LOC_CustomizeMsgTagName).item(0).childNodes
							
							var Index=0;
							var LOC_MatchFound=1
							//Loop through the MSG_CUTOMIZE node for each item.
							for (Index=0;Index < LOC_CustomizeMsgChildNodeTag.length; Index ++)
								{
										var LOC_CustomizeMsg= LOC_CustomizeMsgChildNodeTag.item(Index)										
										//Check the name of attribute in which Original String Message has written.
										if (LOC_CustomizeMsg.attributes(0).name=="OriginalMsg")
											{
												//alert(LOC_CustomizeMsg.attributes(0).value.toUpperCase() + "==" + Para_MSG.toUpperCase())												
												//Check If Original String Passed and Written String in attribute matches or not							
												if (trimX(LOC_CustomizeMsg.attributes(0).value.toUpperCase())==trimX(Para_MSG.toUpperCase()))
												{
												
												  //IF Match found then Display/Return Customize String.
												  if (Para_ReplaceStringFlag=="1")
												     {
												       return LOC_CustomizeMsg.text
												     }
												  else
												     {   
														alert(LOC_CustomizeMsg.text)					    
														return true
													  }	
											 }
											else
												{
												   //If Matching String not found then Update this variable each time.
													LOC_MatchFound = 0	      
												}
											}		
								}
								/*
								  IF this variable's value is 1 that means no Matching string is found so we need to return/Display
								  Original Passed string.
								 */ 
														 
								if (LOC_MatchFound==0)    
								{
								 if (Para_ReplaceStringFlag=="1")
									 {
									       return Para_MSG
									 }
								  else
								     {	 
											alert(Para_MSG)
									 }		
								}
						
						}
						else //IF Property.xml would not able to load properly then below routing will be exectute
					    {
					        //Return/Display  the original Message String.
					        if (Para_ReplaceStringFlag=="1")
									 {
									      //alert( Para_MSG)
									       return Para_MSG
									 }
								  else
								     {	 
											//alert("FileNotAbleToLoad(replacestring) : " + Para_MSG)
											alert(Para_MSG)
									 }
					      
					    }
						
				  }
				catch(exception) //If in any case error occurs, system will display/return original message 	    
					{					    
					    if (Para_ReplaceStringFlag=="1")
					    {					    
					      //alert("Exception : " + Para_MSG)						
					      return Para_MSG
					    }
					    else
					    {
							alert(Para_MSG)						
					    }
					    
				  }
		  	}	
		  	
		/*==================End of Custimize SHOWMessages=======================*/

		/*NileshT | CRF#24823 | 20060705
		  Added this function to get the path for Home, OurMission, Company Profile
		  and News page on Default.aspx */
		function GetCurrentPath()
		{
		  try{
		  
					var LOC_FullPath = new Array();
					//Get whole URL Path from virtual directory (e.g. /pweb/powerweb/IntroductionSysware.htm)
					var VirtualDir = window.location.pathname		 			
					/* Split the path from / and store it in array (e.g. LOC_FullPath[0],
					LOC_FullPath[1],LOC_FullPath[2])
					LOC_FullPath[0] = ""
					LOC_FullPath[1] = "pweb"
					LOC_FullPath[2] = "powerweb"
					LOC_FullPath[3] = "IntroductionSysware.htm"
					*/
					LOC_FullPath = VirtualDir.split('/');	
										
					/* If there is Virtual Directory configured for PowerWEB then 
					length of LOC_FullPath array will be more than 3 so append virtual
					directory in CurrentPath otherwise not */
					if (LOC_FullPath.length > 4)
					{		
						var LOC_CurrentPath = "/" + LOC_FullPath[1]+ "/powerweb/HomePages/introduction.htm"
						var Path = window.location.protocol + "//" + window.location.hostname + "/" + LOC_FullPath[1] + "/powerweb/HomePages/"		 		 		 
						
					}
					else
					{		
						var LOC_CurrentPath = "/powerweb/HomePages/introduction.htm"
						var Path = window.location.protocol + "//" + window.location.hostname + "/powerweb/HomePages/"		 		 		 
						
					}
					LOC_FullPath[0]= Path;
					LOC_FullPath[1]= LOC_CurrentPath 
					
					return LOC_FullPath;
				}
				catch(exception)	
				{
				}
		}
		
		/*
			VipulP | CRF#25111 | 20060808
			General Functions Related to Display/Print Reports
		*/
		
	/*#################  Start General Functions for Report Display#######################################*/
		/*
		   
		   Called From :  SaveAllFile function which will be call when report is saved.
		   Purpose :	This is the general function which displays the saved report filename with link
		   Paratmeters -- Status->Name of the file 
									Para_msgdivobj --> DIV Object in which Message will be displayed				  	 
								    Para_FullScreenFlag --> Flag fullscreen or not based on which  HTML of DIV Object will be build.
		*/							
		function setMsg(status,Para_msgdivobj,Para_FullScreenflag)
			{
			  try
			  {			    
				var filename=status
				var test=filename
				do 
				{
					test =test.replace(" ","%20");
				}				
				while(test.indexOf(" ") > -1)
					filename = test
				if (status=='')
				{			
						Para_msgdivobj.style.visibility="hidden"
				}				
				else
				{
					if (Para_FullScreenflag==e_FullScreenNo)
					{					
						Para_msgdivobj.style.visibility="visible"
						Para_msgdivobj.innerHTML="<TABLE border=0 cellPadding=3 cellSpacing=0 width=100% valign='top'><TR width=100%><TD width='14%' valign=top><FONT size=2><STRONG>Report saved at:</STRONG></FONT></TD>" + 
						"<TD class='StatusMsg'><a  href='NONE' onclick='return OpenFile(filename.value)'>" + status  + "</a>" + 
						"</TD></TR></TABLE><INPUT type=hidden name=filename value='" + filename + "'>"											
					}	
					else
					{
						Para_msgdivobj.style.visibility="visible"
						Para_msgdivobj.innerHTML="<TABLE border=0 cellPadding=3 cellSpacing=0 width=100% valign='top'><TR width=100%><TD width='14%' valign=top><FONT size=2><STRONG>Report saved at:</STRONG></FONT></TD>" + 
						"<TD class='StatusMsg'><a  href='NONE' onclick='return OpenFile(filename.value)'>" + status  + "</a>" + 
						"</TD></TR></TABLE><INPUT type=hidden name=filename value='" + filename + "'>"
					}
				}
			 }
			 catch(exception)	
			 {
			    //alert(exception)
			 }
			}
			
			//==========================Start OpenFile()======================
			/*
			  CalledFrom: Onclick of the Saved Repor file link 
			  Purpose     :  open the file of the Saved Report
			  Parameters : Para_FileName : Name of the Report file to be open
			  window.RequisitionResults_Functions.filename.value
			*/
			function OpenFile(Para_FileName)
			{
			  try
			    {
				var LOC_Filename= Para_FileName 
				do 
				{
					LOC_Filename =LOC_Filename.replace("%20"," ");
				}
				while(LOC_Filename.indexOf("%20") > -1)
				Para_FileName = LOC_Filename
				//ShowAlert(window.RequisitionResults_Functions.filename.value)
				try{
					window.open (Para_FileName)
				   }
				catch(exception)
				   {
					ShowAlert(e_Message_SaveError)
			       }   	
				return false
				}
				catch(exception)
				{}
			}
			//==========================End OpenFile()======================	
			
			//==========================Start ChangeLinkColor())=====================
				/*
				Called From : 1. OnClick of report page numbers.
				Purpose : To change link of currently selected page number to red.
				It changes the color of currently selected number to red and all other to blue.	
				Description : It accepts clicked page number object as parameter and changes its id to change its color.		  
			*/
			
			function ChangeLinkColor(currentlink)
			{
				try
				{
				var LOC_Tr = document.all.tags("a");
				for(i = 0; i<LOC_Tr.length;i++)
				{	
					if(LOC_Tr[i].id == "ChangeLinkColor")
					LOC_Tr[i].id = "DefaultLinkColor";
				}
				currentlink.id = 'ChangeLinkColor';	
				}
				catch(exception)
				{}
			}			
			
			//==========================End ChangeLinkColor()=====================
		
		
		//=====================================Start ChangeLinkColorButtonPress()========================
		/***********************************************************
			CRF 5298 AJAYB 20030412
			Add PREV and NEXT button to navigate between result pages
		************************************************************/
		function ChangeLinkColorOnButtonPress(TagNumber)
		{
			try
			{
			var LOC_Tr = document.all.tags("a");
						
			var j = 0;
			for(i = 0; i<LOC_Tr.length;i++)
			{
				if (LOC_Tr[i].id == 'ChangeLinkColor' || LOC_Tr[i].id == 'DefaultLinkColor')
				{
				
					if(eval(j) == eval(TagNumber))
					{
						LOC_Tr[i].id = 'ChangeLinkColor';
					}
					else
					{
						LOC_Tr[i].id = 'DefaultLinkColor';	
					}
					j=j+1;
					
				}
				
			}
			}
			catch(exception)
			{}
		}				
		//====================================End ChangeLinkColorButtonPress()============================
		
		//=========================Start fixDate()======================
			/*
			Purpose:To set the value to cookie
			Coder : Juned
			*/
			function fixDate(date) 
			{
			  try
			   {
				var base = new Date(0);
				var skew = base.getTime();
				if (skew > 0)
					date.setTime(date.getTime() - skew);
			  }
			  catch(exception)		
			  {}
			}
			//=========================End fixDate()======================
			
			//=========================Start setCookie()======================
			function setCookie(name,fullscreen,ObjRptControl) 
			{
			  try
			    {
				var now = new Date();
		
				fixDate(now);
				now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
				var expires = now;
				var curCookie
				if (fullscreen=="YES")
				{
					curCookie = name + "=" + escape(ObjRptControl.IniDirPath) +
					((expires) ? "; expires=" + expires.toGMTString() : ""); 
				}
				else
				{
					curCookie = name + "=" + escape(ObjRptControl.IniDirPath) +
					((expires) ? "; expires=" + expires.toGMTString() : ""); 
				}
				//ShowAlert(curCookie)
				document.cookie = curCookie;
				}
				catch(exception)
				{}
			}
			//=========================End setCookie()======================
			
			//=========================Start getCookie()======================
			/*
				Purpose:To get the cookie value
				Coder : Juned.
			*/			
			function getCookie(name) 
			{
			  try
			   {
				var LOC_dc = document.cookie;
				var prefix = name + "=";2
				var begin = LOC_dc.indexOf("; " + prefix);
			  
				if (begin == -1)
				{   
					begin = LOC_dc.indexOf(prefix);
		  
					if (begin != 0) return null;
		    
				} 
				else
					begin += 2;
				var end = document.cookie.indexOf(";", begin);
		  
				if (end == -1)
					end = LOC_dc.length;
				return unescape(LOC_dc.substring(begin + prefix.length, end));
			  }
			  catch(exception)
			  {}
			}
			//=========================End getCookie())======================
		
	/*###############################End General Functions for Report Display##########################################	*/
	
	
 		
		
