﻿///<reference path="jquery-1.3.1-vsdoc.js" />    
var tab1Loaded = true;
var tab2Loaded = false;
var tab3Loaded = false;
var tab4Loaded = false;
var tab5Loaded = false;



$(function () {
    $('#div1').show().load("/ApplicationLinksPanel.htm", null, null);

    $('#tab1').click(function () {
        showLoadingTab($(this));
        $('#div1').show();
        $('#complaintTicketNoTextBox').css('width', 'auto');
        $('#idMainTextBox').css('width', 'auto');
    });

    $('#tab2').click(function () {
        var tab = $(this);
        showLoadingTab(tab);
        $('#div2').show();
        if (!tab2Loaded) {
            $('#div2').load("/InvoiceSearchPanel.aspx", null, function () {
                //console.log("getting the #2 content");
                $.getScript("js/Invoice.js?$Rev: 3515 $", function () {
                    //console.log("getting the #2 script");
                    tab2Loaded = true;
                });
            });
        }
    });

    $('#tab3').click(function () {
        var tab = $(this);
        showLoadingTab(tab);
        $('#div3').show();
        if (!tab3Loaded) {
            $('#div3').load("/ComplaintFormPanel.aspx", null, function () {
                //console.log("getting the #3 content");
                $.getScript("js/ComplaintFormPanel.js?$Rev: 3515 $", function () {
                   // console.log("getting the #3 script");
                    tab3Loaded = true;
                });

            });

        }

    });

    $('#tab4').click(function () {

        var tab = $(this);

        showLoadingTab(tab);
        $('#div4').show();
        if (!tab4Loaded) {
            $('#div4').load("/ComplaintListPanel.aspx", null, function () {
                //console.log("getting the #4 content");
                $.getScript("js/ComplaintListPanel.js?$Rev: 3515 $", function () {
                    //console.log("getting the #4 script");
                });
            });
            tab4Loaded = true;
        }
    });


    $('#privacy_statement_link').click(function () {
        $('#div5').load("/privacy_statement.htm", null, null);
        showLoadingTab(null);
        $('#div5').show();
    });

    $('#copy_statement_link').click(function () {
        $('#div5').load("/copy_statement.htm", null, null);
        showLoadingTab(null);
        $('#div5').show();
    });

    $('#security_statement_link').click(function () {
        $('#div5').load("/security_statement.htm", null, null);
        showLoadingTab(null);
        $('#div5').show();
    });


});


function triggerCheckComplaint(ticket_no) {
    showLoadingTab($(this));
    if (!tab4Loaded) {
        $('#div4').load("/ComplaintListPanel.aspx", null, function () {
            $.getScript("js/ComplaintListPanel.js?$Rev: 3515 $", function () { searchComplaint(ticket_no); });
        });
        tab4Loaded = true;
    } else {

        // $('#ticketNoTextBox').val(ticket_no);
        // searchComplaint(ticket_no);
    }
    $('#div4').show();
}

function triggerCheckPayment(id) {
    showLoadingTab($(this));
    if (!tab2Loaded) {
        $('#div2').load("/InvoiceSearchPanel.aspx", null,
                function () {
                    $('#idTextBox').val(id);
                });
        $.getScript("js/Invoice.js?$Rev: 3515 $", function () { searchInvoice(id); });
        tab2Loaded = true;
    }
    else {
        $('#idTextBox').val(id);
        searchInvoice(id);
    }
    $('#div2').show();
}


function showLoadingTab(tab) {

    if (null != tab) {
        $('.tab_active').removeClass('tab_active').addClass('tab_default');
        tab.removeClass('tab_default').addClass('tab_active');
    }

    $('#div1').hide();
    $('#div2').hide();
    $('#div3').hide();
    $('#div4').hide();
    $('#div5').hide();
    //tab.show();
}
