Template:2010/Donate-now13

 function validateForm( form ) {

var minimums = { 'USD' : 1, 'GBP' : 1, // $1.26 'EUR' : 1, // $1.26 'AUD' : 2, // $1.35 'CAD' : 1, // $0.84 'CHF' : 1, // $0.85 'CZK' : 20, // $1.03 'DKK' : 5, // $0.85 'HKD' : 10, // $1.29 'HUF' : 200, // $0.97 'JPY' : 100, // $1 'NZD' : 2, // $1.18 'NOK' : 10, // $1.44 'PLN' : 5, // $1.78 'SGD' : 2, // $1.35 'SEK' : 10, // $1.28 'ILS' : 5 // $1.39 };

var error = true;

// Get amount selection var amount = null; for ( var i = 0; i < form.amount.length; i++ ) { if ( form.amount[i].checked ) { amount = form.amount[i].value; } }  if ( form.amountGiven.value != "" ) { var otherAmount = form.amountGiven.value; otherAmount = otherAmount.replace(/[,.](\d)$/, '\:$10'); otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, '\:$1$2'); otherAmount = otherAmount.replace(/[,.]/g, ''); otherAmount = otherAmount.replace(/:/, '.'); form.amountGiven.value = otherAmount; amount = otherAmount; }

// Check amount is a real number error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); // Check amount is at least the minimum var currency = form.currency_code.value; if ( typeof( minimums[currency] ) == 'undefined' ) { minimums[currency] = 1; } if ( amount < minimums[currency] || error ) { alert( ' '.replace('$1', minimums[currency] + ' ' + currency ) ); error = true; } return !error; }

function DefaultSubmit(formfield,Action) { var keycode; if (window.event) keycode = window.event.keyCode; else if (Action) keycode = Action.which; else return true;

if (keycode == 13) { if (getCheckedValue(document.paypalcontribution.elements['donate-type']) == 'recurring') { redirectPayment('2'); return false; } else { redirectPayment('1'); return false; }  } else { return true; } }

function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; }	}	return ""; }

function switchButtons { if (getCheckedValue(document.paypalcontribution.elements['donate-type']) == 'recurring') { document.getElementById('cc-donate-button').style.display = 'none'; } else { document.getElementById('cc-donate-button').style.display = 'block'; } }

function redirectPayment(i) { //if i == 1 var paymentType ="cc"; var action_url = "https://payments.wikimedia.org/index.php/Special:PayflowProGateway?uselang= \x26masthead=\x26form_name=\x26text_template=\x26language= " ; if (i==2) { if (getCheckedValue(document.paypalcontribution.elements['donate-type']) == 'recurring') { action_url="http://wikimediafoundation.org/wiki/Special:ContributionTracking/ "; paymentType = "rpp"; document.paypalcontribution.recurring_paypal.value = "true"; } else { action_url="http://wikimediafoundation.org/wiki/Special:ContributionTracking/ "; paymentType = "pp"; document.paypalcontribution.recurring_paypal.value = "false"; }  }

document.paypalcontribution.action = action_url; document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.' + getLandingPage + '.' + paymentType; if(validateForm(document.paypalcontribution)){ if(typeof(OWA) !== 'undefined'){OWATracker.shareStateByPost( document.paypalcontribution );} document.paypalcontribution.submit; } }          



 





* *  *  <p style="margin-top: 1em;">

<script type="text/javascript"> function getQuerystring( key ) { key = key.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' ); var regex = new RegExp( '[\\?&]' + key + '=([a-zA-Z0-9\_\-]*)' ); var qs = regex.exec( window.location.search ); return qs == null ? '' : qs[1]; }

function getLandingPage {  var path = "  ";

if( path == "default"){ pathArray = window.location.pathname.split( '/' ); return pathArray[2]; }  else return path; }

function updateCC( currency ) { if ( ( currency == 'AUD' ) || ( currency == 'CAD' ) || ( currency == 'EUR' ) ||    (currency == 'GBP' ) || ( currency == 'JPY' ) || ( currency == 'USD' ) ) { document.getElementById('cc-donate-button').style.display = " "; } else { document.getElementById('cc-donate-button').style.display = "none"; } } document.paypalcontribution.utm_medium.value = getQuerystring( 'utm_medium' ); document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' ); document.paypalcontribution.referrer.value = document.referrer; window.onload = updateCC(document.getElementById('input_currency_code').value);