var blankImg = "images/logos/blank.gif"; var f = 'DXImageTransform.Microsoft.AlphaImageLoader'; try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {} $(document).ready( function() { $('.form-buttons').show(); $('.noscript').hide(); if ($.browser.msie && $.browser.version < 7) { $("img[@src$='.png'],input[@src$='.png']").each(fixOnePng); } $('.e-mail').each( function() { var text = $(this).html().split(/:/); var email = text[0]; var name = ''; if (text.length == 2) name = text[1]; email = email.replace(/ at /, '@'); email = email.replace(/ dot /g, '.'); text = (name == '' ? email : name); $(this).html(text).wrap(''); }); $(".quick-link li:not(:last-child)").append(" | "); // Make sure the form data is valid $("#reg-form").submit( function () { var elements = this.elements; // Check for required fields var msg = ""; msg = checkRequired(msg, elements, 'first_name', 'First name'); msg = checkRequired(msg, elements, 'last_name', 'Last name'); msg = checkRequired(msg, elements, 'address1', 'Address'); msg = checkRequired(msg, elements, 'city', 'City'); msg = checkRequired(msg, elements, 'state', 'State'); msg = checkRequired(msg, elements, 'zip', 'Zip code'); msg = checkRequired(msg, elements, 'night_phone_a', 'Phone area code'); msg = checkRequired(msg, elements, 'night_phone_b', 'Phone prefix'); msg = checkRequired(msg, elements, 'night_phone_c', 'Phone number'); msg = checkRequired(msg, elements, 'email', 'E-mail address'); msg = checkRequired(msg, elements, 'swe_type', 'SWE membership type'); msg = checkRequired(msg, elements, 'conf_amount', 'Type of conference registration'); if (msg != '') { alert(msg); return false; } // Forward the field data to a page that can send the data to SWE var formValues = new Object(); var element; for (var i = 0; i < elements.length; i++) { element = elements[i]; if (element.type == "text" || element.type == "hidden" || element.type == "select-one" || (element.type == "checkbox" && element.checked) || (element.type == "radio" && element.checked)) { formValues[element.name] = element.value; } } $.ajax({ type: "POST", url: 'http://www.tigerheron.com/swe/swe.php', data: formValues, async: false, complete: function() { } }); // Now allow the form to proceed to PayPal return true; }); // Capture events that change the form total $("input[name=conf_amount]," + "input[name=tour_tek]," + "input[name=tour_portland_spirit]," + "input[name=tour_widmer]," + "input[name=lunches]," + "input[name=banquets]").change( function() { var total = 0; $("input[name=conf_amount]," + "input[name=tour_tek]," + "input[name=tour_portland_spirit]," + "input[name=tour_widmer]").each( function() { if (this.checked) { var value = parseInt(this.value.replace(/[^0-9]*/g, '')); if (!isNaN(value)) total += value; } }); $("input[name=lunches]").each( function() { var value = parseInt(this.value.replace(/[^0-9]*/g, '')) * 20; if (!isNaN(value)) total += value; }); $("input[name=banquets]").each( function() { var value = parseInt(this.value.replace(/[^0-9]*/g, '')) * 50; if (!isNaN(value)) total += value; }); $("input[name=amount]").attr('value', total); }); }); // Determine if a field with a given name exists in an array function nameInArray(name, a) { for (var i = 0; i < a.length; i++) { if (a[i].name == name) return i; } return -1; } // Determine if one radio button is checked function radioChecked(fieldName, a) { for (var i = 0; i < a.length; i++) { if (a[i].name == fieldName && a[i].checked) { return true; } } return false; } // Check that a required field has at least some data var savedBackgrounds = new Object(); function checkRequired(msg, elements, fieldName, description) { var error = false; var index, field; if ((index = nameInArray(fieldName, elements)) != -1) { field = elements[index]; var value = field.value.replace(/^\s+|\s+$/g, '') ; if (value == '') error = true; if (field.type == 'radio' && !radioChecked(fieldName, elements)) error = true; } else { error = true; } // Identify fields for later marking var fields; if (index != -1 && elements[index].type == 'radio') { fields = $("*[name=" + fieldName + "]").parent(); } else { fields = $("*[name=" + fieldName + "]"); } // Save the current background, if not already saved if (typeof savedBackgrounds[fieldName] == 'undefined') { savedBackgrounds[fieldName] = fields.css('background-color'); if (typeof savedBackgrounds[fieldName] == 'undefined') { savedBackgrounds[fieldName] = 'inherit'; } } // Build the error message if (error) { if (msg == '') { msg = "You haven't entered all required fields.\n" + "Please enter these fields:\n" + description + "\n"; $("*[name=" + fieldName + "]").get(0).focus(); } else { msg += description + "\n"; } // Signal which fields have errors fields.css('background-color', '#FFEEEE'); } // Reset fields that have been altered else { fields.css('background-color', savedBackgrounds[fieldName]); } return msg; } function filt(e, s, m) { if (e.filters[f]) { e.filters[f].enabled = s ? true : false; if (s) with (e.filters[f]) { src = s; sizingMethod = m } } else if (s) e.style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'; } function fixOnePng() { var bgImg = this.currentStyle.backgroundImage || this.style.backgroundImage; if (this.tagName == 'IMG') { if (this.currentStyle.width == 'auto') { this.style.width = this.offsetWidth + 'px'; } if ( this.currentStyle.height == 'auto') { this.style.height = this.offsetHeight + 'px'; } filt(this, this.src, 'scale'); this.src = blankImg; } else if (this.tagName == 'INPUT') { filt(this, this.src, 'scale'); this.src = blankImg; } else if (bgImg && bgImg != 'none') { if (bgImg.match(/^url[(\"']+(.*\.png)[)\"']+$/i)) { var s = RegExp.$1; if (this.currentStyle.width == 'auto') { this.style.width = this.offsetWidth + 'px'; } if (this.currentStyle.height == 'auto') { this.style.height = this.offsetHeight + 'px'; } this.style.backgroundImage = 'none'; filt(this, s, 'crop'); // IE link fix. for (var n = 0; n < this.childNodes.length; n++) { if (this.childNodes[n].style) this.childNodes[n].style.position = 'relative'; } } else filt(this); } }