<!-- library.js -->

// For reference:
// ----------------------------------------
//function CSOpenWindow(action) {
//	var wf = "";	
//	wf = wf + "width=" + action[3];
//	wf = wf + ",height=" + action[4];
//	wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
//	wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
//	wf = wf + ",menubar=" + (action[7] ? "yes" : "no");
//	wf = wf + ",toolbar=" + (action[8] ? "yes" : "no");
//	wf = wf + ",directories=" + (action[9] ? "yes" : "no");
//	wf = wf + ",location=" + (action[10] ? "yes" : "no");
//	wf = wf + ",status=" + (action[11] ? "yes" : "no");		
//	window.open(action[1],action[2],wf);
//}


function GetBankImage()
{
   var BankWindowParams;

   BankWindowParams = new Array('',/*URL*/ 'banque.asp','',400,535,false,false,false,false,false,false,false);

   CSOpenWindow(BankWindowParams);

   return false;
}

function MailToFriend(filename)
{
   var WindowParams;
   var SendPage = 'envoyer/index.asp?F='

   filename = str_replace("&", "%26", filename);

   var DirDepth = 1;
   if(MailToFriend.arguments.length > 1)
      DirDepth = MailToFriend.arguments[1];

   for(var i=0; i<DirDepth; i++)
   {
      SendPage = "../" + SendPage;
   }

   WindowParams = new Array('',/*URL*/ SendPage + filename,'',400,535,false,false,false,false,false,false,false);

   CSOpenWindow(WindowParams);

   return false;
}



function ValidateCalcForm(Lang)
{
   var passed;

   InscrireMsg       = new Array(2);
   InscrireMsg[FR]   = 'Tu dois inscrire le prix de l\'article.';
   InscrireMsg[EN]   = 'You must enter the article\'s price.';

   SemainesMsg       = new Array(2);  
   SemainesMsg[FR]   = 'Tu dois inscrire le nombre de semaines en chiffres.';
   SemainesMsg[EN]   = 'You must enter the number of weeks as a numeric value.';

   MontantMsg        = new Array(2);  
   MontantMsg[FR]    = 'Tu dois inscrire le montant par semaine.';
   MontantMsg[EN]    = 'You must enter the weekly amount.';

   document.jsform.CALC_PRICE.value          = str_replace(",", ".", document.jsform.CALC_PRICE.value);
   document.jsform.CALC_AMT_PER_WEEK.value   = str_replace(",", ".", document.jsform.CALC_AMT_PER_WEEK.value);
   
   if(isNaN(document.jsform.CALC_AMT_PER_WEEK.value) || document.jsform.CALC_AMT_PER_WEEK.value.length == 0)
      document.jsform.CALC_AMT_PER_WEEK.value = 0;

   if(isNaN(document.jsform.CALC_WEEKS.value) || document.jsform.CALC_WEEKS.value.length == 0)
      document.jsform.CALC_WEEKS.value = 0;


   passed = FieldNonEmpty(document.jsform.CALC_PRICE, InscrireMsg[Lang]);
   if(!passed) return false;

   passed = FieldIsNumber(document.jsform.CALC_PRICE, InscrireMsg[Lang]);
   if(!passed) return false;

   if(document.jsform.CALC_METHOD[0].checked)
   {
      passed = FieldNonEmpty(document.jsform.CALC_WEEKS, SemainesMsg[Lang]);
      if(!passed) return false;
      passed = FieldIsNumber(document.jsform.CALC_WEEKS, SemainesMsg[Lang]);
      if(!passed) return false;

   }
   else
   {
      passed = FieldNonEmpty(document.jsform.CALC_AMT_PER_WEEK, MontantMsg[Lang]);
      if(!passed) return false;
      passed = FieldIsNumber(document.jsform.CALC_AMT_PER_WEEK, MontantMsg[Lang]);
      if(!passed) return false;

   }

   return true;
}


function ValidateObjectiveForm(Lang)
{
   var passed;

   PriceMsg       = new Array(2);
   PriceMsg[FR]   = 'Tu dois inscrire le prix en chiffres.';
   PriceMsg[EN]   = 'You must enter a price as a numerical value.';

   SemainesMsg       = new Array(2);  
   SemainesMsg[FR]   = 'Tu dois inscrire le nombre de semaines en chiffres.';
   SemainesMsg[EN]   = 'You must enter the number of weeks as a numeric value.';


   // Must accommodate French decimal
   // -------------------------------
   document.jsform.OBJECTIVE_PRICE.value = str_replace(",", ".", document.jsform.OBJECTIVE_PRICE.value);
   document.jsform.OBJECTIVE_WEEKS.value = str_replace(",", ".", document.jsform.OBJECTIVE_WEEKS.value);

   passed = FieldNonEmpty(document.jsform.OBJECTIVE_PRICE, PriceMsg[Lang]);
   if(!passed) return false;
   passed = FieldIsNumber(document.jsform.OBJECTIVE_PRICE, PriceMsg[Lang]);
   if(!passed) return false;

   passed = FieldNonEmpty(document.jsform.OBJECTIVE_WEEKS, 'Tu dois inscrire le nombre de semaines en chiffres.');
   if(!passed) return false;
   passed = FieldIsNumber(document.jsform.OBJECTIVE_WEEKS, 'Tu dois inscrire le nombre de semaines en chiffres.');
   if(!passed) return false;

   return true;
}


// Open the file upload function
// -----------------------------
function GetFile(FormName, FieldName, SizeFieldName, MaxSize, UploadPhysPath)
{
   //alert('UploadFileChoose.asp?formname=' + FormName + '&fieldname=' + FieldName + '&sizefieldname=' + SizeFieldName + '&uploadpath=' + UploadPhysPath + '&maxsize=' + MaxSize + '&lang=' + Lang + '&pic_preview=' + pic_preview + '&pic_path=' + pic_path);

   win = window.open('../../admin/UploadFileChoose.asp?formname=' + FormName + '&fieldname=' + FieldName + '&sizefieldname=' + SizeFieldName + '&uploadpath=' + UploadPhysPath + '&maxsize=' + MaxSize,
                     "Upload",
                     "toolbar=no,location=no,resize=yes,status=yes,width=300,height=150,top=150,left=150"
               );

   win.focus();
}

