
function searchLocation() {
    var z = "";
    z = $('.zip').val();
    window.location.href = '/location/' + z;
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

jQuery.fn.defaultVal = function(value) {
    $(this).val(value);
  $(this).focus(
		function() { if ($(this).val() == value) $(this).val(''); }
	).blur(
		function() { if ($(this).val() == '') $(this).val(value); }
	);
}

$(document).ready(function() {

    var pathname = window.location.pathname;
    if (pathname.toLowerCase().indexOf('aboutus') != -1) {
        if ($('h1:contains(FAQ)').length == 1) {
            // build faq link list
            //  alert($('h1:contains(FAQ)+p strong').length);
            $('h1:contains(FAQ)+p').prepend('<div id="faqjump"></div><br />');
            $('h1:contains(FAQ)+p strong').each(function(i, e) {
            if ($(this).text().length > 20) {
                    if ($(this).find('br').length ==0)
                        $(this).clone().append('<br />').appendTo('#faqjump').wrap('<a href="#id_' + i + '" />');
                    else
                        $(this).clone().appendTo('#faqjump').wrap('<a href="#id_' + i + '" />');
                   
                    // $(this).prepend('<a id="id_' + i _ '" />');
                    $(this).prepend('<a id="id_' + i + '"></a>');
                }
            });

        }
    }
    $("#slider").easySlider({
        auto: true,
        continuous: true,
        controlsFade: false,
        pause: 7000,
        numeric: true
    });

    //    $('.thickbox').colorbox({width:'100%', height:'100%',iframe:true});
    //$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
    $(".thickbox").colorbox(
        { iframe: true,
            innerWidth: 910,
            innerHeight: 706,
            transition: 'fade',
            onOpen: function() { $('html,body').animate({ scrollTop: 0 }, 0); }
        });

    $('#gototop').click(function() {
        $('html,body').animate({ scrollTop: 0 }, 1000);
    });

    $('#content table tr:odd').addClass('odd');
    $('#content table tr td:first-child, #content table tr th:first-child ').addClass('lined');
    /* $('li.clickable').click(function() {
    location.href = '/page/about';
    }); */

    $('div.frame').click(function() {
        var currItem = $('ul#controls li.current');
        var index = $('ul#controls li').index(currItem);
        if ($("#slider li:eq(" + index + ") a").length > 0)
            location.href = $("#slider li:eq(" + index + ") a").attr("href");
    });

    /*
    if ($.trim(($('#content .right').html())) == '') {
    $('#content .right').hide();
    $('#content .left').css('margin-right', '0');
    } */
});

$(window).bind("load", function() {
    $("div#mygalone").slideView()
});


$(document).ready(function() {

    textboxes = $(".zip");

    $('#txtZipLookup').defaultVal('City, State or Zip');
    if ($.browser.mozilla) {
        $(textboxes).keypress(checkForEnter);
    }
    else {
        $(textboxes).keydown(checkForEnter);
    }

    function checkForEnter(event) {
        if (event.keyCode == 13) {
            $('#btnzip').click();
            event.preventDefault();
            return false;
        }
    }
});

$("input,textarea").each(function(i) {


    var obj = $('#' + this.id);

    if (obj.hasClass('defaulttext')) {

        if (obj.val() == '') {
            obj.val(obj.attr('title'));
        }

        obj.focus(function() {
        if ($(this).val() == $(this).attr("title")) {
                $(this).val("");
            }
        });
    }
});
