/**
 * Auto-populates form fields with passed values.
 * - 2009/08/24 Omits 'Element' parameters with no value from email which begin with '%' character(new firefox has a problem with those).
 * - 2010/12/17 No longer attempts to place a "" (blank) value into a form field (label's over inputfiels were being removed with no value).
 */
function populateForm(){var inputFields=document.getElementsByTagName("input");for(var x=0;x<formPopulationObj.name.length;x++){for(var y=0;y<inputFields.length;y++){if(formPopulationObj.name[x]==inputFields[y].name&&formPopulationObj.value[x]!="")inputFields[y].value=formPopulationObj.value[x];}}}
cURL=String(window.location.search);if(!!cURL.match(/[?&]Element[0-9]+=/gi)){if(cURL.indexOf("isDirected=true")==-1){cURL=cURL.replace(/Element[0-9]+=&/g,"");var prams=cURL.substring(1).split("&");for(var i=0;!!(tParam=prams[i]);i++){if(!!tParam.match(/^Element[0-9]+=/i)){var newVal="";for(var n=tParam.indexOf("=")+1;n<tParam.length;n++){newVal+=String(tParam.charCodeAt(n));if(n<tParam.length-1)newVal+=",";}
prams[i]=tParam.substring(0,tParam.indexOf("=")+1)+newVal;}}
cURL=cURL.substring(0,cURL.indexOf("?")+1);for(var x=0;x<prams.length;x++){cURL+=prams[x]+"&";}
cURL+="isDirected=true";location.replace(cURL);}else{var prams=cURL.substring(cURL.indexOf("?")+1).split("&");var formPopulationObj={name:new Array(),value:new Array()};for(var i=0;!!(tParam=prams[i]);i++){if(tParam.indexOf("Element")!=-1){formPopulationObj.name[formPopulationObj.name.length]=tParam.substring(0,tParam.indexOf("="));var charArray=tParam.substring(tParam.indexOf("=")+1).split(",");var newVal="";if(String.fromCharCode(charArray[0])!="%"){for(var c=0;c<charArray.length;c++){if(String.fromCharCode(charArray[c])=="+"){newVal+=" ";}else{newVal+=String.fromCharCode(charArray[c]);}}}
formPopulationObj.value[formPopulationObj.value.length]=decodeURI(newVal);}}
if(window.addEventListener)window.addEventListener("load",populateForm,false);else if(window.attachEvent)window.attachEvent("onload",populateForm);}}
