<br />
<b>Warning</b>:  Unknown: open_basedir restriction in effect. File(/home/dohy/www/access-logs/dohy.net_error_log) is not within the allowed path(s): (/home/dohy:/usr/lib/php:/usr/local/lib/php:/tmp) in <b>Unknown</b> on line <b>0</b><br />
// State table
//
// To edit the list, just delete a line or add a line. Order is important.
// The order displayed here is the order it appears on the drop down.
//

function TrimString(sInString) {
  if ( sInString ) {
    sInString = sInString.replace( /^\s+/g, "" );// strip leading
    return sInString.replace( /\s+$/g, "" );// strip trailing
  }
}

// Populates the country selected with the counties from the country list
function populateCountry(defaultCountry, id) {
  var countryLineArray = country.split('|');  // Split into lines
  var selObj = document.getElementById('countrySelect_'+id);
  selObj.options[0] = new Option(SelectCountry,'');
  selObj.selectedIndex = 0;
  for (var loop = 0; loop < countryLineArray.length - 1; loop++) {
    lineArray = countryLineArray[loop].split(':');
    countryCode  = TrimString(lineArray[0]);
    countryName  = TrimString(lineArray[1]);
    if ( countryCode != '' ) {
      selObj.options[loop + 1] = new Option(countryName, countryCode);
    }
    if ( defaultCountry == countryCode ) {
      if(0 == selObj.selectedIndex) selObj.selectedIndex = loop + 1;
    }
  }
}

function populateState(defaultCountry, defaultState, id) {
  var selObj = document.getElementById('stateSelect_'+id);
  var foundState = false;
  // Empty options just in case new drop down is shorter
//  if ( selObj.type == 'select-one' ) {

    for (var i = 0; i < selObj.options.length; i++) {
      //selObj.options[i] = null;
      selObj.remove(i);
    }
    selObj.options.length=0;
    //alert('select'+selObj.options.length);
    if(document.getElementById('countrySelect_'+id).value == 'US') {
    	selObj.options[0] = new Option(SelectStateUS,'');
    	$('lbl_prov_'+id).innerHTML = ' State: ';
    	$('lbl_zip_'+id).innerHTML = ' ZIP: ';
    	hidden_obj('prov_'+id);
    	show_obj('stateSelect_'+id);
    } else if (document.getElementById('countrySelect_'+id).value == 'CA') {
    	selObj.options[0] = new Option(SelectState,'');
    	$('lbl_prov_'+id).innerHTML = ' Province: ';
    	$('lbl_zip_'+id).innerHTML = ' Postal Code: ';    	
    	hidden_obj('prov_'+id);
    	show_obj('stateSelect_'+id);
    } else {
    	selObj.options[0] = new Option(SelectState,'');
    	$('lbl_prov_'+id).innerHTML = ' Province: ';
    	$('lbl_zip_'+id).innerHTML = ' Postal Code: ';
    	if((document.getElementById('countrySelect_'+id).value != 'AU') && (document.getElementById('countrySelect_'+id).value != 'UK')) {
    		show_obj('prov_'+id);
    		hidden_obj('stateSelect_'+id);
    	} else {
	    	hidden_obj('prov_'+id);
	    	show_obj('stateSelect_'+id);    		
    	}    	
    	//show_obj('prov_'+id);
    	//hidden_obj('stateSelect_'+id);
    }
    selObj.selectedIndex = 0;
//  }
  // Populate the drop down with states from the selected country
  var stateLineArray = state.split("|");  // Split into lines
  var optionCntr = 1;
  //alert('arr'+stateLineArray.length);
  
//  stateLineArray.sort();
  for (var loop = 0; loop < stateLineArray.length; loop++) {
    lineArray = stateLineArray[loop].split(":");
    countryCode  = TrimString(lineArray[0]);
    stateCode    = TrimString(lineArray[1]);
    stateName    = TrimString(lineArray[2]);
  if (document.getElementById('countrySelect_'+id).value == countryCode && countryCode != '' ) {
    // If it's a input element, change it to a select
/*
      if ( selObj.type == 'text' ) {
        parentObj = document.getElementById('stateSelect').parentNode;
        parentObj.removeChild(selObj);
        var inputSel = document.createElement("SELECT");
        inputSel.setAttribute("name","state");
        inputSel.setAttribute("id","stateSelect");
        parentObj.appendChild(inputSel) ;
        selObj = document.getElementById('stateSelect');
        selObj.options[0] = new Option('Select State','');
        selObj.selectedIndex = 0;
      }
*/      
      if ( stateCode != '' ) {
        selObj.options[optionCntr] = new Option(stateName, stateCode);
      }
      // See if it's selected from a previous post
      if ( stateCode == defaultState && countryCode == defaultCountry ) {
        selObj.selectedIndex = optionCntr;
      }
      foundState = true;
      optionCntr++
    }
  }  
  
  /*if(foundState) {
  	hidden_obj('prov_'+id);
  } else {
  	show_obj('prov_'+id);	
  }*/
}
