function ResetAdvSearchForm (theform, piStyle)
{
 var i;
 var attrid, displaytype, datatype;
 
// if (piStyle > 2)
//     PlpRemoveCookie ("plp_advsrch_criteria"); // It will damage IE cookie?

//    if (piStyle > 2)
//       theform.hdnCriteria.value = "";
  
	if (theform.hdnAttrIDs.length > 1)
	{
		for (i=0; i < theform.hdnAttrIDs.length; i++)
		{
			attrid = theform.hdnAttrIDs[i].value;
			displaytype = theform.hdnAttrTypes[i].value;
			datatype = theform.hdnDataTypes[i].value;
			MeasureId = theform.hdnMeasureIDs[i].value;
			ClearSelectedItems(theform, displaytype, attrid, MeasureId);					
		}			
	}
	else
	{
		attrid = theform.hdnAttrIDs.value;
		displaytype = theform.hdnAttrTypes.value;
		datatype = theform.hdnDataTypes.value;
		MeasureId = theform.hdnMeasureIDs.value;
			
		ClearSelectedItems(theform, displaytype, attrid, MeasureId);
	}
}

function ClearSelectedItems (theform, displaytype, attrid, MeasureId)
{
	var j;
	
	if (displaytype=='chk')
	{
	    if(theform["chk_" + "attrid_" + attrid + "_" + MeasureId].length==undefined)
	    {
		 theform["chk_" + "attrid_" + attrid  + "_" + MeasureId].checked = false
		}
		else
		{
			for (j=0; j < theform["chk_" + "attrid_" + attrid  + "_" + MeasureId].length; j++)
			{
				theform["chk_" + "attrid_" + attrid + "_" + MeasureId][j].checked = false;
			}
		}	
	}
	else if (displaytype=='radio')
	{
	    if (theform["radio_" + "attrid_" + attrid  + "_" + MeasureId].length==undefined)
	    {
		 if (theform["radio_" + "attrid_" + attrid  + "_" + MeasureId].value == '0_0')
		 {
		  theform["radio_" + "attrid_" + attrid  + "_" + MeasureId].checked = true;
		 }
		}
		else
		{
			for (j=0; j < theform["radio_" + "attrid_" + attrid  + "_" + MeasureId].length; j++)
			{
			 if (theform["radio_" + "attrid_" + attrid  + "_" + MeasureId][j].value == '0_0')
			 {
				theform["radio_" + "attrid_" + attrid + "_" + MeasureId][j].checked = true;
			 }
			}
		}	
	}else if (displaytype=='bool_radio'){
	    if (theform["bool_radio_" + "attrid_" + attrid].length==undefined)
	    {
			if (theform["bool_radio_" + "attrid_" + attrid].value == '0_0')
			{
			 theform["bool_radio_" + "attrid_" + attrid].checked = true;
			}
		}
		else
		{
			for (j=0; j < theform["bool_radio_" + "attrid_" + attrid].length; j++)
			{
				if (theform["bool_radio_" + "attrid_" + attrid][j].value == '0_0')
				{
				  theform["bool_radio_" + "attrid_" + attrid][j].checked = true;
				}
			}
		}			
	}
	else if (displaytype=='drpdn')
	{
		//theform["drpdn_" + "attrid_" + attrid].value == '0';
		theform.all.item("drpdn_" + "attrid_" + attrid  + "_" + MeasureId).item(0).selected = true;
	}
	else if (displaytype=='listbox')
	{
	 	for (j=0; j < theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options.length; j++)
	 	{
		 if (theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options[j].value == '0_0')
		 {
			theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options[j].selected = true;
		 }
		 else
		 {
			theform["listbox_" + "attrid_" + attrid + "_" + MeasureId].options[j].selected = false;
		 }
		}
	}
	else if (displaytype=='editbox')
	{
		//alert("editbox_" + "attrid_" + attrid + ' is : ' + theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value);
		theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value = '';
	}
	else if (displaytype=='drpdn_range')
	{
		//alert("editbox_" + "attrid_" + attrid + ' is : ' + theform["editbox_" + "attrid_" + attrid].value);
		theform["editbox_" + "attrid_" + attrid + "_" + MeasureId].value = '';
	}
	else if (displaytype=='memobox')
	{
		theform["memobox_" + "attrid_" + attrid + "_" + MeasureId].value = '';
	}
	else if (displaytype=='range')
	{
		theform["range_" + "attrid_" + attrid  + "_" + MeasureId + "_from"].value = '';
		theform["range_" + "attrid_" + attrid  + "_" + MeasureId + "_to"].value = '';
	}
}

