$(function(){
    $('#jobList .jobDetail').unbind('showme').bind('showme', function() {
        $(this).fadeIn(500, function() {
            $(this).next('.jobDetail').trigger('showme');
        });
    }).filter(':first').trigger('showme');
});

if (typeof jQuery != 'undefined') {
    jQuery(function($) {
        $.fn.extend({
            addShowHideLink: function(options) {
                var settings = $.extend({}, $.fn.addShowHideLink.defaults, options);

                return this.each(function() {
                    if ($.fn.jquery < '1.2.6') { return; }
                    var $t = $(this);
                    var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;

                    //Create the toggle link
                    var $p = $('<p />');
                    var $a = $('<a href="#" />')
                    $a.html(o.showText);

                    //Append the elements
                    $p.append($a);
                    $t.before($p);

                    // Hide the object
                    $t.hide();

                    //Assign the classes (if any)
                    if (o.paraClass != null && o.paraClass != '')
                        $p.addClass(o.paraClass);

                    if (o.linkClass != null && o.linkClass != '')
                        $a.addClass(o.linkClass);

                    //Assign the actions (if any)					
                    if (o.linkActions != null)
                        $a.bind('click', o.linkActions);

                    // capture clicks on the newly created link
                    $a.click(function() {
                        // change the link text
                        if ($(this).html() == o.showText) {
                            $(this).html(o.hideText);
                            if (o.openClass != null && o.openClass != '')
                                $(this).addClass(o.openClass);
                        } else {
                            $(this).html(o.showText);
                            if (o.openClass != null && o.openClass != '')
                                $(this).removeClass(o.openClass);
                        }

                        // toggle the display
                        $t.slideToggle();

                        // return false so any link destination is not followed
                        return false;
                    });
                });
            }
        });

        $.fn.addShowHideLink.defaults = {
            linkClass: null,
            paraClass: null,
            openClass: 'open',
            showText: 'Show',
            hideText: 'Hide',
            linkActions: null
        };
    });
}
if (typeof jQuery != 'undefined') {
    jQuery(function($) {
        $.fn.extend({
            appendIfEmpty: function(options) {
            var settings = $.extend({}, $.fn.appendIfEmpty.defaults, options);
                
                return this.each(function() {
                    if ($.fn.jquery < '1.2.6') { return; }
                    var $t = $(this);
                    var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;

                    if ($t.val() != o['origValue'])
                        $t.val($t.val() + o['seperator'] + o['newValue']);
                    else
                        $t.val(o['newValue']);
                });
            }
        });

        /**
        * Set your Plugin Defaults Here…
        */
        $.fn.appendIfEmpty.defaults = {
            'newValue': '',
            'origValue': '',
            'seperator': ', '
        };
    });
}

jQuery.fn.labelOver = function() {
	return this.each(function(){
	    var l = $(this);
	    var t = l.text();
	    var f = l.attr('for');
	    if (f) {
		    var input = $('#' + f);
    		
		    // handlers
		    input.focus(function(){if (input.val() == '' || input.val() == t) input.val('')});
		    input.blur(function() {if (input.val() == '' || input.val() == t) input.val(t)});
    		
		    l.hide();

		    if (input.val() == '')
			    input.val(t);
	    };
	})
}
