//** PayPal STORE BUILDER **//
var flagimage="clear.gif";

function buildStore() {
for (p=0;p<gc;p++) {
if (storeCats[p][2]=="yes") {
document.write('<table cellpadding="2" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#000000"><span class="whitetexthead"><b>'+storeCats[p][0]+'</b></span></td></tr><tr><td><p>'+storeCats[p][1]+'</p></td></tr></table>');
	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">'+ 
'<input type="hidden" name="cmd" value="_cart">'+
'<input type="hidden" name="business" value="'+StoreEmailAddress+'"> ');
if (storeData[y][3]=="n/a" || storeData[y][3]=="N/A" || storeData[y][3]=="NA" || storeData[y][3]=="na")
{} 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]+'"> '+
'<input type="hidden" name="amount" value="'+storeData[y][5]+'"> '+
'<input type="hidden" name="no_shipping" value="0">'+
'<input type="hidden" name="img_url" value="http://www.dakotahistory.org/images/store/logo4paypal.jpg"> '+
'  <table width="100%" cellpadding="5" cellspacing="0" border="0">'+
'    <tr bgcolor="#660033" background="../images/burgundy_dot.gif"> '+
'      <td colspan="2"> <div class="whitebody"><img src="../images/'+flagimage+'" align="left"><strong>'+storeData[y][1]+'</strong></div></td>'+
'    </tr>'+
'    <tr> '+
'    <tr>  <td colspan="2">');
if (thumbnail!="no" && bigimage=="no") {// thumbnail exists, no larger version
document.write('<img src="../images/store/'+storeData[y][4]+'" hspace="5" align="left">')}
else if (thumbnail!="no" && bigimage!="no") {// thunbnail and larger version
document.write('<table align="left"><tr><td align="center"><a href="javascript:imagewindow=window.open(\'\',\'imagewindow\',\'height=500,width=450,scrollbars=yes,status=no,toolbar=no,location=no,resizable=yes\');'+
'imagewindow.document.write(\'<html><head><title>'+storeData[y][1]+'</title><style>td {font-family: Arial, Helvetica, sans-serif;font-size: 10pt;color: #000000;}.whitebody {font-family: Arial, Helvetica, sans-serif;font-size: 10pt;color: #FFFFFF;}</style><body background=\\\'../images/background.gif\\\'><table height=100% width=100%><tr><td height=15 valign=top bgcolor=#660033 background=../images/burgundy_dot.gif><span class=whitebody><strong>'+storeData[y][1]+'</span></strong></td></tr><tr><td align=center valign=middle><img src=\\\'../images/store/'+storeData[y][8]+'\\\'></td></tr><tr><td align=right valign=bottom><a href=\\\'javascript:self.close();\\\'><strong>CLOSE WINDOW</strong>&nbsp;<img src=../images/closelayerX.gif border=0 align=absmiddle></a></td></tr></table></body></html>\');">'+
'<img src="../images/store/'+storeData[y][4]+'" border="0"><br><img src=../images/magnifyer.gif align=absmiddle border=0><span class="fineprint">VIEW LARGER IMAGE</span></a></td></tr></table>')}
else if (thumbnail=="no") {} // if there is no thumbnail do not display anything
document.write(''+storeData[y][2]+'</td>'+
'    </tr>'+
'    <tr> '+
'     <td width="98" align="left"><input name="submit" type="submit" value="ADD to CART"> '+
'      </td>'+
'      <td width="100%" align="left"><div class="header"><strong>$'+storeData[y][5]+'</strong></div></td>'+
'    </tr>'+
'  </table>'+
'<input type="hidden" name="add" value="1"></form>')
} else {}
}
}}}}
