var szaBargain=new Array("10030700","10260510","10070100","10070300","10413020",/*"10413150"*/"10413110",/*"10413120"*/"10384000",/*"10042010"*/"10042040");
var szaBestBuy=new Array("10260510","10070300","10413110","10413020","10042040","10387140","10384000","10035510","10255010","10226010","10036420","10036510");
var szaRecommendedBuys=new Array("10070300","10070100","10260510","10413020","10435510","10387120","10387212","10388100",/*"10413150"*/"10413110",/*"10413120"*/"10384000",/*"10042010"*/"10042040","10042050");
var szaRecommendedMP34=new Array("10070300","10070100","10260510");
var szaRecommendedOP=new Array("10413020","10435510","10387120","10387212","10388100",/*"10413150"*/"10413110",/*"10413120"*/"10384000",/*"10042010"*/"10042040","10042050");
var szaRecommendedIPA=new Array("10388100","10384000","10435510");


															 																 


var szaSales2=new Array("10413020","10121020");


function DisplayBargainProducts(nToShow,nDBPMode)
{	
     var szSelectedItemNo;
    var nSelectedArrayLen;
    var szPromoTitle;
    
     // nToShow
     // 0 This weeks promo
    // 1 Bestbuys of each category
    // 2 Recommended Buys
    // 3 Recommended MP3/MP4
    // 4 Recommended Other Products
    // 5 Recommende Ipod accessories
    
    if ((nToShow<0)||(nToShow>5))
    {
     alert("Invalid parameter for DisplayBargainProducts():nToShow...");
    return -1;
    }
    
    // nDBPMode
    // 0 all
    // 1 MP3 only
    // 2 OP only
    if ((nDBPMode<0)||(nDBPMode>2))
    {
     alert("Invalid parameter for DisplayBargainProducts():nDBPMode...");
    return -1;
    }				
    
    // nToShow
     // 0 This weeks promo
    // 1 Bestbuys of each category
    // 2 Recommended Buys
    switch(nToShow)
    {
      case 0:
          nSelectedArrayLen=szaBargain.length;
    			szPromoTitle="This weeks Promotion";
     			break;
      case 1:
          nSelectedArrayLen=szaBestBuy.length;
    			szPromoTitle="Best-Buys of every category";
     			break;
      case 2:
          nSelectedArrayLen=szaRecommendedBuys.length;    
    			szPromoTitle="Recommended Buys";
     			break;			
      case 3:
          nSelectedArrayLen=szaRecommendedMP34.length;    
    			szPromoTitle="Recommended Buys (MP3/MP4 Players)";
     			break;			
      case 4:
          nSelectedArrayLen=szaRecommendedOP.length;    
    			szPromoTitle="Recommended Buys (Other Products)";
     			break;			
      case 5:
          nSelectedArrayLen=szaRecommendedIPA.length;    
    			szPromoTitle="Recommended iPod Accessories";
     			break;																																																						
     default:
          alert("Parameter not handled [DisplayBargainProducts():nToShow]...");
    			return -1;
    }		
      document.write('<table style="border-color:0000ff;border-width:10px;border-style:solid">');
          document.write('<tr><th style="background-color:ff0000;color:white;font-size:14px">'+szPromoTitle+'</th></tr>');    					
    
          for (www=0;www<nSelectedArrayLen;www++)
          {	           
    
    						  switch(nToShow)
    							{
    							   case 0:
    				 			szSelectedItemNo=szaBargain[www];
    								 			break;
    							   case 1:
    				 			szSelectedItemNo=szaBestBuy[www];
    							break;
    							   case 2:
    				 			szSelectedItemNo=szaRecommendedBuys[www];
    								 			break;					
    							   case 3:
    				 			szSelectedItemNo=szaRecommendedMP34[www];
    								 			break;	
    							   case 4:
    				 			szSelectedItemNo=szaRecommendedOP[www];
    								 			break;		
    							   case 5:
    				 			szSelectedItemNo=szaRecommendedIPA[www];
    								 			break;																																																														
    								 default:
    								      alert("Parameter not handled [DisplayBargainProducts():nToShow]...");
    											return -1;
    							}												
    			
    			     						    
    			 		if (szSelectedItemNo.substr(4,1)=="0")
    					{
    			  if ((nDBPMode==0)||(nDBPMode==1))  
    				{
    			   document.write('<tr style="background-color:yellow;">');
          				   nMP3MP4Index=SearchMP34ByItemCode(szSelectedItemNo);
    					   if (nMP3MP4Index>=0)
          					 {									
    
    						    nListPrice=Column[(nMP3MP4Index*nRecordSize)+19];
    						    nSalesPrice=Column[(nMP3MP4Index*nRecordSize)+5];
    						    nDifference=nListPrice-nSalesPrice;
    								nPercent=(nDifference/nListPrice)*100;
    								szDescription=Column[(nMP3MP4Index*nRecordSize)+1];
    								szPicPath=Column[(nMP3MP4Index*nRecordSize)+0];
    						
          				      document.write('<td  valign=top width="20%" align=center style="padding: 10px;color:darkblue;font-size:10px;line-height:12px;border-width:0px">');
    								//');
                 				document.write('<br><span width="20%" style="font-size:12;"><b>'+szDescription+"</b><br>");
    								document.write('<a href="http://www.mp34store.com/Desc_frame.htm?A'+szSelectedItemNo+'"><img src="'+szPicPath+'" width="150px"></a>');
    							document.write('<br>Only <u style="color:blue">US$'+nSalesPrice+'</u><br><b style="color:red">save '+nPercent.toFixed(1)+'%</b></span>');																																											 
    								
    								document.write('');
    								document.write('</td>');
    					
    						 }
    						 else
    						 {
    						 	  szErrorMsg= szSelectedItemNo;
    								szErrorMsg+=" not found in database...";
    						 	  alert(szErrorMsg);
    						 }
    				}										 										 
    					} // if	(szaBargain[www].substr(4,1)=="0")
    					else
    					{
    			  if ((nDBPMode==0)||(nDBPMode==2))
    				{  
    			   document.write('<tr style="background-color:yellow;">');
          				   nOtherIndex=SearchOPByItemCode(szSelectedItemNo);
    					   if (nOtherIndex>=0)
          					 {									
    						    nListPrice=aFMD[(nOtherIndex*aRecordSize)+3];
    						    nSalesPrice=aFMD[(nOtherIndex*aRecordSize)+1];
    						    nDifference=nListPrice-nSalesPrice;
    								nPercent=(nDifference/nListPrice)*100;
    								szDescription=aFMD[(nOtherIndex*aRecordSize)+0];	
    								szPicPath=aFMD[(nOtherIndex*aRecordSize)+5];															
          				      document.write('<td  valign=top width="20%" align=center style="padding: 10px;color:darkblue;font-size:10px;line-height:12px;border-width:0px">');
    								//');
                 				document.write('<br><span width="20%" style="font-size:12;"><b>'+szDescription+"</b><br>");
    								document.write('<a href="http://www.mp34store.com/frame_fmd.htm?A'+szSelectedItemNo+'"><img src="'+szPicPath+'" width="120px"></a>');
    							document.write('<br>Only <u style="color:blue">US$'+nSalesPrice+'</u><br><b style="color:red">save '+nPercent.toFixed(1)+'%</b></span>');																																											 
    								
    								document.write('');
    								document.write('</td>');
    					
    						 }
    						 else
    						 {
    						 	  szErrorMsg= szSelectedItemNo;
    								szErrorMsg+=" not found in database...";
    						 	  alert(szErrorMsg);
    						 }
    				}											
    					}	
    
    		  document.write('</tr>');
    		} // for(;;)
    	document.write('</table>');
}

function DisplayCategoryData(nChosenCategory,nMode)
{
		var diff, nStockStatus;
		var nCategory;



					
		nCategory=nChosenCategory;
								
		document.write("<table style='background-color:white;border-color:blue;border-width:5px;border-style:solid;font-size:14px'>");
		document.write("<tr><td colspan=2 align=center style='background-color:cyan;color:blue;border-width:0px;padding:0'><b>"+aCategory[nCategory]+"</b></td></tr><tr>");
		for (i=0;i<aNoRecords;i++)
		{
		
//								if ((aFMD[(i*aRecordSize)+8].valueOf()==nCategory)||(aFMD[(i*aRecordSize)+4].substr(5,1).valueOf()=='9'))
				if (aFMD[(i*aRecordSize)+8].valueOf()==nCategory)
				{
									
     						 nStockStatus=aFMD[(i*aRecordSize)+7].valueOf();
         				 document.write("<tr style='border-width:3px;border-style:solid;border-color:red;'>");


    						 document.write("<td  style='border-color:black;border-width:1px'>");

						 if ((aFMD[(i*aRecordSize)+12].valueOf()==1)||(aFMD[(i*aRecordSize)+13].valueOf()==1))
						 {				
				 					document.write("<div class='float9a' align=right>");						 
					 
                      if (aFMD[(i*aRecordSize)+12].valueOf()==1)
                      {
                      	document.write("<img src='awards/OnSale.GIF'>");
                      }
					 				
                      if (aFMD[(i*aRecordSize)+13].valueOf()==1)
                      {
                       	 document.write("<img src='awards/BestBuy.JPG'>");
                      
                      }													 
				 					document.write("</div>");						 
						 }
						 document.write("<u><b style='color:blue'>"+aFMD[(i*aRecordSize)+0]+"</b></u><br><br>");
						 
    						 document.write(" <b>Product ID: </b><u>"+aFMD[(i*aRecordSize)+4]+"</u> ");
    						 document.write("<span style='color:green'>"+GetStatusDescription(nStockStatus)+"</span><br>");
    						 document.write(" <b>List Price: </b>"+"<span style='color:black'>"+"US$"+aFMD[(i*aRecordSize)+3]+"</span><br>");
    						 diff=aFMD[(i*aRecordSize)+3].valueOf();
    						 diff-=aFMD[(i*aRecordSize)+1].valueOf();
    						 diff/=aFMD[(i*aRecordSize)+3].valueOf();
    						 diff*=100;

    						 document.write(" <b>Your Price: </b>"+"<span style='color:blue'><u>"+"US$"+aFMD[(i*aRecordSize)+1]+"</u></span> "+"(<span style='color:red'>save "+diff.toFixed(0)+"%</span>)<br>");
    						 document.write(" <b>Shipping & Handling: </b>1st: "+"<span style='color:blue'><u>"+"US$"+aFMD[(i*aRecordSize)+2]+"</u></span>"+" >=2nd: "+"<span style='color:blue'><u>"+"+US$"+aFMD[(i*aRecordSize)+6]+"</u></span> each<br>");
         				 document.write("<br>");
						 						 
    					   if ((nStockStatus==1)||(nStockStatus==2))
    						 {
    									 document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it is fast, free and secure!"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"><input type="hidden" name="add" value="1"><input type="hidden" name="cmd" value="_cart"><input type="hidden" name="business" value="sales@mp34store.com"><input type="hidden" name="item_name" value="');
    									 document.write(aFMD[(i*aRecordSize)+0]+'">');			 
    									 document.write('<input type="hidden" name="item_number" value="');
    									 document.write(aFMD[(i*aRecordSize)+4]);
    									 document.write('"><input type="hidden" name="amount" value="');
    									 document.write(aFMD[(i*aRecordSize)+1]);
    									 document.write('"><input type="hidden" name="shipping" value="');									 
    									 document.write(aFMD[(i*aRecordSize)+2]);
    									 document.write('"><input type="hidden" name="shipping2" value="');
    									 document.write(aFMD[(i*aRecordSize)+6]);
    									 document.write('"><input type="hidden" name="no_shipping" value="2"><input type="hidden" name="return" value="http://www.mp34store.com/successfultrans.htm"><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="lc" value="US"><input type="hidden" name="bn" value="PP-ShopCartBF">');
    									 document.write('</form>');
    						}			 						 

         				 document.write("</td>");
						 
    						 document.write('<td style="border-width:0px">');
    						 document.write("<a target=_top href="+"frame_fmd.htm?"+i+">");

     						 document.write("<img src='"+aFMD[(i*aRecordSize)+5]+"'width=150></a></td>");										 
						 document.write("</tr>");
		 				 }
		}
		document.write("</table>");				

}

