function icon_imageSwap(imageSrc, clientId) {
    if (imageSrc.indexOf('_off.') != -1) {
        var splitSrcName = imageSrc.split('_off');
        document.getElementById(clientId).src = splitSrcName[0] + '_over' + splitSrcName[1];
    }
    else {
        var splitSrcName = imageSrc.split('_over');
        document.getElementById(clientId).src = splitSrcName[0] + '_off' + splitSrcName[1];
    }
}

function icon_openWindow(url, name, options) {
    nw = window.open(url, name, options);
	nw.focus();
}

function icon_openWindowLocation(url, name, options, x, y) {
    nw = window.open(url, name, options);
    nw.moveTo(x, y);
	nw.focus();
}

function icon_controlCondition(id, operator, value) {
    this.id = id;
    this.operator = operator;
    this.value = value;
    this.control = document.getElementById(this.id);
    
    this.isValid = function() {
        if (this.control)
        {
            var controlValue;
		    if (this.control.type == 'checkbox')
			    controlValue = this.control.checked;
		    else
			    controlValue = this.control.value;
			
			return compareValues(controlValue, this.value, this.operator);
		}
		
		return false;
    }
    
    function compareValues(a, b, operator) {
	    switch (operator) {
		    case '!=': return (a != b);
		    case '<': return (a < b);
		    case '<=': return (a <= b);
		    case '>': return (a > b);
		    case '>=': return (a >= b);
		    default: return (a == b);
	    }
    }
}

function icon_conditionalPopup(message, conditions, mode, compareAll) {
    var isValid = compareAll;
    
    for(var i=0; i<conditions.length; i++) {
        if (conditions[i].isValid()) {
            if (!compareAll) {
                isValid = true;
                break;
            }
        }
        else {
            if (compareAll) {
                isValid = false;
                break;
            }
        }
    }
    
    if (isValid) {
        switch(mode) {
            case "confirmation": return confirm(message);
            case "error": alert(message); return false;
            default: alert(message); return true;
        }
    }
    
    return true;
}

function icon_onTextBoxFocus(controlId, defaultText) {
    textBox = document.getElementById(controlId);
    
    if (textBox.value == defaultText)
        textBox.value = '';
}

function icon_onTextBoxBlur(controlId, defaultText) {
    textBox = document.getElementById(controlId);
    
    if (textBox.value == '')
        textBox.value = defaultText;
}

function hbxStrip(a)
{
     a = a.split("|").join("");
     a = a.split("&").join("");
     a = a.split("'").join("");
     a = a.split("#").join("");
     a = a.split("$").join("");
     a = a.split("%").join("");
     a = a.split("^").join("");
     a = a.split("*").join("");
     a = a.split(":").join("");
     a = a.split("!").join("");
     a = a.split("<").join("");
     a = a.split(">").join("");
     a = a.split("~").join("");
     a = a.split(";").join("");
     a = a.split(" ").join("+");
     return a;
}

var phone_field_length = 0;
function TabNext( obj, event, len, next_field ){
	if( event == 'down' ) {
		phone_field_length = obj.value.length;
	} else if( event == 'up' ) {
		if( obj.value.length != phone_field_length ) {
			phone_field_length = obj.value.length;
			if( phone_field_length == len ) {
				next_field.focus();
			}
		}
	}
}