if(typeof window.MicrositeFormIncluded == 'undefined'){
   window.MicrositeFormIncluded = true;
   // If there is already a onload handler, save it
   if(window.onload) window.OnLoadMethodHandler = window.onload;
   
   window.onload = function (){
      // Auxiliar function to store a value into a form input
      function store_value(input, value){
         var i;
         switch(input.type){
            case 'text':
            case 'hidden':
            case 'textarea':
               input.value = value;
               break;
            case 'select-one':
               for(i=0; i<input.options.length; i++){
                  if(input.options[i].value == value){
                     input.options[i].selected=true;
                     break;
                  }
               }
               break;
            case 'checkbox':
               if(input.value == value) input.checked = true;
               break;
            default:
               if((input[0] != null) && (input[0].type == 'radio')){
                  for(i=0; i<input.length; i++){
                     if(input[i].value == value){
                        input[i].checked=true;
                        break;
                     }
                  }
               }
               break;
         }
      }
   
      // There was defined another handler? If so, execute it
      if(window.OnLoadMethodHandler) window.OnLoadMethodHandler();
   
      // Regular expressions declaration
      var trim_re             = /^[\s\n\r\t]*(.*[^\s\n\r\t])[\s\n\r\t]*$/;
      var microsite_cookie_re = /^MICROSITE_COOKIE_DATA\[(.*)\]$/;
      var BridgeForm_re       = /\/app\/userzone\/BridgeForm\.php$/;
      var RegConfirm_re       = /regconfirm/;
   
      // Loop indexes declaration
      var cookie_idx, form_idx, elements_idx;
   
      // Cookies related variables declaration
      var a_cookie_data, str_cookie, cookie_name, cookie_value, a_cookies = document.cookie.split(";");
   
      // Forms related variables declaration
      var a_inputs, form;
   
      // Loop through all forms looking for those its action is BridgeForm.php
      for(form_idx=0; form_idx<document.forms.length; form_idx++){
         form=document.forms[form_idx];
   
         if((!BridgeForm_re.test(form.action))&&(!RegConfirm_re.test(form.action))) continue;
   
         // This form is an afiliacion.com one, retrieve all his elements storing them into a_inputs
         a_inputs = new Array();
         for(elements_idx=0; elements_idx<form.elements.length; elements_idx++){
            if(form.elements[elements_idx].type=="radio"){
               // Should we store form.elements[elements_idx], we would have a radio, not agregate
               // containing all of them, so we must reference it by name!!!!!
               a_inputs[form.elements[elements_idx].name] = form.elements[form.elements[elements_idx].name];
            }
            else{
               a_inputs[form.elements[elements_idx].name] = form.elements[elements_idx];
            }
         }
   
         // Loop through cookies
         for(cookie_idx=0; cookie_idx<a_cookies.length; cookie_idx++){
            a_cookie_data = a_cookies[cookie_idx].replace(trim_re, "$1").split("=");
   
            cookie_name  = a_cookie_data[0];
            if(!a_cookie_data[1]) continue;
            cookie_value = unescape(a_cookie_data[1].replace(/\+/g," "));
   
            // If cookie was inserted by microsite, recover the name of the field which references
            if(!microsite_cookie_re.test(cookie_name)) continue;
            cookie_name = cookie_name.replace(microsite_cookie_re, "$1");

      	    //alert ('cookiefound: '+cookie_name+','+cookie_value);

            // Loop if the input corresponding to cookie is not defined
            if(!a_inputs[cookie_name]) continue;
   
            // Fill input
            // alert ('store_valeu: '+ cookie_name+','+cookie_value);
            store_value(a_inputs[cookie_name], cookie_value);
         }
      }
      
      // Any post onload defined????
      if(window.PostOnLoad) window.PostOnLoad();
   }
}
