//clearinginput
(function(a){a.extend(a.fn,{clearingInput:function(b){var c={blurClass:"blur"};b=a.extend(c,b);return this.each(function(){var e=a(this).addClass(b.blurClass);var g=e.parents("form:first");var f,h;h=b.text||d()||e.val();if(h){e.val(h);e.blur(function(){if(e.val()===""){e.addClass(b.blurClass).val(h)}}).focus(function(){if(e.val()===h){e.val("")}e.removeClass(b.blurClass)});g.submit(function(){if(e.hasClass(b.blurClass)){e.val("")}});e.blur()}function d(){f=g.find("label[for="+e.attr("id")+"]");return f?f.css({position:"absolute",left:"-9999px"}).text():""}})}})})(jQuery);

function form_labelize(){  jQuery(".labelize input:text").clearingInput(); }   

function list_sort() {
    var templates = {
        valueNames: [ 'category' ]
    };

    var featureList = new List('news-container', templates);

    jQuery('#filter-news').click(function() {
        preventDefault();
        jQuery(this).addClass("active");
    });

    jQuery('#filter-news').click(function() {
        featureList.filter(function(values) {
            if (values.category == "News") {
                return true;
            } else {
                return false;
            }
        });
        return false;
    });

    jQuery('#filter-press-releases').click(function() {
        featureList.filter(function(values) {
            if (values.category == "Press") {
                return true;
            } else {
                return false;
            }
        });
        return false;
    });

    jQuery('#filter-video').click(function() {
        featureList.filter(function(values) {
            if (values.category == "Video") {
                return true;
            } else {
                return false;
            }
        });
        return false;
    });
    
    jQuery('#filter-none').click(function() {
        featureList.filter(function(values) {
            return true;
        });
        return false;
    });

}


jQuery(document).ready(function () {
	form_labelize();
    // list_sort();
    jQuery('#nav > li').hover(function(){jQuery(this).addClass('hover');}, function(){jQuery(this).removeClass('hover');});
    jQuery('#home_carousel').carousel({duration: 700, paginated: true, padding: 800, change: homeCarouselChange});

    // Load custom form controls
    jQuery('#donate_form select').dropdown();
    jQuery('#donate_form input[type=checkbox]').checkbox();
    jQuery('#donate_form input[type=radio]').radio();

    jQuery('#checkout_form_body select').dropdown({width: 261});
    jQuery('#donate_form_container select').dropdown();
    jQuery('.cart_form select').dropdown({width: 219});
    jQuery('#credit_info select').dropdown({width: 75});
    jQuery('#designation select').dropdown({width: 261});
    jQuery('.cart_form select').dropdown();

    jQuery('#checkout_form input[type=checkbox]').checkbox();
    jQuery('#checkout_form input[type=radio]').radio();
});

