// ++=========================================================================++
// || DTO ShowCase v2.0.0 - 213
// || 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 19:12, Fri Jul 16th 2010
// || 623790213_604952770317
// ++ ========================================================================++

function DTO_ShowcaseType()                           {}

function DTO_ShowcaseType_new(id, name, commonName, isExample, postbitHandling)
{
    var obj = new DTO_ShowcaseType();
    DTO_ShowcaseType_init(obj, id, name, commonName, isExample, postbitHandling);
    return obj;
}

function DTO_ShowcaseType_init(obj, id, name, commonName, isExample, postbitHandling)
{
    obj.id = id;
    obj.name = name;
    obj.commonName = commonName; 
    obj.isExample = isExample;
    obj.postbitHandling = postbitHandling;
}

DTO_ShowcaseType_cache = {};
 
function DTO_ShowcaseType_buildLookup(array)  
{
    var count = array.length;
    for (var i=0; i<count; i++) 
    {
        var obj = array[i];   
        DTO_ShowcaseType_cache[obj.id] = obj;
    }
}

function DTO_ShowcaseType_cachedWithID(id)                {return DTO_ShowcaseType_cache[id];}

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

function DTO_ShowcaseTypePopupFormatter()                            {}

function DTO_ShowcaseTypePopupFormatter_new(array)
{
    var obj = new DTO_ShowcaseTypePopupFormatter();
    DTO_ShowcaseTypePopupFormatter_init(obj, array);
    return obj;
}

function DTO_ShowcaseTypePopupFormatter_init(obj, array)
{
    obj.array = array;
    
    obj.count = function()              {return this.array.length;}
    obj.getID = function(i)             {return this.array[i].id;}
    obj.getTitle = function(i)          {return this.array[i].name;}
}

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

function DTO_ShowcaseCompType()                           {}

function DTO_ShowcaseCompType_new(id, showcaseTypeID, classID, maxImages, displayOrder, name)
{
    var obj = new DTO_ShowcaseCompType();
    DTO_ShowcaseCompType_init(obj, id, showcaseTypeID, classID, maxImages, displayOrder, name);
    return obj;
}

function DTO_ShowcaseCompType_init(obj, id, showcaseTypeID, classID, maxImages, displayOrder, name)
{
    obj.id = id;
    obj.showcaseTypeID = showcaseTypeID;
    obj.classID = classID;
    obj.maxImages = maxImages;
    obj.displayOrder = displayOrder;
    obj.name = name;
}

DTO_ShowcaseCompType_cache = {};
DTO_ShowcaseCompType_cacheClass = {};
 
function DTO_ShowcaseCompType_buildLookup(array)  
{
    var count = array.length;
    for (var i=0; i<count; i++) 
    {
        var obj = array[i];   
        DTO_ShowcaseCompType_cache[obj.id] = obj;
        DTO_ShowcaseCompType_cacheClass[obj.classID] = obj;
    }
}

function DTO_ShowcaseCompType_cachedWithID(id)             {return DTO_ShowcaseCompType_cache[id];}
function DTO_ShowcaseCompType_cachedWithClassID(id)        {return DTO_ShowcaseCompType_cacheClass[id];}

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

function DTO_ShowcaseCompTypePopupFormatter()                            {}

function DTO_ShowcaseCompTypePopupFormatter_new(array)
{
    var obj = new DTO_ShowcaseCompTypePopupFormatter();
    DTO_ShowcaseCompTypePopupFormatter_init(obj, array);
    return obj;
}

function DTO_ShowcaseCompTypePopupFormatter_init(obj, array)
{
    obj.array = array;
    
    obj.count = function()              {return this.array.length;}
    obj.getID = function(i)             {return this.array[i].id;}
    obj.getTitle = function(i)          {return this.array[i].name;}
}

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

function DTO_Showcase()                           {}

function DTO_Showcase_new(id, showcaseTypeID, userID, showcaseName, createStamp, modifyStamp, 
                        allowComment, isVisible, isModerated, isSuspended, infraction, viewCount, username)
{
    var obj = new DTO_Showcase();
    DTO_Showcase_init(obj, id, showcaseTypeID, userID, showcaseName, createStamp, modifyStamp, 
                    allowComment, isVisible, isModerated, isSuspended, infraction, viewCount, username);
    return obj;
}

function DTO_Showcase_init(obj, id, showcaseTypeID, userID, showcaseName, createStamp, modifyStamp, 
                         allowComment, isVisible, isModerated, isSuspended, infraction, viewCount, username)
{
    obj.id = id;
    obj.showcaseTypeID = showcaseTypeID;
    obj.userID = userID;
    obj.showcaseName = showcaseName;
    obj.createStamp = createStamp;
    obj.modifyStamp = modifyStamp;
    obj.allowComment = allowComment;
    obj.isVisible = isVisible;
    obj.isModerated = isModerated;
    obj.isSuspended = isSuspended;
    obj.infraction = infraction;
    obj.viewCount = viewCount;
    obj.username = username;
    
    obj.showcaseType = null;    
    
    obj.calcShowcaseType = function()
    {
        if(!this.showcaseType)
            this.showcaseType = DTO_ShowcaseType_cachedWithID(this.showcaseTypeID);
    }
    
    obj.showcaseTypeName = function()
    {
        this.calcShowcaseType();
        return (obj.showcaseType ? obj.showcaseType.name : DTO_Phrase_cachedWithID('dto_showcase_js_no_showcase_type').phrase);
    }
}

DTO_Showcase_cache = {};
 
function DTO_Showcase_buildLookup(array)  
{
    var count = array.length;
    for (var i=0; i<count; i++) 
    {
        var obj = array[i];   
        DTO_Showcase_cache[obj.id] = obj;
    }
}

function DTO_Showcase_cachedWithID(id)             {return DTO_Showcase_cache[id];}

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

function DTO_ShowcaseNameFormatter()                            {}

function DTO_ShowcaseNameFormatter_new()
{
    var obj = new DTO_ShowcaseNameFormatter();
    DTO_ShowcaseNameFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseNameFormatter_init(obj)
{
    obj.getValue = function(obj)          {return obj.showcaseName; }

    obj.draw = function(frag, row)          
    {
        var value = row.id;
        var a = document.createElement("a");
        var txt = document.createTextNode(row.showcaseName);
        a.href = showcaseSearchApp.baseURL() + '/dto_showcase.php?do=preview&g=' + row.id;  
        a.target = "preview_" + row.id; 
        a.appendChild(txt);
        frag.appendChild(a);
    }
}

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

function DTO_ShowcaseTypeFormatter()                            {}

function DTO_ShowcaseTypeFormatter_new()
{
    var obj = new DTO_ShowcaseTypeFormatter();
    DTO_ShowcaseTypeFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseTypeFormatter_init(obj)
{
    obj.getValue = function(obj)          {return obj.showcaseTypeName(); }
}

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

function DTO_ShowcaseUsernameFormatter()                            {}

function DTO_ShowcaseUsernameFormatter_new()
{
    var obj = new DTO_ShowcaseUsernameFormatter();
    DTO_ShowcaseUsernameFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseUsernameFormatter_init(obj)
{
    obj.getValue = function(obj)          {return obj.username; }
}

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

function DTO_ShowcaseThumbFormatter()                            {}

function DTO_ShowcaseThumbFormatter_new()
{
    var obj = new DTO_ShowcaseThumbFormatter();
    DTO_ShowcaseThumbFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseThumbFormatter_init(obj)
{
    obj.draw = function(frag, row)          
    {
        if(row.thumbImage)
        {
            var a = document.createElement("a");
            var img = document.createElement("img");
            a.href = showcaseSearchApp.baseURL() + '/dto_showcase.php?do=preview&g=' + row.id; 
            a.target = "preview_" + row.id; 
            a.style.textDecoration = 'none';   
            img.border = 0;
            img.src = row.thumbImage.url;
            a.appendChild(img);
            frag.appendChild(a);
        }
    }
}

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

function DTO_ShowcaseThumbnailColumnFormatter()                            {}

function DTO_ShowcaseThumbnailColumnFormatter_new()
{
    var obj = new DTO_ShowcaseThumbnailColumnFormatter();
    DTO_ShowcaseThumbnailColumnFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseThumbnailColumnFormatter_init(obj)
{
    obj.draw = function(frag, row)          
    {
        if(row.thumbImageID > 0)
        {
            var value = row.id;
            var a = document.createElement("a");
            var img = document.createElement("img");
            img.border = 0;
            img.src = carFinderApp.baseURL() + '/images/dto_vendor/inventory/thumb_' + row.thumbImageID + '.jpg';
            a.onclick = View_createTagIDEvent(carFinderApp.carMgr, 'fullCar', row.id);
            a.appendChild(img);
            frag.appendChild(a);
        }
    }
}

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

function DTO_ShowcaseComp()                           {}

function DTO_ShowcaseComp_new(id, compTypeID, showcaseID, classID)
{
    var obj = new DTO_ShowcaseComp();
    DTO_ShowcaseComp_init(obj, id, compTypeID, showcaseID, classID);
    return obj;
}

function DTO_ShowcaseComp_init(obj, id, compTypeID, showcaseID, classID)
{
    obj.id = id;
    obj.compTypeID = compTypeID;
    obj.showcaseID = showcaseID;
    obj.classID = classID;
    
    obj.classObject = null;         //set by full details
    obj.attributes = {};          
    obj.images = [];          
    
    obj.addImage = function(image)           {this.images.push(image);}
    obj.addAttribute = function(attr)        {this.attributes[attr.attributeID] = attr;}
}

DTO_ShowcaseComp_cache = {};
 
function DTO_ShowcaseComp_buildLookup(array)  
{
    var count = array.length;
    for (var i=0; i<count; i++) 
    {
        var obj = array[i];   
        DTO_ShowcaseComp_cache[obj.id] = obj;
    }
}

function DTO_ShowcaseComp_cachedWithID(id)             {return DTO_ShowcaseComp_cache[id];}


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

function DTO_ShowcaseCellFormatter()                            {}

function DTO_ShowcaseCellFormatter_new()
{
    var obj = new DTO_ShowcaseCellFormatter();
    DTO_ShowcaseCellFormatter_init(obj);
    return obj;
}

function DTO_ShowcaseCellFormatter_init(obj)
{
    obj.draw = function(frag, row)          
    {
        var url;
        
        var value = row.id;
        var h3 = document.createElement("h3");
        h3.className = "dtoitemtitle";
        
        var a = document.createElement("a");
        var txt = document.createTextNode(row.showcaseName);
        a.href = showcaseSearchApp.baseURL() + '/dto_showcase.php?do=preview&g=' + row.id;  
        a.appendChild(txt);
        h3.appendChild(a);
        
        var p = document.createElement("p");
        p.className = "shade";
        p.appendChild(document.createTextNode(row.username));
        
        var thumb = document.createElement("div");
        thumb.className = "dtothumbcontainer";
        
        if(row.thumbImage)
          url = row.thumbImage.url;
        else
          url = showcaseSearchApp.baseURL() + '/images/dto_showcase/images/no_image.jpg';
          
        var a_img = document.createElement("a");
        var img = document.createElement("img");
        a_img.href = showcaseSearchApp.baseURL() + '/dto_showcase.php?do=preview&g=' + row.id; 
        img.border = 0;
        img.src = url;
        a_img.appendChild(img);
        thumb.appendChild(a_img);
        
        frag.appendChild(thumb);
        frag.appendChild(h3);
        frag.appendChild(p);
        
    }
}




