/*
 * Photo Uploader Functions and Classes
 */
function $I(iframe, element) { 
    //return (_ifrPhoto.contentWindow.document.getElementById(element));
    return eval(iframe).contentWindow.document.getElementById(element);
}

AU2PBP = {
    cost : {
        g : {
            // Gets the Current Total and Returns as a Float
            total : function () {
                return this.custom('total');
            },

            // Gets the Current Shipping and Returns as a Float
            sh : function () {
                return this.custom('sh');
            },

            custom : function (f) {
                var c = $(f).innerHTML.split('$ '); 
                return parseFloat(c[1]);
            }
        },

        u : {
            // Updates the Current Total
            total : function (a) {
                $('total').update('$ ' + a.toFixed(2));
            },

            sh : function (a) {
                $('sh').update('$ ' + a.toFixed(2));
            },

            custom : function (f, a) {
                $(f).update('$ ' + a.toFixed(2));
            }
        }
    },

    /**
     * Calculates the Shipping and Handling Charge
     *
     * a = amount
     * b = base_amount
     * m = min_purchase
     * c = cost_above
     */
    shc : function (a, b, m, c) {
        if (a == 0)
        {
            return a;
        }
        else if (a <= m)
        {
            return b;
        }
        else
        {
            return parseFloat((parseInt(a) - parseInt(m)) * parseFloat(c)) + parseFloat(b);
        }
    },

    disable : {
        cc : function(addr)
        {
            if (typeof $('cc_first_name') !== undefined)
            {
                $('cc_first_name').disable();
            }

            if (typeof $('cc_last_name') !== undefined)
            {
                $('cc_last_name').disable();
            }

            $('cc_number').disable();
            $('cc_type').disable();
            $('cc_month').disable();
            $('cc_year').disable();

            if (typeof $('cc_store') !== undefined)
            {
                $('cc_store').disable();
            }

            if (addr == true)
            {
                this.address('cc');
            }
        },

        address : function(p)
        {
            $(p + '_address_1').disable();
            $(p + '_address_2').disable();
            $(p + '_city').disable();
            $(p + '_state').disable();
            $(p + '_postal_code').disable();
        }
    },

    enable : {
        cc : function(addr)
        {
            if (typeof $('cc_first_name') !== undefined)
            {
                $('cc_first_name').enable();
            }

            if (typeof $('cc_last_name') !== undefined)
            {
                $('cc_last_name').enable();
            }

            $('cc_number').enable();
            $('cc_type').enable();
            $('cc_month').enable();
            $('cc_year').enable();

            if (typeof $('cc_store') !== undefined)
            {
                $('cc_store').enable();
            }

            if (addr == true)
            {
                this.address('cc');
            }
        },

        address : function(p)
        {
            $(p + '_address_1').enable();
            $(p + '_address_2').enable();
            $(p + '_city').enable();
            $(p + '_state').enable();
            $(p + '_postal_code').enable();
        }
    },

    toggle : {
        ed : function(f)
        {
            var f = $(f);
            console.log(f.disabled);
            f[f.disabled ? 'enable' : 'disable']();
        },

        cc : function(addr) {
            this.ed('cc_number');
            this.ed('cc_type');
            this.ed('cc_month');
            this.ed('cc_year');
        }
    }
}

<!--
//copyright 1999 Idocs, Inc. http://www.idocs.com
//Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;

	if (window.event) {
		key = window.event.keyCode;
	} else if (e) {
		key = e.which;
	} else {
		return true;
	}

	keychar = String.fromCharCode(key);

	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) {
		//control keys
		return true;
	} else if ((("0123456789").indexOf(keychar) > -1)) {
		// numbers
		return true;
	} else if (dec && (keychar == ".")) {
		//decimal point jump
		//myfield.form.elements[dec].focus();
		return true;
	} else {
		return false;
	}
}

function removeButton(btnWrapId, messageId)
{
	$(btnWrapId).hide();
	$(messageId).show();
}

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
