﻿var JSDB = {
    news : {
        db: [
          {
              title : 'Hellmann&rsquo;s'
            , copy : 'Hammerhead worked with Hellmann&rsquo;s Mayonnaise on its second commercial shoot with Dale Earnhardt Jr. The commercial emphasizes the importance of southern hospitality and how good southern food is accentuated with Hellmann&rsquo;s. It also features several prominent members of the Earnhardt family, including Dale Jr.&rsquo;s grandmother, two of his aunts, an uncle and a cousin. This shoot truly was a family affair.'
          }
        , {
              title : 'Miss Sprint Cup'
            , copy : 'In January of 2011, Hammerhead produced a photo and video shoot to announce the selection of NASCAR&rsquo;s Miss Sprint Cup, Kim Coon. Coon represents NASCAR in a variety of ways, including public speaking engagements, hospitality visits, and she can be scene posing with winning NASCAR drivers in victory lane. This marked another successful endeavor for Hammerhead in the sport of NASCAR'
          }
        , {
              title : 'AFLAC'
            , copy : 'Hammerhead collaborated with Roush Fenway Racing, Action Sports Photography, driver Carl Edwards and sponsors Aflac and Scotts in the winter of 2010. The trio utilized Hammerhead&rsquo;s state-of-the-art studios, conveniently located in Mooresville, N.C. to produce a video and photo shoot that was a major part of the sponsor&rsquo;s marketing activation for the 2011 racing program. Hammerhead provided the necessary space for a full production day that included a photo shoot with the Scotts racecar, video reads and web content.'
          }
        , {
              title : 'National Guard Webisodes'
            , date  : undefined
            , copy  : 'Hammerhead has completed over 80 webisodes for the National Guard.'
          }
        , {
              title : 'Hammerhead and Wow! Foods'
            , date  : undefined
            , copy  : 'Wow Foods launched their Dale Jr. brand and solicited Hammerhead to produce a marketing video.  The video was part of the Wow Foods display at the National Food Convention in Chicago.'
          }
        , {
              title : 'The Penske Race Team'
            , date  : undefined
            , copy  : 'The audio department spent some time with the Penske race team recording radio reads with Brad Keslowski, Nascar Champion Kurt Busch, and Sam Hornish Jr.'
          }
        , {
              title : 'Pittsburgh Steeler Hines Ward'
            , date  : undefined
            , copy  : 'Finally, our production team had the pleasure of meeting and interviewing the Super Bowl MVP and 4 time pro bowl player, Pittsburgh Steeler Hines Ward, in Atlanta while attending his charity event…more details to come.'
          }
        ],
        init: function (o) {
            this.render.preview(o, this.db);
            //if (o.selector == "div#featured_projects") {
            //    this.render.list(o, this.db);
            //} else {
            //    this.render.feature(o, this.db);
            //}
        },
        render: {
            preview : function (obj, news) {
                var html = ''
                  , i=0
                  , len = news.length;
                for (i;i<3;i++) {
                    html += '<div class="article">';
                    if ( news[i].date !== undefined ) {
                        html += '<span class="date">' + news[i].date + '</span>';
                    }
                    html += '<p><em class="mock_h6">' + news[i].title + '</em> ' +
                            news[i].copy + '</p></div>';
                }
                obj.find('div.loading').html(html);
            }
        }
    },
    work: {
        db: [
        {
              title : 'Tissot Watches'
            , link  : 'tissot-watches/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                preview   : 'pre_tissot.png'
              , featured  : 'fea_tissot.png'
            }
            , copy: {
                featured: 'Tissot Watches has signed on behind Danica Patrick for JR Motorsports. Photos taken at Hammerhead.'
              , teaser : 'Tissot Watches and Danica Patrick'
            }
          }
        , {
              title : 'Back in the Day'
            , link  : 'back-in-the-day/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                preview   : 'pre_bitd.png'
              , featured  : 'fea_bitd.png'
            }
            , copy: {
                featured: 'As the brainchild of Hammerhead, <i>Back in the Day</i> launched the company\'s production efforts in 2006 to a national audience on the Speed Channel by providing a trip into ' +
                          'racing history with its most popular driver, Dale Earnhardt Jr., as the tour guide.'
              , teaser : 'Take a trip into racing history'
            }
          }
        , {
              title : 'Behind the Lines'
            , link  : 'behind-the-lines/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                preview: 'pre_ng.png'
              , featured: 'fea_ng.png'
            }
            , copy: {
                featured: 'Hammerhead works continuously with the National Guard to produce webisodes, television commercials, and audio recordings for use on various platforms.'
              , teaser : 'Hammerhead partners with the National Guard'
            }
        }
        , {
              title : 'Nationwide Insurance'
            , link  : 'nationwide-insurance/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                preview: 'pre_nw.png'
              , featured: 'fea_nw.png'
            }
            , copy: {
                copy  : [ 'For several years, Hammerhead has utilized its post-house production capabilities to craft Nationwide Insurance commercials that are delivered to a wide-ranging audience. The conglomeration ' + 
                          'between the two parties has resulted in significant brand recognition for Nationwide as a leading company in the Insurance industry.'
                        , 'Prior to working with Hammerhead, Nationwide was not considered as a heavy advertiser. In the two years of working together, the Hammerhead team has developed television ad campaigns that have ' +
                          'propelled Nationwide to a market leader.'
                        ]
              , featured: 'When Nationwide Insurance was looking to launch a national advertising campaign, they chose Hammerhead to help deliver their message.'
              , teaser : 'See how Hammerhead lets you know that Nationwide is on your side'
            }
        }
        , {
              title : 'Shifting Gears'
            , link : 'shifting-gears/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                preview : 'pre_sg.png'
              , featured: 'fea_sg.png'
            }
          , copy: {
              copy:   [ 'When Dale Earnhardt Jr. announced his decision to move from the race team his father owned to the NASCAR powerhouse at Hendrick Motorsports, the <i>Shifting Gears</i> television series ' +
                        'became a reality. Hammerhead was given exclusive access behind the scenes in a process that was then produced and witnessed by onlookers all over the world on television icon ESPN.'
                      , 'Hammerhead crews were the pulley in the process that included hundreds of hours of footage and were then produced round-the-clock to deliver a one-of-a-kind product to viewers. The series ' +
                        'aired five one-hour episodes during 2008 and was turned into a DVD later that year.'
                      ]
            , featured: 'During one of the biggest team-transitions in sports history, Hammerhead had the exclusive rights to capture it all on tape in what became <i>Shifting Gears</i>.'
            , teaser : 'Hammerhead took viewers where no one else could behind the scenes with Dale Earnhardt Jr.'
          }
        }
        /*, {
              title : 'Voodoo Ride'
            , link  : 'voodoo-ride/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                  preview : 'pre_vr.png',
                  featured: 'fea_vr.png'
              }
            , copy: {
                copy  : [ 'I am the first paragraph for Voodoo Ride',
                          'I am the second paragraph for Voodoo Ride'
                        ]
              , featured: 'Yo, I got that hit that beat the block you can get that bass overload. I got that rock and roll, that future flow. That digital spit, ' +
                          'next level visual shit, I got that boom boom pow, how the beat bang? boom boom pow.'
              , teaser : 'I am a one-liner'
            }
          }*/
        , {
              title : 'Wow! Foods'
            , link  : 'wow-foods/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                  preview : 'pre_wf.png',
                  featured: 'fea_wf.png'
              }
            , copy: {
                copy  : [ 'I am the first paragraph for Wow! Foods',
                          'I am the second paragraph for Wow! Foods'
                        ]
              , featured: 'WOW! Foods, a national food manufacturer company, commissioned Hammerhead to produce its sales video for its display at the National Food convention in Chicago.'
              , teaser : 'WOW! Foods, had the WOW factor!'
            }
          }
        , {
              title : 'Tom Johnson Camping Center'
            , link  : 'tom-johnson-camping-center/'
            , tags  : [
                ''
              , ''
              , ''
            ]
            , images: {
                  preview : 'pre_tjcc.png',
                  featured: 'fea_tjcc.png'
              }
            , copy: {
                copy  : [ 'I am the first paragraph for Tom Johnson Camping Center',
                          'I am the second paragraph for Tom Johnson Camping Center'
                        ]
              , featured: 'Hammerhead produced the summer television campaign for Tom Johnson Camping Center. TJCC voted the number one camping/RV center in the south east has one location in Marion and ' +
                          'another in Charlotte, North Carolina.'
              , teaser : 'Hammerhead produced the summer television campaign for Tom Johnson Camping Center.'
            }
          }
        ],
        init: function (o) {
            if (o.selector == "div#featured_projects") {
                //this.render.list(o, this.db);
            } else {
                this.render.feature(o, this.db);
            }
        },
        render: {
            feature : function (obj, work) {
                    var html        // html string to insert into DOM
                      , i = 0;      // replace random integer with 0 to select Tissot everytime
                      //Math.floor(Math.random() * work.length);          // quote index
                    html =
                        '<div class="grid_2 alpha">' +
                          '<img src="http://www.hammerheadent.com/static/images/project/' + work[i].images.featured + '" alt="' + work[i].title + '" />' +
                          '<a href="work/' + work[i].link + '"><img src="http://www.hammerheadent.com/static/images/btn_view_project.gif" /></a>' +
                          '<a href="work/"><img src="http://www.hammerheadent.com/static/images/btn_all_projects.gif" /></a></div>' +
                        '<div class="grid_5 omega">' +
                          '<h3>' + work[i].title + '</h3>' +
                          '<p>' + work[i].copy.featured + '</p></div>';
                    obj.find('div.loading').replaceWith(html);
            },
            list : function (obj, work) {
                var html = ''
                  , i=0
                  , len = work.length;
                for (i;i<len;i++) {
                    html +=
                        '<div class="article clearfix">' +
                            '<div class="grid_4 alpha">' +
                                '<img src="http://www.hammerheadent.com/static/images/project/' + work[i].images.preview + '" alt="' + work[i].title + '" />' +
                                '<a href="' + work[i].link + '"><img src="../static/images/btn_view_project.gif" alt="View Project" /></a>' +
                            '</div>' +
                            '<div class="grid_12 omega">' +
                                '<h3>' + work[i].title + '</h3>' +
                                '<p class="grid_6 alpha">' + work[i].copy.copy[0] + '</p>' +
                                '<p class="grid_6 omega">' + work[i].copy.copy[1] + '</p>' +
                            '</div>' +
                        '</div>'
                }
                obj.find('div.loading').append(html);
            },
            view : function (obj, work) {
                var html;
                html = '<h3>' + work.title + '</h3>' +
                       '<p class="tags">';
                //for ( item in work.tags ) {
                //    html +=  '<a href="">' + work.tags[item] + '</a>'
                //}
                html += '</p>' +
                        '<p>' + work.copy.copy[0] + '</p>' +
                        '<p>' + work.copy.copy[1] + '</p>';
                //obj.html(html);

            },
            related : function (obj, db) {
                var html = ""   // html string to insert into DOM
                  , i           // quote index
                  , j           // test to make sure there are no duplicates
                  , k;          // for loop counter
                for (k = 0; k < 3; k++) {
                    if ((i = Math.floor(Math.random() * db.length)) !== j) {
                        j = i;
                        if ( k == 0 ) { html += '<div class="grid_7 alpha part">' }
                        else if ( k == 1 ) { html += '<div class="grid_7 part">' }
                        else if ( k == 2 ) { html += '<div class="grid_7 part omega">' }
                        
                        html +=
                            '<img src="http://www.hammerheadent.com/static/images/project/' + db[j].images.preview + '" />' +
                            '<div class="article">' +
                                '<a href="../' + db[j].link + '">' +
                                    '<h4>' + db[j].title + '</h4>' +
                                    '<span class="tag">' + db[j].tags[k] + '</span>' +
                                    '<span class="teaser"> ' + db[j].copy.teaser + '</span>' +
                                '</a>' +
                            '</div>' +
                        '</div>';
                    } else {
                        k--;
                    }
                } 
                obj.find('div.loading').html(html);
            }
        }
    },
    quotes: {
        db: [
          {
              quote: "In ground-breaking style, Junior's Hammerhead Entertainment production company has pushed the envelope of what should be expected from NASCAR TV programs to a new height. The first three episodes of Shifting Gears have been nothing short of spectacular.",
              client: {
                  name: '',
                  company: 'The Daly Planet'
              },
              project: {
                  link: '',
                  name: ''
              }
          },
          {
              quote: "Their marching orders from the boss were simple and direct. Show the truth, honestly, how it happened. (And while you're at it, make it look cool because the future of my new company is probably riding on it.)",
              client: {
                  name: '',
                  company: 'ESPN Sports'
              },
              project: {
                  link: '',
                  name: ''
              }
          }
        ],
        init: function (o) {
            this.render(o);
        },
        render: function (obj) {
            var html = ""   // html string to insert into DOM
              , i           // quote index
              , j           // test to make sure there are no duplicates
              , k;          // for loop counter
            for (k = 0; k < 2; k++) {
                if ((i = Math.floor(Math.random() * this.db.length)) !== j) {
                    j = i;
                    html += "<div class=\"quote\">"
                    html +=
                    "<q class=\"mark\"></q>" +
                    "<q class=\"quote\">" + this.db[i].quote + "</q>" +
                    "<cite>" + this.db[i].client.name +
                    "<em>" + this.db[i].client.company + "</em>" +
                    "</cite></div>";
                } else {
                    k--;
                }
            }
            obj.find("div.loading").replaceWith(html);
        }
    }
}

if ($("div#quotes")) { JSDB.quotes.init($("div#quotes")); }
if ($("div#recent_news")) { JSDB.news.init($("div#recent_news")); }
if ($("div#featured_projects")) { JSDB.work.init($("div#featured_projects")); }
if ($("div#featured_project")) { JSDB.work.init($("div#featured_project")); }

if ( document.getElementById("related_projects") ) { JSDB.work.render.related( $("div#related_projects"), JSDB.work.db ); }
