// ++=========================================================================++
// || DTO Vendor Tools for vB4 v2.0.0 - 132
// || Copyright © 2008-2010 Drive Thru Online, Inc. All Rights Reserved.
// || This file may not be redistributed in whole or significant part, or
// || used on web site without licensing of the enclosed code,
// || and software features.
// || http://www.drivethruonline.com | info@drivethruonline.com
// || Downloaded 18:37, Thu Dec 23rd 2010
// || 326180132_803122460333
// ++ ========================================================================++

theApp = DTO_CarVendorApp_new();
theApp.gatherConfig();

function showInfo(vendorID)             {theApp.showInfo(vendorID);}
function hideInfo(vendorID)             {theApp.hideInfo(vendorID);}

/*--------------------------------------------------------------*/

function DTO_CarVendorApp()                         {}

function DTO_CarVendorApp_new()
{
    var obj = new DTO_CarVendorApp();
    DTO_CarVendorApp_init(obj);
    return obj;
}

function DTO_CarVendorApp_init(obj)
{
    obj.config = null;
    obj.ajaxCall = DTO_AjaxCall_new(obj, 'getInfo');
    obj.vendorID = 0;
    obj.infoDict = {};
    
    obj.gatherConfig = function()
    {
        this.config = carVendorConfig.config;
    }
    
    obj.showInfo = function(vendorID)
    {
        var info = this.infoDict[vendorID];
        if(info)
            this.drawInfo(vendorID, info);
        else
        {
            var url = this.config.baseURL + '/dto_vendor.php?do=moreInfo&vendorID=' + vendorID; 
            this.vendorID = vendorID;
            this.ajaxCall.call(url);
        }
    }
    
    obj.hideInfo = function(vendorID)
    {
        var info = document.getElementById(vendorID+'_info');
        
        clearChildNodes(info);
    
        var button = document.getElementById(vendorID+'_button');
        
        clearChildNodes(button);
        button.innerHTML = '<a onclick="showInfo(' + vendorID + '); return false;"><img border="0" src="' + this.config.baseURL + '/images/dto_vendor/expand.gif"></a>';
    }
    
    obj.ajaxCallback = function(tag, resp)
    {
        if(tag == 'getInfo')
        {
            this.infoDict[this.vendorID] = resp;
            this.drawInfo(this.vendorID, resp);
            this.vendorID = 0;
        }
    }
    
    obj.drawInfo = function(vendorID, infoHTML)
    {
        var info = document.getElementById(vendorID+'_info');
        
        clearChildNodes(info);
        info.innerHTML = infoHTML;
    
        var button = document.getElementById(vendorID+'_button');
        
        clearChildNodes(button);
        button.innerHTML = '<a onclick="hideInfo(' + vendorID + '); return false;"><img border="0" src="' + this.config.baseURL + '/images/dto_vendor/hide.gif"></a>';
    }
}


