function AddHiddenField(target_form, field_name, field_value) {
if (typeof target_form[field_name] == "undefined") {
newHidden = document.createElement("input");
newHidden.setAttribute("id", field_name);
newHidden.setAttribute("type", "hidden");
newHidden.setAttribute("name", field_name);
newHidden.setAttribute("value", field_value);
target_form.appendChild(newHidden);
} else {
target_form[field_name].value = field_value;
}
}
function PayViaPayPal(tmp_button) {
tmp_form = tmp_button.form;
tmp_form.action = "action/process_paypal.php";
tmp_form.method = "post";
SubmitForm(tmp_form.name, "store_action|process");
return true;
}
// 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 AddViaDrop(drop_target) {
target_field = document.getElementById(drop_target);
target_field.value = window.event.dataTransfer.getData('text');
}
function InitiateDrag(drop_source) {
source_field = document.getElementById(drop_source);
window.event.dataTransfer.setData('text', source_field.value);
}
function replace(inString,oldText,newText) {
return (inString.split(oldText).join(newText));
}
function ToggleID(id) {
if (document.getElementById(id).className.indexOf("hide_id") != -1) {
document.getElementById(id).className = replace(document.getElementById(id).className, " hide_id", " show_id");
} else if (document.getElementById(id).className.indexOf("show_id") != -1) {
document.getElementById(id).className = replace(document.getElementById(id).className, " show_id", " hide_id");
} else {
document.getElementById(id).className += " hide_id";
}
}
function ShowID(id) {
document.getElementById(id).className = "visible";
}
function HideID(id) {
document.getElementById(id).className = "invisible";
}
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_item, PK_var) {
id_str = "selection_" + PK_item;
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_item, PK_var, selection) {
req_str = "div_id|selection_" + PK_item + ((PK_var != "uniques") ? ("_" + PK_var) : ("")) + "`PK_item|" + PK_item + "`PK_var|" + PK_var;
tmp_date = new Date();
tmp_timestamp = tmp_date.getFullYear() + tmp_date.getDate() + tmp_date.getMinutes() + tmp_date.getMilliseconds();
if (action == "add") {
req_str += "`selection|" + selection + "`i_action|add`timestamp|" + tmp_timestamp;
} else if (action == "load") {
req_str += "`timestamp|" + tmp_timestamp;
} else if (action == "del") {
req_str += "`PK_order_item|" + selection + "`i_action|del`timestamp|" + tmp_timestamp;
}
SendReq('get`item_selection', req_str);
return;
}
function GetJSSrc(PK_item, PK_var) {
src_str = GetJSID(PK_item, PK_var);
eval("src_str = " + src_str + ".src;");
src_str = src_str.substring(0, src_str.indexOf(".php") + 4);
return src_str;
}
function RefreshCart() {
tmp_date = new Date();
tmp_timestamp = tmp_date.getFullYear() + tmp_date.getDate() + tmp_date.getMinutes() + tmp_date.getMilliseconds();
new_cart_src = "http://www.halversonforms.com/cart_status.php?is_iframe=true/reloaded=true/timestamp=" + tmp_timestamp;
id_str = "document.getElementById('cart_status').src";
if (parent) {
id_str = "parent." + id_str;
}
//alert(id_str + " = '" + new_cart_src + "';");
eval(id_str + " = '" + new_cart_src + "';");
}
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_item, PK_var) {
is_loaded = false;
if (PK_var != "uniques") {
eval("is_loaded = item_" + PK_item + "_" + PK_var + "_loaded;");
eval("ellipsis_id = 'id_selection_" + PK_item + "_" + PK_var + "';");
} else {
eval("is_loaded = item_" + PK_item + "_loaded;");
eval("ellipsis_id = 'id_selection_" + PK_item + "';");
}
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_item + "', '" + PK_var + "');", 100);
}
}
function onEnterKey(e) {
e = ((window.event) ? (event) : (e)) && ((e.keyCode) ? (e) : (null));
return (e && e.keyCode == 13);
}
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() {
for (i = 0; i < checkFormTasks.length; ++i) {
//eval(checkFormTasks[i]);
}
return true;
}
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]].name = "_old_" + pair[0] + "_old_";
}
AddHiddenField(targetForm, pair[0], pair[1]);
}
}
targetForm.submit();
}
}
function AddHiddenField(targetForm, field_name, field_value) {
newHidden = document.createElement("input");
newHidden.setAttribute("id", field_name);
newHidden.setAttribute("type", "hidden");
newHidden.setAttribute("name", field_name);
newHidden.setAttribute("value", field_value);
targetForm.appendChild(newHidden);
}
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 InsertTag(inserted_field, tag_open, tag_close) {
if (arguments.length > 3) {
args = '';
params = arguments[3].split(',');
for (param in params) {
param = params[param].split('`');
val = prompt(param[1], '');
args += ' ' + param[0] + '=\'' + val + '\'';
}
tag_open = tag_open.substring(0, tag_open.lastIndexOf('>')) + args + '>';
}
InsertText('ss_form', inserted_field, tag_open, tag_close);
}
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 in_array(needle, haystack) {
var j = haystack.length;
for (var i = 0; i < j; i++) {
if (haystack[i] == needle) {
return true;
}
}
return false;
}
function InsertSelectOption(tmp_select, to_pos, text, val) {
var option_count = tmp_select.options.length;
if (to_pos >= 0) {
for (var i = (option_count - 1); i >= to_pos; --i) {
tmp_select.options[i + 1] = new Option(tmp_select.options[i].text, tmp_select.options[i].value);
}
} else {
to_pos = option_count;
}
tmp_select.options[to_pos] = new Option(text, val);
}
function MoveSelectOption(tmp_select, from_pos, to_pos) {
//alert(from_pos + ":" + to_pos);
var option_count = tmp_select.options.length;
if (from_pos > to_pos) {
option_text = tmp_select.options[from_pos].text;
option_value = tmp_select.options[from_pos].value;
for (var i = from_pos; i > to_pos; --i) {
tmp_select.options[i] = new Option(tmp_select.options[i - 1].text, tmp_select.options[i - 1].value);
}
tmp_select.options[to_pos] = new Option(option_text, option_value);
} else {
option_text = tmp_select.options[from_pos].text;
option_value = tmp_select.options[from_pos].value;
for (var i = from_pos; i < to_pos; ++i) {
tmp_select.options[i] = new Option(tmp_select.options[i + 1].text, tmp_select.options[i + 1].value);
}
tmp_select.options[to_pos] = new Option(option_text, option_value);
}
}
function MoveItem(element, from_select_name, to_select_name, move_action) {
var from_select = element.form[from_select_name];
var from_options = from_select.options;
var from_length = from_options.length;
var from_index = from_select.selectedIndex;
var to_select = element.form[to_select_name];
var to_options = to_select.options;
var to_length = to_options.length;
var to_index = to_select.selectedIndex;
if (typeof use_indents == "undefined") {
use_indents = false;
}
if (move_action == "addbutton") {
for (i = 0; i < from_length; i++) {
if (from_options[i].selected) {
in_to = false;
for (j = 0; j < to_length; ++j) {
if (to_options[j].text == from_options[i].text) {
in_to = true;
}
}
if (!in_to) {
InsertSelectOption(to_select, to_index, from_options[i].text, from_options[i].value);
}
}
}
} else if ((move_action == "moveleft" || move_action == "moveright") && (to_index > 0)) {
use_indents = true;
for (i = 0; i < to_length; i++) {
if (to_options[i].selected) {
tmpOptionTextPrev = to_options[i - 1].text;
tmpOptionValue = to_options[i].value;
tmpOptionText = to_options[i].text;
var space_count = CountLeadingSpaces(tmpOptionText);
var prev_space_count = CountLeadingSpaces(tmpOptionTextPrev);
tmpOptionText = tmpOptionText.substring(space_count);
if (move_action == "moveleft" && space_count >= 2) {
space_count -= 2;
}
if (move_action == "moveright" && prev_space_count >= space_count) {
space_count += 2;
}
tmpOptionValue = tmpOptionValue.split("`");
tmpOptionValue = tmpOptionValue[0] + "`" + (space_count / 2);
tmpOptionText = StringRepeat("_", space_count) + tmpOptionText;
to_options[i].value = tmpOptionValue;
to_options[i].text = tmpOptionText;
to_options[i].selected = true;
}
}
} else if (((move_action == "moveup") && (to_index > 0)) || ((move_action == "movedown") && (to_index < (to_length - 1)))) {
s = 0;
for (i = (to_length - 1); i >= 0; i--) {
if (to_options[i].selected) {
++s;
}
}
if (move_action == "movedown") {
from_pos = to_index + s;
to_pos = to_index;
MoveSelectOption(to_select, from_pos, to_pos);
for (i = to_index + 1; i <= to_index + s; i++) {
to_options[i].selected = true;
}
} else {
from_pos = to_index - 1;
to_pos = to_index + s - 1;
MoveSelectOption(to_select, from_pos, to_pos);
for (i = to_index - 1; i < to_index + s - 1; i++) {
to_options[i].selected = true;
}
}
} else if (move_action == "remove") {
j = 0;
for (i = (to_length - 1); i >= 0; i--) {
if (to_options[i].selected) {
to_options[to_index] = null;
j = i;
}
}
to_select.selectedIndex = ((to_select.options.length - 1) < j) ? (j - 1) : (j);
}
UpdateSelectVals(element.form, to_select_name, 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;
} else {
break;
}
}
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;
//alert(to_vals);
}
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() {
return confirm('Are you sure you want to delete this item?\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) {
if (arguments.length > 3) {
window_name = arguments[3];
} else {
window_name = "popup";
}
pop_window = window.open(url, window_name, "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1");
pop_window.focus();
//eval("win_" + window_name + " = pop_window;";
}
function NewWin(url) {
new_window_name = "popup_" + Math.round(Math.random() * 254321);
new_win = window.open(url, new_window_name, "width=1024,height=768,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes");
}
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) {
params = params.replace(/#/, "%23");
//alert(params);
//s = prompt(action, "http://www.halversonforms.com/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 && typeof document.ss_form.ajax_calls != "undefined") {
alert(document.ss_form.ajax_calls.value);
document.ss_form.ajax_calls.value += "http://www.halversonforms.com/js/ajax_call.php?action=" + action + "¶ms=" + params + "\n";
}
http_in_use[i] = true;
http[i].open("post", "http://www.halversonforms.com/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;
//alert(i + " = " + response);
var update = new Array();
if (response.indexOf("``innerHTML``") != -1) {
//alert(response);
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();
break;
}
}
}
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 = input_this.form;
if (v == 'other') {
document.getElementById(o).className = 'input_text visible';
document.getElementById(o).value = df[o].value;
} else {
document.getElementById(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 != null) {
oTextbox.value = sMatch;
textboxSelect(oTextbox, iLen, oTextbox.value.length);
}
return false;
}
}
function New_Image_Load(index) {
tmp_str = "Image Preview:";
if (arguments.length > 1) {
tmp_str = arguments[1] + tmp_str;
}
tmp_str += " ";
eval("tmp_str += document.images.image_" + index + ".width + \" x \" + document.images.image_" + index + ".height + \" pixels\";");
tmp_str += " ";
eval("tmp_str += document.images.image_" + index + ".fileSize + \" bytes\";");
document.getElementById("img_dims_" + index).innerHTML = tmp_str;
}
function Existing_Image_Load(index) {
tmp_str = "Current ";
if (arguments.length > 2) {
tmp_str += arguments[2];
} else {
tmp_str += "Image";
}
tmp_str += ":";
tmp_str += " ";
if (arguments.length > 1) {
tmp_str = '' + arguments[1] + ':
' + tmp_str;
is_thumb = true;
} else {
is_thumb = false;
}
eval("current_image_src = document.images.current_image_" + index + ".src;");
if (current_image_src.indexOf('spacer.gif') != -1) {
tmp_str += "This image doesn't exist on the server yet.";
} else {
eval("tmp_str += document.images.current_image_" + index + ".width + \" x \" + document.images.current_image_" + index + ".height + \" pixels\";");
tmp_str += " ";
eval("tmp_str += document.images.current_image_" + index + ".fileSize + \" bytes\";");
last_slash = current_image_src.lastIndexOf("/");
next_last_slash = current_image_src.lastIndexOf("/", last_slash - 1);
if (current_image_src.indexOf("/thumbs/") != -1) {
next_next_last_slash = current_image_src.lastIndexOf("/", next_last_slash - 1);
current_image_filename = current_image_src.substring(next_next_last_slash + 1);
} else {
current_image_filename = current_image_src.substring(next_last_slash + 1);
}
eval("tmp_str += \" Delete Image.\";");
}
document.getElementById("current_img_dims_" + index).innerHTML = tmp_str;
}
function Preview_Image(tmp_index, tmp_path) {
if (tmp_path != '') {
tmp_path = tmp_path.replace(/\\/g, "/");
eval("document.images." + tmp_index + ".src = '" + tmp_path + "';");
} else {
eval("document.images." + tmp_index + ".src = 'http://www.halversonforms.com/media/common/spacer.gif';");
document.getElementById("img_dims_" + tmp_index).innerHTML = "";
}
}
function GetFormVals(field_search) {
form_fields = "";
//alert(document.forms[0].name);
if (arguments.length == 2) {
negative_search = arguments[1];
} else {
negative_search = "";
}
if (arguments.length == 3) {
return_empty_checkboxes = true;
} else {
return_empty_checkboxes = false;
}
//alert(field_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("Name: " + document.forms[0][field].name + "\n"
+ "Type: " + document.forms[0][field].type + "\n"
+ "Name Typeof: " + typeof document.forms[0][field].name + "\n"
+ "Length Typeof: " + typeof document.forms[0][field].length);
*/
if (document.forms[0][field].type == "text" || document.forms[0][field].type == "hidden") {
value = document.forms[0][field].value;
form_fields += field + "|" + value + "`";
} else if (typeof document.forms[0][field].name != "undefined" && 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 if (typeof document.forms[0][field].name != "undefined" && document.forms[0][field].type.indexOf("textarea") != -1) {
//alert(document.forms[0][field].name + ": " + typeof document.forms[0][field].name);
value = document.forms[0][field].value;
form_fields += field + "|" + value + "`";
} else if (typeof document.forms[0][field] == "object") {
if (typeof document.forms[0][field].name == "undefined" && typeof document.forms[0][field].length != "undefined") {
//alert(document.forms[0][field].name + ": " + typeof document.forms[0][field].name);
for (i = 0; i < document.forms[0][field].length; ++i) {
//alert(document.forms[0][field][i].value);
if (document.forms[0][field][i].checked || return_empty_checkboxes) {
value = document.forms[0][field][i].value;
label = document.forms[0][field][i].label + "::";
form_fields += field + "|" + ((label == "undefined::") ? ("") : (label)) + value + "`";
}
}
} else if (typeof document.forms[0][field].checked == "boolean") {
if (document.forms[0][field].checked || return_empty_checkboxes) {
value = document.forms[0][field].value;
label = document.forms[0][field].label + "::";
form_fields += field + "|" + ((label == "undefined::") ? ("") : (label)) + value + "`";
}
} else {
value = document.forms[0][field].value;
form_fields += field + "|" + 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;
}
function GetDocDivs(div_search) {
var doc_divs = new Array();
//alert(document.forms[0].name);
if (arguments.length == 2) {
negative_search = arguments[1];
} else {
negative_search = "";
}
//alert(field_search);
var document_divs = document.getElementsByTagName('div');
for (i = 0, j = document_divs.length; i < j; ++i) {
div_id = document_divs[i].id;
if (div_id != '') {
//alert(div_id + " " + div_search);
if (div_id.indexOf(div_search) != -1 && (negative_search == "" || div_id.indexOf(negative_search) == -1)) {
doc_divs[doc_divs.length] = div_id;
}
}
}
return doc_divs;
}
function HideDocDivs(div_search) {
doc_divs = GetDocDivs(div_search);
for (div_id in doc_divs) {
HideID(doc_divs[div_id]);
}
}
function ShowDocDivs(div_search) {
doc_divs = GetDocDivs(div_search);
for (div_id in doc_divs) {
ShowID(doc_divs[div_id]);
}
}
window.onload = initPage;
// Make sure that no other javscripts assign a fuction to window.onload
// There can be only one window.onload at a time
function initPage() {
if (typeof popupLinkConfig != "undefined") {
initPopupLinks();
}
// place here any other code you wish to run when the page loads.
}
function initPopupLinks()
{
if (!document.getElementsByTagName) return true;
var pageLinks = document.getElementsByTagName("a");
for (var i = 0; i < pageLinks.length; i++)
{
if (((pageLinks[i].className != null) &&
(pageLinks[i].className != "")) ||
((pageLinks[i].parentNode.className != null) &&
(pageLinks[i].parentNode.className != "")))
{
var linkClass = " " + pageLinks[i].className + " ";
if ((linkClass == " ") && (pageLinks[i].parentNode.className != ""))
{
linkClass = " " + pageLinks[i].parentNode.className + " ";
}
for (var theKey in popupLinkConfig)
{
if (linkClass.indexOf(" " + theKey + " ") > -1)
{
if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
{
pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
}
pageLinks[i].settings = popupLinkConfig[theKey][1];
pageLinks[i].onclick = popUp;
}
}
}
}
return true;
}
function popUp()
{
newWin = window.open(this.href, this.target, this.settings);
newWin.focus();
return false;
}
function LoadFlash() {
isStd = (navigator.appName == "Netscape") ? true : false;
var flash_obj = document.getElementById("flash_swf");
var makeitwork = document.createElement("div");
// Firefox must use decode() to convert '<' and '>' to '<' and '>' respectively
// MSIE does not copy the inner 'param' tag as part of innerHTML, but it is not needed by IE anyhow
alert(flash_obj.innerHTML);
if (isStd) {
makeitwork.innerHTML = decode(flash_obj.innerHTML);
} else {
makeitwork.innerHTML = flash_obj.innerHTML;
}
flash_obj.parentNode.insertBefore(makeitwork, flash_obj);
}
old_border_color = '';
function DarkenBorder(e) {
old_border_color = e.style.borderColor;
e.style.borderColor = '#000000';
}
function RestoreBorder(e) {
e.style.borderColor = old_border_color;
}