function searchResult (objid, section, title, subtitle, stocknum, vcode, objclass, objtype, thumbsrc1, thumbwidth1, thumbheight1, brief, catchline, searchweight, shortcutmatch) {
this.objid = objid;
this.section = section;
this.title = title;
this.subtitle = subtitle;
this.stocknum = stocknum;
this.vcode = vcode;
this.objclass = objclass;
this.objtype = objtype;
this.thumbsrc1 = thumbsrc1;
if (this.thumbsrc1 == "clear.gif") {
	this.thumbwidth1 = 110;
	this.thumbheight1 = 110;
	this.thumbborder = 0;
} else {
	this.thumbwidth1 = thumbwidth1;
	this.thumbheight1 = thumbheight1;
	this.thumbborder = 0;
}
this.brief = brief;
this.catchline = catchline;
this.searchweight = searchweight;
this.shortcutmatch = shortcutmatch;
}




///////////////////////////////////////////////////////////////////////////////////////////
// Begin newstuff
// GJ 12/2007
///////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////
// Global properties
///////////////////////////////////////////////////////////////////////
var tabs = new Array();		// the array of tabs
var tabSelection = 0;		// the selected tab
var tabsLoaded = false;		// have the tabs been loaded yet?


///////////////////////////////////////////////////////////////////////
// Load the tabs. Called the first time drawResults() is called
///////////////////////////////////////////////////////////////////////
function initializeSearch()
{	
	// process the result arrays into searchTab objects
	var nextTab = 0;
	
	// Select the default tab
	var defaultTab = getParameter("tab");
	if (defaultTab != null) tabSelection = 0;
	
	processTab("Products", productResults);
	processTab("Info", infoResults);
	//processTab("Services", serviceResults);
	//processTab("Glossary", glossaryResults);
	//processTab("Articles", articleResults);
	//processTab("Misc", miscResults);
	
	tabsLoaded = true;
	
	// Instantiate tabs when there's results
	function processTab(title, resultArray)
	{	if (resultArray.length > 0)
		{	if (defaultTab != null && defaultTab.toUpperCase() == title.toUpperCase())
			{	tabSelection = nextTab;
			}
			tabs[nextTab] = new SearchTab(title, resultArray, nextTab);
			nextTab++;
		}
	}
}


///////////////////////////////////////////////////////////////////////
// Select a new tab and display it
///////////////////////////////////////////////////////////////////////
function selectTab(newTab)
{	tabSelection = newTab;
	drawResults();
}


///////////////////////////////////////////////////////////////////////
// Everything you need to be a searchtab
///////////////////////////////////////////////////////////////////////
function SearchTab(newTitle, newResults, newTabIndex)
{	
	///////////////////////////////////////////////////////////////////////
	// Properties
	///////////////////////////////////////////////////////////////////////
	var title = newTitle;			// the tab title
	var results = newResults;	// the array of result hits
	var loaded = false;			// have the tabs been loaded?
	var tabIndex = newTabIndex;	// which tab number is this?
	
	
	///////////////////////////////////////////////////////////////////////
	// initialize
	///////////////////////////////////////////////////////////////////////
	function _initialize()
	{	
	} this.initialize = _initialize;
	
	
	///////////////////////////////////////////////////////////////////////
	// Turn it into html. The raw HTML components
	// should be moved into an include file
	///////////////////////////////////////////////////////////////////////
	function _getHTML()
	{	
		//var out = "<B>" + title + "</B><BR>";
		var out = "";
		for (i = 0; i < results.length; i++)
		{	out +="<TABLE>";
			out +="<TR>";
			out +="<TD WIDTH='55'>";
			out+= "<A HREF=\"/cgi-bin/search.cgi?mode=choose&id=" + searchResultID + "&objid=" + results[i].objid + "&url=/html/eng/" + results[i].objid + ".shtml\">";
			out +="<IMG BORDER='0' WIDTH='55' HEIGHT='55' SRC='" + imageServer + "/images/eng/products/110/" + results[i].thumbsrc1 +"'>";
			out += "</A>";
			
			//out +="<TD WIDTH='100%' VALIGN='TOP' STYLE='background-color:" + ((i % 2 == 0) ? "#FFFFFF" : "#F5F5F5") + ";'>";
			out +="<TD WIDTH='100%' VALIGN='TOP'>";
			
			
			out +="<DIV STYLE='font-weight:bold;font-size:12px'>";
			out+= "<A HREF=\"/cgi-bin/search.cgi?mode=choose&id=" + searchResultID + "&objid=" + results[i].objid + "&url=/html/eng/" + results[i].objid + ".shtml\" CLASS=\"searchlink\">";
			//out+= "<A HREF=\"/cgi-bin/search.cgi?mode=choose&id=" + searchResultID + "&objid=" + results[i].objid + "&url=/html/eng/" + results[i].objid + ".shtml\">";
			out += results[i].title;
			out+= "</A>";
			out +="</DIV>";
			
			out +="<DIV>";
			out += results[i].brief;
			out +="</DIV>";
			
			out += "</TABLE>";
			out += "<BR>";
			//out += "<HR>";
		}
		out+= "<BR>";
		return out;
		//return title + ": " + results.length + "<BR>";
	} this.getHTML = _getHTML;
	
	
	///////////////////////////////////////////////////////////////////////
	// Gets
	///////////////////////////////////////////////////////////////////////
	function _getTitle()
	{	return title;
	} this.getTitle = _getTitle;
	function _getResults()
	{	return results;
	} this.getResults = _getResults;
	function _getTabIndex()
	{	return tabIndex;
	} this.getTabIndex = _getTabIndex;
}


///////////////////////////////////////////////////////////////////////
// Draws search results. Using old name
// to stay compatible with legacy code
///////////////////////////////////////////////////////////////////////
function drawResults()
{	
	// if its not initialized, initialize it
	if (!tabsLoaded) initializeSearch();
	
	// the tab headers
	var outstring = "<TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0'><TR>";
	outstring+= "<TD WIDTH='4px' HEIGHT='7px'>";
	outstring+="<IMG SRC='/images/eng/general/SearchTabCap.jpg'>";
	for (t = 0; t < tabs.length; t++)
	{	outstring+= "<TD>";
		outstring+= "<DIV  ";
		if (tabSelection == t)
		{	outstring+= "STYLE=\" padding-top:1px;color:#222222;font-size:120%;cursor:default;text-align:center;vertical-align:top;display:table-cell;width:137px;height:25px;background-image:url('/images/eng/general/SearchTabSelected.jpg'); \" >";
		} else
		{	outstring+= "onClick=\"javascript:selectTab(" + t + ");\" ";
			outstring+= "onMouseOver=\"javascript:tabMouseIn(" + t + ", this);\" ";
			outstring+= "onMouseOut=\"javascript:tabMouseOut(" + t + ", this);\" ";
			outstring+= "STYLE=\"  padding-top:2px;color:#222222;font-size:120%;cursor:pointer;text-align:center;vertical-align:top;display:table-cell;width:137px;height:25px;background-image:url('/images/eng/general/SearchTab.jpg'); \" >";
		}
		outstring+= tabs[t].getTitle() + " ("  + "<SPAN STYLE=\" font-size:80%\">" + tabs[t].getResults().length + "</SPAN>)";
		outstring+= "</DIV>";
	}
	outstring+= "<TD WIDTH='4px' HEIGHT='7px'>";
	outstring+="<IMG SRC='/images/eng/general/SearchTabCap.jpg'>";
	outstring+= "</TABLE><BR>";
	
	// the results
	outstring+=tabs[tabSelection].getHTML();
	
	// Stick it in the main canvas
	var theCanvas = document.getElementById("productResults");
	theCanvas.innerHTML = outstring;
}


///////////////////////////////////////////////////////////////////////
// Mouse-in
///////////////////////////////////////////////////////////////////////
function tabMouseIn(index, el)
{	if (index != tabSelection)
	{	
		el.style.backgroundImage = "url('/images/eng/general/SearchTabMouseOver.jpg')";
	}
	
}


///////////////////////////////////////////////////////////////////////
// Mouse-in
///////////////////////////////////////////////////////////////////////
function tabMouseOut(index, el)
{	if (index != tabSelection)
	{	
		el.style.backgroundImage = "url('/images/eng/general/SearchTab.jpg')";
	}
	
}


///////////////////////////////////////////////////////////////////////
// Get a URL parameter. Returns null if nothing is found
///////////////////////////////////////////////////////////////////////
function getParameter(name)
{	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );

	if( results == null )
		return null;
	else
		return results[1];
}
