<!-- Begin Javascript
// MY SCRIPTS
// Use this area to add new scripts that you need for your site

function moveSelected(from,to) {
    newTo = new Array();
    for(i=0; i<from.options.length; i++) {
      if (from.options[i].selected) {
        newTo[newTo.length] = cloneOption(from.options[i]);
        from.options[i] = null;
        i--;
      }
    }
    for(i=0; i<to.options.length; i++) {
      newTo[newTo.length] = cloneOption(to.options[i]);
      newTo[newTo.length-1].selected = false;
    }
    to.options.length = 0;
    for(i=0; i<newTo.length; i++) {
      to.options[to.options.length] = newTo[i];
    }
    selectionChanged(to,from);
  }

  function selectionChanged(selectedElement,unselectedElement) {
    for(i=0; i<unselectedElement.options.length; i++) {
      unselectedElement.options[i].selected=false;
    }
  }

  function cloneOption(option) {
    var out = new Option(option.text,option.value);
    out.selected = option.selected;
    out.defaultSelected = option.defaultSelected;
    return out;
  }

  function selectAll(control) {
    for(i=0; i<control.options.length; i++) {
      control.options[i].selected = true;
    }
  }
  
  function myLogout(loc) {
    document.location = loc;
  }

  function highlightRow(rowName, rowToHighlight, numberOfRows) {
    for(i=1; i<=numberOfRows; i++) {
    	document.getElementById(rowName+i).style.color = 'black';
    }
    document.getElementById(rowName+rowToHighlight).style.color = 'red';
  }
  
  function determineFeeCalcRegYears() {
    var yearsRegistered = document.getElementById('yearsRegistered');
    var modelYearComboBox = document.getElementById('modelYear');
    var modelYear;
    for(i = 0; i < modelYearComboBox.options.length; i++) {
      if(modelYearComboBox.options[i].selected) {
        modelYear = modelYearComboBox.options[i].value;
        break;
      }
    }
    
    var d = new Date();
    var currentYear = d.getFullYear();
    
    var maxRegistrationYears = 5;
    if(modelYear < currentYear) {
      maxRegistrationYears = 5 - (currentYear - modelYear);
    }
    if(maxRegistrationYears < 2) { 
      maxRegistrationYears = 2;
    }
    
    for(i = 0; i < yearsRegistered.options.length; ) {
      yearsRegistered.options[i] = null;
    }
    
    for(i = 0; maxRegistrationYears >= 1; i++) {
      yearsRegistered.options[i] = new Option(maxRegistrationYears, maxRegistrationYears);
      maxRegistrationYears--;
    }
    
    
  }
  
  
  
  
////////////////////re-loads an image for Captcha//////////////////////////////
// imgId - is the id of the image
// src - is the new source url of the image
  function reloadImage(imgId,src) {
  	var srcurl=src+'&nc='+new Date().getTime();
        document.getElementById(imgId).src = srcurl;
    }
    
    function reloadImage() {
    	var srcurl='/public.ejs?command=PublicCaptcha&nc='+new Date().getTime();
    	document.getElementById('cptImg').src = srcurl;
    }
 //////////////////////////////////////////////////////////////////   
// End Javascript -->


