Make a friend happy. Give the gift of SmugMug for 20% less!

Now you can save 20% on a one-, two-, or three-year gift subscription + get 20% of the retail price in credit toward your SmugMug subscription renewal or for additional gifts. Now go on and share some SmugMug love with the people you love by choosing a plan.

Power

  • UNLIMITED, full-resolution storage
  • A website with secure galleries
  • Extensive privacy and security controls
  • Complete customization
  • Stunning themes
  • Custom right-click message
  • Your own custom domain
  • Beautiful prints & gifts
  • Heroic support 365 days/year
PICK PLAN
  • 1 year$
  • 2 years$
  • 3 years$

Portfolio

All Power plan features

  • Set prices and sell for profit
  • Integrated e-commerce and order fulfillment
  • Custom watermarks
  • Custom printmarks
  • Backprinting
PICK PLAN
  • 1 year$
  • 2 years$
  • 3 years$

Pro

All other plans' features

  • Branded shopping cart
  • Custom print packages
  • Discount coupons
  • Event marketing
  • Customized packaging
  • Gallery and Photo specific pricing
PICK PLAN
  • 1 year$
  • 2 years$
  • 3 years$

One good deed deserves another. They’ll get a gift they can use 365 days a year and you’ll save 20% on the cost of the plan. For more info about the Gift of SmugMug visit our Help Center.

Gift of SmugMug discount is only valid on new accounts and cannot be combined with other offers. The 20% credit is only available to current SmugMug account holders in good standing. All prices plus applicable taxes.

'+ '
Normally $'+costYear+'
'+ 'Save '+discountText+'!'+ '
'; YD.getElementsByClassName('boxMiddle', 'div', 'box'+level)[0].innerHTML = middleBoxContent; YD.getElementsByClassName('cost1', 'span', 'box'+level)[0].innerHTML = calculateDiscountPrice(discountPercent, 1, costYear); YD.getElementsByClassName('cost2', 'span', 'box'+level)[0].innerHTML = calculateDiscountPrice(discountPercent, 2, costYear); YD.getElementsByClassName('cost3', 'span', 'box'+level)[0].innerHTML = calculateDiscountPrice(discountPercent, 3, costYear); } }; updatePrices(); YE.on(YD.getElementsByClassName('planPrice', 'li', 'content'),'click',function(e) { var selected = YD.getElementsByClassName('radialSelected', 'span', 'columns'); YD.removeClass(selected,'radialSelected'); var pickedPlan = YD.getElementsByClassName('pickedPlan', 'div', 'columns'); YD.removeClass(pickedPlan,'pickedPlan'); YD.addClass(YD.getAncestorByClassName(this,'column'),'pickedPlan'); YD.addClass(YD.getElementsByClassName('radialPlan', 'span', this),'radialSelected'); }); // misc error panel var errorPanel = new YAHOO.widget.Panel('errorPanel', { 'underlay': 'shadow', 'visible': false, 'draggable': false, 'constraintoviewport': false, 'width': '460px', 'zIndex': 9000, 'modal': true }); errorPanel.setHeader(['
'].join('')); errorPanel.setBody(['
', '

', '
', '
'].join('')); errorPanel.setFooter(['
', ' ', '
', '
'].join('')); errorPanel.render(document.body); YE.onAvailable('errorPanel',function() { YD.addClass(this,'errorPanel'); errorPanel.center(); }); // get this ready var paymentPanel = new YAHOO.widget.Panel('paymentPanel', { 'underlay': 'shadow', 'visible': false, 'draggable': false, 'constraintoviewport': false, 'width': '600px', 'zIndex': 9000, 'modal': true }); paymentPanel.setHeader([ '

', '
', '  ', ' plan  ', '', '', ' + applicable taxes', '
', 'Your Gift', '
', '

', '
', '
', '

Somebody\'s popular! You\'ve got $ in referral credits that we will put toward your gift. So your cost is only $. Nice work.. We will put it towards your gift purchase and save the remaining $ for you to use later.

', '', '

notify your lucky friend immediately

', '', '', '
', '
' ].join('')); paymentPanel.setBody(['
', '
', '', '
'].join('')); paymentPanel.setFooter(['
', 'McAfee SECURE sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams', '
', '

Secure Checkout

', '
'].join('')); paymentPanel.render(document.body); YE.onAvailable('paymentPanel',function(e) { // wire up spoil stuff YE.on('Spoil','click',function() { if(YD.hasClass(this,'checked')){ giftInfo.Spoil = '0'; YD.removeClass(this,'checked'); YD.removeClass('Notify','on'); } else { giftInfo.Spoil = '1'; YD.addClass(this,'checked'); YD.addClass('Notify','on'); } }); YE.on('SpoilHelpie','mouseover',function() { YD.addClass(this,'showHelpie'); }); YE.on('SpoilHelpie','mouseout',function() { YD.removeClass(this,'showHelpie'); }); var selects = {"CardExpMonth":{"1 - Jan":"01","2 - Feb":"02","3 - Mar":"03","4 - Apr":"04","5 - May":"05","6 - Jun":"06","7 - Jul":"07","8 - Aug":"08","9 - Sep":"09","10 - Oct":10,"11 - Nov":11,"12 - Dec":12},"CardExpYear":{"2024":"24","2025":"25","2026":"26","2027":"27","2028":"28","2029":"29","2030":"30","2031":"31","2032":"32","2033":"33","2034":"34"},"State":{"Alabama":"AL","Alaska":"AK","Alberta":"AB","American Samoa":"AS","Arizona":"AZ","Arkansas":"AR","Armed Forces Europe":"AE","Armed Forces Americas":"AA","Armed Forces Canada":"AC","Armed Forces Middle East":"AM","Armed Forces Pacific":"AP","British Columbia":"BC","California":"CA","Colorado":"CO","Connecticut":"CT","Delaware":"DE","District of Columbia":"DC","Federated States of Micronesia":"FM","Florida":"FL","Fleet Post Office":"FP","Georgia":"GA","Guam":"GU","Hawaii":"HI","Idaho":"ID","Illinois":"IL","Indiana":"IN","Iowa":"IA","Kansas":"KS","Kentucky":"KY","Louisiana":"LA","Maine":"ME","Manitoba":"MB","Marshall Islands":"MH","Maryland":"MD","Massachusetts":"MA","Michigan":"MI","Minnesota":"MN","Mississippi":"MS","Missouri":"MO","Montana":"MT","Nebraska":"NE","Nevada":"NV","New Brunswick":"NB","New Hampshire":"NH","New Jersey":"NJ","New Mexico":"NM","New York":"NY","Newfoundland and Labrador":"NL","North Carolina":"NC","North Dakota":"ND","Northern Mariana Islands":"MP","Northwest Territories":"NT","Nova Scotia":"NS","Nunavut":"NU","Ohio":"OH","Oklahoma":"OK","Ontario":"ON","Oregon":"OR","Palau":"PW","Pennsylvania":"PA","Prince Edward Island":"PE","Puerto Rico":"PR","Quebec":"QC","Rhode Island":"RI","Saskatchewan":"SK","South Carolina":"SC","South Dakota":"SD","Tennessee":"TN","Texas":"TX","Utah":"UT","Vermont":"VT","Virgin Islands":"VI","Virginia":"VA","Washington":"WA","West Virginia":"WV","Wisconsin":"WI","Wyoming":"WY","Yukon":"YK"},"Country":{"United States":"United States","Afghanistan":"Afghanistan","\u00c5land Islands":"\u00c5land Islands","Albania":"Albania","Algeria":"Algeria","American Samoa":"American Samoa","Andorra":"Andorra","Angola":"Angola","Anguilla":"Anguilla","Antarctica":"Antarctica","Antigua and Barbuda":"Antigua and Barbuda","Argentina":"Argentina","Armenia":"Armenia","Aruba":"Aruba","Australia":"Australia","Austria":"Austria","Azerbaijan, Republic of":"Azerbaijan, Republic of","Bahamas":"Bahamas","Bahrain":"Bahrain","Bangladesh":"Bangladesh","Barbados":"Barbados","Belarus":"Belarus","Belgium":"Belgium","Belize":"Belize","Benin":"Benin","Bermuda":"Bermuda","Bhutan":"Bhutan","Bolivia, Plurinational State of":"Bolivia, Plurinational State of","Bonaire, Sint Eustatius and Saba":"Bonaire, Sint Eustatius and Saba","Bosnia and Herzegovina":"Bosnia and Herzegovina","Botswana":"Botswana","Bouvet Island":"Bouvet Island","Brazil":"Brazil","British Indian Ocean Territory":"British Indian Ocean Territory","Brunei Darussalam":"Brunei Darussalam","Bulgaria":"Bulgaria","Burkina Faso":"Burkina Faso","Burundi":"Burundi","Cambodia":"Cambodia","Cameroon":"Cameroon","Canada":"Canada","Cape Verde":"Cape Verde","Cayman Islands":"Cayman Islands","Central African Republic":"Central African Republic","Chad":"Chad","Chile":"Chile","China":"China","Christmas Island":"Christmas Island","Cocos (Keeling) Islands":"Cocos (Keeling) Islands","Colombia":"Colombia","Comoros":"Comoros","Congo":"Congo","Congo, the Democratic Republic of the":"Congo, the Democratic Republic of the","Cook Islands":"Cook Islands","Costa Rica":"Costa Rica","C\u00f4te d'Ivoire":"C\u00f4te d'Ivoire","Croatia":"Croatia","Cura\u00e7ao":"Cura\u00e7ao","Cyprus":"Cyprus","Czech Republic":"Czech Republic","Denmark":"Denmark","Djibouti":"Djibouti","Dominica":"Dominica","Dominican Republic":"Dominican Republic","Ecuador":"Ecuador","Egypt":"Egypt","El Salvador":"El Salvador","Equatorial Guinea":"Equatorial Guinea","Eritrea":"Eritrea","Estonia":"Estonia","Ethiopia":"Ethiopia","Falkland Islands (Malvinas)":"Falkland Islands (Malvinas)","Faroe Islands":"Faroe Islands","Fiji":"Fiji","Finland":"Finland","France":"France","French Guiana":"French Guiana","French Polynesia":"French Polynesia","French Southern Territories":"French Southern Territories","Gabon":"Gabon","Gambia":"Gambia","Georgia":"Georgia","Germany":"Germany","Ghana":"Ghana","Gibraltar":"Gibraltar","Greece":"Greece","Greenland":"Greenland","Grenada":"Grenada","Guadeloupe":"Guadeloupe","Guam":"Guam","Guatemala":"Guatemala","Guernsey":"Guernsey","Guinea":"Guinea","Guinea-Bissau":"Guinea-Bissau","Guyana":"Guyana","Haiti":"Haiti","Heard Island and McDonald Islands":"Heard Island and McDonald Islands","Holy See (Vatican City State)":"Holy See (Vatican City State)","Honduras":"Honduras","Hong Kong":"Hong Kong","Hungary":"Hungary","Iceland":"Iceland","India":"India","Indonesia":"Indonesia","Iraq":"Iraq","Ireland":"Ireland","Isle of Man":"Isle of Man","Israel":"Israel","Italy":"Italy","Jamaica":"Jamaica","Japan":"Japan","Jersey":"Jersey","Jordan":"Jordan","Kazakhstan":"Kazakhstan","Kenya":"Kenya","Kiribati":"Kiribati","Korea, Republic of":"Korea, Republic of","Kuwait":"Kuwait","Kyrgyzstan":"Kyrgyzstan","Lao People's Democratic Republic":"Lao People's Democratic Republic","Latvia":"Latvia","Lebanon":"Lebanon","Lesotho":"Lesotho","Liberia":"Liberia","Libya, State of":"Libya, State of","Liechtenstein":"Liechtenstein","Lithuania":"Lithuania","Luxembourg":"Luxembourg","Macao":"Macao","Macedonia, the former Yugoslav Republic of":"Macedonia, the former Yugoslav Republic of","Madagascar":"Madagascar","Malawi":"Malawi","Malaysia":"Malaysia","Maldives":"Maldives","Mali":"Mali","Malta":"Malta","Marshall Islands":"Marshall Islands","Martinique":"Martinique","Mauritania":"Mauritania","Mauritius":"Mauritius","Mayotte":"Mayotte","Mexico":"Mexico","Micronesia, Federated States of":"Micronesia, Federated States of","Moldova, Republic of":"Moldova, Republic of","Monaco":"Monaco","Mongolia":"Mongolia","Montenegro":"Montenegro","Montserrat":"Montserrat","Morocco":"Morocco","Mozambique":"Mozambique","Myanmar":"Myanmar","Namibia":"Namibia","Nauru":"Nauru","Nepal":"Nepal","Netherlands":"Netherlands","New Caledonia":"New Caledonia","New Zealand":"New Zealand","Nicaragua":"Nicaragua","Niger":"Niger","Nigeria":"Nigeria","Niue":"Niue","Norfolk Island":"Norfolk Island","Northern Mariana Islands":"Northern Mariana Islands","Norway":"Norway","Oman":"Oman","Pakistan":"Pakistan","Palau":"Palau","Palestinian Territory, Occupied":"Palestinian Territory, Occupied","Panama":"Panama","Papua New Guinea":"Papua New Guinea","Paraguay":"Paraguay","Peru":"Peru","Philippines":"Philippines","Pitcairn":"Pitcairn","Poland":"Poland","Portugal":"Portugal","Puerto Rico":"Puerto Rico","Qatar":"Qatar","R\u00e9union":"R\u00e9union","Romania":"Romania","Russian Federation":"Russian Federation","Rwanda":"Rwanda","Saint Barth\u00e9lemy":"Saint Barth\u00e9lemy","Saint Helena, Ascension and Tristan da Cunha":"Saint Helena, Ascension and Tristan da Cunha","Saint Kitts and Nevis":"Saint Kitts and Nevis","Saint Lucia":"Saint Lucia","Saint Martin (French part)":"Saint Martin (French part)","Saint Pierre and Miquelon":"Saint Pierre and Miquelon","Saint Vincent and the Grenadines":"Saint Vincent and the Grenadines","Samoa":"Samoa","San Marino":"San Marino","Sao Tome and Principe":"Sao Tome and Principe","Saudi Arabia":"Saudi Arabia","Senegal":"Senegal","Serbia":"Serbia","Seychelles":"Seychelles","Sierra Leone":"Sierra Leone","Singapore":"Singapore","Sint Maarten (Dutch part)":"Sint Maarten (Dutch part)","Slovakia":"Slovakia","Slovenia":"Slovenia","Solomon Islands":"Solomon Islands","Somalia":"Somalia","South Africa":"South Africa","South Georgia and the South Sandwich Islands":"South Georgia and the South Sandwich Islands","South Sudan":"South Sudan","Spain":"Spain","Sri Lanka":"Sri Lanka","Suriname":"Suriname","Svalbard and Jan Mayen":"Svalbard and Jan Mayen","Swaziland":"Swaziland","Sweden":"Sweden","Switzerland":"Switzerland","Taiwan":"Taiwan","Tajikistan":"Tajikistan","Tanzania, United Republic of":"Tanzania, United Republic of","Thailand":"Thailand","Timor-Leste":"Timor-Leste","Togo":"Togo","Tokelau":"Tokelau","Tonga":"Tonga","Trinidad and Tobago":"Trinidad and Tobago","Tunisia":"Tunisia","Turkey":"Turkey","Turkmenistan":"Turkmenistan","Turks and Caicos Islands":"Turks and Caicos Islands","Tuvalu":"Tuvalu","Uganda":"Uganda","Ukraine":"Ukraine","United Arab Emirates":"United Arab Emirates","United Kingdom":"United Kingdom","United States Minor Outlying Islands":"United States Minor Outlying Islands","Uruguay":"Uruguay","Uzbekistan":"Uzbekistan","Vanuatu":"Vanuatu","Viet Nam":"Viet Nam","Virgin Islands, British":"Virgin Islands, British","Virgin Islands, U.S.":"Virgin Islands, U.S.","Wallis and Futuna":"Wallis and Futuna","Western Sahara":"Western Sahara","Yemen":"Yemen","Zambia":"Zambia","Zimbabwe":"Zimbabwe"}}; // Clear associated input field when its X button is clicked YE.on(YD.getElementsByClassName('inputClear','div','paymentPanel'),'click',function(e) { var input = YD.getPreviousSiblingBy(this,function(node) { if(YD.hasClass(node,'inputText')) { return node; } if(YD.hasClass(node,'inputTextArea')) { return node; } }); if(input) { YD.removeClass(YD.getAncestorByClassName(input,'inputWrapper'),'inputTextError'); input.value = ''; input.focus(); YD.removeClass(input.id+'Li','inputError'); } }); // toggle for credit card area var togglePayment = function() { var toggle = true; for(var i in formErrors) { if(formErrors[i]) { //console.log(i); toggle = false; } } if(toggle) { var bd = YD.getElementsByClassName('bd','div','paymentPanel')[0]; YD.setStyle('ToFrom','overflow','hidden'); YD.setStyle('ToFrom','height',0); YD.setStyle(bd,'overflow','visible'); YD.setStyle(bd,'height','auto'); YD.addClass('paymentPanel','paymentCredit'); } }; YE.on('editToFrom','click',function() { var bd = YD.getElementsByClassName('bd','div','paymentPanel')[0]; /* reset the formErrors - validation will be done with the next submit */ for (var i in formErrors) { formErrors[i] = false; } YD.setStyle('ToFrom','overflow','visible'); YD.setStyle('ToFrom','height','auto'); YD.setStyle(bd,'overflow','hidden'); YD.setStyle(bd,'height',0); YD.removeClass('paymentPanel','paymentCredit'); }); // Examples (placeholder text for each input) var exampleInputs = { 'CardExpMonth' : 'Month', 'CardExpYear' : 'Year', 'FirstName' : 'First', 'LastName' : 'Last', 'Street1' : 'Street', 'Street2' : 'Apt, Suite, Bldg. (optional)', 'City' : 'City', 'State' : 'State', 'Zip' : 'Zip', 'Country' : 'Country', 'PhoneNum' : '555-555-5555' }; var addressInputs = { 'Street1' : 'Street', 'City' : 'City', 'State' : 'State', 'Zip' : 'Zip', 'Country' : 'Country' }; var _checkAddressInputs = function() { var inputs = YD.get('paymentForm').elements, canCalculateTax = true; for (var idx = 0; idx < inputs.length-1; idx++) { var currId = inputs[idx].id; if(inputs['Country'].value !== 'US' && (inputs['City'].value !== 'City' || inputs['City'].value !== '')) { break; } if (addressInputs[currId]) { if (inputs[idx].value === '' || addressInputs[currId] === inputs[idx].value) { return; } else { continue; } //being so lazy right here it hurts if (currId === 'Country') { canCalculateTax = true; } } } if (canCalculateTax) { doRPC('Tax'); } }; var addressInputElements = YD.get(Object.keys(addressInputs)); for (element in addressInputElements) { YE.on(addressInputElements[element], 'blur', _checkAddressInputs); } var _checkInputs = function() { var inputs = YD.get('paymentForm').elements, canActivatePayButton = false; for(var idx = 0; idx < inputs.length-1; idx++) { var currId = inputs[idx].id; if(inputs['Country'].value !== 'US' && (inputs['City'].value !== 'City' || inputs['City'].value !== '')) { canActivatePayButton = true; break; } if (exampleInputs[currId]) { //We have a non empty, non example value if (inputs[idx].value === '' || exampleInputs[currId] === inputs[idx].value) { if (inputs[idx].id === 'Street2' || inputs[idx].id === 'PhoneNum') { //apartment number/etc and phone number are optional continue; } else { return; } } } else if (inputs[idx].value === '') { break; } if (idx+1 === inputs.length-1) { canActivatePayButton = true; } } if (canActivatePayButton) { _togglePaymentButton('show'); } else { _togglePaymentButton('hide'); } }; // state: string hide|show var _togglePaymentButton = function(state) { if (state === 'hide' && !YD.hasClass('buttonPayGift', 'disabled')) { YD.addClass('buttonPayGift', 'disabled'); YD.setAttribute('buttonPayGift', 'disabled', 'true'); } else if (state === 'show') { YD.removeClass('buttonPayGift', 'disabled'); YD.get('buttonPayGift').removeAttribute('disabled'); } }; var currInput; for(var i in exampleInputs) { currInput = YD.get(i); if(currInput.value.length == 0) { currInput.value = exampleInputs[i]; YD.addClass(i,'inputExample'); } if(currInput.tagName != 'SELECT') { // When an input gains focus, clear out the example text (placeholder) YE.on(i,'focus',function(e, example) { if(this.value == example) { this.value = ''; YD.removeClass(this,'inputExample'); } }, exampleInputs[i]); // Clear the error classes from an element if it's empty when blurred YE.on(i,'blur',function(e,example) { if(this.value == '') { this.value = example; YD.addClass(this,'inputExample'); YD.removeClass(YD.getAncestorByClassName(this.id,'inputWrapper'),'inputTextError'); if(YD.getElementsByClassName('inputTextError','div','CardNumLi').length == 0) { YD.removeClass('CardNumLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','CvnNumLi').length == 0) { YD.removeClass('CvnNumLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','NameLi').length == 0) { YD.removeClass('NameLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','Street1Li').length == 0) { YD.removeClass('Street1Li','inputError'); } if(YD.getElementsByClassName('inputTextError','div','LocationLi').length == 0) { YD.removeClass('LocationLi','inputError'); } } }, exampleInputs[i]); } //More blur event handlers for checking state/local tax we need to make sure they have all of the info YE.on(i, 'blur', _checkInputs) YE.on(YD.get('CvnNum'), 'blur', _checkInputs); } // Add focus styles to sm-select divs and remove error classes when their select is focused. YD.getElementsByClassName('sm-select', 'div', 'paymentPanel', function(elem) { var select = elem.lastChild; // Set focus & change handlers if (select.id == 'Country') { // Verify the country/state combination when the country changes YE.on(select, 'change', function(e) { checkCountry(); }); } else { // Gray out selects when they're set on the default/placeholder text YE.on(select, 'change', function(e) { if (this.selectedIndex > 0) { YD.removeClass(this, 'inputExample'); } else if (!YD.hasClass(this, 'inputExample')) { YD.addClass(this, 'inputExample'); } }); } // Set focus class and remove error indicators YE.on(select, 'focus', function(e) { YD.addClass(elem, 'inputFocus'); YD.removeClass(elem, 'inputTextError'); }); // Set blur handlers YE.on(select, 'blur', function(e) { YD.removeClass(elem, 'inputFocus'); if(YD.getElementsByClassName('inputTextError','div','CardExpLi').length == 0) { YD.removeClass('CardExpLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','LocationLi').length == 0) { YD.removeClass('LocationLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','CountryLi').length == 0) { YD.removeClass('CountryLi','inputError'); } }); }); // In IE8 and less, the width of selects must be set to auto when open // so their options aren't clipped. if (YAHOO.env.ua.ie && YAHOO.env.ua.ie < 9) { // Set select's width to auto when it's open var _setWidthAuto = function(e) { // Don't modify the select on a right click if (e.type == 'keydown' || e.which == 1 || e.button == 1) { this.style.width = 'auto'; } }; // Set the select's to its default value when it's closed var _setWidthDefault = function(e) { this.style.width = ''; }; var _selectsToFixWidth = ['State', 'Country']; YE.on(_selectsToFixWidth, 'change', _setWidthDefault); YE.on(_selectsToFixWidth, 'blur', _setWidthDefault); YE.on(_selectsToFixWidth, 'keydown', _setWidthAuto); YE.on(_selectsToFixWidth, 'mousedown', _setWidthAuto); } var STATE_FULL_ATTR = 'data-fullname'; var stateSelect = YD.get('State'); var _abbrOption = function(e) { var selectedOption = this[this.selectedIndex]; // Set the new option to the shortened state name, if it hasn't been done already. if (!selectedOption.getAttribute(STATE_FULL_ATTR)) { selectedOption.setAttribute(STATE_FULL_ATTR, selectedOption.textContent || selectedOption.innerText); selectedOption.innerHTML = ''; selectedOption.appendChild(document.createTextNode(selectedOption.value)); } }; YE.on(stateSelect, 'change', _abbrOption); YE.on(stateSelect, 'blur', _abbrOption); var _resetOption = function(e) { // Don't modify the select on a right click if (e.type == 'keydown' || e.which == 1 || e.button == 1) { var elem; var children = YD.getChildren(this); for (var i = 0; elem = children[i]; i++) { if (elem.getAttribute(STATE_FULL_ATTR)) { elem.innerHTML = ''; elem.appendChild(document.createTextNode(elem.getAttribute(STATE_FULL_ATTR))); elem.setAttribute(STATE_FULL_ATTR, ''); break; } } } }; YE.on(stateSelect, 'keydown', _resetOption); YE.on(stateSelect, 'mousedown', _resetOption); // Called when a country option is selected function checkCountry() { var inputCountry = YD.get('Country'); var foundUsState = false; var stateIconStyle = YD.getElementsByClassName('sm-icon','div','wrapperState')[0].style; if(inputCountry.value == "US" || inputCountry.value == "CA") { stateSelect.disabled = false; stateIconStyle.display = ''; for(var i in selects['State']) { if(selects['State'][i] == YD.get('State').value) { foundUsState = true; } } if(!foundUsState) { YD.addClass('State','inputExample'); stateSelect.value = exampleInputs['State']; } } else { stateSelect.selectedIndex = 0; YD.addClass('State','inputExample'); stateSelect.disabled = true; stateIconStyle.display = 'none'; YD.removeClass('wrapperState','inputTextError'); for(var i in selects['State']) { if(selects['State'][i] == YD.get('State').value) { stateSelect.value = ''; } } } } checkCountry(); // When an input gains focus, set the inputFocus class on its wrapper so it's styled correctly. YE.on(YD.getElementsByClassName('inputText','input','paymentPanel'),'focus',function(e) { var inputWrapper = YD.getAncestorByClassName(this,'inputWrapper'); // give focus if(!YD.hasClass(inputWrapper,'inputTextError')) { YD.addClass(inputWrapper,'inputFocus'); } }); // When an input loses focus, remove the focus class from its wrapper. YE.on(YD.getElementsByClassName('inputText','input','paymentPanel'),'blur',function(e) { YD.removeClass(YD.getAncestorByClassName(this,'inputWrapper'),'inputFocus'); }); var formErrors = { 'Coupon' :false, 'CardNum' : false, 'CvnNum' : false, 'CvnNumNumeric' : false, 'CardExpYear' : false, 'CardExpMonth' : false, 'FirstName' : false, 'LastName' : false, 'Street1' : false, 'Street2' : false, 'City' : false, 'State' : false, 'Zip' : false, 'Country' : false, 'PhoneNum' : false }; var inFlightRPC = {}; function doRPC(ids,obj) { if(!YAHOO.lang.isArray(ids)) { var tmp = ids; var ids = []; ids.push(tmp); } if(SM.util.in_array('CardNum',ids)) { var CardNumValue = SM.util.trimString(YD.get('CardNum').value); if(obj.callback && CardNumValue == '') { YD.addClass('wrapperCardNum','inputTextError'); YD.addClass('CardNumLi','inputError'); YD.get('CardNumError').innerHTML = 'Credit card number required.'; formErrors['CardNum'] = true; ids = SM.util.remove_array('CardNum',ids); } else if (!obj.callback && CardNumValue == '') { YD.removeClass('wrapperCardNum','inputTextError'); YD.removeClass('CardNumLi','inputError'); formErrors['CardNum'] = false; ids = SM.util.remove_array('CardNum',ids); } } if(SM.util.in_array('ToEmail',ids)) { var ToEmailValue = SM.util.trimString(YD.get('ToEmail').value); if(obj.callback && ToEmailValue == '') { YD.addClass('wrapperToEmail','inputTextError'); YD.addClass('ToEmailLi','inputError'); YD.get('ToEmailError').innerHTML = 'Email address required.'; formErrors['ToEmail'] = true; ids = SM.util.remove_array('ToEmail',ids); } else if (!obj.callback && ToEmailValue == '') { YD.removeClass('wrapperToEmail','inputTextError'); YD.removeClass('ToEmailLi','inputError'); formErrors['ToEmail'] = false; ids = SM.util.remove_array('ToEmail',ids); } } if(SM.util.in_array('FromEmail',ids)) { var FromEmailValue = SM.util.trimString(YD.get('FromEmail').value); if(obj.callback && FromEmailValue == '') { YD.addClass('wrapperFromEmail','inputTextError'); YD.addClass('FromEmailLi','inputError'); YD.get('FromEmailError').innerHTML = 'Email address required.'; formErrors['FromEmail'] = true; ids = SM.util.remove_array('FromEmail',ids); } else if (!obj.callback && ToEmailValue == '') { YD.removeClass('wrapperFromEmail','inputTextError'); YD.removeClass('TFromEmailLi','inputError'); formErrors['FromEmail'] = false; ids = SM.util.remove_array('FromEmail',ids); } } var methods = []; var level = planLevels[giftInfo.PlanID]; for(var i in ids) { var method = ''; switch (ids[i]) { case 'ToEmail': method = { 'method' : 'checkEmail', 'FormName' : 'ToEmail', 'SkipExisting' : false, 'Email' : ToEmailValue }; break; case 'FromEmail': /* For non-logged-in users, do a lookup on Email so we can prompt them to login if needed */ var loggedIn = ''; method = { 'method' : 'checkEmail', 'FormName' : 'FromEmail', 'SkipExisting' : loggedIn ? true : false, 'Email' : FromEmailValue }; break; case 'CardNum': method = { 'method' : 'checkCardNum', 'CardNum' : getCardNum(), 'NickName' : browseUser.NickName }; break; case 'Tax': var cost = planInfo[level]['Year']['Cost'] * giftInfo.Duration, discount = planInfo[level]['Year']['Cost'] * discountPercent * giftInfo.Duration; var method = { 'method': 'calcSubscriptionTax', 'Street1': YD.get('Street1').value, //need these, even if not required, for address verification 'Street2': YD.get('Street2').value, 'City' : YD.get('City').value, 'State': YD.get('State').value, 'Country' : YD.get('Country').value, 'Zip' : YD.get('Zip').value, 'Discount' : discount, 'PlanID' : giftInfo.PlanID, 'Amount' : cost, 'Type' : 'Gift' }; break; case 'TaxLoggedIn': var cost = planInfo[level]['Year']['Cost'] * giftInfo.Duration, discount = planInfo[level]['Year']['Cost'] * discountPercent * giftInfo.Duration; var method = { 'method': "calcSubscriptionTax", 'Street1': "", //need these, even if not required, for address verification 'Street2': "", 'City' : "", 'State' : "", 'Country' : "", 'Zip' : "", 'Discount' : discount, 'PlanID' : giftInfo.PlanID, 'Amount' : cost, 'Type' : 'Gift' }; break; } if(method != '') { methods.push(method); } } var handleSuccess = function(o) { if (o.responseText !== undefined) { try { var returnedData = YAHOO.lang.JSON.parse(o.responseText); } catch (x) { return; } if (returnedData.status == 'success') { for (var i in returnedData.methods) { var method = returnedData.methods[i]; switch(method['method']) { case "checkEmail" : switch(method.EmailStatus) { case 'valid': YD.addClass(method.FormName+'Li','inputGood'); YD.removeClass(method.FormName+'Li','inputError'); YD.removeClass('wrapper'+method.FormName,'inputTextError'); YD.get(method.FormName+'Error').innerHTML = ''; formErrors[method.FormName] = false; break; case 'emailExists': YD.removeClass(method.FormName+'Li','inputGood'); YD.addClass(method.FormName+'Li','inputError'); YD.addClass('wrapper'+method.FormName,'inputTextError'); //YD.get(method.FormName+'Error').innerHTML = 'Already has a SmugMug account.'; if (method.FormName === 'ToEmail') { YD.get(method.FormName+'Error').innerHTML = 'Looks like your friend already has an account! Gifting works for new accounts only.'; } else { var loginUrl = '/login.mg?' + 'goTo=https%3A%2F%2Fwww.smugmug.com%2Fgift\u0026goToToken=eyJzdHJpbmciOiJodHRwczovL3d3dy5zbXVnbXVnLmNvbS9naWZ0IiwidGltZSI6MTczMTQ1OTI1MCwic2lnbmF0dXJlIjoiWlRBell6SmpaVFkyTVRkak1ESTBabUV3TmpKa1pqSmlOVEJpWkRObVl6Z3hZamszT0dJME1nPT0iLCJ2ZXJzaW9uIjoxLCJhbGdvcml0aG0iOiJzaGExIn0%3D'; YD.get(method.FormName+'Error').innerHTML = 'Is your Mug already Smug? ' + 'Login here.'; } formErrors[method.FormName] = true; break; case 'malformedEmail': YD.removeClass(method.FormName+'Li','inputGood'); YD.addClass(method.FormName+'Li','inputError'); YD.addClass('wrapper'+method.FormName,'inputTextError'); YD.get(method.FormName+'Error').innerHTML = 'Please check your entry.'; formErrors[method.FormName] = true; break; } break; case "checkCardNum": YD.removeClass('paymentPanel','visa'); YD.removeClass('paymentPanel','mc'); YD.removeClass('paymentPanel','amex'); YD.removeClass('paymentPanel','discover'); switch(method.CardNumStatus) { case 'valid': formErrors['CardNum'] = false; YD.removeClass('CardNumLi','inputError'); YD.removeClass('wrapperCardNum','inputTextError'); switch(method['CardNumType']) { case 'Visa': YD.addClass('paymentPanel','visa'); break; case 'Mastercard': YD.addClass('paymentPanel','mc'); break; case 'American Express': YD.addClass('paymentPanel','amex'); break; case 'Discover/Novus': YD.addClass('paymentPanel','discover'); break; } break; default: YD.get('CardNumError').innerHTML = 'Invalid credit card number.'; YD.addClass('CardNumLi','inputError'); YD.addClass('wrapperCardNum','inputTextError'); formErrors['CardNum'] = true; } break; case "calcSubscriptionTax": //update state taxes /* console.log('calcSubscriptionTax called'); console.log(method); console.log(returnedData); */ document.getElementById('paymentErrorText').style.visibility = 'hidden'; if (returnedData.status === 'success') { var disclaimerNode = YD.getElementsByClassName('disclaimer')[0], totalTax = escape(method.TotalTax); if (totalTax > 0) { var safeStr = document.createTextNode(' + $' + totalTax + ' local tax'); disclaimerNode.innerHTML = safeStr.nodeValue; } else { disclaimerNode.innerHTML = ' + local taxes'; } disclaimerNode.className = 'disclaimer totalTax'; var totalCost = parseFloat(o.argument.cost) - parseFloat(o.argument.discount) + parseFloat(totalTax); // decide if they have money to burn or need to enter card info if(browseUser && browseUser.ReferralAmount > 0) { YD.addClass('paymentPanel','referralPay'); YD.getElementsByClassName('referralAmount', 'span', 'paymentPanel')[0].innerHTML = browseUser.ReferralAmount.toFixed(2); if(browseUser.ReferralAmount >= totalCost) { YD.getElementsByClassName('adjustCost', 'span', 'paymentPanel')[0].innerHTML = '  FREE!'; YD.getElementsByClassName('referralRemainder', 'span', 'paymentPanel')[0].innerHTML = (browseUser.ReferralAmount-totalCost).toFixed(2); YD.removeClass('paymentPanel','referralPaySome'); YD.addClass('paymentPanel','referralPayAll'); } else { YD.getElementsByClassName('adjustCost', 'span', 'paymentPanel')[0].innerHTML = '  $'+(totalCost-browseUser.ReferralAmount).toFixed(2); YD.getElementsByClassName('referralBalance', 'span', 'paymentPanel')[0].innerHTML = (totalCost-browseUser.ReferralAmount).toFixed(2); YD.removeClass('paymentPanel','referralPayAll'); YD.addClass('paymentPanel','referralPaySome'); } } else { YD.removeClass('paymentPanel','referralPay'); YD.removeClass('paymentPanel','referralPayAll'); YD.addClass('paymentPanel','referralPaySome'); } //_togglePaymentButton('show'); } break; } } // are they trying to submit? if(o.argument.obj && o.argument.obj.callback) { o.argument.obj.callback.call(obj,obj); } } else { //for(var i in returnedData.methods) { // if ('calcSubscriptionTax' === returnedData.methods[i].method) { var disclaimerNode = YD.getElementsByClassName('disclaimer')[0]; disclaimerNode.innerHTML = ' + applicable taxes'; disclaimerNode.className = 'disclaimer'; document.getElementById('paymentErrorText').style.visibility = 'visible'; _togglePaymentButton('hide'); // } //} } } }; var handleFailure = function() { }; var callback = { success: handleSuccess, failure: handleFailure, scope: this, argument : { 'obj' : obj , 'cost': cost, 'discount': discount } }; if(methods.length > 0) { var rpcName = ''; for(var i in methods) { rpcName += methods[i].method; } if(YAHOO.lang.isObject(inFlightRPC[rpcName])) { YAHOO.util.Connect.abort(inFlightRPC[rpcName]); } inFlightRPC[rpcName] = YAHOO.util.Connect.asyncRequest('POST', '/rpc/trial.mg', callback, 'methods='+encodeURIComponent(YAHOO.lang.JSON.stringify(methods))+'&_token='+encodeURIComponent(_token)); } }; YE.on(['CardNum'],'blur',function(e) { doRPC(this.id,{}); }); YE.on(['FromEmail'],'blur',function(e) { doRPC(this.id,{}); }); YE.on(['ToEmail'],'blur',function(e) { doRPC(this.id,{}); }); YE.on(['CvnNum', 'FromName','FromEmail','ToName','ToEmail','FirstName','LastName','Street1','City','State','Zip','Country','PhoneNum'],'blur',function() { YD.removeClass(YD.getAncestorByClassName(this,'inputWrapper'),'inputTextError'); if(YD.getElementsByClassName('inputTextError','div',this.id+'Li').length == 0) { YD.removeClass(this.id+'Li','inputError'); } if(YD.getElementsByClassName('inputTextError','div','NameLi').length == 0) { YD.removeClass('NameLi','inputError'); } if(YD.getElementsByClassName('inputTextError','div','LocationLi').length == 0) { YD.removeClass('LocationLi','inputError'); } }); YE.on(YD.getElementsByClassName('sendGift','input','paymentPanel'),'click',function(e) { if(this.id == 'buttonGiveGift') { var type = 'payReferral'; var callback = GiveGift; } else if(this.id == 'buttonPayGift') { var type = 'payCredit'; var callback = GiveGift; } else { var type = 'togglePayment'; var callback = togglePayment; } if(type != 'togglePayment') { if(YD.hasClass(this,'inputSubmitted')) { return false; } YD.addClass(this,'inputSubmitted'); } /* show empty errors, fun */ var checkEmptyExample = [ 'FromName', 'FromEmail', 'ToName', 'ToEmail' ]; var rpcCall = ['ToEmail','FromEmail']; if(type == 'payCredit') { checkEmptyExample = checkEmptyExample.concat([ 'CardNum', 'CvnNum', 'CardExpMonth', 'CardExpYear', 'FirstName', 'LastName', 'Street1', 'City', 'Zip', 'Country', 'PhoneNum' ]); rpcCall = rpcCall.concat(['CardNum']); } for(var i in checkEmptyExample) { var id = checkEmptyExample[i]; var value = SM.util.trimString(YD.get(id).value); if(value == '' || value == exampleInputs[id]) { YD.addClass('wrapper'+id,'inputTextError'); formErrors[id] = true; } else { YD.removeClass('wrapper'+id,'inputTextError'); formErrors[id] = false; } } var CvnNumValue = SM.util.trimString(YD.get('CvnNum').value); if(CvnNumValue != '' && !CvnNumValue.match(/^\d{3,4}$/)) { formErrors['CvnNumNumeric'] = true; } else { formErrors['CvnNumNumeric'] = false; } if(!formErrors['FromName']) { YD.removeClass('FromNameLi','inputError'); } else { YD.get('FromNameError').innerHTML = 'Name required.'; YD.addClass('FromNameLi','inputError'); } if(!formErrors['FromEmail']) { YD.removeClass('FromEmailLi','inputError'); } else { YD.get('FromEmailError').innerHTML = 'Email address required.'; YD.addClass('FromEmailLi','inputError'); } if(!formErrors['ToName']) { YD.removeClass('ToNameLi','inputError'); } else { YD.get('ToNameError').innerHTML = 'Name required.'; YD.addClass('ToNameLi','inputError'); } if(!formErrors['ToEmail']) { YD.removeClass('ToEmailLi','inputError'); } else { YD.get('ToEmailError').innerHTML = 'Email address required.'; YD.addClass('ToEmailLi','inputError'); } if(type == 'payCredit') { if(!formErrors['CardNum']) { YD.removeClass('CardNumLi','inputError'); } else { YD.get('CardNumError').innerHTML = 'Credit card number required.'; YD.addClass('CardNumLi','inputError'); } if(formErrors['CvnNum']) { YD.get('CvnNumError').innerHTML = 'Security code required.'; YD.addClass('CvnNumLi','inputError'); } else if(formErrors['CvnNumNumeric']) { YD.get('CvnNumError').innerHTML = 'Security code must be numeric.'; YD.addClass('CvnNumLi','inputError'); } else { YD.removeClass('CvnNumLi','inputError'); } if(!formErrors['CardExpMonth'] && !formErrors['CardExpYear']) { YD.removeClass('CardExpLi','inputError'); } else { var expErrors = []; if(YD.get('CardExpMonth').value == '' || YD.get('CardExpMonth').value == exampleInputs['CardExpMonth']) { expErrors.push('Month'); } if(YD.get('CardExpYear').value == '' || YD.get('CardExpYear').value == exampleInputs['CardExpYear']) { expErrors.push('Year'); } YD.get('CardExpError').innerHTML = expErrors.join(", ")+' required.'; YD.addClass('CardExpLi','inputError'); } if(!formErrors['FirstName'] && !formErrors['LastName']) { YD.removeClass('NameLi','inputError'); } else { var nameErrors = []; if(YD.get('FirstName').value == '' || YD.get('FirstName').value == exampleInputs['FirstName']) { nameErrors.push('First'); } if(YD.get('LastName').value == '' || YD.get('LastName').value == exampleInputs['LastName']) { nameErrors.push('Last'); } YD.get('NameError').innerHTML = nameErrors.join(", ")+' name required.'; YD.addClass('NameLi','inputError'); } if(!formErrors['Street1']) { YD.removeClass('Street1Li','inputError'); } else { YD.get('Street1Error').innerHTML = 'Street required.'; YD.addClass('Street1Li','inputError'); } if(!formErrors['Country']) { YD.removeClass('CountryLi','inputError'); } else { YD.get('CountryError').innerHTML = 'Country required.'; YD.addClass('CountryLi','inputError'); } if(!formErrors['PhoneNum']) { YD.removeClass('PhoneNumLi','inputError'); } else { YD.get('PhoneNumError').innerHTML = 'Phone number required.'; YD.addClass('PhoneNumLi','inputError'); } /* Make sure if the card expires this year that it has not already */ if(parseInt(SM.util.trimString(YD.get('CardExpYear').value)) < 24 || (parseInt(SM.util.trimString(YD.get('CardExpYear').value)) == 24 && parseInt(SM.util.trimString(YD.get('CardExpMonth').value)) < 11)) { YD.get('CardExpError').innerHTML = 'Card has expired.'; YD.addClass('CardExpLi','inputError'); YD.addClass('wrapperCardExpMonth','inputTextError'); YD.addClass('wrapperCardExpYear','inputTextError'); } var locationErrors = []; if (formErrors['City']) { locationErrors.push('City'); } /* Is US or Canada, must have valid state */ formErrors['State'] = false; if(SM.util.trimString(YD.get('Country').value) == 'US' || SM.util.trimString(YD.get('Country').value) == 'CA') { var foundUsState = false; for(var i in selects['State']) { if(selects['State'][i] == YD.get('State').value) { foundUsState = true; } } if(!foundUsState) { formErrors['State'] = true; locationErrors.push('State'); YD.addClass('wrapperState','inputTextError'); } } if (formErrors['Zip']) { locationErrors.push('Zip'); } if (formErrors['City'] || formErrors['State'] || formErrors['Zip']) { YD.get('LocationError').innerHTML = locationErrors.join(", ") + ' required.'; YD.addClass('LocationLi', 'inputError'); } else { YD.removeClass('LocationLi', 'inputError'); } } doRPC(rpcCall,{ 'callback': callback, 'type': type }); }); var GiveGift = function(obj) { // submit all info via rpc var submit = true; for(var i in formErrors) { if(formErrors[i]) { submit = false; break; } } if(submit) { // remove examples for(var i in exampleInputs) { if(YD.get(i).value == exampleInputs[i]) { YD.get(i).value = ''; } } var methods = []; var method = { 'method' : 'GiftGiven', 'NickName' : browseUser.NickName, 'PlanID' : giftInfo.PlanID, 'Duration' : giftInfo.Duration, 'Spoil' : giftInfo.Spoil, 'FromName' : SM.util.trimString(YD.get('FromName').value), 'FromEmail' : SM.util.trimString(YD.get('FromEmail').value), 'ToName' : SM.util.trimString(YD.get('ToName').value), 'ToEmail' : SM.util.trimString(YD.get('ToEmail').value), 'ToMessage' : SM.util.trimString(SM.util.removeBreaks(YD.get('ToMessage').value)), 'PartnerID' : browseUser.PartnerID, 'DiscountValue' : discountPercent }; // always send if(obj.type == 'payCredit' || 1==1) { method = YAHOO.lang.merge(method,{ 'CardNum' : getCardNum(), 'CvnNum' : SM.util.trimString(YD.get('CvnNum').value), 'CardExpMonth' : SM.util.trimString(YD.get('CardExpMonth').value), 'CardExpYear' : SM.util.trimString(YD.get('CardExpYear').value), 'FirstName' : SM.util.trimString(YD.get('FirstName').value), 'LastName' : SM.util.trimString(YD.get('LastName').value), 'Street1' : SM.util.trimString(YD.get('Street1').value), 'Street2' : SM.util.trimString(YD.get('Street2').value), 'City' : SM.util.trimString(YD.get('City').value), 'State' : SM.util.trimString(YD.get('State').value), 'Zip' : SM.util.trimString(YD.get('Zip').value), 'Country' : SM.util.trimString(YD.get('Country').value), 'PhoneNum' : SM.util.trimString(YD.get('PhoneNum').value) }); } methods.push(method); var handleSuccess = function(o) { if (o.responseText !== undefined) { try { var returnedData = YAHOO.lang.JSON.parse(o.responseText); } catch (x) { return; } if (returnedData.status == 'success') { for (var i in returnedData.methods) { var method = returnedData.methods[i]; switch(method['method']) { case 'GiftGiven' : if(method['GiftGiven']) { location.href = 'http://www.smugmug.com/gift/thanks/?GiftID='+method['GiftID']+"&EH="+method['EmailHash']; } else { if(method['Exception'] == 'ccFailed') { // highlight the cc fields YD.addClass('CardNumLi','inputError'); YD.addClass('wrapperCardNum','inputTextError'); YD.addClass('wrapperCvnNum','inputTextError'); YD.addClass('wrapperCardExpMonth','inputTextError'); YD.addClass('wrapperCardExpYear','inputTextError'); YD.get('CardNumError').innerHTML = 'We couldn\'t validate that credit card. Please try again.'; formErrors['CardNum'] = true; formErrors['CardExpMonth'] = true; formErrors['CardExpYear'] = true; } else { YD.get('errorMessage').innerHTML = method['Message']; errorPanel.center(); errorPanel.show(); } YD.removeClass('buttonGiveGift','inputSubmitted'); YD.removeClass('buttonPayGift','inputSubmitted'); } break; } } } else { if (returnedData.redirectUrl) { location.assign(returnedData.redirectUrl); } } } }; var handleFailure = function() { // something bad happened }; var callback = { success: handleSuccess, failure: handleFailure, scope: this }; if(YAHOO.lang.isObject(inFlightRPC['giveGift'])) { YAHOO.util.Connect.abort(inFlightRPC['giveGift']); } inFlightRPC['giveGift'] = YAHOO.util.Connect.asyncRequest('POST', '/rpc/trial.mg', callback, 'methods='+encodeURIComponent(YAHOO.lang.JSON.stringify(methods))+'&_token='+encodeURIComponent(_token)); } else { YD.removeClass('buttonGiveGift','inputSubmitted'); YD.removeClass('buttonPayGift','inputSubmitted'); } }; var getCardNum = function() { return SM.util.trimString(YD.get('CardNum').value).replace(/[-' ']/g,''); }; YE.on(YD.getElementsByClassName('buttonSignUp','img','content'),'click',function() { var level = YD.getAncestorByClassName(this,'column').id.slice(3); var selectedTerm = YD.getElementsByClassName('radialSelected','span','box'+level); if(selectedTerm.length == 0) { return false; } if(YD.hasClass(selectedTerm,'radial1')[0]) { giftInfo.Duration = 1; } else if(YD.hasClass(selectedTerm,'radial2')[0]) { giftInfo.Duration = 2; } else { giftInfo.Duration = 3; } giftInfo.PlanID = planInfo[level]['Year']['PlanID']; var cost = planInfo[level]['Year']['Cost'] * giftInfo.Duration - (planInfo[level]['Year']['Cost'] * giftInfo.Duration * discountPercent); // update prices and chosen level YD.getElementsByClassName('plan', 'span', 'paymentPanel')[0].innerHTML = level; YD.getElementsByClassName('term', 'span', 'paymentPanel')[0].innerHTML = giftInfo.Duration+'-year'+(giftInfo.Duration > 1 ? 's' : ''); YD.getElementsByClassName('cost', 'span', 'paymentPanel')[0].innerHTML = "$"+cost.toFixed(2); //Honestly this is heinous that we cannot leave useful comments because they will never be stripped out here. YD.removeClass('paymentPanel','referralPay'); YD.removeClass('paymentPanel','referralPayAll'); YD.addClass('paymentPanel','referralPaySome'); paymentPanel.center(); paymentPanel.show(); }); YE.on(YD.getElementsByClassName('container-close','a','paymentPanel')[0],'click',function() { paymentPanel.hide(); }); });