﻿// Class: FaceMakeup
// Constructor: var fm = new FaceMakeup( facePart {"F, C, E, L"}, sku {product sku}, webRoot {the root of the web application}
// Usage:  Create an istance like in the example above and access the following properties:
// fm.AsianMakeup, fm.AfricanMakeup, fm.BlondeMakeup, and fm.BrunetteMakeup to
// access the image urls for those models for the specified face part.


function FaceMakup( facePart, sku, webRoot )
    {
        this.getMakeupUrl = function( model )
        {
            return this.webRoot + "images/makeup/" + this.getFilenameFromSku( model );
        }
        
        this.getFilenameFromSku = function( model )
        {
            var lead = this.sku.substring(0, this.sku.indexOf("-") + 1);
            var shade = this.sku.substring(lead.length);
            if( shade.length <= 6 ) return model + "_" + this.facePart + "_" + lead + shade + ".jpg";
            
            var temp = shade.substring(0, 4);
            temp += shade.substring(shade.length - 2);
            
            return model + "_" + this.facePart + "_" + lead + temp + ".jpg";
        }
        
        this.webRoot = webRoot;
        this.facePart = facePart;
        this.sku = sku;
        this.asianMakeup = this.getMakeupUrl( "as" );
        this.africanMakeup = this.getMakeupUrl( "bk" );
        this.blondeMakeup = this.getMakeupUrl( "bd" );
        this.brunetteMakeup = this.getMakeupUrl( "bt" );
    }
