// Original JavaScript code by Duncan Crombie: dcrombie@chirp.com.au
// Please acknowledge use of this code by including this header.
// CONSTANTS
var separator = ","; // use comma as 000's separator
var decpoint = "."; // use period as decimal point
var percent = "%";
var currency = "$"; // use dollar sign for currency
function formatNumber(number, format, print) { // use: formatNumber(number, "format")
if (print) document.write("formatNumber(" + number + ", \"" + format + "\")
");
if (number - 0 != number) return null; // if number is NaN return null
var useSeparator = format.indexOf(separator) != -1; // use separators in number
var usePercent = format.indexOf(percent) != -1; // convert output to percentage
var useCurrency = format.indexOf(currency) != -1; // use currency format
var isNegative = (number < 0);
number = Math.abs (number);
if (usePercent) number *= 100;
format = strip(format, separator + percent + currency); // remove key characters
number = "" + number; // convert number input to string
// split input value into LHS and RHS using decpoint as divider
var dec = number.indexOf(decpoint) != -1;
var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";
// split format string into LHS and RHS using decpoint as divider
dec = format.indexOf(decpoint) != -1;
var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";
// adjust decimal places by cropping or adding zeros to LHS of number
if (srightEnd.length < nrightEnd.length) {
var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
nrightEnd = nrightEnd.substring(0, srightEnd.length);
if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1); // round up
// patch provided by Patti Marcoux 1999/08/06
while (srightEnd.length > nrightEnd.length) {
nrightEnd = "0" + nrightEnd;
}
if (srightEnd.length < nrightEnd.length) {
nrightEnd = nrightEnd.substring(1);
nleftEnd = (nleftEnd - 0) + 1;
}
} else {
for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
if (srightEnd.charAt(i) == "0") nrightEnd += "0"; // append zero to RHS of number
else break;
}
}
// adjust leading zeros
sleftEnd = strip(sleftEnd, "#"); // remove hashes from LHS of format
while (sleftEnd.length > nleftEnd.length) {
nleftEnd = "0" + nleftEnd; // prepend zero to LHS of number
}
if (useSeparator) nleftEnd = separate(nleftEnd, separator); // add separator
var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : ""); // combine parts
output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
if (isNegative) {
// patch suggested by Tom Denn 25/4/2001
output = (useCurrency) ? "(" + output + ")" : "-" + output;
}
return output;
}
function strip(input, chars) { // strip all characters in 'chars' from input
var output = ""; // initialise output string
for (var i=0; i < input.length; i++)
if (chars.indexOf(input.charAt(i)) == -1)
output += input.charAt(i);
return output;
}
function separate(input, separator) { // format input using 'separator' to mark 000's
input = "" + input;
var output = ""; // initialise output string
for (var i=0; i < input.length; i++) {
if (i != 0 && (input.length - i) % 3 == 0) output += separator;
output += input.charAt(i);
}
return output;
}
// Stop hiding -->
var isNav4, isNav6, isIE4;
openCal = false;
openTime = false;
openThumb = false;
function cancelEvent() {
event.returnValue = false;
}
function replace(inString,oldText,newText) {
return (inString.split(oldText).join(newText));
}
function ToggleID(id) {
if (document.getElementById(id).style.visibility == "visible") {
HideID(id);
} else {
ShowID(id);
}
}
function ShowID(id) {
document.getElementById(id).style.visibility = "visible";
document.getElementById(id).style.position = "relative";
}
function HideID(id) {
document.getElementById(id).style.visibility = "hidden";
document.getElementById(id).style.position = "absolute";
}
function HiLite(imgDocID, imgStatus) {
tmp = eval(imgDocID + "_" + imgStatus + ".src");
document.images[imgDocID].src = tmp;
}
function SetBrowser() {
if (navigator.appVersion.charAt(0) == "4") {
if (navigator.appName.indexOf("Explorer") >= 0) {
isIE4 = true;
} else {
isNav4 = true;
}
} else if (navigator.appVersion.charAt(0) > "4") {
isNav6 = true;
}
}
SetBrowser();
rxTxt = new RegExp("[^-a-zA-Z0-9,\._@ ]");
rxNum = new RegExp("[^-0-9 \., ]");
function Validate(iVal,iName,iForm,type,text,minVal,maxVal) {
errTxt = "";
switch (type) {
case "num":
if (rxNum.test(iVal)) {
errTxt = errTxt + text + " may only consist of the characters within the brackets [0-9, . -]\n";
} else {
iVal = iVal*1;
if (minVal != "" && iVal < (minVal*1)) {
errTxt = errTxt + text + " must be greater than or equal to " + minVal + "\n";
}
if (maxVal != "" && iVal > (maxVal*1)) {
errTxt = errTxt + text + " must be less than or equal to " + maxVal + "\n";
}
}
break;
case "txt":
if (rxTxt.test(iVal)) {
errTxt = errTxt + text + " may only consist of the following:\n\n\t0-9\n\ta-z\n\tA-Z\n\t@\n\t, (comma)\n\t. (period)\n\t- (dash)\n\t_ (underscore)\n";
}
break;
default:
//Nothing
break;
}
if (errTxt != "") {
alert(errTxt);
eval("document."+iForm+" . "+iName+".focus();");
return false;
} else {
return true;
}
}
function ReturnDiv(divarea,txt) {
if (isNav4) {
var lyr = document.layers[divarea].document;
lyr.open()
lyr.write(txt);
lyr.close();
} else if (isIE4) {
divRoot = document;
divRoot.all[divarea].innerHTML = txt;
}
}
function ID_checkIn(div_ID) {
var theObj,ss,sr,i,j,WM_layers=new Array();
if (document.all || document.getElementById) {
if(false && (document.getElementById(div_ID).style.position != 'absolute') && (document.getElementById(div_ID).style.position != 'relative')){
for (ss = 0 ; ss < document.styleSheets.length; ss++) {
for (sr = 0 ; sr < document.styleSheets(ss).rules.length; sr++) {
if (document.styleSheets(ss).rules(sr).selectorText == '#' + div_ID) {
theObj = document.styleSheets(ss).rules(sr).style;
break;
}
}
}
} else {
theObj = document.getElementById(div_ID).style;
}
} else if(document.layers) {
WM_layers = new Array();
with (document) {
for (i = 0; i= 0; i--) {
ruleList = sheetList[i].cssRules;
for (j = 0; j -1 && value.indexOf("url(") == -1) {
value = "url(\'" + value + "\')";
//alert(id + ":" + property + ":" + value);
}
if (isNav6) {
var styleObject = document.getElementById(id);
if (styleObject != null) {
styleObject = styleObject.style;
styleObject[property] = value;
}
} else if (isNav4) {
//alert(id+"&"+property);
document[id][property] = value;
} else if (isIE4) {
eval("div_OBJ."+property+"= value;");
}
}
function GetJSID(PK_prod, PK_var) {
id_str = "selection_" + PK_prod;
if (PK_var != "uniques") {
id_str += "_" + PK_var;
}
id_str = "document.getElementById('" + id_str + "')";
if (parent) {
id_str = "parent." + id_str;
}
return id_str;
}
function ChangeSelection(action, PK_prod, PK_var, selection) {
tmp_date = new Date();
tmp_timestamp = tmp_date.getFullYear() + tmp_date.getDate() + tmp_date.getMinutes() + tmp_date.getMilliseconds();
if (action == "add") {
selection = escape(selection);
}
str = GetJSSrc(PK_prod, PK_var);
if (action == "add") {
str += "/is_iframe=true/p=item_selection/PK_prod=" + PK_prod + "/PK_var=" + PK_var + "/selection=" + selection + "/i_action=add/timestamp=" + tmp_timestamp;
} else if (action == "load") {
str += "/is_iframe=true/p=item_selection/PK_prod=" + PK_prod + "/PK_var=" + PK_var + "/timestamp=" + tmp_timestamp;
} else if (action == "del") {
str += "/is_iframe=true/p=item_selection/PK_prod=" + PK_prod + "/PK_var=" + PK_var + "/PK_item=" + selection + "/i_action=del/timestamp=" + tmp_timestamp;
}
id = GetJSID(PK_prod, PK_var);
str = id + ".src = '" + str + "';";
if (PK_var != "uniques") {
eval("item_" + PK_prod + "_" + PK_var + "_loaded = false;");
} else {
eval("item_" + PK_prod + "_loaded = false;");
}
eval(str);
if (action == "del") {
RefreshCart();
} else {
return false;
}
}
function GetJSSrc(PK_prod, PK_var) {
src_str = GetJSID(PK_prod, PK_var);
eval("src_str = " + src_str + ".src;");
src_str = src_str.substring(0, src_str.indexOf(".php") + 4);
return src_str;
}
cursor_pos = -1;
function MarkSelection(txtObj) {
if (txtObj.createTextRange) {
cursor_pos = document.selection.createRange().duplicate();
isSelected = true;
}
}
function InsertText(txtForm, txtName, txtBefore, txtAfter) {
var txtObj = eval("document." + txtForm + "[\"" + txtName + "\"]");
if (window.isSelected == null) {
txtObj.focus();
MarkSelection(txtObj);
}
if (isSelected) {
if (txtObj.createTextRange && cursor_pos != -1) {
if (cursor_pos.text == "" && txtAfter != "" && confirm("You have selected a tag that normally goes around something else.\nDo you want to specify this something else?\n(possibly text if this is a formatting, ie, bold, italic, etc, tag?")) {
val = prompt("Enter the text you want to go between the selected tags.", "");
tag_text = val;
} else {
tag_text = cursor_pos.text;
}
var caretPos = cursor_pos;
caretPos.text = ((txtAfter != "") ? (txtBefore + tag_text + txtAfter) : (txtBefore + tag_text));
if (cursor_pos.text == '') {
isSelected = false;
txtObj.focus();
}
MarkSelection(txtObj);
}
} else {
// placeholder for loss of focus handler
}
}
function AnimEllipsis(PK_prod, PK_var) {
is_loaded = false;
if (PK_var != "uniques") {
eval("is_loaded = item_" + PK_prod + "_" + PK_var + "_loaded;");
eval("ellipsis_id = 'id_selection_" + PK_prod + "_" + PK_var + "';");
} else {
eval("is_loaded = item_" + PK_prod + "_loaded;");
eval("ellipsis_id = 'id_selection_" + PK_prod + "';");
}
if (is_loaded == false) {
str = document.getElementById(ellipsis_id).innerHTML;
switch (str) {
case "Loading...": {
str = "Loading...";
break;
}
case "Loading...": {
str = "Loading...";
break;
}
case "Loading...": {
str = "Loading...";
break;
}
case "Loading...": {
str = "Loading...";
break;
}
}
document.getElementById(ellipsis_id).innerHTML = str;
setTimeout("AnimEllipsis('" + PK_prod + "', '" + PK_var + "');", 100);
}
}
function handleTAB(e, field) {
e = ((window.event) ? (event) : (e)) && ((e.keyCode) ? (e) : (null));
if (e && e.keyCode == 9 && 1 == 0) {
InsertText(field.form.name, field.name, "\t", "");
return false;
}
return true;
}
checkFormTasks = Array();
function CheckForm() {
is_ok = true;
for (i = 0; i < checkFormTasks.length; ++i) {
is_ok = eval(checkFormTasks[i]);
}
return is_ok;
}
function SubmitForm() {
if (arguments.length == 0 || arguments[0] == '') {
form_name = document.forms[0].name;
} else {
form_name = arguments[0];
}
if (CheckForm()) {
targetForm = document.forms[form_name];
if (arguments.length > 1) {
params = arguments[1].split(',');
num_params = params.length;
for (i = 0; i < num_params; ++i) {
pair = params[i].split('|');
if (targetForm[pair[0]]) {
targetForm[pair[0]].value = pair[1];
} else {
newHidden = document.createElement("input");
newHidden.setAttribute("id", pair[0]);
newHidden.setAttribute("type", "hidden");
newHidden.setAttribute("name", pair[0]);
newHidden.setAttribute("value", pair[1]);
targetForm.appendChild(newHidden);
}
}
}
targetForm.submit();
}
}
function CopyTextarea(textareaID) {
tempval = document.getElementById(textareaID);
tempval.focus();
tempval.select();
ItemCode = tempval.createTextRange();
ItemCode.execCommand("Copy");
tempval.value = tempval.value;
tmpStr = "The code has been copied to your clipboard.";
alert(tmpStr);
}
function AlertElementProperties(element) {
group_len = 15;
items = 0;
for (v in element) {
++items;
}
groups = 0;
while (groups < items) {
tmp = '';
for (i = groups; i < (groups + group_len); ++i) {
t = 0;
for (v in element) {
if (t == i) {
tmp += v + ' = ' + element[v] + '\\\n';
}
++t;
}
}
alert(tmp);
groups += group_len;
}
}
function MoveItem(element, from_select, to_select) {
var elmtname = element.name;
var sel_f = element.form[from_select];
var sel_t = element.form[to_select];
var tmpNumOptions = sel_t.options.length;
var tmpOptions = sel_t.options;
var tmpIndex = sel_t.selectedIndex;
if (typeof use_indents == "undefined") {
use_indents = false;
}
if (elmtname == "addbutton") {
var tmpFrom = sel_f.options;
var optSize = tmpFrom.length;
var obLng = tmpOptions.length;
for (i=0; i < optSize; i++) {
if (tmpFrom[i].selected) {
in_to = false;
for (j = 0; j < sel_t.options.length; ++j) {
if (sel_t.options[j].text == tmpFrom[i].text) {
in_to = true;
}
}
if (!in_to) {
var selText = tmpFrom[i].text;
var selVal = tmpFrom[i].value;
var newOpt = new Option(selText,selVal);
tmpOptions[obLng++] = newOpt;
}
}
}
} else if ((elmtname == "moveleft" || elmtname == "moveright") && (tmpIndex > 0)) {
use_indents = true;
tmpOptionTextPrev = tmpOptions[tmpIndex - 1].text;
tmpOptionValue = tmpOptions[tmpIndex].value;
tmpOptionText = tmpOptions[tmpIndex].text;
var space_count = CountLeadingSpaces(tmpOptionText);
var prev_space_count = CountLeadingSpaces(tmpOptionTextPrev);
tmpOptionText = tmpOptionText.substring(space_count);
tmpOptionTextPrev = tmpOptionTextPrev.substring(prev_space_count);
if (elmtname == "moveleft" && space_count >= 2) {
space_count -= 2;
}
if (elmtname == "moveright" && prev_space_count >= space_count) {
space_count += 2;
}
tmpOptionValue = tmpOptionValue.split("`");
tmpOptionValue = tmpOptionValue[0] + "`" + (space_count / 2);
tmpOptionText = StringRepeat("_", space_count) + tmpOptionText;
tmpOptions[tmpIndex].value = tmpOptionValue;
tmpOptions[tmpIndex].text = tmpOptionText;
tmpOptions[tmpIndex].selected = true;
} else if (((elmtname == "moveup") && (tmpIndex > 0)) || ((elmtname == "movedown") && (tmpIndex < (tmpNumOptions - 1)))) {
moveDir = (elmtname == "moveup") ? (-1) : (1);
tmpOptionValue = tmpOptions[tmpIndex + moveDir].value;
tmpOptionText = tmpOptions[tmpIndex + moveDir].text;
tmpOptions[tmpIndex + moveDir].value = tmpOptions[tmpIndex].value;
tmpOptions[tmpIndex + moveDir].text = tmpOptions[tmpIndex].text;
tmpOptions[tmpIndex].value = tmpOptionValue;
tmpOptions[tmpIndex].text = tmpOptionText;
tmpOptions[tmpIndex + moveDir].selected = true;
} else if (elmtname == "remove") {
if (sel_t.selectedIndex >= 0) {
tmpOptions[tmpIndex] = null;
}
sel_t.selectedIndex = ((sel_t.options.length - 1) < tmpIndex) ? (tmpIndex - 1) : (tmpIndex);
}
UpdateSelectVals(element.form, to_select, use_indents);
}
function StringRepeat(str, count) {
var tmp_str = "";
for (var i = 0; i < count; ++i) {
tmp_str += str;
}
return tmp_str;
}
function CountLeadingSpaces(tmpString) {
var space_count = 0;
for (var i = 0; i < tmpString.length; ++i) {
if (tmpString.substr(i, 1) == "_") {
++space_count;
}
}
return space_count;
}
function UpdateSelectVals(element_form, to_select) {
var sel_t = element_form[to_select];
to_vals = "";
for (j = 0; j < sel_t.options.length; ++j) {
if (j > 0) {
to_vals += ",";
}
to_vals += sel_t.options[j].value;
if (arguments.length > 2 && arguments[2]) {
to_vals += "`" + (CountLeadingSpaces(sel_t.options[j].text) / 2);
}
}
element_form[to_select + "_vals"].value = to_vals;
}
function SwapSelectVals(element_form, to_select, new_vals) {
var sel_t = element_form[to_select];
var tmpOptions = sel_t.options;
var tmpNumOptions = sel_t.options.length;
for (i = 0; i < tmpNumOptions; ++i) {
tmpOptions[i] = null;
}
num_new_vals = new_vals.length;
for (i = 0; i < num_new_vals; ++i) {
var newOpt = new Option(new_vals[i], new_vals[i]);
tmpOptions[i] = newOpt;
}
}
function AddSelectVal(element_form, to_select, new_val) {
var sel_t = element_form[to_select];
var tmpOptions = sel_t.options;
var tmpNumOptions = sel_t.options.length;
var newOpt = new Option(new_val, new_val);
tmpOptions[tmpNumOptions] = newOpt;
}
function CheckAll(box_name, box_object) {
box_checked = box_object.checked;
eval('box_form = document.' + box_object.form.name);
num_boxes = box_form[box_name].length;
if (num_boxes > 0) {
for (i = 0; i < num_boxes; ++i) {
box_form[box_name][i].checked = (box_checked) ? (true) : (false);
}
}
}
function DeleteConfirmation() {
item_name = (arguments.length == 1) ? (arguments[0]) : ("item");
return confirm('Are you sure you want to delete this ' + item_name + '?\nIt cannot be undone!');
}
function DeleteTripleConfirmation() {
delete_ok = false;
if (confirm('Are you sure you want to delete this item?\nIt cannot be undone!')) {
if (confirm('Are you really sure?\nIt really cannot be undone!')) {
if (confirm('Are you really, really sure?\nI\'m not kidding about this not being able to be undone...')) {
delete_ok = true;
}
}
}
return delete_ok;
}
function resizeIframe() {
// Must launched on the body onload event handler for IE
// Use document.documentElement if you are in Compat mode
if (parent && window.name) {
i = parent.document.getElementById(window.name);
iHeight = document.body.scrollHeight;
i.style.height = iHeight + "px";
iWidth = document.body.scrollWidth;
i.style.width = iWidth + "px";
}
}
function clickHandler(evt) {
cancelClick = true;
elementType = 'unknown';
if (document.layers) {
alert(evt.target);
} else if (evt.stopPropagation || window.event) {
focussedElement = (evt.target) ? (evt.target) : (event.srcElement);
if (focussedElement.form && focussedElement.type == 'submit') {
// submit button
elementType = 'submit';
focussedElement.disabled = 'disabled';
focussedElement.value = submitWaitText;
}
if (focussedElement.href || (focussedElement.nodeValue && focussedElement.baseURI)) {
// link
elementType = 'link';
if (focussedElement.nodeValue) {
focussedElement.nodeValue = linkWaitText;
} else if (focussedElement.innerHTML) {
focussedElement.innerHTML = linkWaitText;
}
focussedElement.href = focussedElement.href + '#'
}
}
if (cancelClick) {
if (evt.stopPropagation) {
evt.stopPropagation();
evt.preventDefault();
}
return false;
} else {
if (elementType == 'submit') {
focussedElement.form.submit();
}
return true;
}
}
function initClickHandler() {
if (document.layers) {
window.captureEvents(Event.CLICK);
window.onclick = clickHandler;
} else if (document.all && !document.getElementById) {
document.onclick = clickHandler;
} else if (document.all) {
document.attachEvent('onclick', clickHandler);
} else if (document.addEventListener) {
document.addEventListener('click', clickHandler, true);
}
}
//initClickHandler();
function clickElement (element) {
if (element.click)
element.click();
else if (element.dispatchEvent) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent(
'click',
true,
true,
window,
1,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
element.dispatchEvent(evt);
}
}
function Pause(Amount) {
d = new Date() //today's date
while (1) {
mill = new Date() // Date Now
diff = mill - d //difference in milliseconds
if (diff > Amount) {
break;
}
}
}
function PopWin(url, width, height) {
window.open(url, "popup", "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1");
}
function SetScroll(X, Y) {
alert(X);
if ((X > 0) || (Y > 0)) {
if ((top.opera) && (typeof window.pageYOffset != 'undefined')) {
window.pageYOffset = Y;
window.pageXOffset = X;
} else if ((window.document.compatMode) && (window.document.compatMode != 'BackCompat')) {
window.document.documentElement.scrollLeft = X;
window.document.documentElement.scrollTop = Y;
} else if ((window.document.body) && (typeof window.document.body.scrollTop != 'undefined')) {
window.document.body.scrollLeft = X;
window.document.body.scrollTop = Y;
} else {
window.scrollTo(X, Y);
}
}
}
function ReturnMatches(text, regex) {
var re = new RegExp(regex, "gim");
var m = re.exec(text);
var matches = new Array();
if (m == null) {
return "";
} else {
var s = "Match at position " + m.index + ":\n";
for (i = 0; i < m.length; i++) {
matches[matches.length] = m[i];
s += "\n" + m[i];
}
//alert(s);
}
return matches;
}
function CreateRequestObject() {
var ro;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
var http = new Object();
var http_in_use = new Array();
var num_http_objects = 20;
for (var i = 0; i < num_http_objects; ++i) {
http[i] = CreateRequestObject();
http_in_use[i] = false;
}
function SendReq(action, params) {
//s = prompt(action, "http://www.pastorsschool.com/js/js/ajax_call.php?action=" + action + "¶ms=" + params);
for (i = 0; i < num_http_objects; ++i) {
if (http_in_use[i] == false) {
if (action.indexOf("nope") != -1) {
//alert(document.ss_form.ajax_calls.value);
document.ss_form.ajax_calls.value += "http://www.pastorsschool.com/js/js/ajax_call.php?action=" + action + "¶ms=" + params + "\n";
}
http_in_use[i] = true;
http[i].open("post", "http://www.pastorsschool.com/js/js/ajax_call.php?action=" + action + "¶ms=" + params);
http[i].onreadystatechange = HandleResponse;
http[i].send(null);
}
}
}
function HandleResponse() {
for (i = 0; i < num_http_objects; ++i) {
if (http[i].readyState == 4 && http[i].status == 200) {
http_in_use[i] = false;
var response = http[i].responseText;
var update = new Array();
if (response.indexOf("``innerHTML``") != -1) {
update = response.split("``innerHTML``");
matches = ReturnMatches(update[0], "[_0-9a-z]+");
//alert("|" + update[0] + "|");
update[0] = matches[0];
//alert("|" + update[0] + "|");
//alert(update[1]);
document.getElementById(update[0]).innerHTML = update[1];
}
http[i] = CreateRequestObject();
}
}
}
function GetFormVals(field_search) {
form_fields = "";
//alert(document.forms[0].name);
for (field in document.forms[0]) {
if (field.indexOf(field_search) != -1) {
form_fields += field + "|" + document.forms[0][field].value + "`";
}
}
form_fields = form_fields.substring(0, form_fields.length - 1);
//alert(form_fields);
return form_fields;
}
function ClearFormVals(field_search) {
form_fields = "";
//alert(document.forms[0].name);
for (field in document.forms[0]) {
if (field.indexOf(field_search) != -1) {
document.forms[0][field].value = "";
}
}
}
function ShowHideOtherInput(input_this) {
v = input_this.value;
o = input_this.name;
o = o.replace("_select", '');
if (arguments.length > 1) {
n = arguments[1];
} else {
n = o.replace("_other", '');
}
df = eval("document." + input_this.form.name);
if (v == 'other') {
eval("df." + o + ".className = 'input_text';");
eval("df['" + n + "'].value = df['" + o + "'].value;");
} else {
eval("df." + o + ".className = 'invisible';");
eval("df['" + n + "'].value = v;");
}
}
var isOpera = navigator.userAgent.indexOf("Opera") > -1;
var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera;
var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera;
function textboxSelect (oTextbox, iStart, iEnd) {
switch(arguments.length) {
case 1:
oTextbox.select();
break;
case 2:
iEnd = oTextbox.value.length;
/* falls through */
case 3:
if (isIE) {
var oRange = oTextbox.createTextRange();
oRange.moveStart("character", iStart);
oRange.moveEnd("character", -oTextbox.value.length + iEnd);
oRange.select();
} else if (isMoz){
oTextbox.setSelectionRange(iStart, iEnd);
}
}
oTextbox.focus();
}
function textboxReplaceSelect (oTextbox, sText) {
if (isIE) {
var oRange = document.selection.createRange();
oRange.text = sText;
oRange.collapse(true);
oRange.select();
} else if (isMoz) {
var iStart = oTextbox.selectionStart;
oTextbox.value = oTextbox.value.substring(0, iStart) + sText + oTextbox.value.substring(oTextbox.selectionEnd, oTextbox.value.length);
oTextbox.setSelectionRange(iStart + sText.length, iStart + sText.length);
}
oTextbox.focus();
}
function autocompleteMatch (sText, arrValues) {
for (var i = 0; i < arrValues.length; i++) {
var tmp_val = arrValues[i].toLowerCase();
if (tmp_val.indexOf(sText.toLowerCase()) == 0) {
return arrValues[i];
}
}
return "null";
}
function autocomplete(oTextbox, oEvent, arrValues) {
switch (oEvent.keyCode) {
case 38: //up arrow
case 40: //down arrow
case 37: //left arrow
case 39: //right arrow
case 33: //page up
case 34: //page down
case 36: //home
case 35: //end
case 13: //enter
case 9: //tab
case 27: //esc
case 16: //shift
case 17: //ctrl
case 18: //alt
case 20: //caps lock
case 8: //backspace
case 46: //delete
return true;
break;
default:
textboxReplaceSelect(oTextbox, String.fromCharCode(isIE ? oEvent.keyCode : oEvent.charCode));
var iLen = oTextbox.value.length;
var sMatch = autocompleteMatch(oTextbox.value, arrValues);
if (sMatch.indexOf("|") != -1) {
vals = sMatch.split("|");
sMatch = vals[0];
document.getElementById(arguments[3]).value = vals[1];
}
if (sMatch != "null") {
oTextbox.value = sMatch;
textboxSelect(oTextbox, iLen, oTextbox.value.length);
}
return false;
}
}
function GetFormVals(field_search) {
form_fields = "";
//alert(document.forms[0].name);
if (arguments.length == 2) {
negative_search = arguments[1];
} else {
negative_search = "";
}
for (field in document.forms[0]) {
if (form_fields.indexOf(field + "|") == -1 && field.indexOf(field_search) != -1 && (negative_search == "" || field.indexOf(negative_search) == -1)) {
label = "";
//alert(field);
if (typeof document.forms[0][field] == "object") {
//alert(document.forms[0][field].name + ": " + typeof document.forms[0][field].name);
if (typeof document.forms[0][field].name == "undefined") {
for (i = 0; i < document.forms[0][field].length; ++i) {
//alert(document.forms[0][field][i].value);
if (document.forms[0][field][i].checked) {
value = document.forms[0][field][i].value;
label = document.forms[0][field][i].label + "::";
form_fields += field + "|" + ((label == "undefined::") ? ("") : (label)) + value + "`";
}
}
} else {
value = document.forms[0][field].value;
label = document.forms[0][field].label + "::";
form_fields += field + "|" + ((label == "undefined::") ? ("") : (label)) + value + "`";
}
} else if (document.forms[0][field].type.indexOf("select") != -1) {
value = document.forms[0][field].value;
label = document.forms[0][field].options[document.forms[0][field].selectedIndex].text + "::";
form_fields += field + "|" + ((label == "undefined::") ? ("") : (label)) + value + "`";
} else {
value = document.forms[0][field].value;
form_fields += field + "|" + value + "`";
}
}
}
form_fields = form_fields.substring(0, form_fields.length - 1);
//alert(form_fields);
return form_fields;
}