function AssessorsUI(parcelStr, rootDirStr)
{
    this.parcelStr          = parcelStr;
    this.rootDirStr         = rootDirStr;
    this.photoPageStr       = this.rootDirStr + '/popup.php?parcel=' + this.parcelStr;
    this.diagramPageStr     = this.rootDirStr + '/popup.php?parcel=' + this.parcelStr + '&is_diagram=true';
    this.photoFeatsStr      = 'width=662,height=570,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no';
    this.digramFeatsStr     = 'width=1030,height=470,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no';
    this.pageCtrlsStr       = '<strong><a href="#collapseAll" id="collapseAll"><img src="' + this.rootDirStr + '/imgs/minus.gif" alt=""/> Collapse All</a></strong>';
    this.pageCtrlsStr       += '&nbsp;<strong><a href="#expandAll" id="expandAll"><img src="' + this.rootDirStr + '/imgs/plus.gif" alt=""/> Expand All</a></strong>';
    this.pageCtrlsID        = '#collapseCtrls';
    this.collapseIDStr      = '#collapseAll';
    this.expandIDStr        = '#expandAll';
    this.cardSelectFrmID    = '#cardSelectFrm';
    this.cellCtrlsStr       = '<span style="position:absolute;right:32px;"><a href="#collapse" title="Collapse" class="collapse"><img src="' + this.rootDirStr + '/imgs/minus.gif" alt=""/></a>';
    this.cellCtrlsStr       += '&nbsp;<a href="#expand" title="Expand" class="expand"><img src="' + this.rootDirStr + '/imgs/plus.gif" alt=""/></a></span>';
}

AssessorsUI.prototype.init = function()
{
    this.createPageCtrls();
    this.createSelectMenu();
    this.createImgPopups();
    this.createCellCtrls();
}

AssessorsUI.prototype.createPageCtrls = function()
{
    $(this.pageCtrlsID).html(this.pageCtrlsStr);
    $(this.collapseIDStr).click(function()
    {
        $('.cellHdr>div').each(function()
        {
            $(this).parent().parent().next().find('td>div').hide();
        });
        return false;
    });
    $(this.expandIDStr).click(function()
    {
        $('.cellHdr>div').each(function()
        {
            $(this).parent().parent().next().find('td>div').show();
        });
        return false;
    });
}

AssessorsUI.prototype.createSelectMenu = function()
{
    var rootDirStr = this.rootDirStr;
    var parcelStr = this.parcelStr;
    var getCardFunc = this.getCard;

    $(this.cardSelectFrmID).find('select').change(function()
    {
        getCardFunc(rootDirStr, parcelStr, $(this).val());
    });
    $(this.cardSelectFrmID).find('input:submit').click(function(){
        
        getCardFunc(rootDirStr, parcelStr, $(this.cardSelectFrmID).find('select').val());
        return false;
    });
}

AssessorsUI.prototype.getCard = function(rootDirStr, parcelStr, cardNumStr)
{
    $.ajax(
    {
        url:        rootDirStr + '/ajax.php',
        type:       'post',
        data:       'parcel=' + parcelStr + '&card_num=' + cardNumStr,
        success:    function(data)
        { 
            $('#ajaxArea').html(data.replace(/\\"/g, '"')); 
        }
    });
}

AssessorsUI.prototype.createImgPopups = function()
{
    var photoPageStr        = this.photoPageStr;
    var diagramPageStr      = this.diagramPageStr;
    var photoFeatsStr       = this.photoFeatsStr;
    var digramFeatsStr      = this.digramFeatsStr;
    
    $('#assrPhoto').click(function()
    {
        window.open(photoPageStr,'imgPopupWin',photoFeatsStr);
        return false;
    });
    $('.photoInfo').click(function()
    {
        window.open(photoPageStr,'imgPopupWin',photoFeatsStr);
        return false;
    });
    $('#assrDiagram').click(function()
    {
        window.open(diagramPageStr,'imgPopupWin',digramFeatsStr);
        return false;
    });
    $('.diagramInfo').click(function()
    {
        window.open(diagramPageStr,'imgPopupWin',digramFeatsStr);
        return false;
    });
}

AssessorsUI.prototype.createCellCtrls = function()
{
    var cellCtrlsStr = this.cellCtrlsStr;
    $('.cellHdr>div').each(function()
    {
        $(this).append(cellCtrlsStr);
    });
    $('a.collapse').click(function()
    {
        $(this).parent().parent().parent().parent().next().find('td>div').hide();
        var colEleID = $(this).parent().parent().parent().parent().parent().parent().parent().prev();
        $(colEleID).find('table>tbody>tr').next().find('td>div').hide();
        return false;
    });
    $('a.expand').click(function()
    {
        $(this).parent().parent().parent().parent().next().find('td>div').show();
        var colEleID = $(this).parent().parent().parent().parent().parent().parent().parent().prev();
        $(colEleID).find('table>tbody>tr').next().find('td>div').show();
        return false;
    });
}

