/*
 This set of source codes is protected by international copyright laws...
 No copying is allowed. 
 http://www.mp34store.com
 Copyright (C) 2007. All Rights Reserved.
 Version: NE 0.90a
*/
    var aSearchResult=new Array();
		var nNoOfSR_items=0;
		var nSearchPagePointer=0,nDisplayItemIndex=0;
		var szSpecialSignal1="@ENG@";
		var gnFramed=0;
		
		


    function myCharCodeAt(text,position) {
        var tmp = text.substring(position,position+1);
        for (var i=1;i<=255;i++) {
            if (unescape('%' + i.toString(16)) == tmp)
                return i;
        }
        return 0;
    }

		
		function strcmp(szA,szB)
		{
		   var nCount=0;
			 var nLen;
			 var nDiff;
			 
			 nLen=(szA.length>szB.length)?szA.length:szB.length;
			 
			 while (nCount<nLen)
			 {
			     nDiff=myCharCodeAt(szA,nCount)-myCharCodeAt(szB,nCount);
           //nDiff=szA.substr(nCount,1).valueOf()-szB.substr(nCount,1).valueOf();
					 //document.write(nDiff);
					 
			     if (nDiff<0) return -1;
			     if (nDiff>0) return 1;					 

					 nCount++;
					 // case nDiff==0 just continue
			 }				
			 if (szA.length>szB.length) return 1;
			 if (szA.length<szB.length) return -1;
			 return 0;			 
		}
	
		
		function ContainsSearchString(szRecordDesc,szSearchString1,szSearchString2,szSearchString3,szSearchString4)
		{
		 		 // Handle just one string first....expand slowly in future....
				 var nRecordDescLength;
				 var nLen1,nLen2,nLen3,nLen4;
				 //var nDescLength1,nDescLength2,nDescLength3,nDescLength4;
				 var nTerminate1,nTerminate2,nTerminate3,nTerminate4;

				 nRecordDescLength=szRecordDesc.length;

				 //nTerminate=2+nRecordDescLength-nDescLength;

				 if (szSearchString1!=null)
				 { 
				 		nLen1=szSearchString1.length;
				 		nTerminate1=3+nRecordDescLength-nLen1;
				 }						
				 if (szSearchString2!=null)
				 { 
				 	  nLen2=szSearchString2.length;
				 		nTerminate2=3+nRecordDescLength-nLen2;						
				 }
				 if (szSearchString3!=null)
				 { 
				 		nLen3=szSearchString3.length;
				 		nTerminate3=2+nRecordDescLength-nLen3;						
				 }
				 if (szSearchString4!=null)
				 { 
				 		nLen4=szSearchString4.length;
				 		nTerminate4=2+nRecordDescLength-nLen4;						
				 }				 
				 //document.write("Searching for :"+szSearchString1+"<br>");
				// document.write(nLen1,nLen2);
				 
         for (var nZZZZ=0;nZZZZ<nTerminate1;nZZZZ++)
				 {			 
				 		 if (szRecordDesc.substr(nZZZZ,nLen1)==szSearchString1)
						 {
						   if (szSearchString2==null)
							 {
							 	  return 1;
							 }
							 else
							 {							    
         			 		 for (var nZZZZZ=0;nZZZZZ<nTerminate2;nZZZZZ++)
				           {		
									     						 
          				 		 if (szRecordDesc.substr(nZZZZZ,nLen2)==szSearchString2)
          						 {
											 	  //document.write("----"+szRecordDesc+"<br>");	
											    //document.write("<br>123");		
            						  if (szSearchString3==null)
            							{
															//			 document.write("<br>123");													
            							 	  return 1;
            							}			
													else
												  {			
                     			 		 for (var nZZZZZZ=0;nZZZZZZ<nTerminate3;nZZZZZZ++)
            				           {																		 				
                  				 		 		if (szRecordDesc.substr(nZZZZZZ,nLen3)==szSearchString3)
                  						 		{
                      						   if (szSearchString4==null)
                      							 {																 
                      							 	  return 1;
                      							 }
                      							 else
                      							 {																		
                               			 		 for (var nZZZZZZZ=0;nZZZZZZZ<nTerminate4;nZZZZZZZ++)
                      				           {																		
                              				 		 		if (szRecordDesc.substr(nZZZZZZZ,nLen4)==szSearchString4)
                              						 		{																																		
                  						 		 	 					      return 1;	
																							}
																				 }																	
																		 }
        													}																				 			
															 }
													 }																			
          						 }										 
									 }
							 }																					
						 }							 		 
				 }				 
				 
				 return 0;													 // not found 
		}
		
		function DisplayProductInfo(szProductCode,nColsPerRow,bDisplaySH,nIndexNo)
		{
 		    var nHeightSize,nDiff,nPercent,nSellingPrice,nListedPrice,nProductStatus,nSAH;
				var szProductDesc,szProductCode,szPicPath;		
				
		    // Determine height-size here
			  nHeightSize=100;
        
				if ((nRV=SearchMP34ByItemCode(szProductCode))>=0)
        {
            document.write("<span style='color:black'>");
					  szPicPath=Column[(nRV*nRecordSize)+0];
					  szProductDesc=Column[(nRV*nRecordSize)+1];
					  szProductCode=Column[(nRV*nRecordSize)+2];
					  nProductStatus=Column[(nRV*nRecordSize)+20];
					  nSellingPrice=Column[(nRV*nRecordSize)+5];
					  nSAH=Column[(nRV*nRecordSize)+6];						
						nListedPrice=Column[(nRV*nRecordSize)+19];
  					nDiff=nListedPrice-nSellingPrice;
  					nPercent=nDiff/Column[(nRV*nRecordSize)+19];
  					nPercent*=100;
				}
			  else
				{
						if ((nRV=SearchOPByItemCode(szProductCode))>=0)
            {
                document.write("<span style='color:black'>");
    					  szPicPath=aFMD[(nRV*aRecordSize)+5];
    					  szProductDesc=aFMD[(nRV*aRecordSize)+0];
    					  szProductCode=aFMD[(nRV*aRecordSize)+4];
    					  nProductStatus=aFMD[(nRV*aRecordSize)+7];
    					  nSellingPrice=aFMD[(nRV*aRecordSize)+1];
    					  nSAH=aFMD[(nRV*aRecordSize)+2];						
    						nListedPrice=aFMD[(nRV*aRecordSize)+3];
      					nDiff=nListedPrice-nSellingPrice;
      					nPercent=nDiff/aFMD[(nRV*aRecordSize)+3];
      					nPercent*=100;		
						}
						else
						{
						    // Not supposed to have an else
						}		
				}
//document.write(" "+nIndexNo);  					
					 if (nColsPerRow==2)
					 {
					 		if ((nIndexNo%2)==0) document.write("</tr><tr>");
					 }	
/*					 
					 else 
					     document.write("<tr>");
*/							 		
																	
					 document.write('<td ><a target="_top" href="Desc_frame.htm?A'+szProductCode+'"><img src="'+szPicPath+'" height='+nHeightSize+'></a></td><td style="background-color:lightyellow">');
           document.write("<span style='font-size:14px'>"+szProductDesc+"</span>");
           document.write("<br><span style='font-size:13px;color:black'>");			
           document.write("<b>Item Code :</b> "+szProductCode+"<br> Status: ");
				 
					if ((nProductStatus==1)||(nProductStatus==2))
							document.write("<span style='color: blue'><b>"+GetStatusDescription(nProductStatus)+"</b></span>"+"<br>");
					else	
							document.write("<span style='color: red'><b>"+GetStatusDescription(nProductStatus)+"</b></span>"+"<br>");
																
           document.write("<b>Listed Price :</b> "+"US$"+nListedPrice+"<br>");															
           document.write("<b>Your Price :</b> "+'<span style="color:blue">'+"<u>US$"+nSellingPrice+"</u></span>"+" (save "+"<span style='color:red'>"+nPercent.toFixed(2)+"% "+"<span style='color:black'>"+" or "+"</span>"+"US$"+nDiff.toFixed(2)+"</span>"+")<br>");			
           if (bDisplaySH) 
						 document.write("<b>Ship+Handle:</b> "+'<span style="color:green">'+"<u>US$"+nSAH+"</u>");
					 else
					 {
							//document.write("^^^");
					 }			
           //document.write("S&H : US$"+Column[(nRV*nRecordSize)+6]+"<br>");												
           document.write("</span><br>");																																
         document.write("<br></span></td>");		
			 if (nColsPerRow==2)
			 {
			 		if ((nIndexNo%2)==1) document.write("</tr>");
			 }	
			 else 
			 		document.write("</tr>");			 

				return 0;
		}		

	  function SortSearchResult(nField,bAscending)
		{
		 			 var nFoundIndex;
	 				 var aIndex=new Array();
					 var aKeyField= new Array();
					 var nA,nB,nC,nD,nTemp;
					 var bDebug=0;

					 if ((nField<0)||(nField>4)) return -1;
        		function SwapItems(ItemAIndex,ItemBIndex)
        		{
         				 var Temp;
        				 
								 //document.write(ItemAIndex+"^"+ItemBIndex+"<br>");
        				 Temp=aIndex[ItemAIndex];
        				 aIndex[ItemAIndex]=aIndex[ItemBIndex]; 
        				 aIndex[ItemBIndex]=Temp; 
        		}					 
						function DisplayArray()
						{
					 	 				 for (var ffff=0;ffff<nNoOfSR_items;ffff++)
					 					 {		
										 			document.write(" "+aIndex[ffff]+"("+aKeyField[aIndex[ffff]]+")");				
										 }
								 			document.write("<br>");														 
						}

					 //
					 // Insert data for fields
					 //

					var nTempv0,nTempv1,nTempv2,nTempv3,nTempv4,nTempv5,nTempv6,szTempv7;			
					var nTemp,nTemp1,nTemp2;							 
					 for (var uuu=0;uuu<nNoOfSR_items;uuu++)
					 {

							 aIndex[uuu]=uuu;
							 								
							 if ((nFoundIndex=SearchMP34ByItemCode(aSearchResult[uuu]))>=0)
							 {									
									// 0: Selling Price
									// 1: Savings
									// 2: Savings Percentage
									// 3: Selling + S/H
									// 4: Listed-Price 
									// 5: Product Description
									
									nTempv1=Column[(nFoundIndex*nRecordSize)+19];
									nTempv2=Column[(nFoundIndex*nRecordSize)+5];
									nTempv3=nTempv1-nTempv2;
									nTempv4=nTempv3/Column[(nFoundIndex*nRecordSize)+19];

									nTempv6=Column[(nFoundIndex*nRecordSize)+6];									
									nTempv5=nTempv1;  // supposed to be total-cost instead of listed-price
									szTempv7=Column[(nFoundIndex*nRecordSize)+1];


									switch(nField)
									{
									 	  case 0:
													 nTempv0=nTempv2;
													 break;
									 	  case 1:
													 nTempv0=nTempv3;
													 break;
									 	  case 2:
													 nTempv0=nTempv4;
													 break;
									 	  case 3:
													 nTempv0=nTempv5;																			// supposed to be nTempv5
													 break;
									 	  case 4:
													 nTempv0=szTempv7;
													 break;																							 													 													 													 
											default:
													// insert here
									}
									
									//aKeyField[uuu]=Column[(nFoundIndex*nRecordSize)+5]);
									aKeyField[uuu]=nTempv0;
									//alert(aKeyField[uuu]);
							 }
							 else
							 {
							 		 if ((nFoundIndex=SearchOPByItemCode(aSearchResult[uuu]))>=0)
									 {
									 		
											
    									// 0: Selling Price
    									// 1: Savings
    									// 2: Savings Percentage
    									// 3: Selling Price + S/H
    									// 4: Listed-Price 
    									
    									nTempv1=aFMD[(nFoundIndex*aRecordSize)+3];
    									nTempv2=aFMD[(nFoundIndex*aRecordSize)+1];
    									nTempv3=nTempv1-nTempv2;
    									nTempv4=nTempv3/aFMD[(nFoundIndex*aRecordSize)+3];
  										nTempv6=aFMD[(nFoundIndex*aRecordSize)+2];
	  									nTempv5=nTempv1;   // supposed to be total-cost instead of listed-price
											szTempv7=aFMD[(nFoundIndex*aRecordSize)+0];

												

											//nTemp=aFMD[(nFoundIndex*aRecordSize)+2]+" "+nTempv2+" "+nTempv5;
											
											
    									switch(nField)
    									{
    									 	  case 0:
    													 nTempv0=nTempv2;
    													 break;
    									 	  case 1:
    													 nTempv0=nTempv3;
    													 break;
    									 	  case 2:
    													 nTempv0=nTempv4;
    													 break;
    									 	  case 3:
    													 nTempv0=nTempv5;
    													 break;
    									 	  case 4:
    													 nTempv0=szTempv7;
															 //alert(nTempv0);
    													 break;													 													 													 													 
    											default:
    													// insert here
    									}
									    
											aKeyField[uuu]=nTempv0;
											//alert(aKeyField[uuu]);
									 }
									 else
									 {
									 		//
											document.write(aSearchResult[uuu]+" Error somewhere....record not found searching OP<br>")
											//
									 }
							 }
									  
					 		 // supposed to determine based on nField
							 //aKeyField[uuu]=;
					 }
					 //
					 //	 Sort Data
					 //
					 if (bDebug) DisplayArray();
			 
					 for (var pppp=0;pppp<(nNoOfSR_items-1);pppp++)
					 {
					 	   if (bDebug) document.write("================="+pppp+"=========<br>");
					 		 for (var qqqqq=0;qqqqq<(nNoOfSR_items-pppp-1);qqqqq++)
					 		 {
							     nTemp=aKeyField[aIndex[qqqqq]];
							 	   nA=nTemp.valueOf();
									 nTemp=aKeyField[aIndex[qqqqq+1]];
							     nB=nTemp.valueOf();

									 if (nField==4)
									 {
    									 if (bAscending)
											 {
    									    if (strcmp(nA,nB)<0) 
    												 nD=1;		
    											else
    											   nD=0;															 							 
											 }
											 else
											 {
    									    if (strcmp(nA,nB)>0) 
    												 nD=1;
    											else
    											   nD=0;													 
											 }									 
									 }
									 else
									 {
    									 if (bAscending)
    									    nC=nA-nB;										 		
    									 else
    									 		nC=nB-nA; 		
											 
											 if (nC<0)
											 		nD=1;
											 else
											    nD=0;
											 //if (nC>0)nC==1;								 
									 }
			
		 
							 		 if (nD)
									 {
										 if (bDebug)
										 { 
										     document.write(qqqqq+" *");
										     DisplayArray();				
										     document.write("["+nA+"<"+nB+"]");
										 }										 					 

									 	 SwapItems(qqqqq,qqqqq+1);
										 
										 if (bDebug)
										 { 
										     document.write(qqqqq+" =");
										     DisplayArray();
										 }
									 }
									 else
									 {
									   if (bDebug) document.write(qqqqq+" * No swap<br>");
//										 										 document.write("["+aKeyField[aIndex[qqqqq]]+">"+aKeyField[aIndex[qqqqq+1]]+"]");										 					 

									 }
							 }					 	
					 }
					 //
					 // Update aSearchResult[uuu]	
					 //
					 for (uuu=0;uuu<nNoOfSR_items;uuu++)
					 {
					 	   aKeyField[uuu]=aSearchResult[uuu];
					 }
					 
					 for (uuu=0;uuu<nNoOfSR_items;uuu++)
					 {
					 	   aSearchResult[uuu]=aKeyField[aIndex[uuu]];
					 }
					 					 
				 
		 			 return 0;
		}	
		
		function DisplaySearchResult(nDisplayMode)
		{
		 	  var nRV;
				var nDiff3,nPercent3;
		 		if ((nDisplayMode>2)||(nDisplayMode<0)) return -1;
				// 0: text
				// 1: graphical (150
				// 2: graphics with data

				if (nDisplayMode==0) document.write("<table style='background-color:white'><tr>");
        if (nDisplayMode==1) document.write("<table style='background-color:white'><tr>");				
        if (nDisplayMode==2) document.write("<table style='background-color:white'><tr>");
				
			  if (nDisplayMode==0) document.write("<tr style='color:red'><td>No</td><td>Product Code</td><td>Price</td><td>Savings<br>(US$)</td><td>Savings<br>(%)</td><td>Product Description</td></tr>");								     										
    		for (qqq=0;qqq<nNoOfSR_items;qqq++)
    		{
				 		  switch(nDisplayMode)
							{
							  case 0:
											 document.write("<tr><td>"+qqq+"</td>");
										 document.write("<td>"+aSearchResult[qqq]+"</td>");
										 //document.write(qqq+" "+aSearchResult[qqq]+" ");
										 if ((nRV=SearchMP34ByItemCode(aSearchResult[qqq]))>=0)
										 {
										   nDiff3=( +Column[(nRV*nRecordSize)+19] - +Column[(nRV*nRecordSize) +5]);
											 nPercent3= +nDiff3/ +Column[(nRV*nRecordSize)+19];
											 nPercent3*=100;
											 nPercent3 = nPercent3.toFixed(2);
											 nDiff3= +nDiff3.toFixed(2);
											 
										   document.write("<td><span style='color:green'>"+" US$"+Column[(nRV*nRecordSize)+5]+"</td>");
										   document.write("<td><span style='color:red'>"+" US$"+ nDiff3+"</td>");
										   document.write("<td><span style='color:red'>"+" "+ nPercent3+"%</td>");													 											 
										 	 document.write('<td><a target="_top" href="'+'Desc_frame.htm?A'+aSearchResult[qqq]+'">'+Column[(nRV*nRecordSize)+1]+'</a>');
										 }
										 else
										 {
  										 if ((nRV=SearchOPByItemCode(aSearchResult[qqq]))>=0)
  										 {
										    nDiff3=( +aFMD[(nRV*aRecordSize)+3] - +aFMD[(nRV*aRecordSize)+1]);
											  nPercent3= +nDiff3/ +aFMD[(nRV*aRecordSize)+3];
											  nPercent3*=100;
											  nPercent3 = nPercent3.toFixed(2);
											  nDiff3= +nDiff3.toFixed(2);
											 											 
										    document.write("<td><span style='color:blue'>"+" US$"+aFMD[(nRV*aRecordSize)+1]+"</td>");
										    document.write("<td><span style='color:red'>"+" US$"+ nDiff3+"</td>");
										    document.write("<td><span style='color:red'>"+" "+ nPercent3+"%</td>");																								 
  										 	document.write('<td><a target="_top" href="'+'frame_fmd.htm?A'+aSearchResult[qqq]+'">'+aFMD[(nRV*aRecordSize)+0]+'</a>');
  										 }
											 else
											 {
										    document.write("<span style='color:red'>");											 
											  document.write("Unknown");
											 }										 
										 }
										 document.write("</span></td><tr>");
										 break;
							  case 1:
										 var nMaxPerLine=5;
								     DisplayMP34NAccPicLinks3(aSearchResult[qqq],"",0,150);
										 if (qqq%nMaxPerLine==4) document.write("</tr><tr>");
										 break;
								case 2:
										 var nItemsPerPage=25;
										 DisplayProductInfo(aSearchResult[qqq],2,0,qqq);
										 break;
								default:										 
							}
           																
    		}

        if (nDisplayMode==2) document.write("</tr></table>");			
        if (nDisplayMode==1) document.write("</tr></table>");			
        if (nDisplayMode==1) document.write("</tr></table>");								
				
		}
				
		function SearchRecords(szSearchString)
		{
        if (szSearchString=="") return;
        
        var nNoRecords=0;
        var nCounter,nFound=0;;
				var nCountMP34,nCountOP;
				var szSearchString1,szSearchString2,szSearchString3,szSearchString4;
				var nNoSearchStrings;
				var bDisplayFound=0;
			  var bDisplay2=0;
			  var bDisplay3=1;				
				var bDisplay4=1;
				//
				//  Supposed to check szSearchString here and ensure only whole word included here
				//							
				function ExtractFromSearchString(szSearchString)
				{
				  var nStart,nEnd,nLenSearch;
					var szSearch=new Array("a","b","c","d");
					var bDisplay2=0;


					
					nLenSearch=szSearchString.length;
					nStart=0;
					nNoSearchStrings=0;
					nStart=0;					
					nEnd=0;
					//document.write(szSearchString+" ### "+nLenSearch+" !");
					/*
					var szTemp;					
					szTemp="*"+szSearchString+"*";
					alert(szTemp);
					*/
					while (nEnd<nLenSearch)
					{
					 			if (szSearchString.substr(nEnd,1)==" ")
								{
							     if ((nEnd-nStart)>0)
									 {
									     if (szSearchString.substr(nStart,nEnd-nStart)!=" ")					 
											 {
        								 	 szSearch[nNoSearchStrings]=szSearchString.substr(nStart,nEnd-nStart);
        								   // extract
        									 nNoSearchStrings++;
        									 nStart=nEnd+1;
											 }
											 else
											 {
											 	nStart=nEnd;
											 }
									 }
									 else
									 {
									 	  // Ignore one blank
									 }
								}
					  		nEnd++; 
					}
					// Need to handle special last string
					// From nStart to last character
					if (nStart!=nLenSearch)
					{
					   szSearch[nNoSearchStrings]=szSearchString.substr(nStart,nLenSearch-nStart);
					 	 nNoSearchStrings++;
					}					
					
					// Extract from array and update essential variables
					szSearchString1=szSearch[0];
					szSearchString1=szSearchString1.toLowerCase();
					if (nNoSearchStrings>=2)
					{ 
						 szSearchString2=szSearch[1];
						 szSearchString2=szSearchString2.toLowerCase();
					}
					if (nNoSearchStrings>=3)
					{ 
						 szSearchString3=szSearch[2];
						 szSearchString3=szSearchString3.toLowerCase();
					}
					if (nNoSearchStrings>=4)
					{ 
						 szSearchString4=szSearch[3];
						 szSearchString4=szSearchString4.toLowerCase();	
					}			
																
					

					if (bDisplay2)
					{
					  document.write("No of words : "+nNoSearchStrings);	
					  //document.write("<br>");
						for (ssss=0;ssss<nNoSearchStrings;ssss++)
  					{
  					 		document.write(ssss+"|"+szSearch[ssss]+"|<br>");
  					}
					}			
				}
				
				// Call extraction routine
				ExtractFromSearchString(szSearchString);
					
																			
				if (bDisplay4) document.write("<span style='color:darkgreen;font-size:12px'>To redisplay in another format or order, select your preference from the list-boxes and click on [Search] again...</span>");																												
				if (bDisplay3) document.write("<br>"+"Search results for : "+"<span style='color:red'>"+szSearchString+"</span>");
				if (bDisplay2) document.write("<br>-----------------------------<br>");
        for (nCounter=0;nCounter<mp3records.GetNoOfRecords();nCounter++)
        {
				 		szRecordDesc=Column[(nCounter*nRecordSize)+1];
						//document.write(szRecordDesc+"!"+szSearchString1);
						if (nNoSearchStrings==1)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=Column[(nCounter*nRecordSize)+2];
    							 nFound++;
    						}
						}
						else if (nNoSearchStrings==2)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=Column[(nCounter*nRecordSize)+2];									 
    							 nFound++;
    						}						
						}		        		
						else if (nNoSearchStrings==3)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2,szSearchString3)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=Column[(nCounter*nRecordSize)+2];									 
    							 nFound++;
    						}								
						}
						else if (nNoSearchStrings==4)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2,szSearchString3,szSearchString4)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=Column[(nCounter*nRecordSize)+2];									 
    							 nFound++;
    						}								
						}						
        }
				nCountMP34=nCounter-1;
        for (nCounter=0;nCounter<aNoRecords;nCounter++)
        {
				 		szRecordDesc=aFMD[(nCounter*aRecordSize)+0];
						//document.write(szRecordDesc+"!"+szSearchString1);
	
						if (nNoSearchStrings==1)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=aFMD[(nCounter*aRecordSize)+4];
    							 nFound++;
    						}
						}
						else if (nNoSearchStrings==2)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=aFMD[(nCounter*aRecordSize)+4];
    							 nFound++;
    						}						
						}		        		
						else if (nNoSearchStrings==3)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2,szSearchString3)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=aFMD[(nCounter*aRecordSize)+4];
    							 nFound++;
    						}								
						}
						else if (nNoSearchStrings==4)
						{
        		 		if (ContainsSearchString(szRecordDesc.toLowerCase(),szSearchString1,szSearchString2,szSearchString3,szSearchString4)==1)
    						{
    						 	 if (bDisplayFound) document.write("["+nFound+"] "+nCounter+" "+szRecordDesc+" <br>");
									 aSearchResult[nFound]=aFMD[(nCounter*aRecordSize)+4];
    							 nFound++;
    						}								
						}							
								
				}			
				nNoOfSR_items=nFound;
				
				nCountOP=nCounter-1;	

				if (bDisplay2) document.write("<br>-----------------------------<br>");
				if (bDisplay3) document.write("<br>"+nFound+" record/s found....");				
				if (bDisplay2) document.write("<br>End of search for "+"<span style='color:blue'>"+nCountMP34+"</span>"+" MP3/MP4 records and "+"<span style='color:blue'>"+nCountOP+"</span>"+" OP records");
				
				//
				// Display search result
				//				

/*				
				document.write('<br>');
        document.write("<table><tr>");					
				for (i=0;i<nNoOfSR_items;i++)
				{
         				DisplayMP34NAccPicLinks(aSearchResult[i],"",0,150);																
				}
        document.write("</tr></table>");
*/											
		}				
	
	
            function DisplayExternalSearchTable(nFramed,bRight,bLower)
            {   											 
						    gnFramed=nFramed;
								
								if (bRight==null) bRight=0;
								if (bLower==null) bLower=0;
								    
            		//document.write('<FORM enctype="text/plain"  method=POST name=form2 action=""> ');
								if (bLower){ 
									 document.write("<center><table style='border-width:5px;border-style:solid;border-color:blue;color:black'><tr><td>");
									 document.write("<tr><td style='background-color:red;color:white'><center>Product<br>Search-Box</center></td></tr><tr><td>");
								}
								
								//document.write("<span style='color:black'>Search Box:<br></span:"); 
								if (bRight) document.write("<div style='float:right;align:right;width=140px'>");	            		
								document.write('<INPUT TYPE="text"  SIZE="17" maxlength="30" id="SearchBox1b" onChange="DisplaySearchB()" >');
								if (bLower) document.write("<br>");								

								//document.getElementById("SearchBox").value=szOptionS;
						
            		document.write('<INPUT TYPE="button" value="Search" onClick="DisplaySearchB()">');
								if (bLower) document.write("</td></tr></table></center><br>");
								if (bRight) document.write('</div>');
            		//document.write('<INPUT TYPE="text" value="" SIZE=1  maxlength="1" name="SearchBox2" onChange="">');

																	
            		//document.write('</FORM>');
								 
            }
/*						
						// old one
            function DisplaySearchB()
            { // 0 originally without frame , 1 originally with frame 
						    var bAscending=0;
								var nField;
								var bDisplayStyle;
																

            		//szSearchString=document.form2.SearchBox.value;
								//alert(SearchBox1b.value);
            		szSearchString=SearchBox1b.value;
								nField=0;
								bAscending=1;					
								bDisplayStyle=0;												
								
    						var szNewSearch;		
							
							 	
								//szNewSearch="Search_Products.htm?S='"+szSearchString+"'";
								if (gnFramed==0)
								{						
									 szNewSearch="frame2_SearchProducts.htm?S='"+szSearchString+"'";
								}
								else								
									 szNewSearch="Search_Products.htm?S='"+szSearchString+"'";
														

								szNewSearch+=(",O='"+nField+"'");							
								szNewSearch+=(",A='"+bAscending+"'");
								szNewSearch+=(",D='"+bDisplayStyle+"'");
																																	
    						window.location=szNewSearch;  								
            }
*/						
						// new one
            function DisplaySearchB()
            { // 0 originally without frame , 1 originally with frame 
              var bAscending=0;
              var nField;
              var bDisplayStyle;
              var szNewSearch,szTemp;	
              var bFoundSearchValue=0;
              var szSearchValue;
              var links = document.getElementsByTagName("input");
          
              for (var j = 0; j < links.length; j++) 
              {
                //szTemp="*"+links[j].className+"*"+TabLink+"#";
                //szTemp="*"+j+" "+links[j].id+"*"+"______"+"#";
                //alert(szTemp);
                if (links[j].id=="SearchBox1b")
                {
                   bFoundSearchValue=1;
                   szSearchValue=links[j].value;
                }            
              }    
          
              szSearchString=szSearchValue;
              //alert("post string assignment");
              nField=0;
              bAscending=1;					
              bDisplayStyle=1;												
          
          	
          
              //alert("before path");	
              if (gnFramed==0)
              {						
              		szNewSearch="frame2_SearchProducts.htm?S='"+szSearchString+"'";
              }
              else								
                  szNewSearch="Search_Products.htm?S='"+szSearchString+"'";
          				
              //alert("Post path");	
              szNewSearch+=(",O='"+nField+"'");							
              szNewSearch+=(",A='"+bAscending+"'");
              szNewSearch+=(",D='"+bDisplayStyle+"'");
          		//alert(szNewSearch);												
              window.location=szNewSearch;  								
            }
          						
/*
 This set of source codes is protected by international copyright laws...
 No copying is allowed. 
 http://www.mp34store.com
 Copyright (C) 2007. All Rights Reserved.
 Version: NE 0.90a
*/										