/*
Joel Margate
Oct 6, 2006
/**/
function js_parseForm(p_obj) {
    var arr_text = new Array()

	try {
	    for (i=0; i<p_obj.elements.length; i++) {
	        if (p_obj.elements[i].type == "text" && p_obj.elements[i].value.length > 0) {
	            arr_text[arr_text.length] = p_obj.elements[i].name;
	        }
	    }

	    for (i=(arr_text.length-1);arr_text.length>=i;i--) {
	        var t = "";
	        o = eval("p_obj." + arr_text[i]);
	        source = o.value;

	        for (i2=0; i2<source.length; i2++) {
	            if (source.charCodeAt(i2) == 34 || source.charCodeAt(i2) == 92) { // replace character " and \
	                t += '&#' + source.charCodeAt(i2) + ';'; 
	            }
	            else if (source.charCodeAt(i2) >= 32 && source.charCodeAt(i2) <= 126) {
		            t += source.charAt(i2);
	            }
	            else {
		            t += '&#' + source.charCodeAt(i2) + ';'; 
	            }
	        }

	        o.value = t;
	        o = null;
	    }
	}
	catch(e) {
		//do nothing
	}

    //alert(p_obj);
    return true;
    //return false;
}

function js_objForm(p_form, p_obj) {
	try {
    	o = eval("p_form." + p_obj.name);
    	o.value = js_convertToUnicode(js_trim(o.value));
    }
    catch (e) {
    	//do nothing
    }
}

function js_convertToUnicode(source) { 
  result = '';

  try {
	  for (i=0; i<source.length; i++) {
	    if (source.charCodeAt(i) == 34 || source.charCodeAt(i) == 92) { // replace character " and \
	        result += '&#' + source.charCodeAt(i) + ';'; 
	    }
	  	else if (source.charCodeAt(i) >= 32 && source.charCodeAt(i) <= 126) {
			result += source.charAt(i);
	  	}
		else {
			result += '&#' + source.charCodeAt(i) + ';'; 
		}
	  }
  }
  catch (e) {
   	//do nothing
  }
  return result; 
}

function js_trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function js_inq_recipient_add(p_obj, p_value) {
  try {
	    var to = p_obj;
	    var p_v = js_trim(p_value.value);

	    if (p_v != null && p_v != "") {
	        to.options[to.options.length] = new Option( p_v, p_v, false, false);
	        p_value.value = "";
	    }
  }
  catch (e) {
   	//do nothing
  }
}

function js_inq_recipient_remove(p_obj) {
    var to = p_obj;

    to.options[to.selectedIndex] = null;
}
