var MultiOptin;
//var jQuery;

if (MultiOptin == undefined || MultiOptin.version < 1.08) {
MultiOptin = {
   version : 1.08,

   cookies : true,
   finalForm : null,

   confirmPrompt : "",

   enable : true, // connect a function to this for conditional submissions

   formsSubmitted : 0,
   mainForm : null,

   box : null,
   formList : [ ],

   emailSource : null,
   firstnameSource : null,

   ready : false,
   layered : false,

   clone : function(obj) {
        var clone = {};
        for(var i in obj) {
            if(typeof(obj[i])=="object")
                clone[i] = MultiOptin.clone(obj[i]);
            else
                clone[i] = obj[i];
        }
        return clone;
    },


   fill : function(tag, value) {
      if (tag == "firstname") {
         if (MultiOptin.firstnameSource != null) {
            document.getElementById(MultiOptin.firstnameSource).value = value;
         }
      }
      else if (tag == "lastname") {
         if (MultiOptin.lastnameSource != null) {
            document.getElementById(MultiOptin.lastnameSource).value = value;
         }
      }
      else if (tag == "email") {
         if (MultiOptin.emailSource != null) {
            document.getElementById(MultiOptin.emailSource).value = value;
         }
      }
   },

   send : function() {
        MultiOptin.debug("Submission process started: " + MultiOptin.formList.length);

         if (MultiOptin.formList.length == 0) { return true; }
         // First, find out if we should be doing this.
         MultiOptin.ready = true;

         if (typeof MultiOptin.enable == "function" && !MultiOptin.enable()) { return true; }
         else if (!MultiOptin.enable) { return true; }

         // Disable if we've already subscribed
         //else if (MultiOptin.cookies && MultiOptinCookie.get("firstname") != undefined) { return true; }

         MultiOptin.formsSubmitted = 0;

         // Tell all catcher iframes to hit formDone when finished loading
         for (i=0;i<MultiOptin.formList.length;i++) {
            var catcherName = "catcher[" + i + "]";
            document.getElementById(catcherName).onload = MultiOptin.formDone;
         }

         // Copy just the first name over (not the last name)
         var firstname = document.getElementById(MultiOptin.firstnameSource).value.replace(/ .*$/, '');
         var lastname = document.getElementById(MultiOptin.firstnameSource).value.replace(/^.* /, '');

         if (MultiOptin.lastnameSource != null) {
            if (document.getElementById(MultiOptin.firstnameSource)) {
               lastname = document.getElementById(MultiOptin.lastnameSource).value.replace(/^.* /, '');
            }
         }

         //if (lastname == '') { lastname = firstname; }
         if (lastname == '' || lastname == firstname) { lastname = '-'; }

         // Copy the email address over.
         var email = document.getElementById(MultiOptin.emailSource).value;

         //if (firstname != '' && email != '') { MultiOptinCookie.set("firstname", firstname); }

         // Fill in all "firstname" fields
         var nameFields = MultiOptin.getClass("firstname");
         for (i=0;i<nameFields.length;i++) { nameFields[i].value = firstname; }

         // Fill in all "lastname" fields
         var nameFields = MultiOptin.getClass("lastname");
         for (i=0;i<nameFields.length;i++) { nameFields[i].value = lastname; }

         // Fill in all "email" fields
         var emailFields = MultiOptin.getClass("email");
         for (i=0;i<emailFields.length;i++) {
            emailFields[i].value = email;
         }

         // Submit all the forms
         for (i=0;i<MultiOptin.formList.length;i++) {
            MultiOptin.debug("submit form " + i);
            MultiOptin.submitForm(MultiOptin.formList[i]);
         }
         MultiOptin.debug("forms away");

         return false;
   },

   timezone : function() {
      var d = new Date();
      var hour = -d.getTimezoneOffset()/60;

      // Daylight savings
      var gmtTime = 1329935836;
      var localTime = d.getTime()/1000;
      var difference = (localTime-gmtTime);
      //alert(difference);

      
      var zones = new Array();
      zones[0] =    { id:50, name:"(GMT) Greenwich Mean Time" };
      zones[1] =    { id:49, name:"(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna" };
      zones[2] =    { id:44, name:"(GMT+02:00) Athens, Istanbul, Minsk, Cairo" };
      zones[3] =    { id:36, name:"(GMT+03:00) Moscow, St. Petersburg, Volgograd" };
      zones[4] =    { id:33, name:"(GMT+04:00) Abu Dhabi, Muscat" };
      zones[4.5] =  { id:31, name:"(GMT+04:30) Kabul" };
      zones[5] =    { id:29, name:"(GMT+05:00) Islamabad, Karachi, Tashkent" };
      zones[5.5] =  { id:28, name:"(GMT+05:30) Calcutta, Chennai, Mumbai, New Delhi" };
      zones[5.75] = { id:27, name:"(GMT+05:45) Kathmandu" };
      zones[6] =    { id:26, name:"(GMT+06:00) Almaty, Novosibirsk" };
      zones[6.5] =  { id:23, name:"(GMT+06:30) Rangoon" };
      zones[7] =    { id:21, name:"(GMT+07:00) Bangkok" };
      zones[8] =    { id:15, name:"(GMT+08:00) Taipei" };
      zones[9] =    { id:14, name:"(GMT+09:00) Osaka, Sapporo, Tokyo, Seoul" };
      zones[9.5] =  { id:10, name:"(GMT+09:30) Darwin" };
      zones[10] =   { id: 9, name:"(GMT+10:00) Brisbane" };
      zones[10] =   { id: 8, name:"(GMT+10:00) Canberra, Melbourne, Sydney, Guam" };
      zones[11] =   { id: 4, name:"(GMT+11:00) Magadan, Solomon Is., New Caledonia" };
      zones[12] =   { id: 2, name:"(GMT+12:00) Fiji, Kamchatka, Auckland" };
      zones[13] =   { id: 1, name:"(GMT+13:00) Nukualofa" };
      zones[-1] =   { id:53, name:"(GMT-01:00) Azores" };
      zones[-3] =   { id:54, name:"(GMT-03:00) Buenos Aires, Georgetown" };
      zones[-4] =   { id:59, name:"(GMT-04:00) Atlantic Time" };
      zones[-5] =   { id:61, name:"(GMT-05:00) Eastern Time" };
      zones[-6] =   { id:64, name:"(GMT-06:00) Central Time (US and Canada)" };
      zones[-7] =   { id:65, name:"(GMT-07:00) Mountain Time (US and Canada)" };
      zones[-8] =   { id:67, name:"(GMT-08:00) Pacific Time (US and Canada); Tijuana" };
      zones[-9] =   { id:68, name:"(GMT-09:00) Alaska" };
      zones[-10] =  { id:69, name:"(GMT-10:00) Hawaii" };
      zones[-11] =  { id:70, name:"(GMT-11:00) Midway Island, Samoa" };

      if (zones[hour]) { return parseInt(zones[hour].id); }
      return 0;
   },

   debug : function(msg) {
      if (MultiOptin.getParameter("test")) {
         if (msg != undefined) { alert(msg); }
         return true;
      }
      return false;
   },

   init : function(box, emailSource, firstnameSource, lastnameSource) {
      var i;
      var j;
      var blocks;
      var inputs;
      var box;

      //var jQuery;

      //MultiOptin.debug("Beginning init procedure... box = " + box + ", obj = " + document.getElementById(box));

      if (box == undefined || box == null || document.getElementById(box) == null) {
         //MultiOptin.debug("webinar optin form = " + document.getElementById("webinaroptin-form"));
         if (document.getElementById("webinaroptin-form") != null) {
            //MultiOptin.debug("box = found the webinar optin form");
            MultiOptin.box = document.getElementById("webinaroptin-form");
         }

         else if (document.getElementById("actioncomments-form") != null) {
            MultiOptin.debug("box = action comments form");
            MultiOptin.box = document.getElementById("actioncomments-form");
         }
      }
      else {
         //MultiOptin.debug("box = innerHTML");
         if (document.getElementById(box).getElementsByTagName("FORM")[0] != null) {
            MultiOptin.box = document.getElementById(box).getElementsByTagName("FORM")[0];
         }
         else {
            MultiOptin.box = document.getElementById(box.innerHTML);
         }
      }

      MultiOptin.debug("box = " + MultiOptin.box);

      MultiOptin.firstnameSource = firstnameSource;
      MultiOptin.lastnameSource = null;

      if (lastnameSource != undefined && lastnameSource != '' && document.getElementById(lastnameSource)) { MultiOptin.lastnameSource = lastnameSource; }
      MultiOptin.emailSource = emailSource;

      MultiOptin.debug("first name source = " + firstnameSource + ", obj = " + document.getElementById(firstnameSource));

      if (!document.getElementById(firstnameSource) || !document.getElementById(emailSource)) {
         MultiOptin.debug("Could not find first name or last name, quitting.");
         return false;
      }

      MultiOptin.mainForm = document.getElementById(MultiOptin.firstnameSource).form;
      MultiOptin.debug("main form chosen: " + MultiOptin.mainForm.innerHTML);
     
      if (MultiOptin.mainForm.className == "webinar") {
         // Copy main form to a background form
         MultiOptin.formList[MultiOptin.formList.length] = MultiOptin.mainForm;
      }

      // null due to redirect
      else if (MultiOptin.mainForm.WebinarOptinRedirect != undefined && MultiOptin.mainForm.WebinarOptinRedirect.value != undefined && MultiOptin.mainForm.WebinarOptinRedirect.value != null && MultiOptin.mainForm.WebinarOptinRedirect.value != "http://") {
         MultiOptin.debug("Copied main form to secondary due to having a redirect");
         MultiOptin.formList[MultiOptin.formList.length] = MultiOptin.mainForm;
      }

      // null due to background class
      else if (MultiOptin.mainForm.className == "background" || MultiOptin.mainForm.className == "autosubmit") {
         MultiOptin.formList[MultiOptin.formList.length] = MultiOptin.mainForm;
      }

      // Old way (removed) -- just grab all form tags on the page
      // MultiOptin.formList = MultiOptin.getTag("form", MultiOptin.box);

      // New way -- find extra forms on the page containing "email" class form fields
      var emailFields = MultiOptin.getClass("email");

      MultiOptin.debug("email fields: " + emailFields);

      for (i=0;i<emailFields.length;i++) {
         // Do not add the main form to the form list if we submit in the current or main window
         if (emailFields[i].form == MultiOptin.mainForm) {
            MultiOptin.debug("skipped main form: " + emailFields[i].action);
         }
         else {
            MultiOptin.formList[MultiOptin.formList.length] = emailFields[i].form;
            MultiOptin.debug("add form: " + emailFields[i].action);
         }
      }

      if (MultiOptin.mainForm.className == "webinar") {
         MultiOptin.finalForm = MultiOptin.formList[1];
         MultiOptin.formList.splice(1, 1);
      }

      // Hide the box...
      if (MultiOptin.box != null) { MultiOptin.box.style.display = "none"; }

      
      var mydomain = document.domain + "";
      var yourdomain = "www.scottbuendia.com";
      var domainreplace = new RegExp("^www\.", "gi");
      if (mydomain != yourdomain) { return; }

      MultiOptin.debug("form list: " + typeof MultiOptin.formList);
      MultiOptin.debug("email fields: " + emailFields);
      MultiOptin.debug("number of forms: " + MultiOptin.formList.length);

      // Tell all forms to submit inside that invisible iframe...
      for (i=0;i<MultiOptin.formList.length;i++) {

         // Is this a GoToWebinar form? If so, auto-detect timezone
         if (MultiOptin.formList[i].WebinarKey) {
            if (MultiOptin.formList[i].RegistrantTimeZoneKey) { MultiOptin.formList[i].RegistrantTimeZoneKey.value = MultiOptin.timezone(); }
            else { MultiOptin.formList[i].innerHTML += '<input type="hidden" name="RegistrantTimeZoneKey" value="' + MultiOptin.timezone() + '">'; }
         }

         MultiOptin.debug(MultiOptin.formList[i].action + " ... " + MultiOptin.formList[i].innerHTML);

         // Add a frame to the document to "catch" the form submission
         var catcherName = "catcher[" + i + "]";
         if (MultiOptin.debug()) {
            var newIframe = document.createElement('span');
            newIframe.innerHTML = '<iframe id="' + catcherName + '" name="' + catcherName + '" width="300" height="300" style="display:inline" src="about:blank" onload="MultiOptin.formDone()"></iframe>';
            MultiOptin.insertAfter(MultiOptin.formList[i], newIframe);
         }
         else {
            var newIframe = document.createElement('span');
            newIframe.innerHTML = '<iframe id="' + catcherName + '" name="' + catcherName + '" width="1" height="1" style="display:none" src="about:blank" onload="MultiOptin.formDone()"></iframe>';
            MultiOptin.insertAfter(MultiOptin.formList[i], newIframe);

            //MultiOptin.formList[i].innerHTML += ('<iframe id="' + catcherName + '" name="' + catcherName + '" width="1" height="1" style="display:none" src="about:blank" onload="MultiOptin.formDone()"></iframe>');
         }

         // Submit normally if this form's target is blank or top
         if (MultiOptin.formList[i].target != "_blank" && MultiOptin.formList[i].target != "_top") {
            //MultiOptin.formList[i].onsubmit = null;
            MultiOptin.formList[i].target = catcherName;
         }
      }

      // old spot for mainForm selection... seems to work better when we move it
      MultiOptin.debug("main form = " + MultiOptin.mainForm.innerHTML);

      if (false && jQuery && jQuery != undefined && typeof jQuery == "function") {
         jQuery(MultiOptin.mainForm).submit(MultiOptin.send);
      }
      else {
         MultiOptin.mainForm.onsubmit = MultiOptin.send;

         if (MultiOptin.mainForm.addEventListener != undefined && typeof MultiOptin.mainForm.addEventListener == "function") {
            //alert("add event listener");
            MultiOptin.mainForm.addEventListener("submit", MultiOptin.send, true);
         }
         else if (MultiOptin.mainForm.attachEvent != undefined && MultiOptin.mainForm.attachEvent && (typeof MultiOptin.mainForm.attachEvent == "function" || typeof MultiOptin.mainForm.attachEvent == "object")) {
            //alert("attach event");
            MultiOptin.mainForm.attachEvent("onsubmit", MultiOptin.send);
         }
         else {
            //alert("apply onsubmit");
            MultiOptin.mainForm.onsubmit = MultiOptin.send;
         }
      }

      for (i=0;i<MultiOptin.formList.length;i++) {
         MultiOptin.formList[i].onsubmit = null;
      }
   },

   submitForm : function(theForm) {
      //var jQuery;
      //alert("theForm.submit = " + typeof theForm.submit);               // IE9 = object, FF = fnction
      //alert("theForm.submit.click = " + typeof theForm.submit.click);   // IE9 = undefined, FF = function
      //alert("theForm.fireEvent = " + typeof theForm.fireEvent);

      //alert("jquery = " + typeof jQuery);                               // IE9 = undefined, FF = undefined
      //alert("theForm.onsubmit = " + typeof theForm.onsubmit);           // IE9 = object, FF = undefined

      //alert(theForm.action);

      // Try to submit the first submit button we see
      for (var i=0; i<theForm.elements.length; i++ ) {
         if (theForm.elements[i].type == 'submit') {
            //theForm.onsubmit = function() { return true; };

            //alert(typeof theForm.elements[i].click);
            //alert(theForm.onsubmit);
            theForm.elements[i].click();
            return true;
         }
      }

      // First, try to click the button named submit
      if (theForm.submit && theForm.submit.click && theForm.submit.click != undefined && (typeof theForm.submit.click == "function" || typeof theForm.submit.click == "object")) {
         //alert("the form submit.click");
         theForm.submit.click();
         return true;
      }

      // Then, try to submit the form without clicking the button
      if (theForm.submit && (typeof theForm.submit == "function" || typeof theForm.submit == "object")) {
         //alert("the form.submit");
         theForm.submit();
         return true;
      }

      if (jQuery && jQuery != undefined && typeof jQuery == "function") {
         //alert("jquery submit");
         jQuery(theForm).submit(); return true;
      }
   },

   insertAfter : function( referenceNode, newNode ) {
      referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );
   },

   formDone : function() {
      if (!MultiOptin.ready) { return false; }

      MultiOptin.formsSubmitted++;
      MultiOptin.debug("forms submitted = " + MultiOptin.formsSubmitted + " out of " + MultiOptin.formList.length);

      // Have all forms been submitted?
      if (MultiOptin.formsSubmitted >= MultiOptin.formList.length) {
         if (MultiOptin.debug() && !confirm("All forms submitted... continue or cancel?")) { return false; }

         // formerly else if
         if (MultiOptin.mainForm.WebinarOptinRedirect != undefined && MultiOptin.mainForm.WebinarOptinRedirect.value != undefined && MultiOptin.mainForm.WebinarOptinRedirect.value != null && MultiOptin.mainForm.WebinarOptinRedirect.value != "http://") {
            MultiOptin.debug("redirecting");
            document.location = MultiOptin.mainForm.WebinarOptinRedirect.value;
         }
         else if (MultiOptin.finalForm != null) {
            MultiOptin.mainForm = MultiOptin.finalForm;

            if (MultiOptin.mainForm.removeEventListener != undefined && (typeof MultiOptin.mainForm.removeEventListener == "function" || typeof MultiOptin.mainForm.removeEventListener == "function")) {
               MultiOptin.mainForm.removeEventListener("submit", MultiOptin.send, true);
            }
            if (MultiOptin.mainForm.attachEvent != undefined && MultiOptin.mainForm.attachEvent && (typeof MultiOptin.mainForm.attachEvent == "function" || typeof MultiOptin.mainForm.attachEvent == "object")) {
               MultiOptin.mainForm.detachEvent("onsubmit", MultiOptin.send);
            }

            //MultiOptin.mainForm.onsubmit = function() { return true; };
            MultiOptin.mainForm.onsubmit = null;
            //alert("submit main form");
            MultiOptin.submitForm(MultiOptin.mainForm);
         }
         else if (MultiOptin.mainForm.className == "background" || MultiOptin.mainForm.className == "autosubmit") {
            MultiOptin.mainForm.onsubmit = function() { return false; };
            if (MultiOptin.mainForm.attachEvent != undefined && MultiOptin.mainForm.attachEvent && typeof MultiOptin.mainForm.attachEvent == "function") { detachEvent("onsubmit", MultiOptin.mainForm); }

            MultiOptin.debug("hide the main form at this point");
            MultiOptin.mainForm.style.display = "none";
         }
         else if (MultiOptin.formList[0] != MultiOptin.mainForm) {
            // Don't get us caught in a loop
            //alert("submitting the main form");

            if (MultiOptin.mainForm.removeEventListener != undefined && (typeof MultiOptin.mainForm.removeEventListener == "function" || typeof MultiOptin.mainForm.removeEventListener == "function")) {
               MultiOptin.mainForm.removeEventListener("submit", MultiOptin.send, true);
            }
            if (MultiOptin.mainForm.attachEvent != undefined && MultiOptin.mainForm.attachEvent && (typeof MultiOptin.mainForm.attachEvent == "function" || typeof MultiOptin.mainForm.attachEvent == "object")) {
               MultiOptin.mainForm.detachEvent("onsubmit", MultiOptin.send);
            }

            //MultiOptin.mainForm.onsubmit = function() { return true; };
            MultiOptin.mainForm.onsubmit = null;
            //alert("submit main form");
            MultiOptin.submitForm(MultiOptin.mainForm);
         }

         for (i=0; i<MultiOptin.formList.length; i++) {
            // If any of the forms were GoToWebinar forms, make sure to hide them after submitting
            if (MultiOptin.formList[i].action.indexOf("gotomeeting.com") > -1) {
               MultiOptin.formList[i].style.display = "none";
            }
         }
      }
   },

   // Try to figure out which "firstname" "lastname" and "email" fields to use
   detect : function() {
      //if (MultiOptin.layered) { return; }

      if (document.getElementById("firstname")) {
         MultiOptin.debug("firstname already exists");
      }
      else {
         // Tag each input element inside a "multioptin-firstname" under the firstname class
         blocks = MultiOptin.getClass("multioptin-firstname");
         if (blocks && blocks.length > 0) {
            for (i=0; i<blocks.length; i++) {
               inputs = blocks[i].getElementsByTagName("INPUT");
               for (j=0; j<inputs.length; j++) {
                  inputs[j].id = "firstname";
               }
            }
         }
      }

      if (!document.getElementById("lastname")) {
         blocks = MultiOptin.getClass("multioptin-lastname");
         if (blocks && blocks.length > 0) {
            for (i=0; i<blocks.length; i++) {
               inputs = blocks[i].getElementsByTagName("INPUT");
               for (j=0; j<inputs.length; j++) { inputs[j].id = "lastname"; }
            }
         }
      }

      if (!document.getElementById("email")) {
         blocks = MultiOptin.getClass("multioptin-email");
         if (blocks && blocks.length > 0) {
            for (i=0; i<blocks.length; i++) {
               inputs = blocks[i].getElementsByTagName("INPUT");
               for (j=0; j<inputs.length; j++) { inputs[j].id = "email"; }
            }
         }
      }

      // Guess the firstname and email fields if they are not defined
      //if (!document.getElementById("firstname")) {
         blocks = document.getElementsByTagName("INPUT");
         var nameGuess = '|name|firstname|fname|firstname|from|SubscriberName|category2|SendName|Contact0FirstName|Name_First|';
         for (i=0;i<blocks.length;i++) {
            if (nameGuess.indexOf('|' + blocks[i].name + '|') > -1) {

               MultiOptin.debug("first name = " + blocks[i].name);

               blocks[i].id = "firstname";
               break;
            }
         }
      //}

      //if (!document.getElementById("lastname")) {
         blocks = document.getElementsByTagName("INPUT");
         var nameGuess = '|lname|lastname|Contact0LastName|Name_Last|';
         for (i=0;i<blocks.length;i++) {
            if (nameGuess.indexOf('|' + blocks[i].name + '|') > -1) {
               blocks[i].id = "lastname";
               break;
            }
         }
      //}

      //if (!document.getElementById("email")) {
         blocks = document.getElementsByTagName("INPUT");
         var emailGuess = '|email|Email1|MailFromAddress|category3|SendEmail|Contact0Email|Email|';
         var nonEmailGuess = '|password|';
         for (i=0;i<blocks.length;i++) {
            if (emailGuess.indexOf('|' + blocks[i].name + '|') > -1) {

               if (nonEmailGuess.indexOf('|' + blocks[i].name + '|') > -1) {
                  continue; // skip over this one
               }

               MultiOptin.debug("email = " + blocks[i].name);
               blocks[i].id = "email";
               break;
            }
         }
      //}

      MultiOptin.layered = true;
   },

   getClass : function(clsName, source) {
      if (source == undefined) {
         source = document;
      }

      var retVal = new Array();
      var elements = source.getElementsByTagName("*");

      for (var i=0;i < elements.length;i++) {
         if (elements[i].className.indexOf(" ") >= 0) {

            var classes = elements[i].className.split(" ");
            for (var j = 0;j < classes.length;j++) {
               if (classes[j] == clsName) { retVal.push(elements[i]); }
            }
         }
         else if(elements[i].className == clsName) {
            retVal.push(elements[i]);
         }
      }
      return retVal;
   },

   getTag : function(tagName, source) {
      if (source == undefined) {
         source = document;
      }

      var retVal = new Array();
      var elements = source.getElementsByTagName(tagName);

      for (var i=0;i < elements.length;i++) {
         retVal.push(elements[i]);
      }
      return retVal;
   },

   getParameter : function(parameter, url) {
      if (url == undefined) { url = window.location.search.substring(0); }
      else { url = url.substring(0); }

      if (url == "") { return undefined; }

      var results = url.match(
         new RegExp("(?:&|\\?)" + parameter + "=(.*?)(?:&|$)", "")
      );

      if (results && results != null && results.length >= 1) {
         return unescape(results[1]);
      }
      return undefined;
   }
};

}
// End MultiOptin framework

function WebinarOptin(url) {

   this.print = function(url) {
      // GoToWebinar
      if (url.match(/[0-9]{9,}/) || url.indexOf("gotomeeting.com") > -1) {
         var webinarID = url.match(/[0-9]{9,}/);

         // Find a 9-plus digit number in the URL...
         if (webinarID) {
            var html = document.getElementById("webinaroptin").innerHTML;
            var formCode = '<form action="https://www2.gotomeeting.com/en_US/island/webinar/registration.flow" method="post" class="webinar">';

            var timezone = MultiOptin.timezone();
            if (timezone > 0) { formCode += '<input type="hidden" name="RegistrantTimeZoneKey" value="' + timezone + '">'; }

            formCode += '<input type="hidden" name="Form" value="webinarRegistrationForm">' +
            '<input type="hidden" name="WebinarKey" value="' + webinarID + '">' +
            'Firstname: <input type=text name="Name_First" class="firstname"> ' +
            'Lastname: <input type=text name="Name_Last" class="lastname">' +
            'Email: <input type=text name="Email" class="email">' +
            '<input type="submit">' +
            '</form>';

            html = html + formCode;
            document.getElementById("webinaroptin").innerHTML = html;
         }
      }
   }; // end this.print

   if (url != undefined) {
      if (!document.getElementById("webinaroptin")) {
         document.write('<div id="webinaroptin" style="display:none;"></div>');
      }
      this.print(url);
   }

   MultiOptin.cookies = false;
   MultiOptin.detect();
   MultiOptin.init("webinaroptin", "email", "firstname", "lastname");
   MultiOptin.enable = true;

   // Next, try to fill in query string variables
   var firstname = undefined;
   var lastname = undefined;
   var email = undefined;

   // Look for squeeze.html?firstname=Robert&lastname=Plank notation
   firstname = MultiOptin.getParameter("firstname");
   lastname = MultiOptin.getParameter("lastname");
   email = MultiOptin.getParameter("email");

   // Also accept f, l, and e
   if (!firstname) { firstname = MultiOptin.getParameter("f"); }
   if (!lastname) { lastname = MultiOptin.getParameter("l"); }
   if (!email) { email = MultiOptin.getParameter("e"); }

   if (firstname != undefined) {
      firstname = firstname.replace(/.html?$/, '');
   }
   if (email != undefined) {
      email = email.replace(/.html?$/, '');
   }

   if (email == "[[email]]" || email == "[email]" || email == "!email" || email == '{email}' || email == 'email') { email = undefined; }
   if (firstname == '{firstname}') { firstname = undefined; }

   if (firstname != undefined && lastname == undefined) {
      lastname = "-";
   }

   MultiOptin.debug("query string firstname = " + firstname);

   // Fill in form fields if applicable
   if (firstname != undefined) {
      MultiOptin.fill("firstname", firstname);
   }
   if (lastname != undefined) {
      lastname = lastname.replace(/.html?$/, '');
      MultiOptin.fill("lastname", lastname);
   }
   if (email != undefined) {
      MultiOptin.fill("email", email);
   }

   if (firstname != undefined && email != undefined) {
      //alert("submit!!");
      if (MultiOptin.debug()) { alert("Submitting the form..."); }

      if (MultiOptin.debug()) {
      }
      else {
         MultiOptin.submitForm(MultiOptin.mainForm); // auto submit the form
      }
   }

    // Submit all forms with class "autosubmit"
    for (i=0;i<MultiOptin.formList.length;i++) {
       MultiOptin.debug(MultiOptin.formList[i].className);
       if (MultiOptin.formList[i].className == "autosubmit") {
         MultiOptin.debug("autosubmit: " + MultiOptin.formList[i].id + ", class: " + MultiOptin.formList[i].className);
         MultiOptin.send(MultiOptin.formList[i]);
       }
    }
} // WebinarOptin

if (document.getElementById("webinaroptin-id") != null) { WebinarOptin(document.getElementById("webinaroptin-id").value); } else { WebinarOptin(); }
