/**
 * jQuery Templates
 *
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Written by: Stan Lemon <stanlemon@mac.com>
 */
(function($){$.template=function(html,options){return new $.template.instance(html,options);};$.template.instance=function(html,options){if(options&&options.regx){options.regx=this.regx[options.regx];}this.options=$.extend({compile:false,regx:this.regx.standard},options||{});this.html=html;if(this.options.compile){this.compile();}this.isTemplate=true;};$.template.regx=$.template.instance.prototype.regx={jsp:/\$\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,ext:/\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,jtemplates:/\{\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}\}/g};$.template.regx.standard=$.template.regx.jsp;$.template.helpers=$.template.instance.prototype.helpers={substr:function(value,start,length){return String(value).substr(start,length);}};$.extend($.template.instance.prototype,{apply:function(values){if(this.options.compile){return this.compiled(values);}else{var tpl=this;var fm=this.helpers;var fn=function(m,name,format,args){if(format){if(format.substr(0,5)=="this."){return tpl.call(format.substr(5),values[name],values);}else{if(args){var re=/^\s*['"](.*)["']\s*$/;args=args.split(",");for(var i=0,len=args.length;i<len;i++){args[i]=args[i].replace(re,"$1");}args=[values[name]].concat(args);}else{args=[values[name]];}return fm[format].apply(fm,args);}}else{return values[name]!==undefined?values[name]:"";}};return this.html.replace(this.options.regx,fn);}},compile:function(){var sep=$.browser.mozilla?"+":",";var fm=this.helpers;var fn=function(m,name,format,args){if(format){args=args?","+args:"";if(format.substr(0,5)!="this."){format="fm."+format+"(";}else{format='this.call("'+format.substr(5)+'", ';args=", values";}}else{args="";format="(values['"+name+"'] == undefined ? '' : ";}return"'"+sep+format+"values['"+name+"']"+args+")"+sep+"'";};var body;if($.browser.mozilla){body="this.compiled = function(values){ return '"+this.html.replace(/\\/g,"\\\\").replace(/(\r\n|\n)/g,"\\n").replace(/'/g,"\\'").replace(this.options.regx,fn)+"';};";}else{body=["this.compiled = function(values){ return ['"];body.push(this.html.replace(/\\/g,"\\\\").replace(/(\r\n|\n)/g,"\\n").replace(/'/g,"\\'").replace(this.options.regx,fn));body.push("'].join('');};");body=body.join("");}eval(body);return this;}});var $_old={domManip:$.fn.domManip,text:$.fn.text,html:$.fn.html};$.fn.domManip=function(args,table,reverse,callback){if(args[0].isTemplate){args[0]=args[0].apply(args[1]);delete args[1];}var r=$_old.domManip.apply(this,arguments);return r;};$.fn.html=function(value,o){if(value&&value.isTemplate){var value=value.apply(o);}var r=$_old.html.apply(this,[value]);return r;};$.fn.text=function(value,o){if(value&&value.isTemplate){var value=value.apply(o);}var r=$_old.text.apply(this,[value]);return r;};})(jQuery);
/** DigitalStories Modal  */
var DigitalStories=function(Y){var Q="digitalstories";var S=function(){};var X=function(){};var K={};var M={enumeratorText:"of",all:"Asset",image:"Image",videolist:"Videolist",text:"Text"};var n=!(Y(new Image()).get(0)==null);var H={};var f="all";var W=false;var c=false;var O=1;var I="all";var G=[];var A={};var l=false;var E={};var P=700;var b=380;var i=2;E.isOpera=(window.opera||null);E.isIE=false;E.isIE6=false;E.isIE7=false;E.isIE8=false;if(window.ActiveXObject){var U=-1;var e=navigator.userAgent;var d=new RegExp("Trident/([0-9]{1,}[.0-9]{0,})");if(d.exec(e)!=null){U=parseFloat(RegExp.$1);}E.isIE8=(U==4);E.isIE7=((window.XMLHttpRequest&&!E.isIE8)?true:false);E.isIE6=!(E.isIE7||E.isIE8);E.isIE=true;}var g=location.href.split("/");while(g.length>3){g.pop();}E.location=g.join("/");A.image=Y.template('<div id="ds-panel-${id}" class="ds-panel ds-panel-image" style="display: none; margin-top: ${marginTop}px"><img src="${url}" width="${width}" height="${height}" /></div>');A.text=Y.template('<div id="ds-panel-${id}" class="ds-panel ds-panel-text"  style="display: none;">${content}</div>');A.videolist=Y.template('<div id="ds-panel-${id}" class="ds-panel ds-panel-video" style="display: none;margin-top: ${marginTop}px"><object " type="application/x-shockwave-flash" data="${location}/${assetsPath}/videoplayer.swf?xml=${source}" width="${width}" height="${height}"><param name="allowfullscreen" value="true" /><param name="autoplay" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="${location}/${assetsPath}/videoplayer.swf?xml=${source}" /><param name="flashvars" value="xml=${source}" /></object></div>');function a(v,t){v=k(v);G=[];for(var s=0,w=1,q=v.length,u=null,r="";s<q;s++,w++){u=v[s];switch(u.type){case"image":Y("#ds-content").append(A.image,{id:w,url:u.url,width:u.width,height:u.height,marginTop:(u.height>=470?0:Math.round((470-u.height)/2))});p(w,u);break;case"text":Y("#ds-content").append(A.text,{id:w,content:u.content});break;case"videolist":Y("#ds-content").append(A.videolist,{id:w,source:u.url,location:E.location,assetsPath:B(),width:P,height:b,marginTop:i});break;}G.push(u);}F(v);h(D(t));}function p(s,r){if(n&&typeof (H[r.url])=="undefined"){Y("#ds-content #ds-panel-"+s+".ds-panel-image").addClass("loader");var q=new Image();q.onload=function(){H[q.src]=true;Y("#ds-content #ds-panel-"+s+".ds-panel-image").removeClass("loader");};q.src=r.url;}else{}}function k(r){if(r.length>1){var q=[];Y(["image","videolist","text"]).each(function(s,t){Y(r).each(function(u,v){if(v.type==t){q[q.length]=v;}});});r=q;}return r;}function D(q){var r=1;if(q=="all"||Z()!="all"){return r;}Y(G).each(function(s,t){if((t.type==q)){r=(s+1);return ;}});return r;}function h(q){if((q==0)||(q>G.length)){return ;}Y("#ds-content #ds-panel-"+J()).hide();Y("#ds-content #ds-panel-"+q).show();Y("#ds-options .ds-description").html(G[q-1]["description"]);Y("#ds-options .ds-enumerator").html(M[Z()]+" "+q+" "+M.enumeratorText+" "+Y("#ds-content .ds-panel").length);if(G[q-1]["type"]=="videolist"){Y("#ds-options").addClass("videolist");Y("#ds-options .ds-prev-button").addClass("ds-prev-button-hover");Y("#ds-options .ds-next-button").addClass("ds-next-button-hover");window.setTimeout(function(){Y("#ds-options .ds-prev-button").fadeOut((c==false?925:250),function(){Y("#ds-options .ds-prev-button").fadeIn();Y("#ds-options .ds-prev-button").removeClass("ds-prev-button-hover");});Y("#ds-options .ds-next-button").fadeOut((c==false?925:250),function(){Y("#ds-options .ds-next-button").fadeIn();Y("#ds-options .ds-next-button").removeClass("ds-next-button-hover");});if(c==false){c=true;}},(W==false?1850:250));}else{Y("#ds-options").removeClass("videolist");}if(Y("#ds-content .ds-panel").length>1){Y("#ds-options .ds-prev-button").removeClass("hidden");Y("#ds-options .ds-next-button").removeClass("hidden");if(q==1){Y("#ds-options .ds-prev-button").addClass("hidden");}else{if(q==G.length){Y("#ds-options .ds-next-button").addClass("hidden");}}}o(q);}function N(){if(E.isIE6){m();}Y("#ds-overlay").css("opacity",0.85);Y("#ds-lightbox").show();if(W==false){Y("#ds-container").animate({height:520,top:0,width:700},800,"swing",function(){Y("#ds-content").removeClass("hidden");Y("#ds-options").removeClass("hidden");});W=true;}T(true);}function m(){var q=document.body.scrollHeight>=document.body.clientHeight?document.body.scrollHeight:document.body.clientHeight;Y(["#ds-overlay","#ds-lightbox"]).each(function(s,r){Y(r).css("position","absolute");Y(r).height(q);});if(Y(document).scrollTop()>0){Y(document).scrollTop(0);}}function J(){return O;}function o(q){O=q;}function V(){return I;}function F(s){var r="all";if(s.length>1){var q=[];Y(s).each(function(t,u){if(Y.inArray(u.type,q)==-1){q[q.length]=u.type;}});r=(q.length>1?r:q[0]);}f=r;}function Z(){return f;}function T(q){l=q;}function j(){return(l==true?true:null);}function R(q){Q=q;}function B(){return Q;}function L(r){if(!j()){return ;}try{switch(r.keyCode){case 39:DigitalStories.next();break;case 37:DigitalStories.prev();break;case 27:DigitalStories.close();break;}}catch(q){}}function C(){Y("#ds-lightbox").hide();Y("#ds-overlay").hide();Y("#ds-content").html("");try{X();}catch(q){}}return{initialize:function(q){q=q||{};if(typeof (q.assetsPath)!="undefined"){R(q.assetsPath);}if(typeof (q.onOpen)!="undefined"){S=q.onOpen;}if(typeof (q.onClose)!="undefined"){X=q.onClose;}Y(document.body).append('<div id="ds-overlay" style="display: none; opacity: 0.85;"></div>');Y(document.body).append('<div id="ds-lightbox" style="display: none;"><div id="ds-container" style="width: 350px; height: 260px; top: 200px;"><div id="ds-content" class="hidden"></div></div></div>');Y("#ds-container").append('<div id="ds-options" class="hidden"><p class="ds-enumerator">Asset 1 of 3</p><p class="ds-description">This is my description</p><a href="#close" class="ds-close-button" onclick="DigitalStories.close(); return false;"><!-- close --></a><a href="#prev" class="ds-prev-button hidden" onclick="DigitalStories.prev(); return false;" onfocus="$(this).doBlurAndHidefocus();" onmousedown="$(this).doBlurAndHidefocus();" onmouseup="$(this).doBlur();" onmouseout="$(this).doBlur();"><!-- prev --></a><a href="#next" class="ds-next-button hidden" onclick="DigitalStories.next(); return false;" onfocus="$(this).trigger(\'blur\');$(this).doBlurAndHidefocus();" onmousedown="$(this).doBlurAndHidefocus();" onmouseup="$(this).doBlur();" onmouseout="$(this).doBlur();"><!-- next --></a></div>');if(E.isIE){Y("#ds-container").addClass("isIE");Y(["isIE8","isIE7","isIE6"]).each(function(r,s){if(E[s]==true){Y("#ds-container").addClass(s);}});}if(E.isIE6){Y(document.body).addClass("ds-enabled");}Y(document).bind("keydown",L);Y("#ds-content").bind("keydown",L);},openLightbox:function(q){DigitalStories.openLightboxWithType(q,"all");},openLightboxWithType:function(s,q){a(s,q);try{S();}catch(r){}Y("#ds-overlay").fadeIn("normal",N);},close:function(){T(false);C();return false;},prev:function(){if(!l){return ;}h(J()-1);},next:function(){if(!l){return ;}h(J()+1);},setLabel:function(q,r){M[q]=r;},getLabel:function(q){return(typeof (M[q])!="undefined"?M[q]:"");}};}(jQuery);jQuery.fn.doBlurAndHidefocus=function(){try{this.blur();this.hideFocus=true;this.style.outline="none";}catch(A){}};jQuery.fn.doBlur=function(){try{this.blur();this.hideFocus=false;this.style.outline=null;}catch(A){}};
// Initialize.
// jQuery(document).ready(function(){ DigitalStories.initialize({}); });
jQuery(document).ready(function(){
	var userAgent = navigator.userAgent.toLowerCase();
	var hideContentObject = null;
 	if(window.ActiveXObject || ((/chrome/.test(userAgent)) && (/windows/.test(userAgent)))){
		hideContentObject = true;
	}
 	DigitalStories.initialize({
	  "assetsPath": "assets",
	  onOpen: function(){ if(hideContentObject){ $('.content-object object').css('visibility', 'hidden'); }}, 
	  onClose: function(){ if(hideContentObject){ $('.content-object object').css('visibility', 'visible'); }}
	}); 
});
