        var colort = '70889c';
        var colorb = 'b08468';
        function updateTester() {
            $("#texthilite").css("background-image", "-moz-linear-gradient(top, #" + colort.toString() + ", #" + colorb.toString() + ")");

        }
        function reset() {
            $("#texthilite").css("background-image", "-moz-linear-gradient(top, #70889c, #b08468)");
            document.getElementById('toppick').color.fromString('70889c');
            document.getElementById('botpick').color.fromString('b08468');

        }

        $(document).ready(function () {

            var icons = {
                header: "ui-icon-triangle-1-e",
                headerSelected: "ui-icon-triangle-1-s"
            };

            $("#accordion").accordion({
                autoHeight: false,
                navigation: true,
                collapsible: true,
                active: false,
                icons: icons
            });

            $('#b-contact').button()
                .click(function () {
                    $('#dlg-findout').dialog('open');
                });



            var name = $("#name"),
			email = $("#email"),
			phone = $("#phone"),
			btc = $("#btc"),
            msg = $("#msg"),

			allFields = $([]).add(name).add(email).add(phone).add(btc).add(msg),
			tips = $(".validateTips");


            function updateTips(t) {
                tips
				.text(t)

				.addClass('ui-state-highlight');
                setTimeout(function () {
                    tips.removeClass('ui-state-highlight', 1500);
                }, 500);
            }

            function checkLength(o, n, min, max) {

                if (o.val().length > max || o.val().length < min) {
                    o.addClass('ui-state-error');
                    updateTips("Length of " + n + " must be between " + min + " and " + max + ".");
                    return false;
                } else {
                    return true;
                }

            }

            function checkRegexp(o, regexp, n) {

                if (!(regexp.test(o.val()))) {
                    o.addClass('ui-state-error');
                    updateTips(n);
                    return false;
                } else {
                    return true;
                }

            }

            function formatEmail(m) {
                var msg = "";
                msg = msg + "Request for more information about the BUMP studies:\n\n";
                msg = msg + "Name: \t" + m[0] + "\n";
                msg = msg + "Email: \t" + m[1] + "\n";
                msg = msg + "Phone: \t" + m[2] + "\n";
                msg = msg + "Best time to call: \t" + m[3] + "\n";
                msg = msg + "Message: \t" + m[4] + "\n\n";

                msg = msg + "Formatted:'" + m.join("|") + "'";
                return msg;

            }

            $("#dlg-findout").dialog({
                dialogClass: 'dlg',
                autoOpen: false,
                stack: true,
                height: 520,
                width: 680,
                position: ['center', 'center'],
                modal: true,
                buttons: {
                    'Submit': function () {
                        var bValid = true;
                        allFields.removeClass('ui-state-error');

                        bValid = bValid && checkLength(name, "name", 0, 100);
                        bValid = bValid && checkLength(email, "email", 0, 80);

                        // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                        //if (email.length > 1) {
                        //    bValid = bValid && checkRegexp(email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "please format email like this: abc@def.com");
                        //}
                        if (bValid) {
                            var subj = "SFBUMP.COM Contact Request";
                            var arr = [name.val(), email.val(), phone.val(), $("input[name='btc']:checked").val(), msg.val()];
                            //format the form fields into the body of the email message
                            //send an email using the form data
                            $.post("./send.php", { subject: subj, message: formatEmail(arr) }, function (data) {
                                if (data.length > 0) {
                                    $("#dlg-mailres").html(data);
                                }
                                else {
                                    $("#dlg-mailres").html("<h3>Ooops.  Error sending email.</h3>");
                                }
                            })

                            $(this).dialog('close');

                            $("#dlg-mailres").dialog({
                                dialogClass: 'dlg',
                                height: 200,
                                modal: true,
                                buttons: {
                                    Ok: function () {
                                        $(this).dialog('close');
                                    }
                                }
                            });
                        }
                    },
                    Cancel: function () {
                        $(this).dialog('close');

                    }
                },
                close: function () {
                    allFields.val('').removeClass('ui-state-error');
                }
            });

        });

 
