function listStores(storeType)
{
	var tier=0;
	document.getElementById('productsList').style.visibility = "hidden";
	document.getElementById('productsList').innerHTML = "";
	document.getElementById('productTable').style.visibility = "hidden";
	document.getElementById('merchantImage').style.visibility = "hidden";
	document.getElementById('merchantImage').innerHTML = "";
	//document.getElementById('storeList').style.border= "1px solid #6D929B"; 
	directoryTable = '';
	//----------------------------- This routine is driven by and lists Stores by STORE TYPE
	findStore(storeType)
	directoryTable ="<TABLE border='0' align='center' border='0' valign='top' cellspacing='0' cellpadding='0'>";
		for (i=0;i<tableEntries[0];i++)
		{
			parseMerchantString();	//-returns:  affiliateProgram,merchantCategory,merchantLink,merchantName,merchantProducts
			switch (tier)
			{
			case 0:
				directoryTable = directoryTable +"<TR>";
				//directoryTable = directoryTable +"<TD align='left' width='225'><a href="+merchantLink+" target='_blank' class='merchantNameSelect' onclick='merchantName=this.innerHTML;getProducts(merchantName);'>"+merchantName+"</a></TD>";
				directoryTable = directoryTable +"<TD align='left' width='225'><a href='#' class='merchantName' onclick='selectedMerchant=this.innerHTML;getProducts(selectedMerchant);'>"+merchantName+"</a></TD>";
				tier=1
				break;
			case 1:
				directoryTable = directoryTable +"<TD align='left' width='225'><a href='#' class='merchantName' onclick='selectedMerchant=this.innerHTML;getProducts(selectedMerchant);'>"+merchantName+"</a></TD>";
				tier=2
				break;
			case 2:
				directoryTable = directoryTable +"<TD align='left' width='225'><a href='#' class='merchantName' onclick='selectedMerchant=this.innerHTML;getProducts(selectedMerchant);'>"+merchantName+"</a></TD>";
				tier=3
				break;
			case 3:
				directoryTable = directoryTable +"<TD align='left' width='225'><a href='#' class='merchantName' onclick='selectedMerchant=this.innerHTML;getProducts(selectedMerchant);'>"+merchantName+"</a></TD>";
				tier=0
				directoryTable = directoryTable +"</TR>";
			}
		}
	directoryTable = directoryTable +"</TABLE>";
	document.getElementById('storeList').innerHTML = directoryTable;
	//document.getElementById('storeList').style.visibility = "visible";
	
}
var aType;
var prodDisplay = '';
var selectedMerchant;
var storeSelected;
function getProducts(selectedMerchant)
{
	for (i=0;i<tableEntries[0];i++)
	{
		parseMerchantString();
		if (selectedMerchant == merchantName)
		{
			document.getElementById('aStoreMerchant').innerHTML = "<TABLE><TR><TD align='center' width='300'><a href="+merchantLink+" target='_blank' class='storeTypeHeader'>"+merchantName+"&nbsp;&nbsp;Web Site</font></a></TD></TR></TABLE>";
			convertDisplay();
			//prodDisplay = merchantProducts;
			document.getElementById('productsList').innerHTML = prodDisplay + "<BR>";
			//document.getElementById('productsList').style.class="top:+1; left:+2; color:#1A80DB;"
			findMerchantImages(storeSelected);
			if (merchantI.length == 0)
			{document.getElementById('merchantImage').innerHTML = "";
			document.getElementById('productsList').style.height = '100%';}
			else
			{document.getElementById('merchantImage').innerHTML = merchantI[i];
			position = document.getElementById('merchantImage').offsetHeight;
			document.getElementById('productsList').style.height = position;
			//document.getElementById('productsList').currentStyle.verticalAlign = "true";
			document.getElementById('merchantImage').style.visibility = "visible";}
		}
	}
	//document.getElementById('productTable').style.border= "2px double #6D929B"; 
	document.getElementById('productTable').style.padding = "5px 5px 5px 5px"; 
	document.getElementById('productTable').style.background = 'FFFFFF';
	document.getElementById('productTable').style.visibility = "visible";
	
	document.getElementById('productsList').style.visibility = "visible";
}
function convertDisplay()
{
	prodDisplay = '';
	var aValue = "<img border='0' src='http://www.i-shopping-mall.com/images/blueball.gif' width='8' height='8'>";
	//var aValue = "<font color='#191970'>•</font>";
	while (merchantProducts.length > 1)
	{
		position = merchantProducts.indexOf(",");
		if (position != -1)
		{
			aString = aValue + " " + merchantProducts.substring(0,position);
			prodDisplay = prodDisplay + aString + "  ";
			theLength = merchantProducts.length;
			merchantProducts = merchantProducts.substring(position+1,theLength);
		}
		else
		{
			aString = aValue + merchantProducts;
			prodDisplay = prodDisplay + aString;
			return;
		}
	}
}
function globalSearch()
{
	var workingString;
	var workingString1;
	document.getElementById('aStoreType').innerHTML = "Mall Stores List";
	document.getElementById('aStoreMerchant').innerHTML = 'Store Products List';
	document.getElementById('merchantImage').innerHTML = "";
	document.getElementById('merchantImage').style.visibility = "hidden";
	document.getElementById('productsList').innerHTML = "";
	document.getElementById('productsList').style.visibility = "hidden";
	aString = document.getElementById('searchArgument').value;
	if (aString.length <= 2)
	{document.getElementById('searchArgument').value = "ENTER SEARCH";return;}
	document.getElementById('storeList').innerHTML = '';
	document.getElementById('storeList').style.visibility = '';
	document.getElementById('productsList').innerHTML = '';
	document.getElementById('merchantImage').innerHTML = '';
	directoryTable = '';
	directoryTable ="<TABLE border='3' align='center' bordercolor='#6D929B' bgcolor='#FFFFFF' valign='top' cellspacing='3' cellpadding='1'>";
	directoryTable = directoryTable +"<TR><TD><span style='font-family: arial rounded mt bold; font-size: 11pt; color: #000080; font-variant: small-caps; font-weight: normal; '>Search Results for</span></TD>";
	//aString = document.getElementById('productsList').value;
	directoryTable = directoryTable +"<TD align='center'><span style='font-family: arial rounded mt bold; font-size: 11pt; color: #000080; font-variant: small-caps; font-weight: normal; '>"+aString+"</span></TD>";
	//directoryTable = directoryTable +"<TD>&nbsp;</TD>";
	directoryTable = directoryTable +"<TD>&nbsp;</TD></TR>";

	for (i=0;i<36;i++)
	{
		switch(i)
		{
		case 0:
			storeType="Ancestry";
			break;
		case 1:
			storeType="Auto";
			break;
		case 2:
			storeType="Baby";
			break;
		case 3:
			storeType="Business";
			break;
		case 4:
			storeType="Children";
			break;
		case 5:
			storeType="Clothing";
			break;
		case 6:
			storeType="Collectables";
			break;
		case 7:
			storeType="Computer";
			break;
		case 8:
			storeType="DeptStores";
			break;
		case 9:
			storeType="Education";
			break;
		case 10:
			storeType="Electronic";
			break;
		case 11:
			storeType="Employment";
			break;
		case 12:
			storeType="Financial";
			break;
		case 13:
			storeType="Flower";
			break;
		case 14:
			storeType="Food";
			break;
		case 15:
			storeType="ForHer";
			break;
		case 16:
			storeType="ForHim";
			break;
		case 17:
			storeType="Furniture";
			break;
		case 18:
			storeType="Games";
			break;
		case 19:
			storeType="GiftBasket";
			break;
		case 20:
			storeType="GiftCards";
			break;
		case 21:
			storeType="Health";
			break;
		case 22:
			storeType="Hobby";
			break;
		case 23:
			storeType="HomeGarden";
			break;
		case 24:
			storeType="Jewelry";
			break;
		case 25:
			storeType="Medical";
			break;
		case 26:
			storeType="Movies";
			break;
		case 27:
			storeType="Outlets";
			break;
		case 28:
			storeType="Party";
			break;
		case 29:
			storeType="Personalized";
			break;
		case 30:
			storeType="Pet";
			break;
		case 31:
			storeType="Retirement";
			break;
		case 32:
			storeType="Social";
			break;
		case 33:
			storeType="Sports";
			break;
		case 34:
			storeType="Travel";
			break;
		case 35:
			storeType="Wine";
			//break;
		}
		// This routine searches all TYPES of Stores (Every Merchant) for match of product name.
		findStore(storeType);
		aStoreCount = tableEntries[0];
		for (j=0;j<aStoreCount;j++)
		{
			aString = merchant[j];
			
			position = aString.indexOf("|");
			affiliateProgram = aString.substring(0,position);
			theLength = aString.length;
			aString = aString.substring(position+1,theLength);
			position = aString.indexOf("|");

			merchantLink = aString.substring(0,position);
			theLength = aString.length;
			aString = aString.substring(position+1,theLength);
			position = aString.indexOf("|");

			merchantName = aString.substring(0,position);
			theLength = aString.length;
			aString = aString.substring(position+1,theLength);
			merchantProducts = aString;
			
			aString = merchantProducts.toLowerCase();
			var aString1 = document.getElementById('searchArgument').value.toLowerCase();
			position = aString.indexOf(aString1);
			if (position >= 0)
			{
				workingString = aString.substring(0,position);
				workingString1 = aString.substring(position,aString.length);
				workingString = workingString+"<font color='#FF6347' size='3'>";
				position = workingString1.indexOf(',');
				
				if (position == -1)
				{
					workingString = workingString + workingString1.substring(0,workingString1.length);
					workingString = workingString+"</font>";
				}
				else
				{
					workingString = workingString + workingString1.substring(0,position);
					workingString = workingString+"</font>";
					workingString = workingString + workingString1.substring(position,workingString1.length);
				}
				aString = workingString;
					directoryTable = directoryTable +"<TR>";
					directoryTable = directoryTable +"<TD align='left' width='200' valign='top'><a href="+merchantLink+" class='merchantNameSelect' target='_blank'><span style='font-size: 10pt; color: blue; font-variant: small-caps; font-family: arial rounded mt;'><B>"+merchantName+"</B></span></a></TD>";
					directoryTable = directoryTable +"<TD align='left' width='150' valign='top'><span style='font-size: 10pt; color: #1A80DB; font-variant: small-caps; font-family: arial rounded mt;'>"+storeType+"</span></a></TD>";
					directoryTable = directoryTable +"<TD align='left' width='550' valign='top'><span style='font-size: 10pt; color: #1A80DB; font-family: arial rounded mt;'>"+aString+"</span></a></TD>";
					directoryTable = directoryTable +"</TR>";
			}
		}
	}
		directoryTable = directoryTable +"</TABLE>";
		document.getElementById('storeList').innerHTML = directoryTable;
		document.getElementById('searchButton').style.visibility = 'visible';
}
function showHowToShop(e) 
{
var height = e.clientY + parseInt('5');
    
     var offsetHeight = parseInt(e.offsetY);	// Get the height inside the clicked image
     height = height - offsetHeight;
     var width = e.clientX;			// Get the click location(width)
     var offsetWidth = parseInt(e.offsetX);		// Get the width inside the clicked image
     width = width - offsetWidth;
     var div = document.getElementById('tooltip');
     div.style.position = 'absolute';
     div.style.top = parseInt(height) + parseInt('20');	// Set the div top to the height 
     div.style.left = parseInt(width) + parseInt('20');	// Set the div Left to the height 
   	div.style.display  = "block";
   	div.innerText = txt;
   	div.style.visibility  = "";
}
function hideHowToShop() 
{
  document.getElementById("tooltip").style.display = "none";
}

document.onmousemove = tt_mouse_move;		// detect the mouse position and move the text

function tt_mouse_move(e) 
{
  var posx = 0;
  var posy = 0;

  if (e == null) { e = window.event; 
  }
  	if (e.pageX | e.pageY) 
  	{
	    posx = e.pageX;
	    posy = e.pageY;
  	}
  	else if (e.clientX | e.clientY) 
  	{
    	if (document.documentElement.scrollTop) 
    	{
      		posx = e.clientX+document.documentElement.scrollLeft;
      		posy = e.clientY+document.documentElement.scrollTop;
    	}
    	else 
    	{
      		posx = e.clientX+document.body.scrollLeft;
      		posy = e.clientY+document.body.scrollTop;
    	}

  }
  document.getElementById('tooltip').style.top = (posy+15)+"px";
  document.getElementById('tooltip').style.left = (posx+15)+"px";
}
