function buildsalaryRangeSelectControl(jobType, salaryRange, salaryRangeDefault,  countryCode)
    {
	
        // Clear the select control
        clearSelectControl(salaryRange);
        
    
        // Get the selected parent value (country)
        var selectedParentValueCountry;
        selectedParentValueCountry = countryCode;
         // Get the selected parent value (jobType)
        var selectedParentIndexJobType, selectedParentValueJobType;

        var user_input = '';
        for (i=0;i<jobType.length;i++)
        {
          if (jobType[i].checked)
          {
           selectedParentIndexJobType = i;
           selectedParentValueJobType = jobType[i].value;
 
          }
        }
        
        // The key used to find the index in the salaryRangeOptions array is a combination
        // of the countryId and the jobtypeId
        var parentKey = selectedParentValueJobType;
      
       
    
        // Search for the key in the parent array list to try and find it's index
        // that will be used in the children array.
        var found = false;
        var childrenIndex;
    
      
        for (var i=0; i < countryJobType.length && !found; i++) {
             if (countryJobType[i] == parentKey) {
                found = true;
                childrenIndex = i;
            }
        }

        // Loop through the parent's children array and add each one as an option
        // to the select control
   

        if (found && salaryRangeOptions[childrenIndex].length > 0) {
           	 
            // enable the child
             salaryRange.disabled = false;

            // Add any pre options that are to be added to each children list

            var newOp = new Option(salaryRangeDefault, '0', true, true);
            salaryRange.options[salaryRange.length] = newOp;

            // Loop through the parent's children array and add each one as an option
            // to the select control
            for (var i=0; i < salaryRangeOptions[childrenIndex].length; i++) {
            	
                var newOp = new Option(salaryRangeOptions[childrenIndex][i][0] , salaryRangeOptions[childrenIndex][i][1], false, false);
                salaryRange.options[salaryRange.length] = newOp;
            }
        }
        
        else {
      
            // Add any pre options that are to be added to each children list
            var newOp = new Option(salaryRangeDefault, '0', true, true);
            salaryRange.options[salaryRange.length] = newOp;
            
            // Loop through the parent's children array and add each one as an option
            // to the select control
            for (var i=0; i < salaryRangeAllOptions.length; i++) {
            	
                var newOp = new Option(salaryRangeAllOptions[i][0], salaryRangeAllOptions[i][1], false, false);
                salaryRange.options[salaryRange.length] = newOp;
            }        	
        	
        	
//        	
//            // Add a reason for the user to explain why there are no salaries
//            var newOp = new Option(thisForm.noSalaryRangeAvailableMessage.value, '-2', true, true);
//            thisForm.salaryRange.options[thisForm.salaryRange.length] = newOp;
//
//            // Disable the child
//            thisForm.salaryRange.disabled = false;
//            thisForm.salaryRange.selectedIndex = 0;
        }
    }

    function clearSelectControl(controlObject) {

        // Clear the select control
        while (controlObject.length > 0) {
            controlObject.options[0] = null;
        }
    }

    /**
     * 
     * @param specPL The specialisation pick list.
     * @param subspecPL The sub-specialisation pick list.
     * @param specKeys A one-dimensional array with specialisation keys.
     * @param subSpecOptions A two-dimensional array with sub-specialisation key and value.
     * @param defaultSubSpecOption The label text for the pre option for the sub specialisation
     *        pick list. If the pre option is an empty string, no pre option will be added.
     */
    function buildSubSpecialisationSelectControl(specPL, subSpecPL, specKeys, subSpecOptions, defaultSubSpecOption) {
  
        // Clear the select control
        clearSelectControl(subSpecPL);

        // Get the selected parent specialisation value
        var selectedParentIndex, selectedParentValue;
        selectedParentIndex = specPL.selectedIndex;
        selectedParentValue = specPL.options[selectedParentIndex].value;
        //alert("selected parent index = " + selectedParentIndex + "|" + selectedParentValue);
        // Search for the value in the parent array list to try and find it's index
        // that will be used in the children array. This needs to be done instead of
        // simply using the parent index incase a 'please select....' option has been added
        // to the parent control
        var found = false;
        var childrenIndex;
        for (var x=0; x < specKeys.length && !found; x++) {
            if (specKeys[x] == selectedParentValue) {
                found = true;
                childrenIndex = x;
            }
        }

        // Add any pre options that are to be added to each children list
        if (defaultSubSpecOption == null || defaultSubSpecOption != "") {
        	var newOp = new Option(defaultSubSpecOption, '0', true, true);
        	subSpecPL.options[subSpecPL.length] = newOp;
        }

        // Loop through the parent's children array and add each one as an option
        // to the select control
        if (found) {
            // enable the child
        	subSpecPL.disabled = false;

            // Loop through the parent's children array and add each one as an option
            // to the select control
    //alert(subSpecialisationsOptions[childrenIndex].length-1);
            var lengthy = subSpecOptions[childrenIndex].length;
            for (var i=0; i < lengthy; i++) {
            
                var newOp = new Option(subSpecOptions[childrenIndex][i][0].replace('&quot;', "'"), subSpecOptions[childrenIndex][i][1], false, false);
    //alert(subSpecialisationsOptions[childrenIndex][i][0]);
                subSpecPL.options[subSpecPL.length] = newOp;
            }
        }
        else {
            // Disable the child
        	subSpecPL.disabled = true;
        	subSpecPL.selectedIndex = -1;
        }
    }
    
    function hideTextFieldLabel(inObj, hide) {
  	  var field_for;
  	  var labels = document.getElementsByTagName('label');
  	  for (var i = 0; i < labels.length; i++) {
  	    field_for = labels[i].htmlFor || labels[i].getAttribute('for');
  	    if (field_for == inObj.getAttribute('id')) {
  	    		labels[i].style.textIndent = (hide) ? '-10000px' : '0px';
  	    		return true;
  	    }
  	  }
    }
    
    // Initializes labels chosen for hiding (keywords in jobsearch, ...)
    function initOverlabels() {
   	 if (!document.getElementById) return;      

   	  var labels, id, field;

   	  // Set focus and blur handlers to hide and show 
   	  // labels with 'overlabel' class names.
   	  labels = document.getElementsByTagName('label');
   	  for (var i = 0; i < labels.length; i++) {

   	    if (labels[i].className == 'overlabel' || labels[i].className == 'searchbox_overlabel') {

   	      // Skip labels that do not have a named association
   	      // with another field.
   	      id = labels[i].htmlFor || labels[i].getAttribute('for');
   	      
   	      if (!id || !(field = document.getElementById(id))) {
   	        continue;
   	      } 

   	      // Change the applied class to hover the label 
   	      // over the form field.
   	      
   	      if (labels[i].className ==  'searchbox_overlabel') {
   	    	 labels[i].className = 'searchbox_overlabel';
   	      } else {
   	    	  labels[i].className = 'overlabel';
   	      }
   	      
   	      // Hide any fields having an initial value.
   	      if (field.value !== '') {
   	    	hideTextFieldLabel(field, true);
   	    	//alert(id+" hide it!");
   	      }

   	      // Set handlers to show and hide labels.
   	      field.onfocus = function () {
   	    	hideTextFieldLabel(this, true);
   	      };
   	      field.onblur = function () {
   	        if (this.value === '') {
   	        	hideTextFieldLabel(this, false);
   	        }
   	      };

   	      // Handle clicks to label elements (for Safari).
   	      labels[i].onclick = function () {
   	        var id, field;
   	        id = this.getAttribute('for');
   	        if (id && (field = document.getElementById(id))) {
   	          field.focus();
   	        }
   	      };

   	    }
   	  }
   }
   

