 // Function Name : fnAddCategory
// Description   : The function adds all the property Categories in the combo
//				   and keeps the selCategory as the selected Category
// Input param   : the name of the Category combo box 
//				   the Category that should be selected by default
// Ouput Params  : none
function fnAddCategory(cbCategory,selCategory)
{
	
	var selIndex=0,iCount=1;
	cbCategory.length=1;
	for (var iLoop=0;iLoop<Ptype[0].length;iLoop++)
	{
		//alert('in');
		if (Ptype[0][iLoop]==selCategory) selIndex=iCount;
		//alert(country[0][iLoop]);
		cbCategory.length=cbCategory.length+1;
		cbCategory.options[cbCategory.length-1].value=Ptype[0][iLoop];
		cbCategory.options[cbCategory.length-1].text=Ptype[0][iLoop];
		iCount++;
	}
	cbCategory.selectedIndex=selIndex;
	//countryChanged(cbCountry,cbState,cbCity,cbLocality);
}

// Function Name : fnAddSubCategory
// Description   : The function adds all the SubCategory to the combo 
//				   based on the Category selected.
//				   It also keeps the selSubCategory as the selected SubCategory
// Input param   : the name of the SubCategory combo box
//				   the name of the Category combo box 
//				   the state that should be selected by default
// Ouput Params  : none
function fnAddSubCategory(cbSubCategory,cbCategory,selSubCategory)
{
	
	var strCategory=cbCategory.options[cbCategory.selectedIndex].value;
	var lBound,uBound;
	for (var iLoop=0;iLoop<Ptype[0].length;iLoop++)
	{
		if (Ptype[0][iLoop]==strCategory)
		{
			var tempArray = Ptype[1][iLoop].split(",");
			lBound=parseInt(tempArray[0]);
			uBound=parseInt(tempArray[1]);
		}
	}
	var selIndex=0,iCount=1;
	var iLoop;
	cbSubCategory.length=1;
	var tempint=10;
	//alert("upper" + uBound);
	for (iLoop=lBound;iLoop<=uBound;iLoop++)
	{
		//alert('in for');
		if (PSubtype[0][iLoop]==selSubCategory)selIndex=iCount;
		//alert('in if');
		cbSubCategory.length=cbSubCategory.length+1;
		cbSubCategory.options[cbSubCategory.length-1].value=PSubtype[0][iLoop];
		cbSubCategory.options[cbSubCategory.length-1].text=PSubtype[0][iLoop];
		iCount++;
	}
	//alert("upper" + uBound);
	//alert(selIndex);
	cbSubCategory.selectedIndex=selIndex;
}

// Function Name : fnCategoryChanged
// Description   : The function loads the SubCategory
//				   based on the Category selected
// Input param   : the name of the Category combo box
//				   the name of the SubCategory combo box
//
// Ouput Params  : none
function fnCategoryChanged(cbCategory,cbSubCategory)
{
	//alert("in");
	if (cbCategory.selectedIndex==0)
	{
		cbSubCategory.length=1;
		cbSubCategory.selectedIndex=0;
		return;
	}
	else
	{
		fnAddSubCategory(cbSubCategory,cbCategory,"");
		return;
	}
}

//---------------------
//These Are Functions That were used in QuickSearch Not The Above
//Functions
//Modified By PremChand on May sunday 6Th 2001
//---------------------------
 // Function Name : fnAddCategorySrc
// Description   : The function adds all the property Categories in the combo
//				   and keeps the selCategory as the selected Category
// Input param   : the name of the Category combo box 
//				   the Category that should be selected by default
// Ouput Params  : none
function fnAddCategorySrc(cbCategorySrc,selCategorySrc)
{
	
	var selIndexSrc=0,iCountSrc=1;
	cbCategorySrc.length=1;
	for (var iLoopSrc=0;iLoopSrc<PtypeSrc[0].length;iLoopSrc++)
	{
		//alert('in');
		if (PtypeSrc[0][iLoopSrc]==selCategorySrc) selIndexSrc=iCountSrc;
		//alert(country[0][iLoop]);
		cbCategorySrc.length=cbCategorySrc.length+1;
		cbCategorySrc.options[cbCategorySrc.length-1].value=PtypeSrc[0][iLoopSrc];
		cbCategorySrc.options[cbCategorySrc.length-1].text=PtypeSrc[0][iLoopSrc];
		iCountSrc++;
		
	}
	cbCategorySrc.selectedIndex=selIndexSrc;
	//countryChanged(cbCountry,cbState,cbCity,cbLocality);
}

// Function Name : fnAddSubCategorySrc
// Description   : The function adds all the SubCategory to the combo 
//				   based on the Category selected.
//				   It also keeps the selSubCategory as the selected SubCategory
// Input param   : the name of the SubCategory combo box
//				   the name of the Category combo box 
//				   the state that should be selected by default
// Ouput Params  : none
function fnAddSubCategorySrc(cbSubCategorySrc,cbCategorySrc,selSubCategorySrc)
{
	var strCategorySrc=cbCategorySrc.options[cbCategorySrc.selectedIndex].value;
	var lBoundSrc,uBoundSrc;
	for (var iLoopSrc=0;iLoopSrc<PtypeSrc[0].length;iLoopSrc++)
	{
		if (PtypeSrc[0][iLoopSrc]==strCategorySrc)
		{
			var tempArraySrc = PtypeSrc[1][iLoopSrc].split(",");
			lBoundSrc=parseInt(tempArraySrc[0]);
			uBoundSrc=parseInt(tempArraySrc[1]);
		}
	}
	var selIndexSrc=0,iCountSrc=1;
	var iLoopSrc;
	cbSubCategorySrc.length=1;
	var tempintSrc=10;
	//alert("upper" + uBound);
	for (iLoopSrc=lBoundSrc;iLoopSrc<=uBoundSrc;iLoopSrc++)
	{
		//alert('in for');
		if (PSubtypeSrc[0][iLoopSrc]==selSubCategorySrc)selIndexSrc=iCountSrc;
		//alert('in if');
		cbSubCategorySrc.length=cbSubCategorySrc.length+1;
		cbSubCategorySrc.options[cbSubCategorySrc.length-1].value=PSubtypeIdSrc[0][iLoopSrc];
		cbSubCategorySrc.options[cbSubCategorySrc.length-1].text=PSubtypeSrc[0][iLoopSrc];
		iCountSrc++;
	}
	//alert("upper" + uBound);
	//alert(selIndex);
	cbSubCategorySrc.selectedIndex=selIndexSrc;
}

// Function Name : fnCategoryChangedSrc
// Description   : The function loads the SubCategory
//				   based on the Category selected
// Input param   : the name of the Category combo box
//				   the name of the SubCategory combo box
//
// Ouput Params  : none
function fnCategoryChangedSrc(cbCategorySrc,cbSubCategorySrc)
{
	//alert("in");
	if (cbCategorySrc.selectedIndex==0)
	{
		cbSubCategorySrc.length=1;
		cbSubCategorySrc.selectedIndex=0;
		return;
	}
	else
	{
		fnAddSubCategorySrc(cbSubCategorySrc,cbCategorySrc,"");
		return;
	}
}
