
	var arrayTagPosition = new Array();	
	var vCounter=0;
	var vNoOfInstances=0;
	var vStart=0;
	var vEnd=0;
	var vStartText= "<H6>";
	var vEndText = "</H6>";
	var vFoundItem;
	var vFoundItemEdited;
	var vNewLabelContents="";
	var vInfo="Click here for pricing";
		
	function myFunction() 
	{ 
		var vTableToParse ;
		
		if (document.getElementById('layer-for-table') != null)
		{
			vTableToParse = document.getElementById('layer-for-table').innerHTML;
			CountInstances(vTableToParse)
			if (vCounter !=0) 
			{
				CreateArrays(vCounter)
				ParseText(vTableToParse)
			}
		}		
	}
		
	function CountInstances(labelContents)
	{
	    labelContents = labelContents.toUpperCase();
		while (labelContents.indexOf(vStartText,vStart)!= -1) 
		{		
			vStart = labelContents.indexOf(vStartText,vStart ); 
			vStart= vStart + 4;
			vCounter++;
		}	
	}
	
	function CreateArrays(vCounter)
	{
		for (i = 0; i < vCounter; ++ i)
		{
			arrayTagPosition [i] = new Array();
		}
	}
		
	function ParseText(labelContents)
	{
		var vArrayCounter=0;
		var CurrentPrice;
		var sUrl;
		vStart=0;
        var vOriginalLabelContents = labelContents;
        
        labelContents = labelContents.toUpperCase();
        
		while (labelContents.indexOf(vStartText,vStart)!= -1) 
		{
			vStart = labelContents.indexOf(vStartText,vStart )+4; 
			vEnd = labelContents.indexOf(vEndText,vStart);
			vFoundItem = labelContents.slice(vStart,vEnd);
		    
			//alert("vInfo = " + vInfo);
			
			//vFoundItem = "<A href=JavaScript:OpenWin('"+ vFoundItem + "') onMouseOver=" + String.fromCharCode(34) + "Tip('" + vInfo + "', BALLOON, true, ABOVE, true)" + String.fromCharCode(34) + " onMouseOut=UnTip() >" + vFoundItem + "</A>";
			vFoundItem = "<A href=JavaScript:OpenWin('"+ vFoundItem + "') onMouseOver=" + String.fromCharCode(34) + "DoRollover('" + vFoundItem + "')" + String.fromCharCode(34) + " onMouseOut=UnTip() >" + vFoundItem + "</A>";
			arrayTagPosition[vArrayCounter][0]= vStart;
			arrayTagPosition[vArrayCounter][1]= vEnd;
			arrayTagPosition[vArrayCounter][2]= vFoundItem;
				
			vArrayCounter++;
			vStart= vEnd;	
 		}
			
		vStart=0;
		
		for (i = 0; i < vCounter; ++ i)
		{
			vNewLabelContents = vNewLabelContents+vOriginalLabelContents.slice(vStart,arrayTagPosition[i][0]) + arrayTagPosition[i][2];
			vStart=arrayTagPosition[i][1];
		}
		
		vNewLabelContents = vNewLabelContents+vOriginalLabelContents.slice(vStart,labelContents.length)			
		document.getElementById('layer-for-table').innerHTML=vNewLabelContents;
	}
		
	function OpenWin(x) 
		{ 
			window.open("https://www.crawfordscientific-secure.com/csci/advanced_search_result.php?keywords=" + x +"&search_in_description=1&x=8&y=6");
		}
		
	function DoRollover(vFoundItem)
	{
		sURL = "getPrice.asp?partNum=" + vFoundItem;
		fn_Ajax_GetData('layer-price',sURL)


		if (vInfo=="undefined" )
		{

			fn_Ajax_GetData('layer-price',sURL);
			Tip(vInfo , BALLOON, true, ABOVE, true);
		}
		else
		{
			Tip(vInfo , BALLOON, true, ABOVE, true);
		}
		
	}
	
	function fn_Ajax_GetData(eRef, sUrl)
	{  
		var xhr; 
			
			try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
			catch (e) 
			{
				try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
				catch (e2) 
				{
				  try {  xhr = new XMLHttpRequest();     }
				  catch (e3) {  xhr = false;   }
				}
			 }
		  
			xhr.onreadystatechange  = function()
			{ 
				 if(xhr.readyState  == 4)
				 {
					  if(xhr.status  == 200) 
						  //alert(xhr.responseText); 
						  vInfo = xhr.responseText;
						  //Tip(xhr.responseText , BALLOON, true, ABOVE, true)
		
				 }
			}; 
		
		   xhr.open('GET', sUrl, true); 
		   xhr.send(null); 
	}
		
	
	
	
	
	// *************** MM Functions 
	function getRadio()
	{
	    var e = document.getElementsByName("radio");
		var i = getSelectedButton(e);
		
		if (e[i].value=="searchecom")
		{
				doSearch2();
		}
		else
		{
				doSearch();
		}
	}
    
    function getSelectedButton(buttonGroup){
		for (var i = 0; i < buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
				return i;
			}
		}
		return 0;
	}
	
	function doSearch()
	{
		e = document.getElementById("txt_search_ecom");
		document.location.href="search3.asp?target=" + e.value;
	}

	function doSearch2()
	{
	    e = document.getElementById("txt_search_ecom");
		OpenWin(e.value)
	}
	//**************** End of MM Functions




    function old_getRadio()
	{
		//alert("1");
		//alert(document.frm_ecom('radio').value);
		//alert(document.getElementById('radio').value);
	
		var i = getSelectedButton(document.frm_ecom('radio'));
    	//alert("You chose " + document.frm_ecom('radio')[i].value + ".");
	
		
		//alert()
		//alert("2");
		if (document.frm_ecom('radio')[i].value=="searchecom")
		{
				doSearch2();
		}
		else
		{
				doSearch();
		}
	}	
	
	
	function old_getSelectedButton(buttonGroup){
		for (var i = 0; i < buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
				return i;
			}
		}
		return 0;
	}

	function old_doSearch()
	{
		////document.form1.action = "secure-page2.asp?pdfToView=<% 'Response.Write Request("pdfToView") %>"
		////document.frm_ecom.action = "search3.asp?target=" + document.getElementById('txt_search_ecom').value;
		
		//document.frm_ecom.action = "search3.asp?target=pump"
		document.location.href="search3.asp?target=" + document.frm_ecom('txt_search_ecom').value;
		////document.frm_ecom.action = "search3.asp?target=" + document.frm_ecom('txt_search_ecom').value;
		////document.frm_search('formStatus').value=vStatus;
        //document.frm_ecom.submit(); 
	}

	function old_doSearch2()
	{
		//document.form1.action = "secure-page2.asp?pdfToView=<% 'Response.Write Request("pdfToView") %>"
		//alert("x");
		
		OpenWin(document.frm_ecom('txt_search_ecom').value)
		//document.frm_ecom.submit(); 
		//document.frm_ecom.action = "https://www.crawfordscientific-secure.com/csci/advanced_search_result.php?keywords=" + document.frm_ecom('txt_search_ecom').value +"&search_in_description=1&x=8&y=6" ;
		//document.frm_ecom.action = "_target" ;
        //document.frm_ecom.submit(); 
	}

	function clearDefault(el)
	{
  		if (el.defaultValue==el.value) el.value = ""
	}
