
function tp_GroupSearch(form,sID) {
	this.form = document.getElementById(form);
	this.SearchID=sID;
}

tp_GroupSearch.prototype.Search = function(objectTypeID) {

	var args = "s=1"+this.getFormElements();	
	window.location.href = '/community/app/templates/tptgroups.aspx?tp_q=1&OTID='+objectTypeID+'&' + args;
	
}

tp_GroupSearch.prototype.getFormElements = function(){ 
	var s = "";
	for(i=0; i<this.form.elements.length; i++)
	{//if (left(this.form.elements[i].id,3)=="tp_")
		{
			var id=this.form.elements[i].id;
			if(left(id,9)!="tp_calctl"&&left(id,5)!="tp_ra"){
			if (this.form.elements[i].type=="radio")
				{if (this.form.elements[i].checked==true)
					{s = s+"&"+id+"="+this.form.elements[i].value;}// alert(this.form.elements[i].id+'='+this.form.elements[i].value+'\n');}
				}
			if (this.form.elements[i].type=="checkbox")
				{if (this.form.elements[i].value != "")
					{ if (this.form.elements[i].checked==true)
						{s = s+"&"+id+"=on";}
//					else
//			  			{s = s+"&"+id+"=off";}
					}
				else {
						if (this.form.elements[i].checked==true)
							{s = s+"&"+id+"=on";}
//						else {s = s+"&"+id+"=off";}	
					}
				}		
			if (this.form.elements[i].type!="radio" && this.form.elements[i].type!="checkbox")
				{
				if(id=='tp_d')
				{
				if($F('tp_d_month')!= "-1" && $F('tp_d_day')!= "-1" && $F('tp_d_year')!= "-1")
					{
						try{var d=new Date($F('tp_d_year'), $F('tp_d_month')-1, $F('tp_d_day'));}
						catch(e){alert("Please choose a valid date");} 
			 			s = s+"&tp_d="+(d.getMonth()+1)+"-"+d.getDate()+"-"+d.getFullYear();
			 		}	
				}
				else if(id=='tp_sd')
				{
				if($F('tp_sd_month')!= "-1" && $F('tp_sd_day')!= "-1" && $F('tp_sd_year')!= "-1")
					{
						try{var sd=new Date($F('tp_sd_year'), $F('tp_sd_month')-1, $F('tp_sd_day'));this.startDt=sd}
						catch(e){alert("Please choose a valid start date");} 
			 			s = s+"&tp_sd="+(sd.getMonth()+1)+"-"+sd.getDate()+"-"+sd.getFullYear();
			 		}	
				}
			 	else if(id=='tp_ed')
				{
				if($F('tp_ed_month')!= "-1" && $F('tp_ed_day')!= "-1" && $F('tp_ed_year')!= "-1")
					{
						try{var ed=new Date($F('tp_ed_year'), $F('tp_ed_month')-1, $F('tp_ed_day'));this.endDt=ed}
						catch(e){alert("Please choose a valid end date");} 
			 			s = s+"&tp_ed="+(ed.getMonth()+1)+"-"+ed.getDate()+"-"+ed.getFullYear();
			 		}	
				}
				else if(left(id,5)=='tp_sd'||left(id,5)=='tp_ed'||left(id,4)=='tp_d'){}				
				else{s = s+"&"+id+"="+escape(this.form.elements[i].value);}
				}
				}	
				}
		
	}
	return s;
}
tp_GroupSearch.prototype.resetFormElements = function(){ 
	try{
	for(i=0; i<this.form.elements.length; i++)
	{
	if (this.form.elements[i].type=="select-one")
		{this.form.elements[i].selectedIndex=0}
	if (this.form.elements[i].type=="checkbox" || this.form.elements[i].type=="radio")
		{this.form.elements[i].checked=false}
	if (this.form.elements[i].type=="text" || this.form.elements[i].type=="textarea")
		{this.form.elements[i].value="";}	
	}
	}catch(e){}
	return false;
}
