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("Product Results", productResults);
	processTab("Information Results", 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;
			}
			title = title.toUpperCase();
			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 = "";
		for (i = 0; i < results.length; i++) {
			out += ("<div style=\"margin-bottom:18px;\">");
			out += ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>");
			out += ("<td valign=\"top\" align=\"left\" width=\"65\">");
			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\" src=\"" + imageServer + "/images/eng/products/110/" + results[i].thumbsrc1 +"\"></a>");
			out += ("<td valign=\"top\">");
			out += ("<div><a href=\"/cgi-bin/search.cgi?mode=choose&id=" + searchResultID + "&objid=" + results[i].objid + "&url=/html/eng/" + results[i].objid + ".shtml\" class=\"searchlink\" style=\"font-size:12px;color:#222222;\">" + results[i].title + "</a></div>");
			out += ("<div style=\"color:#222222;\">" + results[i].brief + "</div>");
			out += ("</td></tr></table></div>");
		}
		return out;
	} 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;
}


function getCatHeader(t) {
	// the category headers
	var cathead = ("<div style=\"margin-bottom:12px;color:#222222;font-size:12px;font-weight:bold;text-align:left;vertical-align:top;\">");
	cathead += tabs[t].getTitle() + " <span style=\"font-size:14px;\">(" + tabs[t].getResults().length + ")</span>";
	cathead += ("</div>");
	cathead += ("<div style=\"margin-bottom:12px;border-bottom-style:solid;border-bottom-width:1px;border-bottom-color:#cccccc;\"></div>");
	
	return cathead;
}


///////////////////////////////////////////////////////////////////////
// Draws search results. Using old name
// to stay compatible with legacy code
///////////////////////////////////////////////////////////////////////
function drawResults()
{	
	// if its not initialized, initialize it
	if (!tabsLoaded) initializeSearch();
	
	// the product results
	outstring = getCatHeader(0);
	outstring += tabs[0].getHTML();
	
	// Stick it in the main canvas
	var theCanvas = document.getElementById("productResults");
	theCanvas.innerHTML = outstring;

	// the information results
	outstring = getCatHeader(1);
	outstring += tabs[1].getHTML();
	
	// Stick it in the main canvas
	var theCanvas = document.getElementById("infoResults");
	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];
}

