<!--
 
//Used by register.htm to set the form from variables passed by
//the Mangolab application registration screen
//Copyright Mangolab 2002
//NB Non GENERIC 

var TempKeys = new Array(12);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//NB Apps name must be in lower case
//Keys dished out here must be temp. gen. release keys 
//created in regcontrol using username=registered@mangolab.com:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//MANGOREG:
TempKeys[0] = "mangoreg"; //must be app name & lower case        
TempKeys[TempKeys[0]] = "0C54225E56791387AE9616AE";  

//MANGOBOT:
TempKeys[1] = "mangobot"; //must be app name & lower case        
TempKeys[TempKeys[1]] = "0C54225E56791387AE9616AE"; 

//MANGOMART:
TempKeys[2] = "mangomart"; //must be app name & lower case        
TempKeys[TempKeys[2]] = "0C6E2245C9205887AEB85F2B"; 

//DI ALP:
TempKeys[3] = "alp"; //must be app name & lower case        
TempKeys[TempKeys[3]] = "4607125EB59F2913870668F2";

//Santaba:
TempKeys[4] = "santaba"; //must be app name & lower case - this is a 1 year soft license       
TempKeys[TempKeys[4]] = "F75C80AF498255D7CB025AE0";

//Add more products & keys here...

//e.g. ref with AStr = parms['varN']; for search query in form:
//http...page.htm?var1=val1&var2=val2...&varN=valN

var StrErrEmail="<Please enter *your* email address>";

function RegisterFormOnLoad(){
SetRegDetailsFromParams();
PopulateFormFromContactDetailsCookie(0,false);
}

function SetRegDetailsFromParams(){
var astr = location.search;
var FrmInput=document.forms[0];
if (astr != null && astr != ''){ // start conditional
   arraySubParms(astr);
   var StrEmail=parms['username'];
   FrmInput.EdtProduct.value = parms['app'];
   FrmInput.EdtUserName.value = StrEmail; 
   FrmInput.email.value = StrEmail; 
   FrmInput.EdtSerialNumber.value = parms['serial'];
   }
//document.write(astr)
}


function RegThanksWithParams(){
//validate extra registration stuff
if (ValidateRegForm()){
   //pass the params on to the thanks page
   //which sets the redirect field value	
   return FormThanks('http://www.mangolab.com/regis_th.htm'+GetThanksPageSearchParam());
   }
   else {
   return false;
   }
}


function GetThanksPageSearchParam(){
//validate extra registration stuff
var FrmInput=document.forms[0];
var AStr = '?app=' + FrmInput.EdtProduct.value + '&serial='+FrmInput.EdtSerialNumber.value + '&username='+ FrmInput.EdtUserName.value+'&';
return AStr;
}

function SetFormThanksTempLicenseDetails(){
var astr = location.search;
var FrmInput=document.forms[0];
if (astr != null && astr != ''){ // start conditional
   arraySubParms(astr);
   var StrApp = parms['app'];
   var StrUser = parms['username'];
   FrmInput.EdtProduct.value = StrApp;
   FrmInput.EdtUserName.value = StrUser;
   StrApp=StrApp.toLowerCase();	
   FrmInput.EdtRegKey1.value = TempKeys[StrApp].substring(0,4); 
   FrmInput.EdtRegKey2.value = TempKeys[StrApp].substring(4,8);
   FrmInput.EdtRegKey3.value = TempKeys[StrApp].substring(8,12);
   FrmInput.EdtRegKey4.value = TempKeys[StrApp].substring(12,16);
   FrmInput.EdtRegKey5.value = TempKeys[StrApp].substring(16,20);
   FrmInput.EdtRegKey6.value = TempKeys[StrApp].substring(20,24);
   //Add the link to the appropriate reg file
   //tainted: document.anchors["JmpDownLoad"].href = "http://www.mangolab.com/licenses/"+StrApp+".reg";
   }
}

//To download & install license reg file
function DownInstall(){
var astr = location.search;
var FrmInput=document.forms[0];
if (astr != null && astr != ''){ // start conditional
   arraySubParms(astr);
   var StrApp = parms['app'].toLowerCase();
   window.location="http://www.mangolab.com/licenses/"+StrApp+".reg";
   }
return true;
}
   
function ValidateRegForm(){
var FrmInput=document.forms[0];
//now call standard validation in jforms.js
var StrUserName=FrmInput.EdtUserName.value;
StrUserName=StrUserName.toLowerCase();
var StrEmail=FrmInput.email.value;
StrEmail=StrEmail.toLowerCase();
var result = StrUserName!=StrErrEmail.toLowerCase();
if (result) {
   result = ((StrUserName==StrEmail) || (StrEmail==""));
   if (!result) {
      alert("Sorry, the values in the USERNAME and EMAIL fields do not match.  Please amend the form so that both of these values reflect *your* email address and resubmit.");
      }
   }
   else {
   alert("Sorry, you have entered an invalid USERNAME. Please amend the form so that the Username reflects *your* email address and resubmit.");
   result=false;
   } 
return result;
}





//-->
