<!-- // 
// NO GENERAL INSTRUCTIONS IN THIS MODULE PLEASE, ONLY FUNCTION AND GLOBAL VARS FOR THE FUNCTIONS
var arrGrpProp = new Array()
var browserOK = true;
var pics = new Array();
var objCount = 0

//----------------------------------------------------------------------------------------------------
function submitOnce()
{
   if (!formIsPosted)
		formIsPosted = true;
   else    
		return false;
}

function ValidateProvince(txtProvince, txtCountry){
	// accepts the name of the cboCountry and 
	// the cboProvince
	if(txtCountry.options[txtCountry.selectedIndex].value != 'CA'){
		txtProvince.selectedIndex = 0;
	}

}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function ChangeProvince(txtCountry, txtProvince){
	// accepts the name of the cboCountry and 
	// the cboProvince
	if(txtCountry.options[txtCountry.selectedIndex].value != 'CA'){
		txtProvince.selectedIndex = 0;
	}

}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function CountCharacters(txtArea, txtCounter){
	// accepts the name of the textArea and 
	// the Counter
	txtCounter.value = txtArea.value.length;

}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function submitPage(item, f)
{
  var fieldCount = 0
  var mandatoryCount = 0
  var currentStatus = false
  var fieldName=""

	inputArray=createArrayElements(f) //get all fields and values

	// Validate all formats
	for (fieldCount=0;fieldCount < inputArray.length; fieldCount++)
	{

	 if (!inputArray[fieldCount].name) //if field does not have a name then its a group
	  fieldName = inputArray[fieldCount][0].name
	 else
	  fieldName = inputArray[fieldCount].name

	 currentStatus = validateField(item, inputArray[fieldCount],true)

	 if (!currentStatus) // error is found, exit now
	     return false // Exit
	 if ( (!isNaN( arguments.length-2)))
	 {
	   for (mandatoryCount=2; mandatoryCount < arguments.length; mandatoryCount++) //Mandatory list starts at 3rd argument
	    {
//        alert("Argument #" + mandatoryCount + " : " + arguments[mandatoryCount])
	      if (fieldName.toLowerCase()==arguments[mandatoryCount].toLowerCase()) //check if current field is mandatory
	      {
	        currentStatus = validateField(item, inputArray[fieldCount],false)
	
	        if (!currentStatus) //if at least 1 error is found, error message is lauched by validateField..exit...
	          return false // Exit
	      } // end if mandatory check
	    } // end for mandatory
	  } // end arg.length
	} // end loop fields

  return true
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function createArrayElements(f)
{

 // f is a parameter representing full reference to a form, so i only need to f.[fieldname] to access fields
 //This function will create an index of the elements a form.
 // Fields as objects
 

 var arrEl = new Array();
 var processedList = "" // This is to fix a bug when there's fields between a group of radios/checkboxes
 var i = 0;
 var j = 0;
 var tmp = ""

 /*
 The whole processedList nonsensse that you will see is to make sure that we don't process twice the same field
 Groups like radios have 2+ input pointing to the same group
 Since the function will process the group when it sees it the 1st time
 We must make sure not to process it again when we reach other group members
 
 This fixes the bug of fields being skipped when they were between group 2+ radios of the same group.
 */
 for (i=0;i<f.length;i++) //Note it is MANDATORY that all field have a NAME attribute
 {
   // check if length is supported (check the number of elements)
   // not to confuse with .value.length (check the length of the value)
   // I note it 'cause I got confused when I used the code back several months later
   if (f[f[i].name].length) 
   {
     if (!f[f[i].name].options)
      {
       // Is a group not a drop down
       // This will store properties in another array with the name of the group as the reference
       if (eval(processedList.indexOf(f[i].name+";")) == -1)
       {
         arrGrpProp[f[i].name] = new Array("name","type")
         arrGrpProp[f[i].name]['name'] = f[i].name
         arrGrpProp[f[i].name]['type'] = f[i].type
         arrEl[arrEl.length] = f[f[i].name]
         processedList+=f[i].name+";"
       }
      }
     else
     {
      // Is a dropdown
       if (eval(processedList.indexOf(f[i].name+";")) == -1)
       {
         arrEl[arrEl.length] = f[i]
         processedList += f[i].name+";"
       }
     }

   }
   else
   {
      //Is not a group
       if ( eval(processedList.indexOf(f[i].name+";")) == -1)
       {
        arrEl[arrEl.length]=f[i] //Add element to array
        processedList += f[i].name+";"
       }
   }
 }

// Leave this here, for debug usage
/*
 var tmpMsg=""
 for (i=0; i<arrEl.length; i++)
 {
  
// 	alert("i=" + i + ", name=" + arrEl[i].name)
  if (i%2)
  {
    tmpMsg += i + ". " + arrEl[i].name + "\n"
  }
	 else 
  {
    tmpMsg += i + ". " + arrEl[i].name + " | "
  }
 }

 alert("Content of Array of Element\n" + tmpMsg)
*/
 return arrEl
}  
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function validateField(callingItem, field, emptyAllowed)
{
/*
- This function will validate the content of a field
- according the type that is supposed to go in the field
- the type will be retrieved from the name of the field.

- Name of the field will ALWAYS start with the following prefixes :
sin     = Social Insurance Number field
dat     = Date field
tim     = Time field
dtm     = Date & Time field
str     = plain string field
flt     = Fraction (float) field
int     = Integer field
poc     = Postal Code field
tel     = Telephone field
mon     = Monetary field
eml     = Email field

upon the result of validation, function may launch an error message to the client, as needed

Slice starts at [param1] up to [param2] but does not include char at [param2]
note: a string in javascript, as in C++, starts at 0
*/
var fieldName
var fieldValue
var fieldType

//Reset errors
isError=false
errMsg=""

if (!field.name && field.length)
{
  fieldName = arrGrpProp[field[0].name]['name']
  fieldType = arrGrpProp[field[0].name]['type']
}
else
{
  fieldName = field.name
  fieldType = field.type
}

if (fieldType.toLowerCase()=="select-one" || fieldType.toLowerCase()=="select-multiple")
  {
   fieldValue = getSelected(field)
  }
else if (fieldType.toLowerCase()=="radio" || fieldType.toLowerCase()=="checkbox")
  {
   fieldValue = getChecked(field)
  }
else
  {
	 field.value = Trim(field.value)
	 fieldValue = field.value
  }

  fieldValue = Trim(fieldValue)

if (emptyAllowed==false &&  fieldValue.length==0)
{
 errMsg="This field requires your attention"
 isError=true
}
else if ((fieldValue.length>0) )
{ 
 fieldPrefix = fieldName.slice(0,3) //get prefix

 switch(fieldPrefix.toLowerCase())
 {
  case "sin" :
      validateSIN(fieldValue)
      clearsin()
    break;

  case "dat": 
    validateDATE(fieldValue)
    break;

  case "tim": 
    validateTIME(fieldValue)
    break;

  case "dtm": 
    validateDATETIME(fieldValue)
    break;

  case "str":
    //Validation has been removed on purpose here
    break;

  case "flt":
      validateFLOAT(fieldValue)
    break;

  case "int": 
    validateINT(fieldValue)
    break;

  case "poc": 
    validatePOC(fieldValue)
    break;

  case "tel":
    validateTELEPHONE(fieldValue)
    break;

  case "mon":
    validateMONEY(fieldValue)
    break;
  case "eml":
    validateEMAIL(fieldValue)
    break;
    
  default:
    isError=false //Unhandled type...don't care
 }
}

if (isError)
  {
    alert("Error : " + errMsg);
    if (callingItem.type)// This is to support href (header / language change)
    {
      if (callingItem.type.toLowerCase() == "radio" || callingItem.type.toLowerCase()=="checkbox")
      {
        callingItem.checked=false
      }
      else if (callingItem.type.toLowerCase() == "select-one" || callingItem.type.toLowerCase()=="select-multiple")
      {
		callingItem.selectedIndex ? callingItem.selectedIndex=false : null;
      }
    }    
    if (field[0]) //Is it a group (radio/checkbox) or a single field (input text)?
    {
      if (callingItem.type) // This is to support href (header / language change)
      {
        field[0].focus() //will create a loop (sort-of) until data is good
        if (callingItem.type.toLowerCase() == "radio" || callingItem.type.toLowerCase()=="checkbox")
        {
          field[0].checked=false
        }
        else if (callingItem.type.toLowerCase() == "select-one" || callingItem.type.toLowerCase()=="select-multiple")
        {
          field[0].selected=false
        }
      }       
    }
    else
    {
      field.focus() //will create a loop (sort-of) until data is good
      field.select()
    }

    return false
  }
isError = false
errMsg=""
return true
}
//----------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function validateDATE(fieldVal)
{
  // Begin
  // Checks for the following valid date formats:
  // DD/MM/YYYY  DD-MM-YYYY
  // Also separates date into month, day, and year variables
  var datePat = /^(\d{1,2})(\/)(\d{1,2})\2(\d{4})$/;

  
  /*
  ^^^^ Information about this string ^^^^
  Ignore first and last '/' it is code for RegExp
  Anything between () will be matched and remembered for later use
  
  ^ matches first input
  $ matches last input
  \ means that the next char after the '\' has a special meaning
  \2 means same thing as second operation in this case its : (\/)
  d means digit, it matches a number from 0 to 9
  {n,m} = matches at least N and at most M occurences. N & M are assumed to be positive
  */
  
  var matchArray = fieldVal.match(datePat); // is the format ok?
  if (matchArray == null) 
  {
    errMsg ='The date ' + fieldVal + ' is not in a valid format.\nUse the DD/MM/YYYY format'
    isError=true
    datePat = null
    matchArray=null
    return false;
  }
  month = matchArray[3]; // parse date into variables
  day = matchArray[1];

  year = matchArray[4];

  var ar = new Array(12)
  ar[0] = "January"
  ar[1] = "February"
  ar[2] = "March"
  ar[3] = "April"
  ar[4] = "May"
  ar[5] = "June"
  ar[6] = "July"
  ar[7] = "August"
  ar[8] = "September"
  ar[9] = "October"
  ar[10] = "November"
  ar[11] = "December"

  if (month < 1 || month > 12)  // check month range
  { 
    errMsg = fieldVal + ' is not a valid date\nThe month must be between 1 and 12.'
    isError=true
    datePat = null
    matchArray=null
    return false;
  }
  if (day < 1 || day > 31) 
  {
    errMsg = fieldVal + ' is not a valid date\nThe day must be between 1 and 31.'
    isError=true
    datePat = null
    matchArray=null
    return false;
  }
  if ((month==4 || month==6 || month==9 || month==11) && day==31) 
  {
    errMsg = fieldVal + ' is an invalid date\n' + ar[eval(month-1)] + " doesn't have 31 days!"
    isError=true
    datePat = null
    matchArray=null
    return false
  }
  if (month == 2)  // check for february 29th
  {
    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
    if (day>29 || (day==29 && !isleap)) {
    errMsg = fieldVal + ' is an invalid date\n' + ar[eval(month-1)] + " " + year + " doesn't have " + day + " days!";
    isError=true
    datePat = null
    matchArray=null
    return false;
  }
}
datePat = null
matchArray=null
return true;  // date is valid
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function validateINT(fieldVal)
{
// INT a merely the meaning of a number, it does not refer the usual structure of an integer
// that is, from -32765 to 32767 without fraction.
// This one will accept any number ranged from 1 to 10 digits with 1 or 2 digits for decimals
 var intMASK = /^(\d{1,10})((,|\.)(\d{1,2}))?$/
 
 var matchArray = fieldVal.match(intMASK)
 
 if (matchArray==null)
 {
  errMsg = fieldVal + " is not a valid number."
//  errMsg = fieldVal + " is not a valid number.\nYou may enter up to 10 numbers with a maximum of 2 digits for decimals"
  isError=true
  intMASK = null
  matchArray=null
  return false;
 }
intMASK = null
matchArray=null
return true;
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function validatePOC(fieldVal)
{
 var pocMASK = /^([a-z]|[A-Z])(\d{1})([a-z]|[A-Z])(\s|-)?(\d{1})([a-z]|[A-Z])(\d{1})$/
 
 var matchArray = fieldVal.match(pocMASK)
 
 if (matchArray==null)
 {
  errMsg = fieldVal + " is not a valid postal code\nUse the\nX9X 9X9 or\nX9X-9X9 or\nX9X9X9 format"
  isError=true
  pocMASK = null
  matchArray=null
  return false;
 }
pocMASK = null
matchArray=null
return true;
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function validateTELEPHONE(fieldVal)
{
 var telMASK = /^((\(\d{3}\))|(\d{3}))(\s|-)?(\d{3})(\s|-)?(\d{4})$/

 var matchArray = fieldVal.match(telMASK)
 
 if (matchArray==null)
 {
  errMsg = fieldVal + " is not a valid telephone\nUse the\n(999) 999-9999 or\n999-999-9999 format"
  isError=true
  telMASK = null
  matchArray=null
  return false;
 }
telMASK = null
matchArray=null
return true;
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function validateEMAIL(fieldVal)
{
 var mailMASK = /^([a-zA-Z0-9\-\.]+)@([a-zA-Z0-9\-]+).([a-zA-Z]{2,3})(.[a-zA-Z]{2,3})?$/
// Format : bob@myEmail.com
//          or
//          bob@myEmail.qc.ca for example

 var matchArray = fieldVal.match(mailMASK)

 if (matchArray==null)
 {
  errMsg = fieldVal + " is no a valid email format\nPlease use the \"AAAA@BBBB.CC\" format" 
  isError=true
  mailMASK = null
  matchArray=null
  return false;
 }
mailMASK = null
matchArray=null
return true;
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
function getSelected(item) //input = Select
{
 var i=0
 var tmpSelected = ""
 
 if (item.type == "select-one" || item.type=="select-multiple")
 {
  for (i=0; i<item.options.length; i++)
  if (item.options[i].selected)
  {
    tmpSelected += item.options[i].value
  }
 }
 else
 	tmpSelected=item.value
  return tmpSelected
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function getChecked(item)// input = Radio or checkbox
{
 var i=0

 var tmpChecked = ""
 var fieldName = ""
 if (!item[0])
 {
   if (item.checked)  
     tmpChecked = item.value

   else 
     tmpChecked=""
 }
 else
 {
   for (i=0; i<item.length; i++)
   {
     if (item[i].checked==true)

       tmpChecked+=item[i].value + ", "
   }
  tmpChecked = tmpChecked.slice(0,tmpChecked.length-2) // remove last "," and space
 }
 return tmpChecked
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function Trim(fieldValue)
{
var tmpValue = fieldValue
  
 while('' + tmpValue.charAt(tmpValue.length-1)==' ')
  tmpValue = tmpValue.substring(0,tmpValue.length-1);

 while('' + tmpValue.charAt(0)==' ')
  tmpValue = tmpValue.substring(1,tmpValue.length);

 return tmpValue
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function ForceLength(objField, nLength, strWarning)
{
	var strField = new String(objField.value);

	if (strField.length > nLength) {
		alert(strWarning);
		return false;
	} else
		return true;
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
// This function ensures that a field is more than or equal to the
// Length passed in.  You must call this function with the element
// name in your form (for example: "ForceLength(document.forms[0].txtElement)"
// as opposed to "ForceLength(document.forms[0].txtElement.value)"
// If the field's value is too large, an error message is displayed
// and false is returned, else true is returned.

function ForceMinLength(objField, nLength, strWarning)
{
	var strField = new String(objField.value);

	if (strField.length < nLength) {
		alert(strWarning);
		return false;
	} else
		return true;
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function simModalWindow(prmCallerFieldRef, prmName, prmWidth, prmHeigth)
{
//Parameters are NOT optional
   var leftPos = (screen.width-prmWidth)/2
   var topPos = (screen.height-prmHeigth)/2

   var windowprops = "location=no," +
                     "menubar=no," + 
                     "toolbar=no," + 
                     "scrollbars=yes," +
                     "resizable=no," +
                     "left=" + leftPos + "," +
                     "top=" + topPos + "," +
                     "width=" + prmWidth + "," +
                     "height=" + prmHeigth;
  var theWindow = window.open("about:blank", prmName, windowprops)
  
  writeHTML_Specific(theWindow, prmCallerFieldRef)
  
  return theWindow //returns the full reference to the newly created window
}
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
function writeHTML_Specific(inWindow, callerFieldRef)
{
//This function writes a very specific page and is not built to used as a generic function
//We will have to built a javascript function for each "on-the-fly" HTML page we want
 var tmp=""
 // \t = Tab, \n = New line
 tmp="<html>\n"
 tmp+="\t<head>\n"
 tmp+="\t\t<title>On the fly HTML example</title>\n"
 tmp+="\t</head>\n"
 tmp+="<body>\n"
 tmp+="\t<form action=\"#\" method=\"post\">\n"
 tmp+="\t\tHello, my name is Bob and I was created by a javascript function<br/><br/>\n"
 tmp+="\t\t<input type=\"Button\" value=\"Say Hello\" onclick=\"alert('Hello')\"><br/>\n"
 tmp+="\t\tYou may also send a little message to my caller by typing it in the textbox and then clicking on the \"Send\" button<br/>\n"
 tmp+="\t\t<input type=\"Text\" name=\"msg\" value=\"\" size=\"25\" maxlength=\"25\">\n"
 tmp+="\t\t<input type=\"Button\" value=\"Send\" onclick=\"caller.value=form.msg.value\"><br/>\n"
 tmp+="\t\t<input type=\"Button\" value=\"Close Me\" onclick=\"self.close()\"><br/>\n"
 tmp+="\t</form>\n"
 tmp+="</body>\n"
 tmp+="</html>"
 inWindow.document.write(tmp)
 inWindow.caller = callerFieldRef //Create a javascript var called "caller" which will be the ref to the calling field
}
//----------------------------------------------------------------------------------------------------

	function provincesList()
	{
		var provinces = "<option value=99>Select a province --------->" +
  		"<option value=01> Newfoundland and Labrador" +
   		"<option value=02> Nova Scotia" +
	  	"<option value=03> New Brunswick" +
  		"<option value=04> Prince Edward Island" +
		  "<option value=05> Qu&eacute;bec" +
  		"<option value=06> Ontario" +
  		"<option value=07> Manitoba" +
   		"<option value=08> Saskatchewan" +
   		"<option value=09> Alberta" +
	  	"<option value=10> British Columbia" +
  		"<option value=11> Northwest Territories" +
		  "<option value=12> Yukon" +
		  "<option value=13> Nunavut";
		  document.write(provinces);		
	}	
	
	function countriesList()
	{ 
		var countries = "<option> Select a country" + 
		"<option value=\"AFG\"> Afghanistan" + 
		"<option value=\"ALB\"> Albania" + 
		"<option value=\"DZA\"> Algeria" + 
		"<option value=\"ASM\"> American Samoa" + 
		"<option value=\"AND\"> Andorra" + 
		"<option value=\"AGO\"> Angola" + 
		"<option value=\"AIA\"> Anguilla" + 
		"<option value=\"ATG\"> Antigua and Barbuda" + 
		"<option value=\"ARG\"> Argentina" + 
		"<option value=\"ARM\"> Armenia" + 
		"<option value=\"ABW\"> Aruba" + 
		"<option value=\"AUS\"> Australia" + 
		"<option value=\"AUT\"> Austria" + 
		"<option value=\"AZE\"> Azerbaijan" + 
		"<option value=\"BHS\"> Bahamas" + 
		"<option value=\"BHR\"> Bahrain" + 
		"<option value=\"BGD\"> Bangladesh" + 
		"<option value=\"BRB\"> Barbados" + 
		"<option value=\"BLR\"> Belarus" + 
		"<option value=\"BEL\"> Belgium" + 
		"<option value=\"BLZ\"> Belize" + 
		"<option value=\"BEN\"> Benin" + 
		"<option value=\"BMU\"> Bermuda" + 
		"<option value=\"BTN\"> Bhutan" + 
		"<option value=\"BOL\"> Bolivia" + 
		"<option value=\"BIH\"> Bosnia and Herzegovina" + 
		"<option value=\"BWA\"> Botswana" + 
		"<option value=\"BRA\"> Brazil" + 
		"<option value=\"VGB\"> British Virgin Islands" + 
		"<option value=\"BRN\"> Brunei Darussalam" + 
		"<option value=\"BGR\"> Bulgaria" + 
		"<option value=\"BFA\"> Burkina Faso" + 
		"<option value=\"BDI\"> Burundi" + 
		"<option value=\"KHM\"> Cambodia" + 
		"<option value=\"CMR\"> Cameroon" + 
		"<option value=\"CAN\"> Canada" + 
		"<option value=\"CPV\"> Cape Verde" + 
		"<option value=\"CYM\"> Cayman Islands" + 
		"<option value=\"CAF\"> Central African Republic" + 
		"<option value=\"TCD\"> Chad" + 
		"<option value=\"CHL\"> Chile" + 
		"<option value=\"CHN\"> China" + 
		"<option value=\"COL\"> Colombia" + 
		"<option value=\"COM\"> Comoros" + 
		"<option value=\"COG\"> Congo" + 
		"<option value=\"COK\"> Cook Islands" + 
		"<option value=\"CRI\"> Costa Rica" + 
		"<option value=\"HRV\"> Croatia" + 
		"<option value=\"CUB\"> Cuba" + 
		"<option value=\"CYP\"> Cyprus" + 
		"<option value=\"CZE\"> Czech Republic" + 
		"<option value=\"DNK\"> Denmark" + 
		"<option value=\"DJI\"> Djibouti" + 
		"<option value=\"DMA\"> Dominica" + 
		"<option value=\"DOM\"> Dominican Republic" + 
		"<option value=\"ECU\"> Ecuador" + 
		"<option value=\"EGY\"> Egypt" + 
		"<option value=\"SLV\"> El Salvador" + 
		"<option value=\"GNQ\"> Equatorial Guinea" + 
		"<option value=\"ERI\"> Eritrea" + 
		"<option value=\"EST\"> Estonia" + 
		"<option value=\"ETH\"> Ethiopia" + 
		"<option value=\"FLK\"> Falkland Islands" + 
		"<option value=\"FRO\"> Faroe Islands" + 
		"<option value=\"FJI\"> Fiji" + 
		"<option value=\"FIN\"> Finland" + 
		"<option value=\"FRA\"> France" + 
		"<option value=\"GUF\"> French Guiana" + 
		"<option value=\"PYF\"> French Polynesia" + 
		"<option value=\"GAB\"> Gabon" + 
		"<option value=\"GMB\"> Gambia" + 
		"<option value=\"GEO\"> Georgia" + 
		"<option value=\"DEU\"> Germany" + 
		"<option value=\"GHA\"> Ghana" + 
		"<option value=\"GIB\"> Gibraltar" + 
		"<option value=\"GRC\"> Greece" + 
		"<option value=\"GRL\"> Greenland" + 
		"<option value=\"GRD\"> Grenada" + 
		"<option value=\"GLP\"> Guadeloupe" + 
		"<option value=\"GTM\"> Guatemala" + 
		"<option value=\"GIN\"> Guinea" + 
		"<option value=\"GNB\"> Guinea Bissau" + 
		"<option value=\"GUY\"> Guyana" + 
		"<option value=\"HTI\"> Haiti" + 
		"<option value=\"HND\"> Honduras" + 
		"<option value=\"HKG\"> Hong Kong" + 
		"<option value=\"HUN\"> Hungary" + 
		"<option value=\"ISL\"> Iceland" + 
		"<option value=\"IND\"> India" + 
		"<option value=\"IDN\"> Indonesia" + 
		"<option value=\"IRN\"> Iran" + 
		"<option value=\"IRQ\"> Iraq" + 
		"<option value=\"IRL\"> Ireland" + 
		"<option value=\"ISR\"> Israel" + 
		"<option value=\"ITA\"> Italy" + 
		"<option value=\"CIV\"> Ivory Coast" + 
		"<option value=\"JAM\"> Jamaica" + 
		"<option value=\"JPN\"> Japan" + 
		"<option value=\"JOR\"> Jordan" + 
		"<option value=\"KAZ\"> Kazakhstan" + 
		"<option value=\"KEN\"> Kenya" + 
		"<option value=\"KIR\"> Kiribati" + 
		"<option value=\"KWT\"> Kuwait" + 
		"<option value=\"KGZ\"> Kyrgyzstan" + 
		"<option value=\"LAO\"> Laos" + 
		"<option value=\"LVA\"> Latvia" + 
		"<option value=\"LBN\"> Lebanon" + 
		"<option value=\"LSO\"> Lesotho" + 
		"<option value=\"LBR\"> Liberia" + 
		"<option value=\"LBY\"> Libya" + 
		"<option value=\"FL\">  Liechtenstein" + 
		"<option value=\"LTU\"> Lithuania" + 
		"<option value=\"LUX\"> Luxembourg" + 
		"<option value=\"MAC\"> Macau" + 
		"<option value=\"MKD\"> Macedonia" + 
		"<option value=\"MDG\"> Madagascar" + 
		"<option value=\"MWI\"> Malawi" + 
		"<option value=\"MYS\"> Malaysia" + 
		"<option value=\"MDV\"> Maldives" + 
		"<option value=\"MLI\"> Mali" + 
		"<option value=\"MLT\"> Malta" + 
		"<option value=\"MHL\"> Marshall Islands" + 
		"<option value=\"MTQ\"> Martinique" + 
		"<option value=\"MRT\"> Mauritania" + 
		"<option value=\"MUS\"> Mauritius" + 
		"<option value=\"MEX\"> Mexico" + 
		"<option value=\"FSM\"> Micronesia" + 
		"<option value=\"MDA\"> Moldova" + 
		"<option value=\"MCO\"> Monaco" + 
		"<option value=\"MNG\"> Mongolia" + 
		"<option value=\"MSR\"> Montserrat" + 
		"<option value=\"MAR\"> Morocco" + 
		"<option value=\"MOZ\"> Mozambique" + 
		"<option value=\"MMR\"> Myanmar" + 
		"<option value=\"NAM\"> Namibia" + 
		"<option value=\"NPL\"> Nepal" + 
		"<option value=\"NLD\"> Netherlands" + 
		"<option value=\"ANT\"> Netherlands Antilles" + 
		"<option value=\"NCL\"> New Caledonia" + 
		"<option value=\"NZL\"> New Zealand" + 
		"<option value=\"NIC\"> Nicaragua" + 
		"<option value=\"NER\"> Niger" + 
		"<option value=\"NGA\"> Nigeria" + 
		"<option value=\"NFK\"> Norfolk Island" + 
		"<option value=\"PRK\"> North Korea" + 
		"<option value=\"MNP\"> Northern Mariana Islands" + 
		"<option value=\"NOR\"> Norway" + 
		"<option value=\"OMN\"> Oman" + 
		"<option value=\"PAK\"> Pakistan" + 
		"<option value=\"PLW\"> Palau" + 
		"<option value=\"PAN\"> Panama" + 
		"<option value=\"PNG\"> Papua New Guinea" + 
		"<option value=\"PRY\"> Paraguay" + 
		"<option value=\"PER\"> Peru" + 
		"<option value=\"PHL\"> Philippines" + 
		"<option value=\"POL\"> Poland" + 
		"<option value=\"PRT\"> Portugal" + 
		"<option value=\"PRI\"> Puerto Rico" + 
		"<option value=\"QAT\"> Qatar" + 
		"<option value=\"REU\"> Reunion" + 
		"<option value=\"ROM\"> Romania" + 
		"<option value=\"RUS\"> Russia" + 
		"<option value=\"RWA\"> Rwanda" + 
		"<option value=\"SHN\"> Saint Helena" + 
		"<option value=\"KNA\"> Saint Kitts and Nevis" + 
		"<option value=\"LCA\"> Saint Lucia" + 
		"<option value=\"SPM\"> Saint Pierre and Miquelon" + 
		"<option value=\"VCT\"> Saint Vincent/Grenadines" + 
		"<option value=\"WSM\"> Samoa" + 
		"<option value=\"SMR\"> San Marino" + 
		"<option value=\"STP\"> Saotome and Principe" + 
		"<option value=\"SAU\"> Saudi Arabia" + 
		"<option value=\"SEN\"> Senegal" + 
		"<option value=\"SYC\"> Seychelles" + 
		"<option value=\"SLE\"> Sierra Leone" + 
		"<option value=\"SGP\"> Singapore" + 
		"<option value=\"SVK\"> Slovak Republic" + 
		"<option value=\"SVN\"> Slovenia" + 
		"<option value=\"SLB\"> Solomon Islands" + 
		"<option value=\"SOM\"> Somalia" + 
		"<option value=\"ZAF\"> South Africa" + 
		"<option value=\"KOR\"> South Korea" + 
		"<option value=\"ESP\"> Spain" + 
		"<option value=\"LKA\"> Sri Lanka" + 
		"<option value=\"SDN\"> Sudan" + 
		"<option value=\"SUR\"> Suriname" + 
		"<option value=\"SWZ\"> Swaziland" + 
		"<option value=\"SWE\"> Sweden" + 
		"<option value=\"CHE\"> Switzerland" + 
		"<option value=\"SYR\"> Syria" + 
		"<option value=\"TWN\"> Taiwan" + 
		"<option value=\"TJK\"> Tajikistan" + 
		"<option value=\"TZA\"> Tanzania" + 
		"<option value=\"THA\"> Thailand" + 
		"<option value=\"TGO\"> Togo" + 
		"<option value=\"TKL\"> Tokelau" + 
		"<option value=\"TON\"> Tonga" + 
		"<option value=\"TTO\"> Trinidad and Tobago" + 
		"<option value=\"TUN\"> Tunisia" + 
		"<option value=\"TUR\"> Turkey" + 
		"<option value=\"TKM\"> Turkmenistan" + 
		"<option value=\"TCA\"> Turks and Caicos Islands" + 
		"<option value=\"UGA\"> Uganda" + 
		"<option value=\"UKR\"> Ukraine" + 
		"<option value=\"ARE\"> United Arab Emirates" + 
		"<option value=\"GBR\"> United Kingdom" + 
		"<option value=\"USA\"> United States" + 
		"<option value=\"VIR\"> US Virgin Islands" + 
		"<option value=\"URY\"> Uruguay" + 
		"<option value=\"UZB\"> Uzbekistan" + 
		"<option value=\"VUT\"> Vanuatu" + 
		"<option value=\"VAT\"> Vatican" + 
		"<option value=\"VEN\"> Venezuela" + 
		"<option value=\"VNM\"> Vietnam" + 
		"<option value=\"ESH\"> Western Sahara" + 
		"<option value=\"YEM\"> Yemen" + 
		"<option value=\"YUG\"> Yugoslavia" + 
		"<option value=\"ZMB\"> Zambia" + 
		"<option value=\"ZWE\"> Zimbabwe"; 		 
		document.write(countries);
	}


function submitForm(f)
{
 //This function is quite stupid really but it is needed to have the submit works
 //in href properly, it is only used to replace the submit button or input type=image
 //it is VERY important not to have this function return anything
 //otherwise the href will display what is returned by the function.
 f.submit()
}

// If you need to display messages using the alert or confirm functions,
// use the template in common.xsl (mode="message_list") to create hidden form
// fields on your page with the messages. You can then use the following
// function to retrieve a message.
function GetMessage(formName, code)
{
	return eval("document." + formName + ".msg_" + code + ".value");
}

// -->

function ShowConfirmAlert(strMessage, strRedirect)
{
	var strConfirm
	
	strConfirm = confirm(strMessage);
			
	if (strConfirm==true)
		window.location= strRedirect
			
}

//Function call by the onSubmit event to retrieve all options from the next page.
function selectAllOptions(selectBox)
{
	for(i=0; i < selectBox.length-1; i++)
	{
		selectBox.options[i].selected = true;
	}		
}
	
//Function to  transfer an selected option from a selectBox to another selectBox.
function setBoxes(toSelectBox, fromSelectBox)
{		
	for(i=0; i < fromSelectBox.options.length; i++)
	{
		choice = fromSelectBox.options[i];
		if(choice.value != "null" && choice.selected)
		{
			transfer(fromSelectBox, toSelectBox, choice, i);
			i--;
		}
	}
}
//Function call by setBoxes function (previous function)
function transfer(fromSelectBox, toSelectBox, element, pos)
{
	myLength = toSelectBox.options.length;
	toSelectBox.options[myLength-1].text = element.text;
	toSelectBox.options[myLength-1].value = element.value;
	toSelectBox.options[myLength] = new Option;
	toSelectBox.options[myLength].text = "---------------------------------------------------------------------------------";
	toSelectBox.options[myLength].value = "null";
	fromSelectBox.options[pos] = null;
}	

//Function call to select all options from a select box (to submit all options)
function selectAllOptions(selectBox)
{
		for(i=0; i <= selectBox.length-1; i++)
		{
			if(i == selectBox.length-1)
			{
				selectBox.options[i].selected = false;			
			}
			else
			{
				selectBox.options[i].selected = true;
			}
		}		
}

///////////////////////////////////////////////////////////////////////
////  THIS IS ADDED TO DEAL WITH OPENING A NEW WINDOW FROM ANCHOR TAG

window.onload = addHandlers;

function addHandlers()
{

  //every anchor element needs to add its own event handler
  var objAnchorHelpE = document.getElementById('helpLink_e');
  var objAnchorHelpF = document.getElementById('helpLink_f');
  var objAnchorBNE = document.getElementById('bn_link_e');
  var objAnchorBNF = document.getElementById('bn_link_f');
  var objAnchorSIE = document.getElementById('selfident_link_e');
  var objAnchorSIF = document.getElementById('selfident_link_f');
  var objAnchorCPE = document.getElementById('lnkCanPost_e');
  var objAnchorCPF = document.getElementById('lnkCanPost_f');
  var objAnchorCURLE = document.getElementById('lnkCompanyURL_e');
  var objAnchorCURLF = document.getElementById('lnkCompanyURL_f');
  var objAnchorES = document.getElementById('lnkEssenSkills');
  var objAnchorTU = document.getElementById('lnkTermsofUse');
  var objAnchorPI = document.getElementById('lnkPrivInfo');
  var objAnchorPS = document.getElementById('lnkPrivState');
  var objAnchorSaskat = document.getElementById('linkSaskat');
  var objAnchorQuebec = document.getElementById('linkQuebec');
  var objAnchorNorthT = document.getElementById('linkNorthT');
  

  if (objAnchorHelpE)
  {
    objAnchorHelpE.onclick = function(event){return launchWindow(this, event);}
    objAnchorHelpE.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorHelpF)
  {
    objAnchorHelpF.onclick = function(event){return launchWindow(this, event);}
    objAnchorHelpF.onkeypress = function(event){return launchWindow(this, event);}
  }
   
  if (objAnchorBNE)
  {
    objAnchorBNE.onclick = function(event){return launchWindow(this, event);}
    objAnchorBNE.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorBNF)
  {
    objAnchorBNF.onclick = function(event){return launchWindow(this, event);}
    objAnchorBNF.onkeypress = function(event){return launchWindow(this, event);}
  } 
    
  if (objAnchorSIE)
  {
    objAnchorSIE.onclick = function(event){return launchWindow(this, event);}
    objAnchorSIE.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorSIF)
  {
    objAnchorSIF.onclick = function(event){return launchWindow(this, event);}
    objAnchorSIF.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorCPE)
  {
    objAnchorCPE.onclick = function(event){return launchWindow(this, event);}
    objAnchorCPE.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorCPF)
  {
    objAnchorCPF.onclick = function(event){return launchWindow(this, event);}
    objAnchorCPF.onkeypress = function(event){return launchWindow(this, event);}
  }
  
   if (objAnchorCURLE)
  {
    objAnchorCURLE.onclick = function(event){return launchWindow(this, event);}
    objAnchorCURLE.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorCURLF)
  {
    objAnchorCURLF.onclick = function(event){return launchWindow(this, event);}
    objAnchorCURLF.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorES)
  {
	objAnchorES.onclick = function(event){return launchWindow(this, event);}
	objAnchorES.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorTU)
  {
	objAnchorTU.onclick = function(event){return launchWindow(this, event);}
	objAnchorTU.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorPI)
  {
	objAnchorPI.onclick = function(event){return launchWindow(this, event);}
	objAnchorPI.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorPS)
  {
	objAnchorPS.onclick = function(event){return launchWindow(this, event);}
	objAnchorPS.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorSaskat)
  {
    objAnchorSaskat.onclick = function(event){return launchWindow(this, event);}
    objAnchorSaskat.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorQuebec)
  {
    objAnchorQuebec.onclick = function(event){return launchWindow(this, event);}
    objAnchorQuebec.onkeypress = function(event){return launchWindow(this, event);}
  }
  
  if (objAnchorNorthT)
  {
    objAnchorNorthT.onclick = function(event){return launchWindow(this, event);}
    objAnchorNorthT.onkeypress = function(event){return launchWindow(this, event);}
  }
  

}

function launchWindow(objAnchor, objEvent)
{
  var iKeyCode, bSuccess=false;

  // If the event is from a keyboard, we only want to open the
  // new window if the user requested the link (return or space)
  if (objEvent && objEvent.type == 'keypress')
  {
    if (objEvent.keyCode)
      iKeyCode = objEvent.keyCode;
    else if (objEvent.which)
      iKeyCode = objEvent.which;

    // If not carriage return or space, return true so that the user agent
    // continues to process the action
    if (iKeyCode != 13 && iKeyCode != 32)
      return true;
  }

  bSuccess = window.open(objAnchor.href);

  // If the window did not open, allow the browser to continue the default
  // action of opening in the same window
  if (!bSuccess)
    return true;

  // The window was opened, so stop the browser processing further
  return false;
}