//** PayPal SINGLE CLICK BUY **//
var flagimage="clear.gif";
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 singleClick(itemNumber,extent,cart,flag) {
var thumbnail="yes"; // assume there will be a thumbnail image
var bigimage="yes"; // assume there will be a large image of item
c=cart;
y=itemNumber;
e=extent;// valid entries full|button
f=flag; // show flag or not? valid entries 0|1 (no/yes).  Default is YES!

if (storeData[y][6]!="0") {
//-- checks to see whether it is supposed to display the full entry or just a button --//
if (e==null) {e="full"};
if (f==null) {f=1};
if (f==1) {
	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"}} else {}
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 (c!="cart" || (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION")) {c="buynow"}
if (e=="button") {
document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">'); 
if (c=="cart") {document.write('<input type="hidden" name="cmd" value="_cart">');}
else {document.write('<input type="hidden" name="cmd" value="_xclick">');}
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" )
{} 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]+'"> ');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {} else {document.write('<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">');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {
document.write('<input name="submit" type="submit" value="DONATE NOW!">')} else {
if (c=="cart") {document.write('<input name="submit" type="submit" value="ADD to CART">')} 
else {document.write('<input name="submit" type="submit" value="BUY NOW!">')}
}
document.write('      </td>'+
'      <td width="100%" align="left" nowrap>');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {document.write('<span class="header"><strong>$<input type="text" size="8" name="amount" value="10.00" onBlur="if (!validate(this.value)) {alert(\'Price MUST be numbers in x.xx format!\')};a=parseInt(this.value);if (a<1) {alert(\'Sorry, the minimum donation is $1\');this.value=\'1.00\'};"> </strong></span> <span class="body">(Enter any dollar amount)</span>');} else {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 if (e=="full") {
document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> ');
if (c=="cart") {document.write('<input type="hidden" name="cmd" value="_cart">');}
else {document.write('<input type="hidden" name="cmd" value="_xclick">');}
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]+'"> ');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {
document.write('<input type="hidden" name="no_shipping" value="1">')} else {
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="amount" value="'+storeData[y][5]+'"> '+
'<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(\'blank.htm\',\'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">');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {
document.write('<input name="submit" type="submit" value="DONATE NOW!">')} else {
if (c=="cart") {document.write('<input name="submit" type="submit" value="ADD to CART">')} 
else {document.write('<input name="submit" type="submit" value="BUY NOW!">')}
}
document.write('      </td>'+
'      <td width="100%" align="left" nowrap>');
if (storeData[y][0]=="Donation" || storeData[y][0]=="donation" || storeData[y][0]=="DONATION") {document.write('<span class="header"><strong>$<input type="text" size="8" name="amount" value="10.00" onBlur="if (!validate(this.value)) alert(\'Price MUST be numbers in x.xx format!\')"></strong></span> <span class="body">(Enter any dollar amount)</span>');} else {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 {}
}