// Code copyright 2010 changeMode design 


if(!this.TrophyApp){TrophyApp={dataFileName:'trophyData.json',init:function()
{jQuery('#tmpView').remove();this.view=new TrophyApp.TrophyView();this.model=new TrophyApp.TrophyModel(this.dataFileName);if(this.model)
{this.view.renderTrophyList(this.model.bronzeTrophies(),'bronze');this.view.renderTrophyList(this.model.silverTrophies(),'silver');this.view.renderTrophyList(this.model.goldTrophies(),'gold');this.view.renderTrophyList(this.model.platinumTrophies(),'platinum');}else
{console.log("no model");}}}}
(function()
{TrophyApp.TrophyModel=function(fileName)
{var _data=eval(jQuery.ajax({type:"GET",url:"/data/"+fileName,dataType:"json",async:false}).responseText);_data=_data[0];return{bronzeTrophies:function()
{return _data.bronze;},silverTrophies:function()
{return _data.silver;},goldTrophies:function()
{return _data.gold;},platinumTrophies:function()
{return _data.platinum;},allTrophies:function()
{return _data;}}}
TrophyApp.TrophyView=function()
{var _view=jQuery('<div id="wrapper_trophyView"></div>');var _navView=new TrophyApp.TrophyNavView();jQuery('#wrapper_site').append(_view);return{renderTrophyList:function(data,name)
{_view.append('<div class="wrapper_leftBlock"><a name="'+name+'"><img  class="trophyHeader" src="/img/trophyApp/'+name+'Label.jpg" alt="'+name+' Trophies" /></a></div>');_navView.addNavBlock(name,name);_navView.updateNavs();var theList=jQuery('<ul class="trophyList" id="'+name+'_trophyList"></ul>');for(var i=0;i<data.length;i++)
{theList.append('<li><p class="trophyNameLabel">'+data[i].name+'</p><p class="trophyDescLabel">'+data[i].desc+'</p>');}
_view.append(theList);}}}
TrophyApp.TrophyNavView=function()
{_view=jQuery('<ul class="trophyNav"></ul>');return{trophyNavView:function()
{return _view;},updateNavs:function(){jQuery('.trophyNav').remove();jQuery('.trophyHeader').after(_view);},addNavBlock:function(label,linkName)
{_view.append('<li class="'+label+'_nav"><a href="#'+label+'">'+label+'</a></li>');}}}})();jQuery(document).ready(function()
{TrophyApp.init();});

