var objZipCode;
var objStateDDL;
var objCity ;
var objCounty;
var objCountry; 
var objhidStateID ; 
var ExcludeState ; 

var vAryZipCode = new Array();
var vAryStateDDL = new Array();
var vAryCity = new Array();
var vhidStateID = new Array();
//var vAryZipCode = new Array();
var vDefState='US';
var intMaxSearchRow=5;			// Variable to provide max. no of search in multi search control
var strFieldText;				// Array Variable to fill search option Field Text	
var strFieldValue;				// Array Variable to fill search option Field Value	
var strSearchOptions;			// Array Variable to fill search option as text/value pair
var	strOptionsDDLBName;			// Array Variable to fill search List DDLBName	


		
function CountrywiseStateFill(vddlCountry, vState, vHdnState,vStateValue)
//function CountrywiseStateFill(vddlCountry, vState)
{		
	
	if (vddlCountry == null || vState == null  )
	{
		alert('Supplied argument contains null object,Country State cannot proceed.');
		return; 		
	}				
		
	if ( vddlCountry.value != '') 
	{	 
		var response;
		if (vStateValue != '' )
			response = CommonWebUtility.LoadStateSelected(vddlCountry.value,vStateValue)		
		else
			response = CommonWebUtility.LoadState(vddlCountry.value)		
		if (response.error != null)
		{					
			alert(response.error);
			vddlCountry.focus();	
			return;
		}
		var states = response.value;  		
		if (states == null || typeof(states) != "object")
		{
			vState.selectedIndex = 0 ;		
			return;  
		}
		else
		{				
			ClearDropDown(vState); 			 			
			if ( states.Rows.length == 0 ) 
			{
				alert('Invalid Country. (' + vddlCountry.value + ')'); 
				vddlCountry.focus();
				vddlCountry.selectedIndex =0 ;				
				vState.selectedIndex = 0 ; 												
			}
			else
			{	
				for (i=0;i<states.Rows.length ;i++)					
				{	
					var v = new Option(states.Rows[i].State, states.Rows[i].abbreviation); 
					vState.options[vState.options.length]= v; 
				}					
			} 			
		}		 
	}
}


function ClearDropDown(ddl)
{
	for ( var i = ddl.options.length-1; i >= 0 ; i-- )
	{
		ddl.options[i]=null;
	}
}

function CountrywiseState(vddlCountry, vState, vCity, vhdnState, vZipCode, vbtnZipSearch)
{		
	if (vZipCode.value == '')
	{
		vState.selectedIndex = 0 ; 	
		vCity.value = '' ;
		vhdnState.value ='';
		vZipCode.value ='';
	}
	
	if ( vddlCountry == null || vState == null ||  vCity == null || vbtnZipSearch == null )
	{
		alert('Supplied arguement contains null object,Country State cannot proceed.');
		return; 		
	}				
		
	if ( vddlCountry.value != '') 
	{	 
		var response;		
		response = CommonWebUtility.LoadState(vddlCountry.value)		
		if (response.error != null)
		{					
			alert(response.error);
			vddlCountry.focus();	
			return;
		}
		var states = response.value;  		
		if (states == null || typeof(states) != "object")
		{
			vState.selectedIndex = 0 ;		
			return;  
		}
		else
		{				
			ClearDropDown(vState); 			 			
			if ( states.Rows.length == 0 ) 
			{
				alert('Invalid Country. (' + vddlCountry.value + ')'); 
				vddlCountry.focus();
				vddlCountry.selectedIndex =0 ;				
				//vState.selectedIndex = 0 ; 	
				//vCity.value = '' ;
				vhdnState.value ='';
			}
			else
			{	
				for (i=0;i<states.Rows.length ;i++)					
				{	
					var v = new Option(states.Rows[i].State, states.Rows[i].abbreviation);
					 
					vState.options[vState.options.length]= v; 
				}
				vState.disabled= false ;				
			} 			
		}		 
	}
	if ( vddlCountry.value != vDefState) 
	{
		vState.disabled=false ;
		vCity.readOnly=false;	
		vCity.BackColor = "white";
		vbtnZipSearch.style.display = "none";				
		vCity.style.backgroundColor="white";						
	}
	else
	{
		vState.disabled= true ;
		vCity.readOnly= true ;	
		vbtnZipSearch.style.display = "";
		vCity.style.backgroundColor="silver";								
	}	
	vZipCode.focus();	 	
}


function ValidateReferralId(vLOName)
{	
	if ( vLOName == null )
	{
		alert('Supplied arguement contains null object,Valid ReferID cannot proceed.');
		return; 		
	}
	if ( vLOName.value != '') 
	{	
		var response;
		response = CommonWebUtility.ValidateReferralId(vLOName.value);		
		if (response.error != null)
		{					
			alert(response.error);
			vLOName.focus();	
			return;
		}  		  	
			
		var ValidRefID = response.value;
		  
		if ( ValidRefID == '0' ) 
		{
				alert('Please Enter Correct Member ID '); 
				vLOName.focus();
				vLOName.value ='';		
		}
	}
}
	

function CheckDuplicatObject(vZipCode, vState, vCity, vHidStateId)
{
	var vReturn = false; 	
}

function SetObjects ( zip , ddlstate, city  , hidStateID ) 
{
	objZipCode = zip ; 
	objStateDDL = ddlstate ;
	objCity  = city; 
	objhidStateID  = hidStateID ; 
	
}

function SearchZipCode_Ver1()
{
 
	if ( objZipCode.value == '') 
	{	 
		objStateDDL.selectedIndex = 0 ; 
		objCity.value = '';
		objhidStateID.value = ''; 						
	}
	else
	{
	   var dt;
	   dt =	CommonWebUtility.FindCityStateByZipCode( objZipCode.value  );                           
	   alert(dt); 	   
	}
}

function SearchZipCode()
{
	
	if ( objZipCode.value == '') 
	{	 
		objStateDDL.selectedIndex = 0 ; 
		objCity.value = '';
		objhidStateID.value = ''; 						
	}
	else
	{
		CommonWebUtility.FindCityStateByZipCode( objZipCode.value , FindZipCode_CallBack);
		var result;
		result = CommonWebUtility.FindCityStateByZipCode( objZipCode.value  );
		//alert(result);
		//alert(result.value.Rows[0].City) ; 
		alert(result.value.Rows[0].City);
	}
}
function SearchZipCodeWithCountry(vZipCode, vState, vStateHid, vCity, vddlCountry ,vMode,vhdnZip)
{	
	
	if (vddlCountry.value != vDefState)
	{	
		if (vZipCode.value.length < 6 && vZipCode.value.length > 0 )
		{
			alert(' Invalid Zip Code !! ');
			vZipCode.focus();
		}
		else
		{
			vCity.focus();
		}
		return false;
	}
	
	if ( vZipCode == null ||  vState == null  || vStateHid == null ||  vCity == null)
	{
		alert('Supplied arguement contains null object, Zipcode search cannot proceed.');
		return; 		
	}	
	if (vZipCode.value.length > 5 )
	{
		alert('Invalid zipcode Value. (' + vZipCode.value + ')'); 
		vZipCode.focus();
		vZipCode.value ='';
		vState.selectedIndex = 0 ; 
		vCity.value = '';
		//vStateHid.value = ''; 
		return false;
	}
	if ( vZipCode.value == '') 
	{	 
		vState.selectedIndex = 0 ; 
		vCity.value = '';
		//vStateHid.value = ''; 						
	}
	else
	{	
		var response;
		
		if (vMode == '' || vMode!='')
		{
			response = CommonWebUtility.FindCityStateByZipCodeForAll(vZipCode.value,vMode);		
		}
		else
		{
			response = CommonWebUtility.FindCityStateByZipCode(vZipCode.value);		
		}
		if (response.error != null)
		{   
			vState.selectedIndex = 0 ; 
			//vCity.value = '';
			//vStateHid.value = ''; 
			alert(response.error); //we should probably do better than this
			return;
		}  
		if (response.value == "")
		{   
			//vState.selectedIndex = 0 ; 
			//vCity.value = '';
			//vStateHid.value = ''; 
			alert(response.error); //we should probably do better than this
			return;
		}  	
			
		var states = response.value;  
		//if the response wasn't what we expected  
		if (states == null || typeof(states) != "object")
		{
			vState.selectedIndex = 0 ; 
			//vCity.value = '';
			//vStateHid.value = ''; 
			return;  
		}else
		{
			
			if ( states.Rows.length == 0 ) 
			{
				alert('Invalid zipcode Value. (' + vZipCode.value + ')'); 
				if (vhdnZip)
				{
					vZipCode.value =vhdnZip.value ;
					//vZipCode.value ='';
					//vState.selectedIndex = 0 ; 
					//vCity.value = '';
					//vStateHid.value = ''; 
				}
				vZipCode.focus();				
			}
			else
			{
				vCity.value= states.Rows[0].City ; 				
				SetDropDownForValue(vState, states.Rows[0].State ) ;
				vStateHid.value =  states.Rows[0].State ;
				vState.Enabled = false ; 
			}
			
		}
		 
	}
}
function SearchZipCodeWithControls(vZipCode, vState, vStateHid, vCity )
{	
		
	if ( vZipCode == null ||  vState == null  || vStateHid == null ||  vCity == null)
	{
		alert('Supplied arguement contains null object, Zipcode search cannot proceed.');
		return; 		
	}	
	
	if ( vZipCode.value == '') 
	{	 
		vState.selectedIndex = 0 ; 
		vCity.value = '';
		vStateHid.value = ''; 						
	}
	else
	{	
		var response;
		//response = CommonWebUtility.FindCityStateByZipCode(vZipCode.value);		
		response = CommonWebUtility.FindCityStateByZipCodeForAll(vZipCode.value,'');	
		if (response.error != null)
		{   
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			alert(response.error); //we should probably do better than this
			return;
		}  
		if (response.value == "")
		{   
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			alert(response.error); //we should probably do better than this
			return;
		}  	
			
		var states = response.value;  
		//if the response wasn't what we expected  
		if (states == null || typeof(states) != "object")
		{
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			return;  
		}else
		{
			
			if ( states.Rows.length == 0 ) 
			{
				alert('Invalid zipcode Value. (' + vZipCode.value + ')'); 
				vZipCode.focus();
				vZipCode.value ='';
				vState.selectedIndex = 0 ; 
				vCity.value = '';
				vStateHid.value = ''; 
			}
			else
			{
				vCity.value= states.Rows[0].City ; 				
				SetDropDownForValue(vState, states.Rows[0].State ) ;
				vStateHid.value =  states.Rows[0].State ;
				vState.Enabled = false ; 
			}
			
		}
		 
	}
}
function SearchZipCodeCountyWithControls(vZipCode, vState, vStateHid, vCity,vCounty,vdllCountry,vMode)
{
	if ( vZipCode == null ||  vState == null  || vStateHid == null ||  vCity == null ||  vCounty == null)
	{
		alert('Supplied arguement contains null object, Zipcode search cannot proceed.');
		return; 				
	}	
	
	if (vdllCountry != vDefState)
	{
		
		if (vZipCode.value.length < 6 && vZipCode.value.length > 0 )		{
			
			alert(' Invalid Zip Code !!!! ');
			vZipCode.focus();
		}
		else
		{
			vCity.focus();
		}
		return false;
	}	
	if (vZipCode.value.length > 5 )
	{
		alert('Invalid zipcode Value. (' + vZipCode.value + ')'); 
		vZipCode.focus();
		vZipCode.value ='';
		vState.selectedIndex = 0 ; 
		vCity.value = '';
		vStateHid.value = ''; 
		vCounty.value='';
		return false;
	}
	
	if ( vZipCode.value == '') 
	{	 
		vState.selectedIndex = 0 ; 
		vCity.value = '';
		vStateHid.value = ''; 						
		vCounty.value ='';
	}
	else
	{	
		var response;		
		/*if (vMode == '')
		{
			response = CommonWebUtility.FindCityStateByZipCodeForAll(vZipCode.value,'');		
		}
		else
		{
			response = CommonWebUtility.FindCityStateByZipCode(vZipCode.value);		
		}*/
		if (vMode == 'S')
		{
			response = CommonWebUtility.FindCityStateByZipCodeForAll(vZipCode.value,'S');		
		}
		else
		{				
			response = CommonWebUtility.FindCityStateByZipCodeForAll(vZipCode.value,'');		
		}
		if (response.error != null)
		{   
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			vCounty.value ='';
			alert(response.error); //we should probably do better than this
			return;
		}  
		if (response.value == "")
		{   
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			vCounty.value ='';
			alert(response.error); //we should probably do better than this
			return;
		}  	
			
		var states = response.value;  
		//if the response wasn't what we expected  
		if (states == null || typeof(states) != "object")
		{
			vState.selectedIndex = 0 ; 
			vCity.value = '';
			vStateHid.value = ''; 
			vCounty.value ='';
			return;  
		}else
		{
			
			if ( states.Rows.length == 0 ) 
			{
				alert('Invalid zipcode Value. (' + vZipCode.value + ')'); 
				vZipCode.focus();
				//vZipCode.value ='';
				//vState.selectedIndex = 0 ; 
				//vCity.value = '';
				vStateHid.value = '';vCounty.value ='';
				
			}
			else
			{
				vCity.value= states.Rows[0].City ; 
				SetDropDownForValue(vState, states.Rows[0].State ) ;
				vStateHid.value =  states.Rows[0].State ;
				vCounty.value =states.Rows[0].County ;
			}
			
		}
		 
	}
}


function VerifyReferralId(vLOName)
{	
	if ( vLOName == null )
	{
		alert('Supplied arguement contains null object,Valid ReferID cannot proceed.');
		return false; 		
	}
	if ( vLOName.value != '') 
	{	
		var response;
		response = CommonWebUtility.VerifyReferralId(vLOName.value);		
		if (response.error != null)
		{					
			alert(response.error);
			vLOName.focus();	
			return false;
		}  		  	
			
		var ValidRefID = response.value;
		var ValidRefIdCount,IsTransferred,PlanType;
		ValidRefIdCount=ValidRefID.Tables[0].Rows[0].Count;
		IsTransferred=ValidRefID.Tables[0].Rows[0].Transferred;
		PlanType=ValidRefID.Tables[0].Rows[0].PlanType;
		
		if ( ValidRefIdCount == '0' ) 
		{
				alert('Please Enter Correct Member ID '); 
				vLOName.focus();
				vLOName.value ='';
				return false;
		}	
		else
		{
			if(IsTransferred=='1')
			{
				if(PlanType=='B')
				{
					alert('Member Id '+vLOName.value+' has selected Producer Plan');
					vLOName.focus();
					vLOName.value ='';
					return false;
				}
				else
				{
					alert('Member Id '+vLOName.value+' has selected Builder Plan');
					vLOName.focus();
					vLOName.value ='';	
					return false;
				}
			}
		}
		return true; 
	}
	else
		return false;
}

	function SetDropDownForValue(objDDL,  strValue)
	{
		if ( objDDL == null || typeof(objDDL) == 'undefined')
			return ;
			
		for ( var i =0 ; i < objDDL.options.length ; i++) 
		{
			if ( objDDL.options[i].value == strValue ) 
				objDDL.selectedIndex = i ; 
		}			
		
	}
	function FindZipCode_CallBack(response)
	{		
		if (response.error != null)
		{   
			objStateDDL.selectedIndex = 0 ; 
			objCity.value = '';
			objhidStateID.value = ''; 
			alert(response.error); //we should probably do better than this
			return;
		}  
			
			
		var states = response.value;  
		//if the response wasn't what we expected  
		if (states == null || typeof(states) != "object")
		{
			objStateDDL.selectedIndex = 0 ; 
			objCity.value = '';
			objhidStateID.value = ''; 
			return;  
		}else
		{
			
			if ( states.Rows.length == 0 ) 
			{
				alert('Please enter valid zipcode.'); 						
				objStateDDL.selectedIndex = 0 ; 
				objCity.value = '';
				objhidStateID.value = ''; 
			}
			else
			{
				objCity.value= states.Rows[0].City ; 
				SetDropDownForValue(objStateDDL, states.Rows[0].State ) ;
				objhidStateID.value =  states.Rows[0].State ;
			}
			
		}
	}
	
	function getSearchField(strPageName)
	{
		var strDDLBList;		// Stores value returned by CommonWebUtility
		var strFieldOption;		// Split value by "^" sign. Gives # of items to be filled in dropdown
					
		if (strPageName == '') 
			return;
			
		var response = CommonWebUtility.LoadMultiSearchDropdown(strPageName);		
		if (response.error != null )
		{					
			alert(response.error);
			return;
		}
		
		strDDLBList = response.value;  	
		strFieldText = new Array();	
		strFieldValue = new Array();	
		
		for (var i=0;i<strDDLBList.Rows.length ;i++)					
		{	
			strFieldOption = strDDLBList.Rows[i].DDLBVALUE.split("~");
			strFieldText[i]="";
			strFieldValue[i]="";
			strFieldText[i] = strDDLBList.Rows[i].DDLBTEXT;
			strFieldValue[i] = strFieldOption[0] + "~" + strFieldOption[1] + "~";
			if (strFieldOption[2]!="")
			{	
				strFieldValue[i] += strFieldOption[2];
			}
		}		
	}
	
	function getSearchList(strPageName, strPlanType)
	{
		var strDDLBList;		// Stores value returned by CommonWebUtility
				
		if (strPageName == '') 
			return;
		
		var response = CommonWebUtility.LoadSearchList(strPageName, strPlanType)		
		if (response.error != null )
		{					
			alert(response.error);
			return;
		}
		
		strDDLBList = response.value;  	
		strSearchOptions = new Array();		
		strOptionsDDLBName = new Array();		
		for (var i=0;i<strDDLBList.Rows.length;i++)					
		{	
			strOptionsDDLBName[i] = strDDLBList.Rows[i].DDLBName;
			strSearchOptions[i] = strDDLBList.Rows[i].DDLBList;
		}		
	}
	
	function FillSearchList(objddlList,strDDLBName)
	{
		var strDDLBOption;		// Split value by "^" sign. Gives # of items to be filled in dropdown
		var strOptionsList;					// Array Variable to fill search List DDLBName			
		var objOption;
		var intarrIdx = 0;
		for(i=objddlList.options.length-1;i>=0;i--)		
			objddlList.remove(i);
		
		for(i=0;i<strOptionsDDLBName.length;i++)		
		{
			if (strOptionsDDLBName[i] == strDDLBName)
			{
				intarrIdx = i;
				break;
			}
		}
		
		strDDLBOption = strSearchOptions[intarrIdx].split("^");
		for(i=0;i<strDDLBOption.length;i++)		
		{
			var strSearchList = strDDLBOption[i].split("~");
			var objOption = new Option(strSearchList[1], strSearchList[0]); 			
			objddlList.options[objddlList.options.length]= objOption; 
		}
	}
	
	
	function LoadCity(sid)
	{		 
	var	vState = document.getElementById('ddlState_' + sid );
	var	vCity = document.getElementById('ddlCity_' + sid); 	 
	
	if (vState == null)
		{
			alert('Supplied argument contains null object,Loading City cannot proceed.');
			return; 		
		}				
	 	
		if ( vState.value != '') 
		{	 
			var response;
			response = CommonWebUtility.LoadCity(vState.value);	
			 
			if (response.error != null)
			{					
				alert(response.error);
				return;
			}
			var cities = response.value;  		
			if (cities == null || typeof(cities) != "object")
			{
				vCity.selectedIndex = 0 ;		
				return;  
			}
			else
			{					 
			 	ClearDropDown(vCity); 			 			
			 	
				if ( cities.Rows.length == null ) 
				{
					vState.selectedIndex =0 ;				
					vCity.selectedIndex = 0 ; 												
				}
				else
				{					
					var v;			
					v = new Option('- All Cities -', -2 );					 					
					vCity.options[vCity.options.length]= v;					
							
					for (var i=0; i< cities.Rows.length ;i++)		
					{	
						v = new Option(cities.Rows[i].city, i );					 
						vCity.options[vCity.options.length]= v;						
					}
					 		
				} 			
			}		 
		}		
	}
	function RemoveHTMLRow(objCtrl,objtblSearch)
	{
		var ctrl;
		var intRowCount = parseInt(objtblSearch.rows.length);
		if (document.getElementById(objCtrl).selectedIndex==0)
		{
			ctrl = parseInt(objCtrl.substring(parseInt(objCtrl.indexOf('_')+1)))+1;

			for(i=intRowCount-1;i>=ctrl;i--)		
				objtblSearch.deleteRow(i);   
		}
	}
	function createHTMLRow(objtblSearch)
	{
		var newCellHTML="";
		var oCell;
		var intRowCount = parseInt(objtblSearch.rows.length);
		
		var objTr = objtblSearch.insertRow();
				
		oCell = objTr.insertCell();			//td1
		newCellHTML = "";
		newCellHTML += "<TD align='right' ><select id='ddlField_" + intRowCount + "' class='QuickSelect' runat='server' onchange=FillCriteria(this.id);>";
		if (intRowCount == 0)
			newCellHTML += "<option value='ViewAll'>View All</option>";
		else
			newCellHTML += "<option value=''>Select</option>";

		for(i=0;i<strFieldText.length;i++)		
		{
			newCellHTML += "<option value='" + strFieldValue[i] + "'>" + strFieldText[i] + "</option>";
		}
		newCellHTML += "</select>";
		newCellHTML += "<input type='hidden' id='hdnField_" + intRowCount + "' runat='server'></td>";
		oCell.innerHTML = newCellHTML;
		oCell.className = "PlanLabel";
	
		
		oCell = objTr.insertCell();			//td2
		newCellHTML = "";
		newCellHTML += "<TD style='DISPLAY: none;' runat='server' >";
		newCellHTML += "<select id='ddlCriteria_" + intRowCount + "' class='QuickSelect' style='width:110px;' runat='server' onchange=VisibleText('ddlField_" + intRowCount + "');>";
		newCellHTML += "<option Value='='>Equals</option>";
		newCellHTML += "<option Value='<>'>Not Equal</option>";
		newCellHTML += "<option Value='StartWith'>Start With</option>";
		newCellHTML += "<option Value='EndWith'>End With</option>";
		newCellHTML += "<option Value='Contains'>Contains</option></select>";
		newCellHTML += "<select id='ddlCriteriaList_" + intRowCount + "' class='QuickSelect' style='width:110px;display:none;' runat='server' onchange=VisibleText('ddlField_" + intRowCount + "');>";
		newCellHTML += "<option Value='='>Equals</option>";
		newCellHTML += "<option Value='<>'>Not Equal</option></select>";
		newCellHTML += "<select id='ddlCriteriaNo_" + intRowCount + "' class='QuickSelect' style='width:110px;display:none;' runat='server' onchange=VisibleText('ddlField_" + intRowCount + "');>";
		newCellHTML += "<option Value='='>Equals</option>";
		newCellHTML += "<option Value='<>'>Not Equal</option>";
		newCellHTML += "<option Value='<'>Less Than</option>";
		newCellHTML += "<option Value='>'>Greater Than</option>";
		newCellHTML += "<option Value='><'>Between</option></select>";
//		newCellHTML += "<input type='hidden' id='hdnCriteriaType' runat='server'>";
		newCellHTML += "<input type='hidden' id='hdnCriteria_" + intRowCount + "' runat='server'></TD>";
		oCell.innerHTML = newCellHTML;
		oCell.id="tdCriteria_" + intRowCount;
		oCell.className = "PlanLabel";  
		oCell.style.display="None";
		
		oCell = objTr.insertCell();			//td3
		newCellHTML="";
		newCellHTML += " <TD nowrap style='DISPLAY: none; white-space: nowrap;'  align='left' runat='server'>";
		newCellHTML += " <INPUT id='txtText_" + intRowCount + "' style='display:none; ' Runat='server' size=30 Class='text' MaxLength='50' onkeypress='return TextKeyPress(this.id);' >";
		newCellHTML += " <SELECT id='ddlList_" + intRowCount + "' class='formfield' style='WIDTH: 180px;' runat='server'></SELECT>";
		newCellHTML += " <INPUT id='hidddlList_" + intRowCount + "' type='hidden' style='display:none;' runat='server'>";
		
		newCellHTML += " <table id='tblStateCity_" + intRowCount + "' style='display:none;' runat='server' width='100%' cellspacing='0' cellpadding='0' align='left'><tr align='left'><td nowrap style='white-space: nowrap;' align='left'>";
		//newCellHTML += " <asp:Label id='lblState_" + intRowCount + "' Runat='server' class='PlanLabel' style='display:none;'>State:</asp:Label>";		
		newCellHTML += " <SELECT id='ddlState_" + intRowCount + "' Runat='server' Width='100' Class='formfield' style='display:none;' onchange=LoadCity(" + intRowCount + ") ></SELECT>";
		newCellHTML += " <INPUT id='hidddlState_" + intRowCount + "' type='hidden' style='display:none;' runat='server'></td><td nowrap style='white-space: nowrap;' align='left'>" ;
		//newCellHTML += " <asp:Label id='lblCity_" + intRowCount + "' Runat='server' class='PlanLabel' style='display:none;'>City:</asp:Label>";
		newCellHTML += " <SELECT id='ddlCity_" + intRowCount + "' Runat='server' Width='100' Class='formfield' style='display:none;'></SELECT>";
		newCellHTML += " <INPUT id='hidddlCity_" + intRowCount + "' type='hidden' style='display:none;' runat='server'></td></tr></table>";
		
		newCellHTML += " <table  id='tblNo_" + intRowCount + "' style='display:none;' runat='server' width='100%' cellspacing='0' cellpadding='0'><tr><td ><INPUT id='txtFrom_" + intRowCount + "' class='formfield' size=9 type='text' runat='server' onkeypress='return CheckInteger(event,this);'><asp:Label class='PlanLabel' id='lblNoAnd_" + intRowCount + "' Runat='server'>";
		newCellHTML += " AND </asp:Label><INPUT id='txtTo_" + intRowCount + "' class='formfield' size=9 type='text' runat='server' ";
		newCellHTML += " onkeypress='return CheckInteger(event,this);'></td></tr></table>";
		
		newCellHTML += " <table id='tblDate_" + intRowCount + "' style='display:none;' runat='server' width='100%' cellspacing='0' cellpadding='0'><tr><td><table id='tblFrom_" + intRowCount + "' style='display:none;' runat='server' width='100%' cellspacing='0' cellpadding='0'><tr><td align='right'><INPUT id='txtFromDate_" + intRowCount + "' class='formfield' size=10 type='text' readOnly";
		newCellHTML += " runat='server'><INPUT id='imgFromDate_" + intRowCount + "' type='button' class='Calender' onclick='ShowCalender(this.id,event);' ";
		newCellHTML += " style='BACKGROUND-IMAGE: url(" + sRootPath + "NewImages/calendar.gif); BACKGROUND-COLOR: transparent;' runat='server'></td><td><table id='tblTo_" + intRowCount + "' ";
		newCellHTML += " style='display:none;' runat='server' width='100%' cellspacing='0' cellpadding='0'><tr><td><asp:Label class='PlanLabel' id='lblDateAnd_" + intRowCount + "'" ;
		newCellHTML += " Runat='server'> AND </asp:Label><INPUT id='txtToDate_" + intRowCount + "' size=10 class='formfield'"
		newCellHTML += " readOnly type='text' runat='server'><INPUT id='imgToDate_" + intRowCount + "' type='button' class='Calender' onclick='ShowCalender(this.id,event);'";
		newCellHTML += " style='BACKGROUND-IMAGE: url(" + sRootPath + "NewImages/calendar.gif);BACKGROUND-COLOR: transparent;' runat='server'></td></tr></table></td></tr></table></td></tr></table></TD>";
		
		oCell.innerHTML = newCellHTML;
		oCell.id="tdSearchText_" + intRowCount;
		oCell.className = "PlanLabel";  
		oCell.style.display="None";
		oCell.style.whiteSpace = "nowrap";
		
	}
	
	function ShowCalender(objImgDate,eventSource)
	{
		var objtxtDate = objImgDate.replace('img','txt');	
		ShowHideCalender(objImgDate,eventSource,objtxtDate);
	}
	
  

  
  