function doSearch(){
	
	var ukey=Math.floor(Math.random()*100000);	
	url="/legziel/catalog/admin/items.php";
	$("content").innerHTML='<img src="/legziel/images/ajax-loader-purple.gif" class="ajax_loader">';
	var all_ajax=new Ajax.Request(url, { 
    	method:'get', 
		onSuccess: function(transport){ 
   		var ve = transport.responseXML.documentElement.getElementsByTagName("record");
		var theader="";
		var title="";
		theader='<table class="sortable" id="maintable'+ukey+'" style="width:800px;"><thead><tr>';
		theader+='<th style="width:100px;">Shape</th>';
		theader+='<th style="width:60px;">Size</th>';
		theader+='<th style="width:60px;">Color</th>';
		theader+='<th style="width:60px;">Clarity</th>';
		theader+='<th style="width:60px;">Cut</th>';
		theader+='<th style="width:60px;">Polish</th>';
		theader+='<th style="width:60px;">Symmetry</th>';
		theader+='<th style="">GIA Cert</th></tr></thead><tbody>';
		var tfooter="</tbody></table>";
		
		// form items:
		var shape=$F("Shape");
		var size=$F("Size");
		var color=$F("Color");
		var clarity=$F("Clarity");
		var cut=$F("Cut");
		var polish=$F("Polish");
		var symmetry=$F("Symmetry");
		
		
		var temp="";
		var celltext="";
		var total=0;
      	for(i=0;i<ve.length;i++){
			//get row data
			var itemid=(!isIE7) ? ve[i].childNodes[0].textContent:ve[i].childNodes[0].text;
			var item_shape=(!isIE7) ? ve[i].childNodes[2].textContent:ve[i].childNodes[2].text;
			var item_size=(!isIE7) ? ve[i].childNodes[3].textContent:ve[i].childNodes[3].text;
			var item_exactsize=(!isIE7) ? ve[i].childNodes[4].textContent:ve[i].childNodes[4].text;
			var item_color=(!isIE7) ? ve[i].childNodes[5].textContent:ve[i].childNodes[5].text;
			var item_clarity=(!isIE7) ? ve[i].childNodes[6].textContent:ve[i].childNodes[6].text;
			var item_cut=$(!isIE7) ? ve[i].childNodes[7].textContent:ve[i].childNodes[7].text;
			var item_polish=(!isIE7) ? ve[i].childNodes[8].textContent:ve[i].childNodes[8].text;
			var item_symmetry=(!isIE7) ? ve[i].childNodes[9].textContent:ve[i].childNodes[9].text;
			
			//Test row against each field and only show if needed:
			var showrow=true;
			if(shape!="All" && shape!=item_shape){
				showrow=false;
			}else if(size!="All" && size!=item_size){
				showrow=false;
			}else if(color!="All" && color!='' && color!=item_color){
				showrow=false;
			}else if(clarity!="All" && clarity!=item_clarity){
				showrow=false;
			}else if(cut!="All" && cut!=item_cut){
				showrow=false;
			}else if(polish!="All" && polish!=item_polish){
				showrow=false;
			}else if(symmetry!="All" && symmetry!=item_symmetry){
				showrow=false;
			}
			
			if(showrow){
				total+=1;
				temp+='<tr>';
				for(var j=2;j<10;j++){
					if (j != 3) {
						celltext = (!isIE7) ? ve[i].childNodes[j].textContent : ve[i].childNodes[j].text;
						temp += '<td>' + celltext + '</td>';
					}
				}
				//cert:
				gia=(!isIE7) ? ve[i].childNodes[10].textContent:ve[i].childNodes[10].text;
				celltext='<a href="/legziel/upload/'+gia+'" target="_blank">'+gia+'</a>'
				temp+='<td>'+celltext+'</td>';
				temp+='</tr>';
			}
		
      	}
		
		if(total==1){
			title='<div class="searchtitle">Search Results: 1 item found</div>';
		}else{
			title='<div class="searchtitle">Search Results: '+total+' items found</div>';
		}
		
     	if (temp=='') {
				temp='<div class="searchtitle">Search Results: No items found</div><span style="margin:10px;">There are currently no diamonds matching your criteria.</span>';
				$("content").innerHTML =temp;
		}else{
				$("content").innerHTML =title+theader+temp+tfooter;
				TableKit.Sortable.init("maintable"+ukey)
				TableKit.Sortable.sort("maintable"+ukey, 0, 1);
				Try.these(window.parent.iframeResize('cat'));
		}
    		}, 
    		onFailure: function(){ alert('Error loading data...') } 
  		});
}	


function setColors(){
		var shape=$F("Shape");
		var cArray=new Array("All","D","E","F","G","H","I","H","J","K","L","M","N","O","P");
		var fcArray=new Array("All","FIO","FIP","FIY","FLP","FLY","FO","FP","FVO","FVY","FY","LP","P","VLP");
		$("Color").options.length=0;
		$("Color").options[0]=new Option("All","",true,true)
		if (shape == 'FANCY COLOURS') {
			for (i=1; i<fcArray.length; i++) $("Color").options[i]=new Option(fcArray[i])
		}else{
			for (i=1; i<cArray.length; i++) $("Color").options[i]=new Option(cArray[i])
		}
		$("Color").selectedIndex=0;
	}


