var javascriptVersion1_1 = false;
javascriptVersion1_1 = true;

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if (javascriptVersion1_1) {
        window.location.replace(daURL);
    } else {
        window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if (redirectURL && ((pluginFound && redirectIfFound) ||
	    (!pluginFound && !redirectIfFound))) {
        // go away
        goURL(redirectURL);
        return pluginFound;
    } else {
        // stay here and return result of plugin detection
        return pluginFound;
    }
}

function canDetectPlugins() {
    if (detectableWithVB || (navigator.plugins && navigator.plugins.length > 0)) {
        return true;
    } else {
        return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave', 'Flash');
    // if not found, try to detect with VisualBasic
    if (!pluginFound && detectableWithVB) {
        pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave', 'Director');
    // if not found, try to detect with VisualBasic
    if (!pluginFound && detectableWithVB) {
        pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if (!pluginFound && detectableWithVB) {
        pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if (!pluginFound && detectableWithVB) {
        pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		           detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		           detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media');
    // if not found, try to detect with VisualBasic
    if (!pluginFound && detectableWithVB) {
        pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
        var pluginsArrayLength = navigator.plugins.length;
        // for each plugin...
        for (pluginsArrayCounter = 0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++) {
            // loop through all desired names and check each against the current plugin name
            var numFound = 0;
            for (namesCounter = 0; namesCounter < daPlugins.length; namesCounter++) {
                // if desired plugin name is found in either plugin name or description
                if ((navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
		        (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0)) {
                    // this name was found
                    numFound++;
                }
            }
            // now that we have checked all the required names against this one plugin,
            // if the number we found matches the total number provided then we were successful
            if (numFound == daPlugins.length) {
                pluginFound = true;
                // if we've found the plugin, we can stop looking through at the rest of the plugins
                break;
            }
        }
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}




(function (jQuery) {
    jQuery.fn.extend({ elastic: function () {
        var mimics = ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontSize', 'lineHeight', 'fontFamily', 'width', 'fontWeight']; return this.each(function () {
            if (this.type != 'textarea') { return false; }
            var $textarea = jQuery(this), $twin = jQuery('<div />').css({ 'position': 'absolute', 'display': 'none', 'word-wrap': 'break-word' }), lineHeight = parseInt($textarea.css('line-height'), 10) || parseInt($textarea.css('font-size'), '10'), minheight = parseInt($textarea.css('height'), 10) || lineHeight * 3, maxheight = parseInt($textarea.css('max-height'), 10) || Number.MAX_VALUE, goalheight = 0, i = 0; if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
            $twin.appendTo($textarea.parent()); var i = mimics.length; while (i--) { $twin.css(mimics[i].toString(), $textarea.css(mimics[i].toString())); }
            function setHeightAndOverflow(height, overflow) { curratedHeight = Math.floor(parseInt(height, 10)); if ($textarea.height() != curratedHeight) { $textarea.css({ 'height': curratedHeight + 'px', 'overflow': overflow }); } }
            function update() { var textareaContent = $textarea.val().replace(/&/g, '&amp;').replace(/  /g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />'); var twinContent = $twin.html(); if (textareaContent + '&nbsp;' != twinContent) { $twin.html(textareaContent + '&nbsp;'); if (Math.abs($twin.height() + lineHeight - $textarea.height()) > 3) { var goalheight = $twin.height() + lineHeight; if (goalheight >= maxheight) { setHeightAndOverflow(maxheight, 'auto'); } else if (goalheight <= minheight) { setHeightAndOverflow(minheight, 'hidden'); } else { setHeightAndOverflow(goalheight, 'hidden'); } } } }
            $textarea.css({ 'overflow': 'hidden' }); $textarea.keyup(function () { update(); }); $textarea.live('input paste', function (e) { setTimeout(update, 250); }); update();
        });
    }
    });
})(jQuery);

function ToggleCheckbox(sender) {
    if ($(sender).attr('checked'))
        $(sender).removeAttr('checked');
    else
        $(sender).attr('checked', 'checked');
}

$(document).ready(
	function () {
	
		if ($.fancybox != null) {

	        $("a.enlarge").fancybox({
	            'titleShow': false,
	            'transitionIn': 'elastic',
	            'transitionOut': 'elastic'
	        });	    
	        
	        $('a[href^=http://www.youtube.com/]').click(function(){
				$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'elastic',
					'transitionOut'	: 'elastic',
					'title'			: this.title,
					'width'			: 450,
					'height'		: 360,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
					'wmode'				: 'transparent',
					'allowfullscreen'	: 'true'
					}
				});
		
				return false;
	        });

		}
        
	    /* Contact form */
	    
        $('#ContactMenuLink').click(function () {
            $('#overlay').addClass('show');
            return false;
        });

        $('#closeButtonContainer .close, #overlayPanelScreen, #cancelContact').click(function () {
            $('#overlay').removeClass('show');
            return false;
        });

        $('#contactForm form').submit(function () {
            var name = $('#contactName').val();
            var email = $('#contactEmail').val();
            var subject = $('#contactSubject').val();
            var message = $('#contactMessage').val();

            if (name == '' || email == '' || subject == '' || message == '') {
                $('#validateMessage').html('Please make sure all fields are entered correctly.');
                return false;
            } else {
                $('#validateMessage').html('');
                AjaxCall("/home/contactus", { name: name, email: email, subject: subject, message: message }, 60000,
                function (pData) {
                    $('#overlay').removeClass('show');
                    $.prompt("You will be contacted shortly from The Hire Syndicate", { timeout: 4000 });
                });
                return false;
            }
        });
		
		/* END: Contact form */

	    
		$('.pricing.switch li a').click(function(){
			var href = $(this).attr('href');
		
			$('.switch li.selected').removeClass('selected');
			$(this).parent().addClass('selected');
			
			$('.jacket').hide().filter(href).show().find('h2').hide().fadeIn();
		
			return false;
		});


	    if ($('input.acctype').length) {
	        $('input[name="AccountType"]').change(function () {
	            if ($(this).val() != 'recruiter') {
	                $('#acctype_msg').hide().html('<em>The Hire Syndicate is currently not available for this option. If you would like us to get it touch with you when it\'s available, please complete the form below.</em>').fadeIn('fast');
	            } else {
	                $('#acctype_msg').hide().html('').fadeIn('fast');
	            }
	        });
	    }

	    if ($('.scrollFixed').length) {
	        $('.scrollFixed').each(function () {
	            var $self = $(this),
				    offset = $self.offset().top,
				    y;

	            $(window).scroll(function () {
	                y = $(window).scrollTop();
	                if (y >= offset - 10) {
	                    $self.addClass('sidebar-fixed');
	                } else {
	                    $self.removeClass('sidebar-fixed');
	                }
	            });
	        });
	    }

	    /*
	    if ($('.dashboard').length) {
	    $(window).scroll(function () {
	    var y = $(window).scrollTop();
	    if (y >= $('.content:eq(0)').offset().top - 10) {
	    $(".sidebar").addClass('sidebar-fixed');
	    } else {
	    $(".sidebar").removeClass('sidebar-fixed');
	    }
	    });
	    }

	    */
	    
	    $('.labelFilled').each(function(){
	    	var label = $(this).attr('data-label');
	    	$(this).val(label);
	    }).focus(function(){
	    	var label = $(this).attr('data-label');
	    	if ($(this).val() == label) $(this).val('').css('color','#333');
	    }).blur(function(){
	    	var label = $(this).attr('data-label');
	    	if ($(this).val() == '') $(this).val(label).css('color','#999');
	    }).submit(function(){
	    	if ($(this).val() == label) $(this).val('');
	    });
	    
	    if ($('.blank-slate').length) {
	        $('.blank-slate').height($(document).height() - $('.top').height());
	    }

	    if ($('.select-all-none').length) {
	        $('.select-all-none a').click(function () {
	            if ($(this).hasClass('select-all')) {
	                $(this).parent().next().find('input:checkbox').attr('checked', 'checked');
	            }
	            if ($(this).hasClass('select-none')) {
	                $(this).parent().next().find('input:checkbox').removeAttr('checked');
	            }
	        });
	    }

	    if ($('input[name=reason]').length) {
	        $('input[name=reason]:radio').click(function () {
	            $('.deactivate-msg').hide();
	            if ($(this).attr('checked', 'checked')) {
	                $(this).parent().parent().parent().find('.deactivate-msg').fadeIn('fast');
	            }
	        });
	    }

	    if ($('#listingopt').length) {
	        $('#listingopt').change(function () {
	            var $options = $(this);
	            $('.listing-desc').hide();
	            $('#' + $options.find('option:selected').val() + '-listing').fadeIn('fast');
	        }).change();
	    }

	    if ($('.billboard a.joinnow').length) {
	        var $joinnow = $('.billboard a.joinnow').eq(0);
	        var $button = $joinnow.find('.action-primary').eq(0);
	        var backgroundOffset = $joinnow.height() - $button.height() / 2;
	        $('.bottom.wrapper').css({
	            backgroundPosition: '0 ' + backgroundOffset + 'px'
	        });
	    }

	    if ($('#split_before_yes').length) {
	        $('input[name="split_before"]:radio').change(function () {
	            $('#split_size_row').hide();
	            if ($('input[name="split_before"]:radio:checked').val() == 'yes') {
	                $('#split_size_row').fadeIn('fast');
	            }
	        }).change();
	    }

	    if ($('.hasOtherSpecify').length) {
	        $('.hasOtherSpecify').change(function () {
	            var $options = $(this);
	            $options.parent().find('.other-specify').hide();
	            if ($options.find('option:selected').val() == 'other') {
	                $options.parent().find('.other-specify').fadeIn();
	            }
	        }).change();
	    }

	    /*
	    if ($('input[name=job_type]').length && $('p#salary_amount').length) {
	    $('input[name="job_type"]').change(function(){
	    var $options = $(this);
	    var $selectedOption = $options.filter(':checked');						
	    }).change();			
	    }
	    */

	    /*
	    if ($('#salary_currency').length) {
	    $('#salary_currency').change(function(){
	    var currency = $(this).find('option:selected').val();
	    $('.inline-currency').html(currency);
	    }).change();
	    }
	    */

	    if ($('#job_type').length && $('#salary_type').length) {
	        $('#job_type').change(function () {
	            var $options = $(this);
	            if ($options.find('option:selected').val() == 'perm') {
	                $('#salary_type option[value!="yearly"]').removeAttr('selected');
	                $('#salary_type option[value="yearly"]').attr('selected', 'selected');
	            }
	            if (($options.find('option:selected').val() == 'temp') || ($options.find('option:selected').val() == 'temp_to_perm')) {
	                $('#salary_type option[value!="hourly"]').removeAttr('selected');
	                $('#salary_type option[value="hourly"]').attr('selected', 'selected');
	            }
	            $('#salary_type').change();
	        }).change();
	    }

	    if ($('.checkbox-tree').length) {
	        var collapseAddNewJobTree = ($('.add-new-job').length = 0);

	        var collapsedarrow = '/scripts/checkboxtree/images/img-arrow-collapsed.gif';
	        var expandedarrow = '/scripts/checkboxtree/images/img-arrow-expanded.gif';
	        var blankarrow = '/scripts/checkboxtree/images/img-arrow-blank.gif';
	        // Makes sure the sharing options checkbox tree is collapsed for Add new job page
	        $('.checkbox-tree').checkboxTree({
	            collapsedarrow: collapsedarrow,
	            expandedarrow: expandedarrow,
	            blankarrow: blankarrow,
	            // collapsed: false,
	            checkchildren: true
	        })
			.find(':checkbox').each(function () {
			    // Expand checked tree branch
			    if ($(this).attr('checked') && !collapseAddNewJobTree) {
			        $(this).parentsUntil('ul').parent().show().end().find('.checkboxtreeimage').attr('src', expandedarrow);
			    }
			});

	    }

	    if ($('.checkbox-all input:checkbox').length) {
	        $('.checkbox-all').parentsUntil('.inputs').parent().find('input:checkbox').change(function () {
	            var $inputs = $(this).parentsUntil('.inputs').parent();
	            if ($(this).parent().hasClass('checkbox-all')) {
	                if ($(this).attr('checked')) {
	                    $inputs.find('input:checkbox').attr('checked', 'checked');
	                } else {
	                    $inputs.find('input:checkbox').removeAttr('checked');
	                }
	            } else {
	                if ($(this).attr('checked')) {
	                    var allChecked = true;
	                    $inputs.find('label:not(.checkbox-all) input:checkbox').each(function () {
	                        if (allChecked && !($(this).attr('checked')))
	                            allChecked = false;
	                    });
	                    if (allChecked) {
	                        $inputs.find('.checkbox-all input:checkbox').attr('checked', 'checked');
	                    }
	                } else {
	                    $inputs.find('.checkbox-all input:checkbox').removeAttr('checked');
	                }
	            }
	        }).change();
	    }

	    if ($('input[name="distance_type"]').length) {
	        $('input[name="distance_type"]').change(function () {
	            if (($(this).attr('checked')) && ($(this).val() == 'zipcode')) {
	                $('.distance_from').hide();
	                $('#distance_from_zipcode').fadeIn('fast');
	            }
	            if (($(this).attr('checked')) && ($(this).val() == 'candidate')) {
	                $('.distance_from').hide();
	                $('#distance_from_candidate').fadeIn('fast');
	            }
	        }).change();
	    }

	    if ($('.filters #location_country, .filters #location_states').length > 1) {
	        $('#location_country').change(function () {
	            if ($(this).find('option:selected').val() == 'all') {
	                $('#location_states').hide();
	            } else {
	                $('#location_states').fadeIn('fast');
	            }
	        }).change();
	    }

	    if ($('.filters .inputs').length) {
	        $('.filters .inputs').hide().parent('.filter-opened').find('.inputs').show();
	        $('.filters h4:not(.search-heading)').click(function () {
	            if ($(this).parentsUntil('.filters').hasClass('filter-opened')) {
	                $(this).parent().find('.inputs').stop(true, true).slideUp().end().removeClass('filter-opened');
	            } else {
	                $(this).parent().find('.inputs').stop(true, true).slideDown().end().addClass('filter-opened');
	            }
	        });
	        $('.filters .inputs input, .filters .inputs select').change(function () {
	            var $filter = $(this).parentsUntil('.filter').parent();
	            if ($filter.find('.filter-default:checked, .filter-default:selected').length) {
	                $filter.find('h4').removeClass('filter-applied');
	            } else {
	                $filter.find('h4').addClass('filter-applied');
	            }
	        });
	    }

	    if ($('.location-filter').length) {
	        var $locationOptions = $('.location-options');
	        $('#location').change(function () {
	            if ($(this).find('option:selected').val() == 'all') {
	                $locationOptions.hide();
	            } else {
	                $locationOptions.fadeIn('fast');
	            }
	        }).change();
	        $('#location_country').change(function () {
	            if ($(this).find('option:selected').hasClass('use-zipcode')) {
	                $('#location_zipcode, #distance').removeAttr('disabled');
	                $('label[for=location_zipcode], label[for=distance]').removeClass('disabled');
	            } else {
	                $('#location_zipcode, #distance').attr('disabled', 'disabled');
	                $('label[for=location_zipcode], label[for=distance]').addClass('disabled');
	            }
	        }).change();
	        $('#location_zipcode').keyup(function () {
	            if ($(this).val() == '') {
	                $('#distance').attr('disabled', 'disabled');
	                $('label[for=distance]').addClass('disabled');
	            } else {
	                $('#distance').removeAttr('disabled');
	                $('label[for=distance]').removeClass('disabled');
	            }
	        }).keyup();
	    }

	    if ($('.deals .deal-info').length) {
	        $('.deals .deal-info').hide().parent('.deal-opened').find('.deal-info').show();
	        $('.deals h4:not(.search-heading)').click(function () {
	            if ($(this).parentsUntil('.deals').hasClass('deal-opened')) {
	                $(this).parent().find('.deal-info').stop(true, true).slideUp().end().removeClass('deal-opened');
	            } else {
	                $(this).parent().find('.deal-info').stop(true, true).slideDown().end().addClass('deal-opened');
	            }
	        });
	        $('.deal a').click(function (e) {
	            e.preventDefault();
	        });
	        $('.collapse-deals').click(function (e) {
	            e.preventDefault();
	            $('.deal-opened .deal-info').slideUp().parent().removeClass('deal-opened');
	        });
	        $('.expand-deals').click(function (e) {
	            e.preventDefault();
	            $('.deal').not('.deal-opened').find('.deal-info').slideDown().end().addClass('deal-opened');
	        });
	    }

	    if ($('#expiry_date').length) {
	        $('#expiry_date').datepicker({
	    });
	}
	/*
	Check user's default date format.

	The format can be combinations of the following:
	d - day of month (no leading zero)
	dd - day of month (two digit)
	o - day of the year (no leading zeros)
	oo - day of the year (three digit)
	D - day name short
	DD - day name long
	m - month of year (no leading zero)
	mm - month of year (two digit)
	M - month name short
	MM - month name long
	y - year (two digit)
	yy - year (four digit)
	@ - Unix timestamp (ms since 01/01/1970)
	! - Windows ticks (100ns since 01/01/0001)
	'...' - literal text
	'' - single quote
	anything else - literal text
	There are also a number of predefined standard date formats available from $.datepicker:

	ATOM - 'yy-mm-dd' (Same as RFC 3339/ISO 8601)
	COOKIE - 'D, dd M yy'
	ISO_8601 - 'yy-mm-dd'
	RFC_822 - 'D, d M y' (See RFC 822)
	RFC_850 - 'DD, dd-M-y' (See RFC 850)
	RFC_1036 - 'D, d M y' (See RFC 1036)
	RFC_1123 - 'D, d M yy' (See RFC 1123)
	RFC_2822 - 'D, d M yy' (See RFC 2822)
	RSS - 'D, d M y' (Same as RFC 822)
	TICKS - '!'
	TIMESTAMP - '@'
	W3C - 'yy-mm-dd' (Same as ISO 8601)
	*/
	if ($('.datepicker').length) {
	    $('.datepicker').datepicker({
	        dateFormat: 'mm/dd/yy'
	    })
			.live('click', function () {
			    if ($('.ui-datepicker:visible').length)
			        $(this).datepicker('hide');
			    else
			        $(this).datepicker('show');
			});
	}

	if ($('.deleteCandidate').length) {
	    $('.deleteCandidate').click(function (e) {
	        e.preventDefault();
	        $(document.createElement('div'))
					.appendTo('body')
					.addClass('dialog deleteCandidate-dialog')
					.attr('title',
						'Delete "' + $('input[name=current_name]').val() + '"'
					)
					.html(
						'<p>Are you sure you want to delete this candidate? This would terminate any current activities and job submissions.</p>'
					)
					.dialog({
					    resizable: false,
					    modal: true,
					    draggable: false,
					    width: 380,
					    buttons: {
					        Cancel: function () {
					            $(this).dialog('close');
					        },
					        'Delete': function () {
					            // Add action here for deleting candidate, then close the dialog
					            $(this).dialog('close');
					        }
					    },
					    close: function () {
					        $(this).remove();
					    }
					});
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');
	    });
	}

	if ($('.deletePod').length) {
	    $('.deletePod').click(function (e) {
	        e.preventDefault();
	        $(document.createElement('div'))
					.appendTo('body')
					.addClass('dialog deletePod-dialog')
					.attr('title',
						'Delete "' + $('input[name=current_name]').val() + '"'
					)
					.html(
						'<p>Are you sure you want to delete this Pod? This would terminate any current activities, job submissions and connections associated with this Pod.</p>'
					)
					.dialog({
					    resizable: false,
					    modal: true,
					    draggable: false,
					    width: 380,
					    buttons: {
					        Cancel: function () {
					            $(this).dialog('close');
					        },
					        'Delete': function () {
					            // Add action here for deleting pod, then close the dialog
					            $(this).dialog('close');
					        }
					    },
					    close: function () {
					        $(this).remove();
					    }
					});
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');
	    });
	}

	if ($('.requestPodConnection').length) {
	    $('.requestPodConnection').click(function (e) {
	        e.preventDefault();
	        $(document.createElement('div'))
					.appendTo('body')
					.addClass('dialog requestPodConnection-dialog')
					.attr('title',
						'Connect with "' + $('input[name=pod_name]').val() + '"?'
					)
					.html(
						'<p>The Pod manager will have to confirm your request.</p><h4>Notes to Pod manager</h4><p><textarea name="recruiter-note" class="full elastic" rows="5"></textarea></p>'
					)
					.dialog({
					    resizable: false,
					    modal: true,
					    draggable: false,
					    width: 380,
					    buttons: {
					        Cancel: function () {
					            $(this).dialog('close');
					        },
					        'Send request': function () {
					            // Add action here for sending request, then close the dialog
					            $(this).dialog('close');
					        }
					    },
					    close: function () {
					        $(this).remove();
					    }
					});
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');
	    });
	}	

	if ($('.content-tabs').length) {
	    $('.content-tabs').tabs({
	        fx: [
					{}, //hide effects
					{opacity: 'toggle', duration: 'normal'}  //show effects
				]
	    });
	}

	/* if (($('.collapsible-content').length) && ($('.collapsible-content').hasClass('long-content'))) {
	if ($('.collapsible-content').hasClass('content-expanded'))
	$('.expand-content').hide();
	if ($('.collapsible-content').hasClass('content-collapsed'))
	$('.collapse-content').hide();

	$('.expand-content, .collapse-content').click(function (e) {
	e.preventDefault();
	var $target = $(this).parent().find('.collapsible-content');

	if ($(this).hide().hasClass('expand-content')) {
	$target.removeClass('content-collapsed').addClass('content-expanded');
	$(this).parent().find('.collapse-content').show();
	}
	if ($(this).hide().hasClass('collapse-content')) {
	$target.removeClass('content-expanded').addClass('content-collapsed');
	$(this).parent().find('.expand-content').show();
	}
	});
	}*/

	if ($('.submitCandidate').length) {
	    $('.submitCandidate').click(function (e) {
	        e.preventDefault();
	        $(document.createElement('div'))
					.appendTo('body')
					.addClass('dialog submitCandidate-dialog')
					.attr('title', 'Submit candidate')
					.html(
						'<p class="search"><label for="candidate-search">Search</label><input id="candidate-search" class="input" name="q" type="text" /></p><div class="search-results"><ul><li><label class="inline" for="candidate-1"><input type="radio" name="candidate" id="candidate-1">Candidate 1</label></li><li><label class="inline" for="candidate-2"><input type="radio" name="candidate" id="candidate-2">Candidate 2</label></li><li><label class="inline" for="candidate-3"><input type="radio" name="candidate" id="candidate-3">Candidate 3</label></li><li><label class="inline" for="candidate-4"><input type="radio" name="candidate" id="candidate-4">Candidate 4</label></li><li><label class="inline" for="candidate-5"><input type="radio" name="candidate" id="candidate-5">Candidate 5</label></li><li><label class="inline" for="candidate-6"><input type="radio" name="candidate" id="candidate-6">Candidate 6</label></li><li><label class="inline" for="candidate-7"><input type="radio" name="candidate" id="candidate-7">Candidate 7</label></li><li><label class="inline" for="candidate-8"><input type="radio" name="candidate" id="candidate-8">Candidate 8</label></li></ul></div><h4>Notes to recruiter</h4><p><textarea name="recruiter-note" class="full elastic" rows="5"></textarea></p>'
					)
					.dialog({
					    resizable: false,
					    modal: true,
					    draggable: false,
					    width: 480,
					    buttons: {
					        Cancel: function () {
					            $(this).dialog('close');
					        },
					        'Submit': function () {
					            // Add action here for submitting candidate, then close the dialog
					            $(this).dialog('close');
					        }
					    },
					    close: function () {
					        $(this).remove();
					    }
					});
	        $('textarea.elastic').elastic();
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');

	        $('.search-results input:radio').live('change', function () {
	            $('.search-results ul li').removeClass('selected').find('input:radio:checked').parentsUntil('li').parent().addClass('selected');
	        });
	    });
	}

	if ($('.submitJob').length) {
	    $('.submitJob').click(function (e) {
	        e.preventDefault();
	        $(document.createElement('div'))
					.appendTo('body')
					.addClass('dialog submitJob-dialog')
					.attr('title', 'Submit to job')
					.html(
						'<p class="search"><label for="job-search">Search</label><input class="input" id="job-search" name="q" type="text" /></p><div class="search-results"><ul><li><label class="inline" for="job-1"><input type="radio" name="job" id="job-1">Job 1</label></li><li><label class="inline" for="job-2"><input type="radio" name="job" id="job-2">Job 2</label></li><li><label class="inline" for="job-3"><input type="radio" name="job" id="job-3">Job 3</label></li><li><label class="inline" for="job-4"><input type="radio" name="job" id="job-4">Job 4</label></li><li><label class="inline" for="job-5"><input type="radio" name="job" id="job-5">Job 5</label></li><li><label class="inline" for="job-6"><input type="radio" name="job" id="job-6">Job 6</label></li><li><label class="inline" for="job-7"><input type="radio" name="job" id="job-7">Job 7</label></li><li><label class="inline" for="job-8"><input type="radio" name="job" id="job-8">Job 8</label></li></ul></div><h4>Notes to recruiter</h4><p><textarea name="recruiter-note" class="full" rows="5"></textarea></p>'
					)
					.dialog({
					    resizable: false,
					    modal: true,
					    draggable: false,
					    width: 480,
					    buttons: {
					        Cancel: function () {
					            $(this).dialog('close');
					        },
					        'Submit': function () {
					            // Add action here for submitting candidate to job, then close the dialog
					            $(this).dialog('close');
					        }
					    },
					    close: function () {
					        $(this).remove();
					    }
					});
	        $('textarea.elastic').elastic();
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');

	        $('.search-results input:radio').live('change', function () {
	            $('.search-results ul li').removeClass('selected').find('input:radio:checked').parentsUntil('li').parent().addClass('selected');
	        });
	    });
	}

	if ($('.sendMessage').length) {
	    $('.sendMessage').click(function (e) {
	        e.preventDefault();

	        var rel = $(this).attr('rel');
	        var sendBlankMessage = true;

	        if (rel != '') {
	            sendBlankMessage = false;
	            var recipientId = rel.substring(0, rel.search('-'));
	            var recipientName = rel.substring(rel.search('-') + 1).replace('_', ' ');
	        }

	        if (sendBlankMessage) {
	            var $dialog = $(document.createElement('div'))
						.appendTo('body')
						.addClass('dialog sendMessage-dialog')
						.attr('title', 'Send a message')
						.html(
							'<table class="full"><tbody><tr><td class="label-cell"><label for="recipient">To</label></td><td class="input-cell"><input type="hidden" name="recipientId" id="recipientId" /><input type="text" name="recipient" id="recipient" class="input input-long" /></div></td></tr><tr><td class="label-cell"><label for="subject">Subject</label></td><td class="input-cell"><input type="text" name="subject" id="subject" class="input input-long" /></td></tr><tr><td class="label-cell"><label for="message">Message</label></td><td class="input-cell"><textarea id="message" name="message" class="input-long elastic"></textarea></td></tr></tbody></table>'
						);
	            $('#recipient').autocomplete(names,
						{
						    matchContains: true,
						    multiple: true,
						    multipleSeparator: '; '
						}
					);
	        } else {
	            var $dialog = $(document.createElement('div'))
						.appendTo('body')
						.addClass('dialog sendMessage-dialog')
						.attr('title', 'Send a message')
						.html(
							'<table class="full"><tbody><tr><td class="label-cell"><label for="recipient">To</label></td><td class="input-cell"><p><input type="hidden" name="recipientId" id="recipientId" value="' + recipientId + '" />' + recipientName + '</p></td></tr><tr><td class="label-cell"><label for="subject">Subject</label></td><td class="input-cell"><input type="text" name="subject" id="subject" class="input input-long" /></td></tr><tr><td class="label-cell"><label for="message">Message</label></td><td class="input-cell"><textarea id="message" name="message" class="input-long elastic"></textarea></td></tr></tbody></table>'
						);
	        }

	        $dialog.dialog({
	            resizable: false,
	            modal: true,
	            draggable: false,
	            width: 480,
	            buttons: {
	                Cancel: function () {
	                    $(this).dialog('close');
	                },
	                'Send': function () {
	                    // Add action here for sending message, then close the dialog
	                    $(this).dialog('close');
	                }
	            },
	            close: function () {
	                $(this).remove();
	            }
	        });
	        $('textarea.elastic').elastic();
	        $('.ui-dialog .ui-button:first-child').addClass('button-secondary');
	    });
	}

	if ($('textarea.elastic').length) {
	    $('textarea.elastic').elastic();
	}

	if ($('#company_name').length) {
	    $('#company_name').autocomplete(companies,
				{
				    matchContains: true,
				    autofill: true
				}
			);
	}

	if ($('#pod-form #locations').length) {
	    $('#pod-form #locations').autocomplete(locations,
				{
				    matchContains: true,
				    autofill: true,
				    multiple: true,
				    multipleSeparator: '; '
				}
			);
	}

	/* ======================================== */
	/*

	Status:
	- Pending recruiter's review
	- Accepted by recruiter
	- Declined by recruiter
	- Submitted to client
	- Client interview in progress
	- Candidate declined
	- Position filled
	- Position closed (other)
	- Placement made
	- Placement made (fee pending)
	- Placement made (fee paid)

	*/
	/* ======================================== */
	$('.changeStatus').live('click', function (e) {
	    e.preventDefault();
	    $(document.createElement('div'))
				.appendTo('body')
				.addClass('dialog changeStatus-dialog')
				.attr('title', 'Change status')
				.html(
					'<table class="full"><tbody><tr><td class="label-cell"><label>Current status</label></td><td class="input-cell"><p>Client interview in process</p></td></tr><tr><td class="label-cell"><label for="new_status">Change status to</label></td><td class="input-cell"><select name="new_status" id="new_status"><option>Pending recruiter\'s review</option><option>Accepted by recruiter</option><option>Declined by recruiter</option><option>Submitted to client</option><option>Client interview in process</option><option>Candidate declined</option><option>Position filled</option><option>Position closed (other)</option><option value="placement_made">Placement made</option><option>Placement made (fee pending)</option><option>Placement made (fee paid)</option></select><br /><label class="checkbox placement_info" for="mark_other_candidates"><input type="checkbox" id="mark_other_candidates" name="mark_other_candidates" />Mark other candidates\' status as <strong>Position filled</strong></label></td></tr><tr class="placement_info"><td class="label-cell"><label for="start_date">Starting Date</label></td><td class="input-cell"><input type="text" name="start_date" id="start_date" class="input input-short datepicker" style="margin-left: 0;" /></td></tr><tr class="placement_info"><!-- "Annual salary" should change acc. job type --><td class="label-cell"><label for="starting_salary">Starting Salary</label><br /><span class="field-note">Annual salary</span></td><td class="input-cell"><input type="text" class="input input-short input-money" name="starting_salary" id="starting_salary" style="margin-left: 0;" /><label class="inline inline-currency">USD</label></td></tr><tr class="placement_info"><td class="label-cell"><label for="guarantee_period">Guarantee Period</label></td><td class="input-cell"><select name="guarantee_period" id="guarantee_period" class="input"><option value="0">0 (No Guarantee Period)</option><option value="30">30</option><option value="60">60</option><option value="90" selected="selected">90</option><option value="120">120</option><option value="150">150</option><option value="180">180</option></select> &nbsp;days</td></tr><tr class="placement_info"><td class="label-cell"><label>Commission fee</label></td><td class="input-cell">should be <strong>16,000 USD</strong></td></tr><tr class="placement_info"><td class="label-cell"><label for="agreed_fee">Agreed fee</label></td><td class="input-cell"><input type="text" class="input input-short input-money" name="agreed_fee" id="agreed_fee" style="margin-left: 0;" /><label class="inline inline-currency">USD</label></td></tr><tr><td class="label-cell"><label for="recruiter_notes">Notes to recruiter</label></td><td class="input-cell"><textarea id="recruiter_notes" name="recruiter_notes" class="input-long elastic"></textarea></td></tr></tbody></table>'
				)
				.find('.datepicker')
					.datepicker({
					    dateFormat: 'mm/dd/yy'
					})
					.click(function () {
					    if ($('.ui-datepicker:visible').length)
					        $('.datepicker').datepicker('hide');
					    else
					        $('.datepicker').datepicker('show');
					})
				.end()
				.find('#new_status')
					.change(function () {
					    $options = $(this);
					    $options.parentsUntil('.changeStatus-dialog').find('.placement_info').hide();
					    if ($options.find('option:selected').val() == 'placement_made') {
					        $options.parentsUntil('.changeStatus-dialog').find('.placement_info').fadeIn('fast');
					    }

					})
					.change()
				.end()
				.dialog({
				    resizable: false,
				    modal: true,
				    draggable: false,
				    width: 480,
				    buttons: {
				        Cancel: function () {
				            $(this).dialog('close');
				        },
				        'Submit': function () {
				            // Add action here for submitting candidate, then close the dialog
				            $(this).dialog('close');
				        }
				    },
				    close: function () {
				        $('.datepicker').datepicler('hide');
				        $(this).remove();
				    }
				});
	    $('textarea.elastic').elastic();
	    $('.ui-dialog .ui-button:first-child').addClass('button-secondary');
	    $('.ui-dialog-buttonpane').append('<a href="#" class="undo-status">Undo last step</a>');
	});

	if ($('#job_description').length) {
	    tinyMCE.init({
	        content_css: '../assets/css/style.css',
	        mode: 'exact',
	        elements: 'job_description',
	        theme: 'advanced',
	        skin: 'o2k7',
	        plugins: 'paste',
	        height: '240',
	        width: '615',
	        theme_advanced_toolbar_location: 'top',
	        theme_advanced_toolbar_align: 'left',
	        theme_advanced_buttons1: 'undo,redo,|,cut,copy,paste,pastetext,pasteword,|,bold,italic,underline,|,bullist,numlist,|,outdent,indent,|,link,unlink',
	        theme_advanced_buttons2: '',
	        theme_advanced_buttons3: ''
	    });
	}

	if ($('.tooltip').length) {
	    $('.tooltip').tooltip({
	        showURL: false,
	        top: -25,
	        left: 10
	    }).click(false);
	}

	function preProcessJobs(data) {
	    var id, title, recruiter, status;

	    for (var i in data.rows) {
	        id = data.rows[i].cell[0];
	        title = data.rows[i].cell[1];
	        recruiter = data.rows[i].cell[7];
	        status = data.rows[i].cell[9];

	        data.rows[i].cell[0] = '<input type="checkbox" name="job_' + id + '" id="job_' + id + '" />';

	        data.rows[i].cell[1] = '<a href="#" title="">' + title + '</a>';

	        data.rows[i].cell[7] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';

	        if (status == 'Active')
	            data.rows[i].cell[9] = '<a href="#" title="Deactivate this job">Deactivate</a>';
	        if (status == 'Inactive')
	            data.rows[i].cell[9] = '<a href="#" title="Activate this job">Activate</a>';
	    }

	    return data;
	}

	function preProcessCandidates(data) {
	    var id, name, recruiter, relocate;

	    for (var i in data.rows) {
	        /* 				id = data.rows[i].cell[0]; */
	        name = data.rows[i].cell[1];
	        /* 				recruiter = data.rows[i].cell[4]; */
	        relocate = data.rows[i].cell[6];

	        /* 				data.rows[i].cell[0] = '<input type="checkbox" name="candidate_' + id + '" id="candidate_' + id + '" />'; */

	        data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';

	        /* 				data.rows[i].cell[4] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>'; */

	        if (relocate)
	            data.rows[i].cell[6] = '<img width="14" height="14" title="User will consider relocate" src="../assets/images/relocate.gif" />'
	        else
	            data.rows[i].cell[6] = '';
	    }

	    return data;
	}

	function preProcessPods(data) {
	    var name, recruiter, connected;

	    for (var i in data.rows) {

	        name = data.rows[i].cell[1];
	        recruiter = data.rows[i].cell[2];
	        connected = data.rows[i].cell[7];

	        if (connected) {
	            data.rows[i].cell[1] = '<a href="#" class="connected" title="See ' + name + '\'s Profile">' + name + '</a>';
	            data.rows[i].cell[2] = '<a href="#" class="connected" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';
	        } else {
	            data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';
	            data.rows[i].cell[2] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';
	        }
	    }

	    return data;
	}

	function preProcessRecruiters(data) {
	    var name, agency, connected;

	    for (var i in data.rows) {

	        name = data.rows[i].cell[1];
	        agency = data.rows[i].cell[2];
	        connected = data.rows[i].cell[6];

	        if (connected) {
	            data.rows[i].cell[1] = '<a href="#" class="connected" title="See ' + name + '\'s Profile">' + name + '</a>';
	            data.rows[i].cell[2] = '<a href="#" class="connected" title="See ' + agency + '\'s Profile">' + agency + '</a>';
	        } else {
	            data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';
	            data.rows[i].cell[2] = '<a href="#" title="See ' + agency + '\'s Profile">' + agency + '</a>';
	        }

	    }

	    return data;
	}

	function preProcessJobCandidates(data) {
	    var name, recruiter, relocate, status;

	    for (var i in data.rows) {
	        name = data.rows[i].cell[1];
	        recruiter = data.rows[i].cell[6];
	        relocate = data.rows[i].cell[7];
	        status = data.rows[i].cell[8];

	        data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';

	        data.rows[i].cell[6] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';

	        if (relocate)
	            data.rows[i].cell[7] = '<img width="14" height="14" title="User will consider relocate" src="../assets/images/relocate.gif" />'
	        else
	            data.rows[i].cell[7] = '';

	        data.rows[i].cell[8] = '<a href="#" title="Change deal status" class="changeStatus">' + status + '</a>';
	    }

	    return data;
	}

	function preProcessCandidateJobs(data) {
	    var title, recruiter, status;

	    for (var i in data.rows) {
	        title = data.rows[i].cell[1];
	        recruiter = data.rows[i].cell[5];

	        data.rows[i].cell[1] = '<a href="#" title="See more information on ' + title + '">' + title + '</a>';

	        data.rows[i].cell[5] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';
	    }

	    return data;
	}

	function preProcessPodJobs(data) {
	    var id, title, recruiter, status;

	    for (var i in data.rows) {
	        id = data.rows[i].cell[0];
	        title = data.rows[i].cell[1];
	        recruiter = data.rows[i].cell[7];

	        data.rows[i].cell[0] = '<input type="checkbox" name="job_' + id + '" id="job_' + id + '" />';

	        data.rows[i].cell[1] = '<a href="#" title="">' + title + '</a>';

	        data.rows[i].cell[7] = '<a href="#" title="See ' + recruiter + '\'s Profile">' + recruiter + '</a>';
	    }

	    return data;
	}

	function preProcessPodRecruiters(data) {
	    var name, agency;

	    for (var i in data.rows) {

	        name = data.rows[i].cell[1];
	        agency = data.rows[i].cell[2];

	        data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';
	        data.rows[i].cell[2] = '<a href="#" title="See ' + agency + '\'s Profile">' + agency + '</a>';

	    }

	    return data;
	}

	function preProcessRecruiterJobs(data) {
	    var id, title, recruiter, status;

	    for (var i in data.rows) {
	        id = data.rows[i].cell[0];
	        title = data.rows[i].cell[1];

	        data.rows[i].cell[0] = '<input type="checkbox" name="job_' + id + '" id="job_' + id + '" />';

	        data.rows[i].cell[1] = '<a href="#" title="">' + title + '</a>';
	    }

	    return data;
	}

	function preProcessAdminAgencies(data) {
	    var agency, manager;

	    for (var i in data.rows) {

	        agency = data.rows[i].cell[1];
	        manager = data.rows[i].cell[2];

	        data.rows[i].cell[1] = '<a href="#" title="See ' + agency + '\'s Profile">' + agency + '</a>';
	        data.rows[i].cell[2] = '<a href="#" title="See ' + manager + '\'s Profile">' + manager + '</a>';

	    }

	    return data;
	}

	function preProcessAdminRecruiters(data) {
	    var name, agency;

	    for (var i in data.rows) {

	        name = data.rows[i].cell[1];
	        agency = data.rows[i].cell[2];

	        data.rows[i].cell[1] = '<a href="#" title="See ' + name + '\'s Profile">' + name + '</a>';
	        data.rows[i].cell[2] = '<a href="#" title="See ' + agency + '\'s Profile">' + agency + '</a>';

	    }

	    return data;
	}

	function preProcessRequestsReceived(data) {

	}

	function preProcessRequestsSent(data) {

	}

	function preProcessMessages(data) {
	    var id, name, imageURL, date, subject, bodyText, read, messageClass;

	    for (var i in data.rows) {

	        id = data.rows[i].cell[0];
	        name = data.rows[i].cell[1];
	        imageURL = data.rows[i].cell[2];
	        date = data.rows[i].cell[3];
	        subject = data.rows[i].cell[4];
	        bodyText = data.rows[i].cell[5];
	        read = data.rows[i].cell[6];
	        if (read) {
	            messageClass = '';
	        } else {
	            messageClass = 'unread';
	        }

	        data.rows[i].cell[0] = '<input type="checkbox" name="job_' + id + '" id="job_' + id + '" />';
	        data.rows[i].cell[1] = '<p><a href="#" title="See ' + name + '\'s Profile"><img src="' + imageURL + '" style="width: 50px; height: 50px; background: #999;" /><br />' + name + '</a></p>';
	        data.rows[i].cell[2] = '<p class="' + messageClass + '"><a href="#">' + subject + '</a><br />' + bodyText + '</p>';
	        data.rows[i].cell[3] = '<p>' + date + '</p>';

	    }

	    return data;
	}

	if ($('.flextable').length) {
	    $('#jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/jobs-query-flexigrid.json',
					    dataType: 'json',
					    colModel: [
					    /* Show checkbox only for My jobs */
							{display: 'ID', name: 'id', width: 20, sortable: true, align: 'center', hide: false },
							{ display: 'Title', name: 'title', width: 120, sortable: true, align: 'left' },
							{ display: 'Company', name: 'company', width: 100, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 100, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
					    /* Hide Recruiter and show Status column for when showing My jobs, otherwise show Recruiter and hide Status column */
							{display: 'Recruiter', name: 'recruiter', width: 70, sortable: true, align: 'center', hide: true },
							{ display: 'Date Posted', name: 'date_posted', width: 80, sortable: true, align: 'center' },
							{ display: 'Status', name: 'status', width: 70, sortable: true, align: 'center', hide: false }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'Company', name: 'company' },
							{ display: 'Recruiter', name: 'recruiter' },
						],
					    sortname: "title",
					    sortorder: "asc",
					    title: 'My Jobs',
					    usepager: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    useRp: true,
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessJobs
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});

	    $('#candidates_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/candidates-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 120, sortable: true, align: 'left' },
							{ display: 'Title', name: 'title', width: 100, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 130, sortable: true, align: 'left' },
							{ display: '', name: 'relocate', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Date Modified', name: 'date_modified', width: 90, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Title', name: 'title' },
							{ display: 'E-mail', name: 'email' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'My Candidates',
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessCandidates
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});

	    $('#pods_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/pods-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 140, sortable: true, align: 'left' },
							{ display: 'Created by', name: 'recruiter', width: 130, sortable: true, align: 'left', hide: false }, //Hide Created by when 'My Pods' is selected
							{display: 'Industry', name: 'industry', width: 130, sortable: true, align: 'left' },
							{ display: 'Location', name: 'location', width: 130, sortable: true, align: 'left' },
							{ display: 'Members', name: 'members', width: 50, sortable: true, align: 'center' },
							{ display: 'Jobs', name: 'jobs', width: 40, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Created by', name: 'recruiter' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'Public Pods',
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessPods
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});

	    $('#recruiters_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/recruiters-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 140, sortable: true, align: 'left' },
							{ display: 'Agency', name: 'agency', width: 140, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 140, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 130, sortable: true, align: 'left' },
							{ display: 'Experience', name: 'experience', width: 80, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'Public Recruiters',
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessRecruiters
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});

	    $('#job_candidates_table, .job_candidates_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/job-candidates-query-flexigrid.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 120, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 130, sortable: true, align: 'left' },
							{ display: 'Title', name: 'title', width: 130, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 120, sortable: true, align: 'left' },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'Email', name: 'email', width: 120, sortable: true, align: 'left' },
							{ display: 'Recruiter', name: 'recruiter', width: 130, sortable: true, align: 'left' },
							{ display: '', name: 'relocate', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Status', name: 'status', width: 150, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Title', name: 'title' },
							{ display: 'City', name: 'city' },
							{ display: 'Email', name: 'email' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'Candidates',
					    usepager: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    width: 960,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessJobCandidates
					}
				);

	    $('#candidate_jobs_table, .candidate_jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/candidate-jobs-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 120, sortable: true, align: 'left', hide: true },
							{ display: 'Title', name: 'title', width: 150, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 120, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
							{ display: 'Recruiter', name: 'recruiter', width: 120, sortable: true, align: 'left' },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 130, sortable: true, align: 'left' },
							{ display: 'Status', name: 'status', width: 150, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'City', name: 'city' },
							{ display: 'Recruiter', name: 'recruiter' }
						],
					    sortname: "title",
					    sortorder: "asc",
					    title: 'Jobs submitted to',
					    showToggleBtn: false, //show or hide column toggle popup
					    usepager: true,
					    width: 960,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessCandidateJobs
					}
				);

	    $('#pod_jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/pod-jobs-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Title', name: 'title', width: 120, sortable: true, align: 'left' },
							{ display: 'Company', name: 'company', width: 110, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 100, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
							{ display: 'Recruiter', name: 'recruiter', width: 90, sortable: true, align: 'left', hide: false },
							{ display: 'Date Posted', name: 'date_posted', width: 80, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'Company', name: 'company' },
							{ display: 'Recruiter', name: 'recruiter' },
						],
					    sortname: "title",
					    sortorder: "asc",
					    title: 'Jobs in Anadata',
					    usepager: true,
					    useRp: true,
					    rp: 20,
					    showToggleBtn: false, //show or hide column toggle popup
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessPodJobs
					}
				);

	    $('#pod_recruiters_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/pod-recruiters-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 110, sortable: true, align: 'left' },
							{ display: 'Agency', name: 'agency', width: 110, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 110, sortable: true, align: 'left' },
							{ display: 'Experience', name: 'experience', width: 80, sortable: true, align: 'center' },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 130, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'Recruiters in Anadata',
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    rp: 20,
					    showToggleBtn: false, //show or hide column toggle popup
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessPodRecruiters
					}
				);

	    $('#recruiter_jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/recruiter-jobs-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Title', name: 'title', width: 160, sortable: true, align: 'left' },
							{ display: 'Company', name: 'company', width: 150, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 110, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 120, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
							{ display: 'Recruiter', name: 'recruiter', width: 110, sortable: true, align: 'center', hide: true }, //I've used the same JSON structure as Pod_Jobs_Table so that you can reuse the same function, if that's what you use, to call the JSON data
							{display: 'Date Posted', name: 'date_posted', width: 80, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'Company', name: 'company' }
						],
					    sortname: "title",
					    sortorder: "asc",
					    usepager: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    useRp: true,
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessRecruiterJobs
					}
				);

	    $('#recruiter_candidates_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/recruiter-candidates-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 120, sortable: true, align: 'left' },
							{ display: 'Title', name: 'title', width: 100, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 130, sortable: true, align: 'left' },
							{ display: '', name: 'relocate', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Date Modified', name: 'date_modified', width: 90, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Title', name: 'title' },
							{ display: 'E-mail', name: 'email' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessCandidates
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});

	    $('#agency_jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/agency-jobs-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Title', name: 'title', width: 120, sortable: true, align: 'left' },
							{ display: 'Company', name: 'company', width: 110, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 100, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
							{ display: 'Recruiter', name: 'recruiter', width: 90, sortable: true, align: 'left', hide: false },
							{ display: 'Date Posted', name: 'date_posted', width: 80, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'Company', name: 'company' },
							{ display: 'Recruiter', name: 'recruiter' },
						],
					    sortname: "title",
					    sortorder: "asc",
					    title: 'Jobs in A&ndash;List Placement',
					    usepager: true,
					    useRp: true,
					    rp: 20,
					    showToggleBtn: false, //show or hide column toggle popup
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessPodJobs
					}
				);

	    $('#agency_recruiters_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/agency-recruiters-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 160, sortable: true, align: 'left' },
							{ display: 'Agency', name: 'agency', width: 110, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 130, sortable: true, align: 'left' },
							{ display: 'Experience', name: 'experience', width: 80, sortable: true, align: 'center' },
							{ display: 'Phone', name: 'phone', width: 100, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 160, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    title: 'Recruiters in A&ndash;List Placement',
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    rp: 20,
					    showToggleBtn: false, //show or hide column toggle popup
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessPodRecruiters
					}
				);

	    $('#admin_agencies_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/admin-agencies-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Business name', name: 'name', width: 150, sortable: true, align: 'left' },
							{ display: 'Business manager', name: 'manager', width: 140, sortable: true, align: 'left', hide: false }, //hide for non-Admin Agency Manager, and redistribute width to other columns
							{display: 'Industry', name: 'industry', width: 140, sortable: true, align: 'left' },
							{ display: 'Recruiters', name: 'recruiters', width: 70, sortable: true, align: 'center' },
							{ display: 'Jobs', name: 'jobs', width: 70, sortable: true, align: 'center' },
							{ display: 'Candidates', name: 'candidates', width: 70, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    singleSelect: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 960,
					    height: 'auto',
					    preProcess: preProcessAdminAgencies
					}
				);

	    $('#admin_recruiters_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/admin-recruiters-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 150, sortable: true, align: 'left' },
							{ display: 'Agency', name: 'agency', width: 140, sortable: true, align: 'left', hide: false }, //hide for non-Admin Agency Manager, and redistribute width to other columns
							{display: 'Industry', name: 'industry', width: 140, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 130, sortable: true, align: 'left' },
							{ display: 'Experience', name: 'experience', width: 80, sortable: true, align: 'center' },
							{ display: 'Jobs', name: 'jobs', width: 70, sortable: true, align: 'center' },
							{ display: 'Candidates', name: 'candidates', width: 70, sortable: true, align: 'center' },
							{ display: 'Placements', name: 'placements', width: 70, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    singleSelect: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 960,
					    height: 'auto',
					    preProcess: preProcessAdminRecruiters
					}
				);

	    $('#dashboard_jobs_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/jobs-query-flexigrid.json',
					    dataType: 'json',
					    colModel: [
					    /* Show checkbox only for My jobs */
							{display: 'ID', name: 'id', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Title', name: 'title', width: 120, sortable: true, align: 'left' },
							{ display: 'Company', name: 'company', width: 95, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 100, sortable: true, align: 'left', hide: true },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Type', name: 'type', width: 60, sortable: true, align: 'center' },
							{ display: 'Salary (K)', name: 'salary', width: 50, sortable: true, align: 'right' },
					    /* Hide Recruiter and show Status column for when showing My jobs, otherwise show Recruiter and hide Status column */
							{display: 'Recruiter', name: 'recruiter', width: 70, sortable: true, align: 'center', hide: true },
							{ display: 'Date Posted', name: 'date_posted', width: 80, sortable: true, align: 'center' },
							{ display: 'Status', name: 'status', width: 70, sortable: true, align: 'center', hide: true }
						],
					    searchitems: [
							{ display: 'Title', name: 'title' },
							{ display: 'Company', name: 'company' },
							{ display: 'Recruiter', name: 'recruiter' },
						],
					    sortname: "title",
					    sortorder: "asc",
					    usepager: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    useRp: true,
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessJobs
					}
				);

	    $('#dashboard_candidates_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/candidates-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 115, sortable: true, align: 'left' },
							{ display: 'Title', name: 'title', width: 100, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left', hide: true },
							{ display: 'Phone', name: 'phone', width: 80, sortable: true, align: 'left' },
							{ display: 'E-mail', name: 'email', width: 130, sortable: true, align: 'left' },
							{ display: '', name: 'relocate', width: 20, sortable: true, align: 'center', hide: true },
							{ display: 'Date Modified', name: 'date_modified', width: 90, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Title', name: 'title' },
							{ display: 'E-mail', name: 'email' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessCandidates
					}
				);

	    $('#dashboard_pods_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/pods-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 120, sortable: true, align: 'left' },
							{ display: 'Created by', name: 'recruiter', width: 110, sortable: true, align: 'left', hide: false }, //Hide Created by when 'My Pods' is selected
							{display: 'Industry', name: 'industry', width: 120, sortable: true, align: 'left', hide: false },
							{ display: 'Location', name: 'location', width: 115, sortable: true, align: 'left' },
							{ display: 'Members', name: 'members', width: 50, sortable: true, align: 'center' },
							{ display: 'Jobs', name: 'jobs', width: 40, sortable: true, align: 'center', hide: true }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Created by', name: 'recruiter' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessPods
					}
				);

	    $('#dashboard_recruiters_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/recruiters-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 120, sortable: true, align: 'left' },
							{ display: 'Agency', name: 'agency', width: 110, sortable: true, align: 'left' },
							{ display: 'Industry', name: 'industry', width: 120, sortable: true, align: 'left' },
							{ display: 'City', name: 'city', width: 100, sortable: true, align: 'left' },
							{ display: 'Experience', name: 'experience', width: 65, sortable: true, align: 'center' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessRecruiters
					}
				);

	    $('#dashboard_requests_received_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/req-received-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Name', name: 'name', width: 180, sortable: true, align: 'left' },
							{ display: 'Connection', name: 'connection', width: 180, sortable: true, align: 'left' },
							{ display: 'Date requested', name: 'date', width: 80, sortable: true, align: 'left' },
							{ display: 'Actions', name: 'actions', width: 120, sortable: true, align: 'left' },
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessRequestsReceived
					}
				);

	    $('#dashboard_requests_sent_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/req-sent-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: 'ID', name: 'id', width: 20, sortable: true, align: 'left', hide: true },
							{ display: 'Type', name: 'type', width: 120, sortable: true, align: 'left' },
							{ display: 'Connection', name: 'connection', width: 320, sortable: true, align: 'left' },
							{ display: 'Date requested', name: 'date', width: 120, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'Name', name: 'name' },
							{ display: 'Agency', name: 'agency' }
						],
					    sortname: "name",
					    sortorder: "asc",
					    usepager: true,
					    useRp: true,
					    showToggleBtn: false, //show or hide column toggle popup
					    rp: 20,
					    width: 580,
					    height: 'auto',
					    singleSelect: true,
					    preProcess: preProcessRequestsSent
					}
				);

	    $('#messages_table')
				.flexigrid(
					{
					    /* 						striped: false,	 */
					    url: 'http://ths.stilllive.net/query/messages-query.json',
					    dataType: 'json',
					    colModel: [
							{ display: '', name: 'id', width: 20, sortable: true, align: 'left' },
							{ display: 'From', name: 'from', width: 130, sortable: true, align: 'center' }, //'From' will change to 'To' when Sent tab is selected.
							{display: 'Subject', name: 'subject', width: 430, sortable: true, align: 'left' },
							{ display: 'Date', name: 'city', width: 70, sortable: true, align: 'left' }
						],
					    searchitems: [
							{ display: 'From', name: 'from' },
							{ display: 'Subject', name: 'subject' }
						],
					    sortname: "date",
					    sortorder: "desc",
					    title: '',
					    nowrap: false,
					    showToggleBtn: false, //show or hide column toggle popup
					    sortorder: "asc",
					    /* 						singleSelect: true, */
					    usepager: true,
					    useRp: true,
					    rp: 20,
					    width: 700,
					    height: 'auto',
					    preProcess: preProcessMessages
					}
				)
				.find('tbody tr')
				.live('click', function () {
				    var $checkbox = $(this).find('input:checkbox');
				    if ($checkbox.attr('checked'))
				        $checkbox.removeAttr('checked');
				    else
				        $checkbox.attr('checked', 'checked');
				});
	}

}
);
