//** PayPal Featured Items Page Builder **//

function validate(string) {
    if (!string) return false;
    var Chars = "0123456789";

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
} 

function featuredItems(a) {
// a variable is which category to display
var p=a;
if (storeCats[p][2]=="yes") {
	for (y=0;y<InventoryItems;y++){
	if (storeData[y][6]==p) {
var thumbnail="yes"; // assume there will be a thumbnail image
var bigimage="yes"; // assume there will be a large image of item

if ((storeData[y][1]==null || storeData[y][1]==" " || storeData[y][1]=="") || (storeData[y][5]==null || storeData[y][5]=="" || storeData[y][5]==" ") || (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION")) {storeData[y][6]="0"} else {};
	if (storeData[y][6]==p) {
//-- the following plug in some data to make cart work if data items are missing --//
if (storeData[y][0]=="" || storeData[y][0]==" " || storeData[y][0]==null) {storeData[y][0]="XXXX"}
if (storeData[y][2]=="" || storeData[y][2]==" " || storeData[y][2]==null) {storeData[y][2]=" "}
if (storeData[y][4]=="" || storeData[y][4]==" " || storeData[y][4]==null) {thumbnail="no"}
if (storeData[y][8]=="" || storeData[y][8]==" " || storeData[y][8]==null) {bigimage="no"}
if (storeData[y][4]=="" || storeData[y][4]==" " || storeData[y][4]==null) {storeData[y][4]="../images/clear.gif"}
if (storeData[y][7]=="" || storeData[y][7]==" " || storeData[y][7]==null) {flagimage="clear.gif"}
if (storeData[y][7]=="none") {flagimage="clear.gif"}
if (storeData[y][7]=="sale") {flagimage="saleitem_flag.gif"}
if (storeData[y][7]=="new") {flagimage="newitem_flag.gif"}
//-- write item into store page --//
document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">'); 
document.write('<input type="hidden" name="cmd" value="_cart">');
document.write('<input type="hidden" name="business" value="'+StoreEmailAddress+'"> ');
if ((storeData[y][3]=="na" || storeData[y][3]=="NA" || storeData[y][3]=="N/A" || storeData[y][3]=="n/a" ) || (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION"))
{} else {document.write('<input type="hidden" name="shipping" value="'+storeData[y][3]+'">')};
document.write('<input type="hidden" name="item_name" value="'+storeData[y][1]+'"> '+
'<input type="hidden" name="item_number" value="'+storeData[y][0]+'"> ');
document.write('<input type="hidden" name="no_shipping" value="0"><input type="hidden" name="amount" value="'+storeData[y][5]+'">');}
document.write('<input type="hidden" name="img_url" value="http://www.dakotahisotry.org/images/store/logo4paypal.jpg"> '+
'  <table width="100%" cellpadding="5" cellspacing="0" border="0">'+
'    <tr> '+
'      <td colspan="2"><div class="body">');
if (f!=0) {document.write('<img src="../images/'+flagimage+'" align="left">')} else {};
document.write('<strong>'+storeData[y][1]+'</strong></div></td>'+
'    </tr>'+
'    <tr>'+ 
'      <td width="98" align="left">');

document.write('<input name="submit" type="submit" value="ADD to CART">')


document.write('      </td>'+
'      <td width="100%" align="left" nowrap>');
document.write('<div class="header"><strong>$'+storeData[y][5]+'</strong></div></td>')
document.write('    </tr>'+
 '   <tr> '+
 '     <td colspan="2" align="left"><hr></td>'+
 '   </tr>'+
'  </table>'+
'            <input type="hidden" name="add" value="1">'+
'</form>');} else {}
}
}}