//--------------------- STAAR Javascripts ----------------------------------//
//--------------------------------------------------------------------------//
//replace all existences of a character in a string with another
function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );
    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }
    return str;
}
//replace carriage return in a textarea with another character 
function escapeVal(textarea,replaceWith){ 
textarea.value = escape(textarea.value) //encode textarea string's carriage returns

for(i=0; i<textarea.value.length; i++){ 
//loop through string, replacing carriage return encoding with replaceWith

  if(textarea.value.indexOf("%0D%0A") > -1){ 
  //Windows encodes returns as \r\n hex
  textarea.value=textarea.value.replace("%0D%0A",replaceWith);
  }
  else if(textarea.value.indexOf("%0A") > -1){ 
  //Unix encodes returns as \n hex
  textarea.value=textarea.value.replace("%0A",replaceWith);
  }
  else if(textarea.value.indexOf("%0D") > -1){ 
  //Macintosh encodes returns as \r hex
  textarea.value=textarea.value.replace("%0D",replaceWith);
  }
  }
textarea.value=unescape(textarea.value) //unescape all other encoded characters
}

function optionSelected(){
	var strNav = "find-eye-surgeon.php?lstSearch=" + document.findsurgeon.lstSearch.value + "#findsurgeon"; 
  window.location.href = strNav;
}
