// plugins/evisua.basics.js
// plugins/evisua.window.js
// plugins/evisua.messagebox.js
var Handlers=Handlers||{};var Evisua=function(){var handleResponse=function(json,status,XMLObject,handler){if(handler){handler.apply(this,[(((json.success=='true')||(json.success===true))?true:false),json.data]);}}
jQuery.extend(jQuery.expr[':'],{icontains:"jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"});return{idSeed:0,htmlDecodeEl:false,id:function(el,prefix){var el=el?$(el).get(0):false;prefix=prefix||"evisua-gen";var id=prefix+(++this.idSeed);return el?(el.id?el.id:(el.id=id)):id;},addHandlers:function(methods){$.extend(Handlers,methods);},decode:function(json){return eval("("+json+')');},htmlDecode:function(str){this.htmlDecodeEl=this.htmlDecodeEl||$('<a id="html-decode"></a>');return this.htmlDecodeEl.html(str).text();},urlEncode:function(clearString){var output='';var x=0;clearString=clearString.toString();var regex=/(^[a-zA-Z0-9_.]*)/;while(x<clearString.length){var match=regex.exec(clearString.substr(x));if(match!=null&&match.length>1&&match[1]!=''){output+=match[1];x+=match[1].length;}else{if(clearString[x]==' ')
output+='+';else{var charCode=clearString.charCodeAt(x);var hexVal=charCode.toString(16);output+='%'+(hexVal.length<2?'0':'')+hexVal.toUpperCase();}
x++;}}
return output;},makeRequest:function(options){if(!options||!(options.module||options.url))
return false;if(typeof options.params=='string'){var params=options.params;}else if(options.params&&options.params.length>0){var params=options.params.join('/');}
var url=options.url||'/'+options.module+'/'
+(options.controller?options.controller+'/':'index/')
+(options.action?options.action+'/':'index/')
+(params?params:'');if(options.form){if(typeof(options.form)=='string'){var formData=$('#'+options.form).serialize();}else if($(options.form).length==1){var formData=$(options.form).serialize();}else{var formData=[];$.each(options.form,function(){formData.push($('#'+this).serialize());})
formData=formData.join('&');}}
if(options.async===undefined){options.async=true;}
var postData=options.postData?jQuery.param(options.postData):'';var data=(formData?(formData+'&'):'')+postData;if(options.postQuery){data=data+'&'+options.postQuery;}
var handlerFn=(typeof options.handler=='string')?Handlers[options.handler]:((typeof options.handler=='function')?options.handler:false);$.ajax({url:url,success:handleResponse.createDelegate(options.scope||window,handlerFn,true),dataType:'json',async:options.async,data:data||null,type:data?'POST':'GET'});},makeURLString:function(string){return string;}}}();$.extend(Function.prototype,{createCallback:function(){var args=arguments;var method=this;return function(){return method.apply(window,args);};},createDelegate:function(obj,args,appendArgs){var method=this;return function(){var callArgs=args||arguments;if(appendArgs===true){callArgs=Array.prototype.slice.call(arguments,0);callArgs=callArgs.concat(args);}else if(typeof appendArgs=="number"){callArgs=Array.prototype.slice.call(arguments,0);var applyArgs=[appendArgs,0].concat(args);Array.prototype.splice.apply(callArgs,applyArgs);}
return method.apply(obj||window,callArgs);};}});(function(){$.fn.extend({equals:function(compareTo){if(!compareTo||!compareTo.length||this.length!=compareTo.length){return false;}
for(var i=0;i<this.length;i++){if(this[i]!==compareTo[i]){return false;}}
return true;},stripId:function(sep){sep=sep||'-';return this[0].id.substr(this[0].id.lastIndexOf('-')+1);},findParent:function(expr,maxDepth,returnEl){var p=this[0],b=document.body,depth=0;maxDepth=maxDepth||50;while(p&&p.nodeType==1&&depth<maxDepth&&p!=b){if($(p).is(expr)){return returnEl?p:$(p);}
depth++;p=p.parentNode;}
return null;},findNext:function(expr){var current=$(this);while((current=current.next()).length>0){if($(current).is(expr)){return $(current);}}
return $([]);},findPrev:function(expr){var current=$(this);while((current=current.prev()).length>0){if($(current).is(expr)){return $(current);}}
return $([]);},scrollIntoView:function(container,hscroll){var bd=document.body;var cEl=container&&$(container).get(0)||bd;var isBody=(cEl==document.documentElement)||(cEl==document.body);var c=isBody?$(window):$(cEl);var el=$(this).get(0);var o=$(el).getOffsetsTo(cEl);if(bd!=cEl){o[0]=o[0]-c.css('borderLeftWidth').replace('px','');o[1]=o[1]-c.css('borderTopWidth').replace('px','');}
var cScrollTop=c.scrollTop();var cScrollLeft=c.scrollLeft();var l=o[0]+(isBody?0:cScrollLeft),t=o[1]+(isBody?0:cScrollTop),b=t+el.offsetHeight,r=l+el.offsetWidth;var ch=c.height();var cw=c.width();var ct=parseInt(cScrollTop,10);var cl=parseInt(cScrollLeft,10);var cb=ct+ch;var cr=cl+cw;if(el.offsetHeight>ch||t<ct){c.scrollTop(t);}
else if(b>cb){c.scrollTop(b-ch);}
if(hscroll!==false){if(el.offsetWidth>cw||l<cl){c.scrollLeft(l);}
else if(r>cr){c.scrollLeft(r-cw);}}
return this;},getOffsetsTo:function(el){el=$(el).get(0);var o=$(this).offset();var e=(document.documentElement==el||document.body==el)?{top:0,left:0}:$(el).offset();return[o.left-e.left,o.top-e.top];},center:function(){return this.each(function(){$(this).css({position:'absolute'});var leftPos=($(window).width()-$(this).outerWidth())/2+$(window).scrollLeft();var topPos=($(window).height()-$(this).outerHeight())/2+$(window).scrollTop();if(topPos<0)topPos=0;if(leftPos<0)leftPos=0;$(this).css({left:leftPos+'px',top:topPos+'px',zIndex:'1000'});});},mask:function(maskRe){var KEY={BACKSPACE:8,TAB:9,RETURN:13,ESC:27,END:35,HOME:36,DELETE:46};function isNavKey(k){return(k>=33&&k<=40)||k==KEY.RETURN||k==KEY.TAB||k==KEY.ESC;}
this.keypress(function(ev){var k=ev.keyCode;if(!$.browser.msie&&(isNavKey(k)||k==KEY.BACKSPACE||(k==KEY.DELETE&&ev.button==-1))){return;}
if($.browser.msie&&(k==KEY.BACKSPACE||k==KEY.DELETE||isNavKey(k)||k==KEY.HOME||k==KEY.END)){return;}
var c=ev.charCode||ev.keyCode;if(!maskRe.test(String.fromCharCode(c)||'')){return false;}});return this;},fadeOutRemove:function(speed,callback){if(arguments.length==1||arguments.length==0){callback==null;}
var speed=speed||500;var item=$(this);$(this).fadeOut(speed,function(){$(this).remove();if(callback!=null){callback();}});},fadeChangeHtml:function(html,speed){var item=$(this);var html=html;var speed=speed?speed:500;speed=speed/2;$(this).fadeOut(speed);setTimeout(function(){item.html(html);item.fadeIn(speed);},speed+10);},hideAfterFade:function(cnfg){var config=$.extend({fadeSpeed:'fast',visibilityTime:3000,callback:null},cnfg);return $(this).each(function(){var This=$(this);This.fadeIn(config.fadeSpeed,function(){setTimeout(function(){This.fadeOut(config.fadeSpeed,function(){if(config.callback!=null&&(typeof config.callback==='function')){config.callback();}});},config.visibilityTime);});});}});})();jQuery(function(){Evisua.Window=function(title,config){var window,overlay;var $titleEl,$buttonsEl,$bodyEl;var iconCls='';var id=Evisua.id();var buttons={};var moved=false;var config=$.extend({},{windowId:'#evisua-window',modal:true,draggable:false,title:title||'Evisua',content:'',width:200,buttons:[{name:'close',caption:'Close',align:'right',handler:function(){this.hide();}}]},config);var zIndexOverlay=100;$('.evisua-window').each(function(i){zIndexOverlay=zIndexOverlay*(i+2);});var zIndexWindow=zIndexOverlay+10;var popupTemplate=['<div class="evisua-window">','<h3 class="ui-block-header large grey window-header-title">','<span class="tl">&nbsp;</span>','<span class="tr">&nbsp;</span>','</h3>','<div class="window-content-wrap">','<div class="window-body"></div>','<div class="window-buttons"></div>','</div>','</div>'].join('');var buttonTemplate=['<a href="#" class="big-button form-button window-button ui-button grey">','<span>[caption]</span>','</a>'].join('');var createButton=function(text,cb,align,hidden){var btn=$(buttonTemplate.replace('[caption]',text)).addClass('align-'+align).appendTo($buttonsEl).click(function(ev){ev.preventDefault();ev.target.blur();cb();})
if(hidden){btn.hide();}
return btn;}
var returnObj={jq_window:null,renderWindow:function(){if(!window){window=$(popupTemplate).appendTo(document.body).hide();window.id=config.windowId;$bodyEl=window.find('.window-body');$titleEl=window.find('.window-header-title');$buttonsEl=window.find('.window-buttons');this.setTitle(config.title);this.setButtons(config.buttons);this.setContent(config.content);this.setWidth(config.width);if(config.draggable){window.draggable({containment:'document',scroll:true,cursor:'move',handle:$titleEl,stop:function(){moved=true;}});$titleEl.css('cursor','move');}}
return window},hasMoved:function(){return moved;},getOverlay:function(){if(!overlay){var height=document.body.clientHeight;overlay=$('<div class="evisua-window-overlay"></div>').prependTo(document.body).height(height).css({position:'fixed',top:0,left:0,zIndex:zIndexOverlay,width:'100%',height:'100%',opacity:0,backgroundColor:'#000',display:'none'});}
return overlay;},show:function(){var win=this.renderWindow();this.jq_window=win;if(config&&config.cls){win.addClass(config.cls);}
function showWindow(){win.css({opacity:0,zIndex:zIndexWindow}).show().center().css({opacity:1});if(config.autoFocus){$(config.autoFocus).focus();}else if(config.autoSelect){$(config.autoSelect).focus().select();}
win.trigger('show',[this]);}
if(config.modal){this.getOverlay().before(win).show().stop().fadeTo('fast',0.6,function(){showWindow();});return this;}
showWindow();return this;},hide:function(keepOverlay){var win=this.renderWindow();win.hide();if(config&&config.cls){win.removeClass(config.cls);}
if(overlay&&!keepOverlay){overlay.fadeTo('fast',0,function(){overlay.hide();});}
return this;},close:function(){var win=this.renderWindow();win.fadeTo('fast',0,function(){win.remove();});if(overlay){overlay.fadeTo('fast',0,function(){overlay.remove();});}},setButtons:function(btns,add){this.renderWindow();var that=this;add=add||false;if(!add){$.each(buttons,function(){$(this).remove();});}
$.each(btns,function(){that.addButton(this);});},addButton:function(btn){this.renderWindow();buttons=buttons||[];var button=buttons[btn.name||Evisua.id()]=createButton(btn.caption,btn.handler.createDelegate(btn.scope||this,[this,window],true),btn.align||'right',btn.hidden||false);return button;},removeButton:function(name){if(name&&buttons[name]){$(this).remove();delete buttons[name];}},getButton:function(name){if(name&&buttons[name]){return buttons[name];}
return false;},showButton:function(name){if(name&&buttons[name]){buttons[name].show();}
return this;},hideButton:function(name){if(name&&buttons[name]){buttons[name].hide();}
return this;},setTitle:function(title){this.renderWindow();$titleEl.html(title);},setContent:function(content){var win=this.renderWindow();$bodyEl.empty().append(content);},getBody:function(){this.renderWindow();return $bodyEl;},getEl:function(){return this.renderWindow();},setWidth:function(width){window.width(width);return this;},center:function(){return this;}}
if(config.autoRender){returnObj.renderWindow();}
return returnObj;}});$(function(){Evisua.Msg=function(){var opt,window;var $iconEl,$msgEl;var iconCls='';var queue=null;var handleButton=function(button){window.hide();if(typeof opt.fn=='function'){var paramsArray=[button];if(typeof opt.input!='undefined'){var inputValue=$(window.jq_window).find('input[name="'+opt.input+'"]').val();paramsArray.push(inputValue);}
opt.fn.apply(opt.scope||window,paramsArray);}}
var updateButtons=function(b){window.getButton('ok').hide();window.getButton('cancel').hide();window.getButton('yes').hide();window.getButton('no').hide();var btn;for(var k in b){btn=window.getButton(k);if(btn){btn.show();}}};return{getWindow:function(titleText,input,inputLabel){var contentHtml='<div class="mb-icon"></div><p class="mb-message"></p>';if(arguments.length>1){if(arguments.length==3){contentHtml+='<label>'+inputLabel+'</label>';}
contentHtml+='<input type="'+input+'" name="'+input+'" />';}
if(!window){var bt=this.buttonText;window=new Evisua.Window(titleText||"&#160;",{content:contentHtml,cls:'evisua-mb',width:300,buttons:[{name:'cancel',caption:bt['cancel'],handler:handleButton.createCallback('cancel')},{name:'no',caption:bt['no'],handler:handleButton.createCallback('no')},{name:'yes',caption:bt['yes'],handler:handleButton.createCallback('yes')},{name:'ok',caption:bt['ok'],handler:handleButton.createCallback('ok')}]});var $bodyEl=window.getBody();$msgEl=$bodyEl.find('.mb-message');$iconEl=$bodyEl.find('.mb-icon');}
return window;},setText:function(text){$msgEl.html(text||'&#160;');return this;},setTitle:function(title){window.setTitle(title||"&#160;");return this;},setIcon:function(icon){if(icon&&icon!=''){$iconEl.show().removeClass(iconCls).addClass(icon);iconCls=icon;}else{$iconEl.hide();iconCls='';}
return this;},alert:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope});return this;},warning:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.WARNING});return this;},prompt:function(title,msg,fn,type,label,scope){this.show({title:title,msg:msg,buttons:this.OKCANCEL,fn:fn,scope:scope,icon:this.QUESTION,input:type||'password',inputLabel:label||'Password'});return this;},info:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.INFO});return this;},error:function(title,msg,fn,scope){this.show({title:title||'Evisua error',msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.ERROR});return this;},confirm:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.YESNO,fn:fn,scope:scope,icon:this.QUESTION});return this;},addKeysEvents:function(){var This=this;var jq_HiddenInput=$('<input type="text" />').css({'position':'absolute','top':'50px','left':'5px','width':'5px','z-index':'-3'})
setTimeout(function(){This.jq_HTML.find('a.ui-button:visible').last().addClass('active');},500);var __keyHandler=function(ev){var activeButton=$('.window-buttons a.ui-button.active',This.jq_HTML);if(ev.keyCode==13){activeButton.click();return;}
if(ev.keyCode==9){var nextActive=activeButton.next(':visible');if(nextActive.length==0){nextActive=activeButton.findParent('div').find('a.ui-button:visible').first();}
activeButton.removeClass('active');nextActive.addClass('active');jq_HiddenInput.focus();}}
jq_HiddenInput.appendTo(this.jq_HTML);jq_HiddenInput.keypress(__keyHandler);setTimeout(function(){jq_HiddenInput.focus();},400);},updateWindow:function(){this.setTitle(opt.title||"&#160;");this.setText(opt.msg||"&#160;");this.setIcon(opt.icon);updateButtons(opt.buttons);},jq_HTML:null,show:function(options){opt=options;var paramsArray=[];paramsArray.push(opt.title);if(typeof opt.input!='undefined'){paramsArray.push(opt.input);}
if(typeof opt.inputLabel!='undefined'){paramsArray.push(opt.inputLabel);}
var win=this.getWindow.apply(this,paramsArray);this.updateWindow();win.show();this.jq_HTML=win.jq_window;this.addKeysEvents();return this;},OK:{ok:true},YESNO:{yes:true,no:true},OKCANCEL:{ok:true,cancel:true},YESNOCANCEL:{yes:true,no:true,cancel:true},INFO:'info',WARNING:'warning',QUESTION:'question',ERROR:'error',buttonText:{ok:'Ok',cancel:'Cancel',yes:'Yes',no:'No'}}}();});

// front/jquery.formalize.min.js
var FORMALIZE=(function(b,e,f,a){var h="placeholder" in f.createElement("input");var i="autofocus" in f.createElement("input");var g="webkitAppearance" in f.createElement("select").style;var d=!!(b.browser.msie&&parseInt(b.browser.version,10)===6);var c=!!(b.browser.msie&&parseInt(b.browser.version,10)===7);return{go:function(){for(var j in FORMALIZE.init){FORMALIZE.init[j]();}},init:{detect_webkit:function(){if(!g){return;}b("html").addClass("is_webkit");},full_input_size:function(){if(!c||!b("textarea, input.input_full").length){return;}b("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>');},ie6_skin_inputs:function(){if(!d||!b("input, select, textarea").length){return;}var j=/button|submit|reset/;var k=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;b("input").each(function(){var l=b(this);if(this.getAttribute("type").match(j)){l.addClass("ie6_button");if(this.disabled){l.addClass("ie6_button_disabled");}}else{if(this.getAttribute("type").match(k)){l.addClass("ie6_input");if(this.disabled){l.addClass("ie6_input_disabled");}}}});b("textarea, select").each(function(){if(this.disabled){b(this).addClass("ie6_input_disabled");}});},autofocus:function(){if(i||!b(":input[autofocus]").length){return;}b(":input[autofocus]:visible:first").focus();},placeholder:function(){if(h||!b(":input[placeholder]").length){return;}FORMALIZE.misc.add_placeholder();b(":input[placeholder]").each(function(){var j=b(this);var k=j.attr("placeholder");j.focus(function(){if(j.val()===k){j.val("").removeClass("placeholder_text");}}).blur(function(){FORMALIZE.misc.add_placeholder();});j.closest("form").submit(function(){if(j.val()===k){j.val("").removeClass("placeholder_text");}}).bind("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50);});});}},misc:{add_placeholder:function(){if(h||!b(":input[placeholder]").length){return;}b(":input[placeholder]").each(function(){var j=b(this);var k=j.attr("placeholder");if(!j.val()||j.val()===k){j.val(k).addClass("placeholder_text");}});}}};})(jQuery,this,this.document);jQuery(document).ready(function(){FORMALIZE.go();});

// front/libs/polyfills/respond.min.js
/*
 * respond.js - A small and fast polyfill for min/max-width CSS3 Media Queries
 * Copyright 2011, Scott Jehl, scottjehl.com
 * Dual licensed under the MIT or GPL Version 2 licenses. 
 * Usage: Check out the readme file or github.com/scottjehl/respond
*/
(function(d,g){d.respond={};respond.update=function(){};respond.mediaQueriesSupported=g;if(g){return}var s=d.document,q=s.documentElement,h=[],j=[],o=[],n={},f=30,e=s.getElementsByTagName("head")[0]||q,b=e.getElementsByTagName("link"),a=function(){var y=s.styleSheets,u=y.length;for(var x=0;x<u;x++){var w=y[x],v=w.href;if(!!v&&!n[v]){if(!/^([a-zA-Z]+?:(\/\/)?(www\.)?)/.test(v)||v.replace(RegExp.$1,"").split("/")[0]===d.location.host){var t=v;m(v,function(z){l(z,t);n[t]=true})}else{n[v]=true}}}},l=function(B,t){var z=B.match(/@media ([^\{]+)\{([\S\s]+?)(?=\}\/\*\/mediaquery\*\/)/gmi),C=z&&z.length||0,t=t.substring(0,t.lastIndexOf("/"));if(t.length){t+="/"}for(var w=0;w<C;w++){var x=z[w].match(/@media ([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1,u=x.split(","),A=u.length;j.push(RegExp.$2&&RegExp.$2.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+t+"$2$3"));for(var v=0;v<A;v++){var y=u[v];h.push({media:y.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:j.length-1,minw:y.match(/\(min\-width:\s?(\s?[0-9]+)px\s?\)/)&&parseFloat(RegExp.$1),maxw:y.match(/\(max\-width:\s?(\s?[0-9]+)px\s?\)/)&&parseFloat(RegExp.$1)})}}i()},k,p,i=function(C){var t="clientWidth",v=q[t],B=s.compatMode==="CSS1Compat"&&v||s.body[t]||v,x={},A=s.createDocumentFragment(),z=b[b.length-1],u=(new Date()).getTime();if(C&&k&&u-k<f){clearTimeout(p);p=setTimeout(i,f);return}else{k=u}for(var w in h){var D=h[w];if(!D.minw&&!D.maxw||(!D.minw||D.minw&&B>=D.minw)&&(!D.maxw||D.maxw&&B<=D.maxw)){if(!x[D.media]){x[D.media]=[]}x[D.media].push(j[D.rules])}}for(var w in o){if(o[w]&&o[w].parentNode===e){e.removeChild(o[w])}}for(var w in x){var E=s.createElement("style"),y=x[w].join("\n");E.type="text/css";E.media=w;if(E.styleSheet){E.styleSheet.cssText=y}else{E.appendChild(s.createTextNode(y))}A.appendChild(E);o.push(E)}e.insertBefore(A,z.nextSibling)},m=function(t,v){var u=c();if(!u){return}u.open("GET",t,true);u.onreadystatechange=function(){if(u.readyState!=4||u.status!=200&&u.status!=304){return}v(u.responseText)};if(u.readyState==4){return}u.send()},c=(function(){var t=false,u=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new XMLHttpRequest()}],w=u.length;while(w--){try{t=u[w]()}catch(v){continue}break}return function(){return t}})();a();respond.update=a;function r(){i(true)}if(d.addEventListener){d.addEventListener("resize",r,false)}else{if(d.attachEvent){d.attachEvent("onresize",r)}}})(this,(function(f){var g=(function(k){var i=3,l=document.createElement("div"),j=l.getElementsByTagName("i");while(l.innerHTML="<!--[if gt IE "+(++i)+"]><i></i><![endif]-->",j[0]){}return i>4?i:k}());if(f.matchMedia||g&&g>=9){return true}if(g&&g<=8){return false}var e=f.document,a=e.documentElement,b=e.createElement("body"),h=e.createElement("div"),d=e.createElement("style"),c="@media only all { #qtest { position: absolute; } }";h.setAttribute("id","qtest");d.type="text/css";b.appendChild(h);if(d.styleSheet){d.styleSheet.cssText=c}else{d.appendChild(e.createTextNode(c))}a.insertBefore(b,a.firstChild);a.insertBefore(d,b);support=(f.getComputedStyle?f.getComputedStyle(h,null):h.currentStyle)["position"]=="absolute";a.removeChild(b);a.removeChild(d);return support})(this));

// front/libs/jquery.fancybox-1.3.4.min.js
;(function($){var tmp,loading,overlay,wrap,outer,content,close,title,nav_left,nav_right,selectedIndex=0,selectedOpts={},selectedArray=[],currentIndex=0,currentOpts={},currentArray=[],ajaxLoader=null,imgPreloader=new Image(),imgRegExp=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,swfRegExp=/[^\.]\.(swf)\s*$/i,loadingTimer,loadingFrame=1,titleHeight=0,titleStr='',start_pos,final_pos,busy=false,fx=$.extend($('<div/>')[0],{prop:0}),isIE6=$.browser.msie&&$.browser.version<7&&!window.XMLHttpRequest,_abort=function(){loading.hide();imgPreloader.onerror=imgPreloader.onload=null;if(ajaxLoader){ajaxLoader.abort();}
tmp.empty();},_error=function(){if(false===selectedOpts.onError(selectedArray,selectedIndex,selectedOpts)){loading.hide();busy=false;return;}
selectedOpts.titleShow=false;selectedOpts.width='auto';selectedOpts.height='auto';tmp.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');_process_inline();},_start=function(){var obj=selectedArray[selectedIndex],href,type,title,str,emb,ret;_abort();selectedOpts=$.extend({},$.fn.fancybox.defaults,(typeof $(obj).data('fancybox')=='undefined'?selectedOpts:$(obj).data('fancybox')));ret=selectedOpts.onStart(selectedArray,selectedIndex,selectedOpts);if(ret===false){busy=false;return;}else if(typeof ret=='object'){selectedOpts=$.extend(selectedOpts,ret);}
title=selectedOpts.title||(obj.nodeName?$(obj).attr('title'):obj.title)||'';if(obj.nodeName&&!selectedOpts.orig){selectedOpts.orig=$(obj).children("img:first").length?$(obj).children("img:first"):$(obj);}
if(title===''&&selectedOpts.orig&&selectedOpts.titleFromAlt){title=selectedOpts.orig.attr('alt');}
href=selectedOpts.href||(obj.nodeName?$(obj).attr('href'):obj.href)||null;if((/^(?:javascript)/i).test(href)||href=='#'){href=null;}
if(selectedOpts.type){type=selectedOpts.type;if(!href){href=selectedOpts.content;}}else if(selectedOpts.content){type='html';}else if(href){if(href.match(imgRegExp)){type='image';}else if(href.match(swfRegExp)){type='swf';}else if($(obj).hasClass("iframe")){type='iframe';}else if(href.indexOf("#")===0){type='inline';}else{type='ajax';}}
if(!type){_error();return;}
if(type=='inline'){obj=href.substr(href.indexOf("#"));type=$(obj).length>0?'inline':'ajax';}
selectedOpts.type=type;selectedOpts.href=href;selectedOpts.title=title;if(selectedOpts.autoDimensions){if(selectedOpts.type=='html'||selectedOpts.type=='inline'||selectedOpts.type=='ajax'){selectedOpts.width='auto';selectedOpts.height='auto';}else{selectedOpts.autoDimensions=false;}}
if(selectedOpts.modal){selectedOpts.overlayShow=true;selectedOpts.hideOnOverlayClick=false;selectedOpts.hideOnContentClick=false;selectedOpts.enableEscapeButton=false;selectedOpts.showCloseButton=false;}
selectedOpts.padding=parseInt(selectedOpts.padding,10);selectedOpts.margin=parseInt(selectedOpts.margin,10);tmp.css('padding',(selectedOpts.padding+selectedOpts.margin));$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change',function(){$(this).replaceWith(content.children());});switch(type){case'html':tmp.html(selectedOpts.content);_process_inline();break;case'inline':if($(obj).parent().is('#fancybox-content')===true){busy=false;return;}
$('<div class="fancybox-inline-tmp" />').hide().insertBefore($(obj)).bind('fancybox-cleanup',function(){$(this).replaceWith(content.children());}).bind('fancybox-cancel',function(){$(this).replaceWith(tmp.children());});$(obj).appendTo(tmp);_process_inline();break;case'image':busy=false;$.fancybox.showActivity();imgPreloader=new Image();imgPreloader.onerror=function(){_error();};imgPreloader.onload=function(){busy=true;imgPreloader.onerror=imgPreloader.onload=null;_process_image();};imgPreloader.src=href;break;case'swf':selectedOpts.scrolling='no';str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+selectedOpts.width+'" height="'+selectedOpts.height+'"><param name="movie" value="'+href+'"></param>';emb='';$.each(selectedOpts.swf,function(name,val){str+='<param name="'+name+'" value="'+val+'"></param>';emb+=' '+name+'="'+val+'"';});str+='<embed src="'+href+'" type="application/x-shockwave-flash" width="'+selectedOpts.width+'" height="'+selectedOpts.height+'"'+emb+'></embed></object>';tmp.html(str);_process_inline();break;case'ajax':busy=false;$.fancybox.showActivity();selectedOpts.ajax.win=selectedOpts.ajax.success;ajaxLoader=$.ajax($.extend({},selectedOpts.ajax,{url:href,data:selectedOpts.ajax.data||{},error:function(XMLHttpRequest,textStatus,errorThrown){if(XMLHttpRequest.status>0){_error();}},success:function(data,textStatus,XMLHttpRequest){var o=typeof XMLHttpRequest=='object'?XMLHttpRequest:ajaxLoader;if(o.status==200){if(typeof selectedOpts.ajax.win=='function'){ret=selectedOpts.ajax.win(href,data,textStatus,XMLHttpRequest);if(ret===false){loading.hide();return;}else if(typeof ret=='string'||typeof ret=='object'){data=ret;}}
tmp.html(data);_process_inline();}}}));break;case'iframe':_show();break;}},_process_inline=function(){var
w=selectedOpts.width,h=selectedOpts.height;if(w.toString().indexOf('%')>-1){w=parseInt(($(window).width()-(selectedOpts.margin*2))*parseFloat(w)/100,10)+'px';}else{w=w=='auto'?'auto':w+'px';}
if(h.toString().indexOf('%')>-1){h=parseInt(($(window).height()-(selectedOpts.margin*2))*parseFloat(h)/100,10)+'px';}else{h=h=='auto'?'auto':h+'px';}
tmp.wrapInner('<div style="width:'+w+';height:'+h+';overflow: '+(selectedOpts.scrolling=='auto'?'auto':(selectedOpts.scrolling=='yes'?'scroll':'hidden'))+';position:relative;"></div>');selectedOpts.width=tmp.width();selectedOpts.height=tmp.height();_show();},_process_image=function(){selectedOpts.width=imgPreloader.width;selectedOpts.height=imgPreloader.height;$("<img />").attr({'id':'fancybox-img','src':imgPreloader.src,'alt':selectedOpts.title}).appendTo(tmp);_show();},_show=function(){var pos,equal;loading.hide();if(wrap.is(":visible")&&false===currentOpts.onCleanup(currentArray,currentIndex,currentOpts)){$.event.trigger('fancybox-cancel');busy=false;return;}
busy=true;$(content.add(overlay)).unbind();$(window).unbind("resize.fb scroll.fb");$(document).unbind('keydown.fb');if(wrap.is(":visible")&&currentOpts.titlePosition!=='outside'){wrap.css('height',wrap.height());}
currentArray=selectedArray;currentIndex=selectedIndex;currentOpts=selectedOpts;if(currentOpts.overlayShow){overlay.css({'background-color':currentOpts.overlayColor,'opacity':currentOpts.overlayOpacity,'cursor':currentOpts.hideOnOverlayClick?'pointer':'auto','height':$(document).height()});if(!overlay.is(':visible')){if(isIE6){$('select:not(#fancybox-tmp select)').filter(function(){return this.style.visibility!=='hidden';}).css({'visibility':'hidden'}).one('fancybox-cleanup',function(){this.style.visibility='inherit';});}
overlay.show();}}else{overlay.hide();}
final_pos=_get_zoom_to();_process_title();if(wrap.is(":visible")){$(close.add(nav_left).add(nav_right)).hide();pos=wrap.position(),start_pos={top:pos.top,left:pos.left,width:wrap.width(),height:wrap.height()};equal=(start_pos.width==final_pos.width&&start_pos.height==final_pos.height);content.fadeTo(currentOpts.changeFade,0.3,function(){var finish_resizing=function(){content.html(tmp.contents()).fadeTo(currentOpts.changeFade,1,_finish);};$.event.trigger('fancybox-change');content.empty().removeAttr('filter').css({'border-width':currentOpts.padding,'width':final_pos.width-currentOpts.padding*2,'height':selectedOpts.autoDimensions?'auto':final_pos.height-titleHeight-currentOpts.padding*2});if(equal){finish_resizing();}else{fx.prop=0;$(fx).animate({prop:1},{duration:currentOpts.changeSpeed,easing:currentOpts.easingChange,step:_draw,complete:finish_resizing});}});return;}
wrap.removeAttr("style");content.css('border-width',currentOpts.padding);if(currentOpts.transitionIn=='elastic'){start_pos=_get_zoom_from();content.html(tmp.contents());wrap.show();if(currentOpts.opacity){final_pos.opacity=0;}
fx.prop=0;$(fx).animate({prop:1},{duration:currentOpts.speedIn,easing:currentOpts.easingIn,step:_draw,complete:_finish});return;}
if(currentOpts.titlePosition=='inside'&&titleHeight>0){title.show();}
content.css({'width':final_pos.width-currentOpts.padding*2,'height':selectedOpts.autoDimensions?'auto':final_pos.height-titleHeight-currentOpts.padding*2}).html(tmp.contents());wrap.css(final_pos).fadeIn(currentOpts.transitionIn=='none'?0:currentOpts.speedIn,_finish);},_format_title=function(title){if(title&&title.length){if(currentOpts.titlePosition=='float'){return'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+title+'</td><td id="fancybox-title-float-right"></td></tr></table>';}
return'<div id="fancybox-title-'+currentOpts.titlePosition+'">'+title+'</div>';}
return false;},_process_title=function(){titleStr=currentOpts.title||'';titleHeight=0;title.empty().removeAttr('style').removeClass();if(currentOpts.titleShow===false){title.hide();return;}
titleStr=$.isFunction(currentOpts.titleFormat)?currentOpts.titleFormat(titleStr,currentArray,currentIndex,currentOpts):_format_title(titleStr);if(!titleStr||titleStr===''){title.hide();return;}
title.addClass('fancybox-title-'+currentOpts.titlePosition).html(titleStr).appendTo('body').show();switch(currentOpts.titlePosition){case'inside':title.css({'width':final_pos.width-(currentOpts.padding*2),'marginLeft':currentOpts.padding,'marginRight':currentOpts.padding});titleHeight=title.outerHeight(true);title.appendTo(outer);final_pos.height+=titleHeight;break;case'over':title.css({'marginLeft':currentOpts.padding,'width':final_pos.width-(currentOpts.padding*2),'bottom':currentOpts.padding}).appendTo(outer);break;case'float':title.css('left',parseInt((title.width()-final_pos.width-40)/2,10)*-1).appendTo(wrap);break;default:title.css({'width':final_pos.width-(currentOpts.padding*2),'paddingLeft':currentOpts.padding,'paddingRight':currentOpts.padding}).appendTo(wrap);break;}
title.hide();},_set_navigation=function(){if(currentOpts.enableEscapeButton||currentOpts.enableKeyboardNav){$(document).bind('keydown.fb',function(e){if(e.keyCode==27&&currentOpts.enableEscapeButton){e.preventDefault();$.fancybox.close();}else if((e.keyCode==37||e.keyCode==39)&&currentOpts.enableKeyboardNav&&e.target.tagName!=='INPUT'&&e.target.tagName!=='TEXTAREA'&&e.target.tagName!=='SELECT'){e.preventDefault();$.fancybox[e.keyCode==37?'prev':'next']();}});}
if(!currentOpts.showNavArrows){nav_left.hide();nav_right.hide();return;}
if((currentOpts.cyclic&&currentArray.length>1)||currentIndex!==0){nav_left.show();}
if((currentOpts.cyclic&&currentArray.length>1)||currentIndex!=(currentArray.length-1)){nav_right.show();}},_finish=function(){if(!$.support.opacity){content.get(0).style.removeAttribute('filter');wrap.get(0).style.removeAttribute('filter');}
if(selectedOpts.autoDimensions){content.css('height','auto');}
wrap.css('height','auto');if(titleStr&&titleStr.length){title.show();}
if(currentOpts.showCloseButton){close.show();}
_set_navigation();if(currentOpts.hideOnContentClick){content.bind('click',$.fancybox.close);}
if(currentOpts.hideOnOverlayClick){overlay.bind('click',$.fancybox.close);}
$(window).bind("resize.fb",$.fancybox.resize);if(currentOpts.centerOnScroll){$(window).bind("scroll.fb",$.fancybox.center);}
if(currentOpts.type=='iframe'){$('<iframe id="fancybox-frame" name="fancybox-frame'+new Date().getTime()+'" frameborder="0" hspace="0" '+($.browser.msie?'allowtransparency="true""':'')+' scrolling="'+selectedOpts.scrolling+'" src="'+currentOpts.href+'"></iframe>').appendTo(content);}
wrap.show();busy=false;$.fancybox.center();currentOpts.onComplete(currentArray,currentIndex,currentOpts);_preload_images();},_preload_images=function(){var href,objNext;if((currentArray.length-1)>currentIndex){href=currentArray[currentIndex+1].href;if(typeof href!=='undefined'&&href.match(imgRegExp)){objNext=new Image();objNext.src=href;}}
if(currentIndex>0){href=currentArray[currentIndex-1].href;if(typeof href!=='undefined'&&href.match(imgRegExp)){objNext=new Image();objNext.src=href;}}},_draw=function(pos){var dim={width:parseInt(start_pos.width+(final_pos.width-start_pos.width)*pos,10),height:parseInt(start_pos.height+(final_pos.height-start_pos.height)*pos,10),top:parseInt(start_pos.top+(final_pos.top-start_pos.top)*pos,10),left:parseInt(start_pos.left+(final_pos.left-start_pos.left)*pos,10)};if(typeof final_pos.opacity!=='undefined'){dim.opacity=pos<0.5?0.5:pos;}
wrap.css(dim);content.css({'width':dim.width-currentOpts.padding*2,'height':dim.height-(titleHeight*pos)-currentOpts.padding*2});},_get_viewport=function(){return[$(window).width()-(currentOpts.margin*2),$(window).height()-(currentOpts.margin*2),$(document).scrollLeft()+currentOpts.margin,$(document).scrollTop()+currentOpts.margin];},_get_zoom_to=function(){var view=_get_viewport(),to={},resize=currentOpts.autoScale,double_padding=currentOpts.padding*2,ratio;if(currentOpts.width.toString().indexOf('%')>-1){to.width=parseInt((view[0]*parseFloat(currentOpts.width))/100,10);}else{to.width=currentOpts.width+double_padding;}
if(currentOpts.height.toString().indexOf('%')>-1){to.height=parseInt((view[1]*parseFloat(currentOpts.height))/100,10);}else{to.height=currentOpts.height+double_padding;}
if(resize&&(to.width>view[0]||to.height>view[1])){if(selectedOpts.type=='image'||selectedOpts.type=='swf'){ratio=(currentOpts.width)/(currentOpts.height);if((to.width)>view[0]){to.width=view[0];to.height=parseInt(((to.width-double_padding)/ratio)+double_padding,10);}
if((to.height)>view[1]){to.height=view[1];to.width=parseInt(((to.height-double_padding)*ratio)+double_padding,10);}}else{to.width=Math.min(to.width,view[0]);to.height=Math.min(to.height,view[1]);}}
to.top=parseInt(Math.max(view[3]-20,view[3]+((view[1]-to.height-40)*0.5)),10);to.left=parseInt(Math.max(view[2]-20,view[2]+((view[0]-to.width-40)*0.5)),10);return to;},_get_obj_pos=function(obj){var pos=obj.offset();pos.top+=parseInt(obj.css('paddingTop'),10)||0;pos.left+=parseInt(obj.css('paddingLeft'),10)||0;pos.top+=parseInt(obj.css('border-top-width'),10)||0;pos.left+=parseInt(obj.css('border-left-width'),10)||0;pos.width=obj.width();pos.height=obj.height();return pos;},_get_zoom_from=function(){var orig=selectedOpts.orig?$(selectedOpts.orig):false,from={},pos,view;if(orig&&orig.length){pos=_get_obj_pos(orig);from={width:pos.width+(currentOpts.padding*2),height:pos.height+(currentOpts.padding*2),top:pos.top-currentOpts.padding-20,left:pos.left-currentOpts.padding-20};}else{view=_get_viewport();from={width:currentOpts.padding*2,height:currentOpts.padding*2,top:parseInt(view[3]+view[1]*0.5,10),left:parseInt(view[2]+view[0]*0.5,10)};}
return from;},_animate_loading=function(){if(!loading.is(':visible')){clearInterval(loadingTimer);return;}
$('div',loading).css('top',(loadingFrame*-40)+'px');loadingFrame=(loadingFrame+1)%12;};$.fn.fancybox=function(options){if(!$(this).length){return this;}
$(this).data('fancybox',$.extend({},options,($.metadata?$(this).metadata():{}))).unbind('click.fb').bind('click.fb',function(e){e.preventDefault();if(busy){return;}
busy=true;$(this).blur();selectedArray=[];selectedIndex=0;var rel=$(this).attr('rel')||'';if(!rel||rel==''||rel==='nofollow'){selectedArray.push(this);}else{selectedArray=$("a[rel="+rel+"], area[rel="+rel+"]");selectedIndex=selectedArray.index(this);}
_start();return;});return this;};$.fancybox=function(obj){var opts;if(busy){return;}
busy=true;opts=typeof arguments[1]!=='undefined'?arguments[1]:{};selectedArray=[];selectedIndex=parseInt(opts.index,10)||0;if($.isArray(obj)){for(var i=0,j=obj.length;i<j;i++){if(typeof obj[i]=='object'){$(obj[i]).data('fancybox',$.extend({},opts,obj[i]));}else{obj[i]=$({}).data('fancybox',$.extend({content:obj[i]},opts));}}
selectedArray=jQuery.merge(selectedArray,obj);}else{if(typeof obj=='object'){$(obj).data('fancybox',$.extend({},opts,obj));}else{obj=$({}).data('fancybox',$.extend({content:obj},opts));}
selectedArray.push(obj);}
if(selectedIndex>selectedArray.length||selectedIndex<0){selectedIndex=0;}
_start();};$.fancybox.showActivity=function(){clearInterval(loadingTimer);loading.show();loadingTimer=setInterval(_animate_loading,66);};$.fancybox.hideActivity=function(){loading.hide();};$.fancybox.next=function(){return $.fancybox.pos(currentIndex+1);};$.fancybox.prev=function(){return $.fancybox.pos(currentIndex-1);};$.fancybox.pos=function(pos){if(busy){return;}
pos=parseInt(pos);selectedArray=currentArray;if(pos>-1&&pos<currentArray.length){selectedIndex=pos;_start();}else if(currentOpts.cyclic&&currentArray.length>1){selectedIndex=pos>=currentArray.length?0:currentArray.length-1;_start();}
return;};$.fancybox.cancel=function(){if(busy){return;}
busy=true;$.event.trigger('fancybox-cancel');_abort();selectedOpts.onCancel(selectedArray,selectedIndex,selectedOpts);busy=false;};$.fancybox.close=function(){if(busy||wrap.is(':hidden')){return;}
busy=true;if(currentOpts&&false===currentOpts.onCleanup(currentArray,currentIndex,currentOpts)){busy=false;return;}
_abort();$(close.add(nav_left).add(nav_right)).hide();$(content.add(overlay)).unbind();$(window).unbind("resize.fb scroll.fb");$(document).unbind('keydown.fb');content.find('iframe').attr('src',isIE6&&/^https/i.test(window.location.href||'')?'javascript:void(false)':'about:blank');if(currentOpts.titlePosition!=='inside'){title.empty();}
wrap.stop();function _cleanup(){overlay.fadeOut('fast');title.empty().hide();wrap.hide();$.event.trigger('fancybox-cleanup');content.empty();currentOpts.onClosed(currentArray,currentIndex,currentOpts);currentArray=selectedOpts=[];currentIndex=selectedIndex=0;currentOpts=selectedOpts={};busy=false;}
if(currentOpts.transitionOut=='elastic'){start_pos=_get_zoom_from();var pos=wrap.position();final_pos={top:pos.top,left:pos.left,width:wrap.width(),height:wrap.height()};if(currentOpts.opacity){final_pos.opacity=1;}
title.empty().hide();fx.prop=1;$(fx).animate({prop:0},{duration:currentOpts.speedOut,easing:currentOpts.easingOut,step:_draw,complete:_cleanup});}else{wrap.fadeOut(currentOpts.transitionOut=='none'?0:currentOpts.speedOut,_cleanup);}};$.fancybox.resize=function(){if(overlay.is(':visible')){overlay.css('height',$(document).height());}
$.fancybox.center(true);};$.fancybox.center=function(){var view,align;if(busy){return;}
align=arguments[0]===true?1:0;view=_get_viewport();if(!align&&(wrap.width()>view[0]||wrap.height()>view[1])){return;}
wrap.stop().animate({'top':parseInt(Math.max(view[3]-20,view[3]+((view[1]-content.height()-40)*0.5)-currentOpts.padding)),'left':parseInt(Math.max(view[2]-20,view[2]+((view[0]-content.width()-40)*0.5)-currentOpts.padding))},typeof arguments[0]=='number'?arguments[0]:200);};$.fancybox.init=function(){if($("#fancybox-wrap").length){return;}
$('body').append(tmp=$('<div id="fancybox-tmp"></div>'),loading=$('<div id="fancybox-loading"><div></div></div>'),overlay=$('<div id="fancybox-overlay"></div>'),wrap=$('<div id="fancybox-wrap"></div>'));outer=$('<div id="fancybox-outer"></div>').appendTo(wrap);outer.append(content=$('<div id="fancybox-content"></div>'),close=$('<a id="fancybox-close"></a>'),title=$('<div id="fancybox-title"></div>'),nav_left=$('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico">&lt;</span></a>'),nav_right=$('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico">&gt;</span></a>'));close.click($.fancybox.close);loading.click($.fancybox.cancel);nav_left.click(function(e){e.preventDefault();$.fancybox.prev();});nav_right.click(function(e){e.preventDefault();$.fancybox.next();});if($.fn.mousewheel){wrap.bind('mousewheel.fb',function(e,delta){if(busy){e.preventDefault();}else if($(e.target).get(0).clientHeight==0||$(e.target).get(0).scrollHeight===$(e.target).get(0).clientHeight){e.preventDefault();$.fancybox[delta>0?'prev':'next']();}});}
if(!$.support.opacity){wrap.addClass('fancybox-ie');}
if(isIE6){loading.addClass('fancybox-ie6');wrap.addClass('fancybox-ie6');$('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||'')?'javascript:void(false)':'about:blank')+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);}};$.fn.fancybox.defaults={padding:0,margin:40,opacity:false,modal:false,cyclic:false,scrolling:'auto',width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:'transparent'},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:'#777',titleShow:true,titlePosition:'float',titleFormat:null,titleFromAlt:false,transitionIn:'fade',transitionOut:'fade',speedIn:300,speedOut:300,changeSpeed:300,changeFade:'fast',easingIn:'swing',easingOut:'swing',showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};$(document).ready(function(){$.fancybox.init();});})(jQuery);

// front/libs/jquery.marquee.min.js
// http://remysharp/tag/marquee
(function($){$.fn.marquee=function(klass){var newMarquee=[],last=this.length;function getReset(newDir,marqueeRedux,marqueeState){var behavior=marqueeState.behavior,width=marqueeState.width,dir=marqueeState.dir;var r=0;if(behavior=='alternate'){r=newDir==1?marqueeRedux[marqueeState.widthAxis]-(width*2):width;}else if(behavior=='slide'){if(newDir==-1){r=dir==-1?marqueeRedux[marqueeState.widthAxis]:width;}else{r=dir==-1?marqueeRedux[marqueeState.widthAxis]-(width*2):0;}}else{r=newDir==-1?marqueeRedux[marqueeState.widthAxis]:0;}
return r;}
function animateMarquee(){var i=newMarquee.length,marqueeRedux=null,$marqueeRedux=null,marqueeState={},newMarqueeList=[],hitedge=false;while(i--){marqueeRedux=newMarquee[i];$marqueeRedux=$(marqueeRedux);marqueeState=$marqueeRedux.data('marqueeState');if($marqueeRedux.data('paused')!==true){marqueeRedux[marqueeState.axis]+=(marqueeState.scrollamount*marqueeState.dir);hitedge=marqueeState.dir==-1?marqueeRedux[marqueeState.axis]<=getReset(marqueeState.dir*-1,marqueeRedux,marqueeState):marqueeRedux[marqueeState.axis]>=getReset(marqueeState.dir*-1,marqueeRedux,marqueeState);if((marqueeState.behavior=='scroll'&&marqueeState.last==marqueeRedux[marqueeState.axis])||(marqueeState.behavior=='alternate'&&hitedge&&marqueeState.last!=-1)||(marqueeState.behavior=='slide'&&hitedge&&marqueeState.last!=-1)){if(marqueeState.behavior=='alternate'){marqueeState.dir*=-1;}
marqueeState.last=-1;$marqueeRedux.trigger('stop');marqueeState.loops--;if(marqueeState.loops===0){if(marqueeState.behavior!='slide'){marqueeRedux[marqueeState.axis]=getReset(marqueeState.dir,marqueeRedux,marqueeState);}else{marqueeRedux[marqueeState.axis]=getReset(marqueeState.dir*-1,marqueeRedux,marqueeState);}
$marqueeRedux.trigger('end');}else{newMarqueeList.push(marqueeRedux);$marqueeRedux.trigger('start');marqueeRedux[marqueeState.axis]=getReset(marqueeState.dir,marqueeRedux,marqueeState);}}else{newMarqueeList.push(marqueeRedux);}
marqueeState.last=marqueeRedux[marqueeState.axis];$marqueeRedux.data('marqueeState',marqueeState);}else{newMarqueeList.push(marqueeRedux);}}
newMarquee=newMarqueeList;if(newMarquee.length){setTimeout(animateMarquee,25);}}
this.each(function(i){var $marquee=$(this),width=$marquee.attr('width')||$marquee.width(),height=$marquee.attr('height')||$marquee.height(),$marqueeRedux=$marquee.after('<div '+(klass?'class="'+klass+'" ':'')+'style="display: block-inline; width: '+width+'px; height: '+height+'px; overflow: hidden;"><div style="float: left; white-space: nowrap;">'+$marquee.html()+'</div></div>').next(),marqueeRedux=$marqueeRedux.get(0),hitedge=0,direction=($marquee.attr('direction')||'left').toLowerCase(),marqueeState={dir:/down|right/.test(direction)?-1:1,axis:/left|right/.test(direction)?'scrollLeft':'scrollTop',widthAxis:/left|right/.test(direction)?'scrollWidth':'scrollHeight',last:-1,loops:$marquee.attr('loop')||-1,scrollamount:$marquee.attr('scrollamount')||this.scrollAmount||2,behavior:($marquee.attr('behavior')||'scroll').toLowerCase(),width:/left|right/.test(direction)?width:height};if($marquee.attr('loop')==-1&&marqueeState.behavior=='slide'){marqueeState.loops=1;}
$marquee.remove();if(/left|right/.test(direction)){$marqueeRedux.find('> div').css('padding','0 '+width+'px');}else{$marqueeRedux.find('> div').css('padding',height+'px 0');}
$marqueeRedux.bind('stop',function(){$marqueeRedux.data('paused',true);}).bind('pause',function(){$marqueeRedux.data('paused',true);}).bind('start',function(){$marqueeRedux.data('paused',false);}).bind('unpause',function(){$marqueeRedux.data('paused',false);}).data('marqueeState',marqueeState);newMarquee.push(marqueeRedux);marqueeRedux[marqueeState.axis]=getReset(marqueeState.dir,marqueeRedux,marqueeState);$marqueeRedux.trigger('start');if(i+1==last){animateMarquee();}});return $(newMarquee);};}(jQuery));

// front/script.js
// front/libs/easing.js
// front/blog/libs/galleria.js
// front/blog/diary.js
var Site=window.Site||{};var Purple=Purple||{};Purple.fn=Purple.fn||{};Purple.vars=Purple.vars||{};Purple.fn.mag=Purple.fn.mag||{};Purple.vars.mag=Purple.vars.mag||{};(function($){Purple.fn.mag.changeLoginLinksToSettings=function(){$('.js-login-link').each(function(){var This=$(this);This.removeClass('js-login-link').addClass('js-account-settings-link').attr('href','/settings/').attr('title','Account').html('Account').unbind('click');});}
Purple.fn.mag.changeSettingsToLoginLinks=function(){$('.js-account-settings-link').each(function(){var This=$(this);This.removeClass('js-account-settings-link').addClass('js-login-link').attr('href','#').attr('title','Login').html('Login').fancybox({href:'/auth/fetch-login-box/',type:'ajax',titleShow:false,onComplete:function(){}});});}
$(function(){var is_magazine=$("#mag_container").length==1;Purple.vars.mag.jq_SubscribeLink=$('#subscribe_but, .subscribe_button');Purple.vars.mag.int_MagazineId=0;Purple.vars.jq_LoginLink=$('.js-login-link');Purple.vars.jq_RemindLink=$('.js-remind-button');Purple.vars.jq_AccountLink=$('.js-account-settings-link');Purple.vars.jq_AccountSendDetails=$('.js-login-details-button');Purple.vars.jq_LoginForm=$('#js-login-form');Purple.vars.jq_SubscribeLink=$('.js-newsletter-link');Purple.vars.jq_SubscribeButton=$('.js-newsletter-subscribe-button');Purple.vars.jq_NewsletterForm=$('#js-newsletter-form');Purple.vars.jq_NewsletterFormErrors=$('#js-newsletter-form .js-error');Purple.vars.facebook_user=null;Purple.vars.jq_LoginButtons=$('.js-login-button');var __subscriptionSuccess=function(data){if(typeof data.redirect_url!='undefined'){document.location.href=data.redirect_url;}}
$(".js-login-register-link").live('click',function(event){event.preventDefault();fetchLoginRegisterBox();});$(".js-login-link").live('click',function(event){event.preventDefault();fetchLoginRegisterBox(false);});Purple.vars.jq_LoginForm.live('submit',function(ev){ev.preventDefault();var This=$(this);var jq_Error=This.find('.global-error').hide();var jq_Success=This.find('.global-success').hide();Evisua.makeRequest({url:'/auth/login-user/',form:This,handler:function(success,data){if(success){jq_Success.fadeIn('fast',function(){setTimeout(function(){document.location.href=document.location.href;},800);});}else{jq_Error.fadeIn('fast');}}});return false;});Purple.vars.jq_LoginButtons.live('click',function(ev){ev.preventDefault();ev.target.blur();$('#js-login-form').submit();});Purple.vars.mag.jq_SubscribeLink.live('click',function(ev){ev.preventDefault();Evisua.makeRequest({url:'/subscriptions/prepare-subscription/',postData:{magazine_id:Purple.vars.mag.int_MagazineId},handler:function(success,data){if(success){__subscriptionSuccess(data);}}});});Purple.vars.jq_RemindLink.live('click',function(ev){ev.preventDefault();ev.target.blur();$.fancybox.close();setTimeout(function(){Evisua.makeRequest({url:'/auth/fetch-reminder/',handler:function(success,data){if(success){$.fancybox(data.html,{titleShow:false});}}});},1000);});Purple.vars.jq_AccountSendDetails.live('click',function(ev){ev.preventDefault();ev.target.blur();var This=$(this);var jq_FormToSend=This.findParent('#reminder_popup').find('form');var jq_Error=jq_FormToSend.find('.global-error').hide();var jq_Success=jq_FormToSend.find('.global-success').hide();jq_FormToSend.submit(function(ev){ev.preventDefault();return false;})
Evisua.makeRequest({url:'/auth/send-reminding-email/',form:jq_FormToSend,handler:function(success,data){if(!success){jq_Error.show()}else{jq_Success.show();setTimeout(function(){$.fancybox.close();},2000);}}})});try{Purple.vars.jq_SubscribeLink.each(function(){var This=$(this);This.fancybox({href:'/subscriptions/newsletter-popup/',type:'ajax',titleShow:false,onComplete:function(){}});});}catch(exc){if(typeof window.console!='undefined')
console.log(exc);}
Purple.vars.jq_SubscribeButton.live('click',function(ev){ev.preventDefault();ev.target.blur();var This=$(this);$('#js-newsletter-form').submit();});Purple.vars.jq_NewsletterForm.live('submit',function(ev){ev.preventDefault();var This=$(this);var jq_Error=This.find('.global-error').hide();var jq_Success=This.find('.global-success').hide();This.find('.js-error').hide();var str_ActionUrl=This.attr('action');Evisua.makeRequest({url:str_ActionUrl,form:This,handler:function(success,data){if(success){jq_Success.hideAfterFade({callback:function(){$.fancybox.close();}});}else{var str_error;if(data!=''){str_error=data;}else{str_error='Given details are incorrect';}
jq_Error.html(str_error);jq_Error.hideAfterFade();if(typeof data.errors!='undefined'){var er=data.errors;for(var name in data.errors){var fieldError=undefined;try{fieldError=This.find('input[name*='+name+']').findParent('.form-item').find('.js-error');}catch(exception){fieldError=undefined;}
if(typeof fieldError!='undefined'){fieldError.html(er[name]).fadeIn('fast');}}}}}});return false;});try{$('a#magazine-cover, #lets_get_the_mag a[href="/magazine/preview"], #magazine-supplement-cover').live('click',function(event){if(!DataBridge.user_authenticated||(DataBridge.user_authenticated&&!DataBridge.has_subscription)){event.preventDefault();event.target.blur();fetchLoginRegisterBox();}}).filter('a#magazine-cover,a#magazine-supplement-cover').tooltip({track:true,delay:0,extraClass:"lvl_1_tip",id:'tooltip',bodyHandler:function(){return'Click to read';},top:20,left:8,showURL:false});}catch(exc){}
$('.js-register-button').live('click',function(ev){ev.preventDefault();ev.target.blur();$('#js-register-form').submit();});$('#js-register-form').live('submit',function(ev){ev.preventDefault();var This=$(this);This.find('.js-error').hide();Evisua.makeRequest({url:'/auth/basicregisterandlogin/',form:This,handler:function(success,data){if(success){This.find('.global-success').show();setTimeout(function(){if(typeof(DataBridge.magazine)!='undefined'){document.location.href='/magazine/'+DataBridge.magazine.urlname+'/';}
else{document.location.href=document.location.href;}},500);}else{This.find('.global-error').show();for(var index in data.errors){This.find('input[name*="'+index+'"]').findParent('.form-item').find('.js-error').html(data.errors[index]).show();}}}});return false;});var
pages_container=$("#mag"),article_container=$('div#article_container'),mag_li=$('#mag li'),mag_li_div=$('#mag li div'),contents_but=$('a#contents_but'),contents_list=$('#contents_list'),fancy_wrap=$('#fancybox-wrap');$('html:not(#contents_list)').click(function(event){if(event.target!=contents_but.get(0)&&contents_but.hasClass('clicked')){contents_list.hide();contents_but.removeClass('clicked');}});contents_but.click(function(event){event.preventDefault();if($(this).next(contents_list).is(':visible')){$(this).removeClass('clicked').next().hide();}
else{$(this).addClass('clicked').next().css('display','block');}});contents_list.children().hover(function(){$(this).siblings().stop().fadeTo(150,0.5);},function(){$(this).siblings().stop().fadeTo(150,1);});contents_list.find('ul').children().hover(function(){$(this).siblings().stop().fadeTo(150,0.5);},function(){$(this).siblings().stop().fadeTo(150,1);});contents_list.find('> li > a').click(function(event){event.preventDefault();var parent=$(this).parent();var children=parent.find('li');if(children.length>1){if(!parent.hasClass('opened')){parent.addClass('opened');parent.siblings().find('ul').slideUp();parent.find('ul').slideDown();return false;}
else{var parent=$(this).parent();parent.find('ul').slideUp();parent.removeClass('opened');}}
else{if(!is_magazine&&!parent.hasClass('unavailable')){link=children.find('a:first');document.location=link.attr('href');}}});$('#close_news').click(function(event){$(this).parent().fadeOut('slow');return false;});try{$('marquee').marquee('pointer').mouseover(function(){$(this).trigger('stop');}).mouseout(function(){$(this).trigger('start');}).mousemove(function(event){if($(this).data('drag')==true){this.scrollLeft=$(this).data('scrollX')+($(this).data('x')-event.clientX);}}).mousedown(function(event){$(this).data('drag',true).data('x',event.clientX).data('scrollX',this.scrollLeft);}).mouseup(function(){$(this).data('drag',false);});}catch(exc){}
var coming_soon=$('.coming_soon');coming_soon.each(function(index){var thisWidth=$(this).outerWidth(true),originalText=$(this).text();$(this).css({'width':thisWidth,'display':'inline-block','text-align':'center'}).attr('data-text',originalText);coming_soon.hover(function(){$(this).text('coming soon');},function(){$(this).text(originalText);});});coming_soon.live('click',function(){return false;});$('.boutique-add-to-fav').live('click',function(event){event.preventDefault();var $This=$(this);var product_id=$This.attr('data-id');FB.getLoginStatus(function(response){if(response.authResponse){FB.api('/me',function(response){FB.api('/me/'+DataBridge.fb_app_name+':boutique_favourite','post',{boutique_product:$This.attr('data-url')},function(response){var facebook_event_id=response.id||null;addBtqProductToFav($This,product_id,facebook_event_id);});});}else{addBtqProductToFav($This,product_id);}});});function addBtqProductToFav($trigger,product_id,facebook_event_id){Evisua.makeRequest({url:'/boutique/home/ajax-add-to-favorites/',postData:{product_id:product_id,facebook_event_id:facebook_event_id},handler:function(success,data){if(success){$trigger.removeClass('boutique-add-to-fav').addClass('boutique-remove-from-fav').addClass('added');}}});}
$('.boutique-remove-from-fav').live('click',function(event){event.preventDefault();$This=$(this);Evisua.makeRequest({url:'/boutique/home/ajax-remove-from-favorites/',postData:{product_id:$This.attr('data-id')},handler:function(success,data){if(success){$This.removeClass('boutique-remove-from-fav').removeClass('added').addClass('boutique-add-to-fav');if(data.facebook_event_id!==null){FB.getLoginStatus(function(response){if(response.authResponse){FB.api('/me',function(response){FB.api(data.facebook_event_id,'delete',function(response){});});}else{}});}}}});});$('.switch_link').live('click',function(){$(this).parents('.switch_content').hide();$(this).parents('.switch_content').siblings('.switch_content').show();return false;});$(".login-by-facebook").live('click',function(event){event.preventDefault();FB.getLoginStatus(function(response){if(response.authResponse){FB.api('/me',function(response){loginUser(response);});}else{FB.login(function(response){if(response.authResponse){console.log('Welcome!  Fetching your information.... ');FB.api('/me',function(response){loginUser(response);});}else{console.log('User cancelled login or did not fully authorize.');}},{scope:'publish_stream, email'});}});});function loginUser(user_data){Evisua.makeRequest({url:'/auth/isuserconnectedwithfacebook',postData:{user:user_data},handler:function(success,data){if(!data.is_connected){Purple.vars.facebook_user=user_data;$.fancybox(data.login_prompt,{titleShow:false});}
else{loginRegisterUser(user_data);}}});}
$('#set_new_user_login').live('submit',function(event){event.preventDefault();$this=$(this);$this.find('.error').hide();Evisua.makeRequest({url:'/auth/validatenewlogin',form:$this,handler:function(success,data){if(success){additional_data={login:$this.find('input[name="login[login]"]').val()};var user_data=$.extend(Purple.vars.facebook_user,additional_data);console.log(additional_data);console.log(user_data);loginRegisterUser(user_data);}
else{$.each(data.errors,function(index,error){$this.find('input[name="login['+index+']"]').nextAll('.error:eq(0)').html(error).fadeIn();});}}});});function loginRegisterUser(user_data){Evisua.makeRequest({url:'/auth/facebookloginregister',postData:{'user':user_data},handler:function(success,response){if(success){document.location=document.location;}}});}
function fetchLoginRegisterBox(with_type){if(typeof(with_type)=='undefined'){with_type=true;}
if(with_type){post_data={type:$('body').attr('id')};}
else{post_data=null;}
Evisua.makeRequest({url:'/auth/fetch-login-register',postData:post_data,handler:function(success,data){var $html=$(data.html);if(DataBridge.user_authenticated){$html.find('#loggedout').hide();$html.find('#loggedin').show();}
var $wrapper=$('<div />');$wrapper.html($html);$.fancybox($wrapper.html(),{titleShow:false});}});}});})(jQuery);jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d);},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b;},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b;}});(function($){var undef,window=this,doc=window.document,$doc=$(doc),DEBUG=false,NAV=navigator.userAgent.toLowerCase(),HASH=window.location.hash.replace(/#\//,''),CLICK=function(){return Galleria.TOUCH?'touchstart':'click';},IE=(function(){var v=3,div=doc.createElement('div'),all=div.getElementsByTagName('i');do{div.innerHTML='<!--[if gt IE '+(++v)+']><i></i><![endif]-->';}while(all[0]);return v>4?v:undef;}()),DOM=function(){return{html:doc.documentElement,body:doc.body,head:doc.getElementsByTagName('head')[0],title:doc.title};},_eventlist='data ready thumbnail loadstart loadfinish image play pause progress '+'fullscreen_enter fullscreen_exit idle_enter idle_exit rescale '+'lightbox_open lightbox_close lightbox_image',_events=(function(){var evs=[];$.each(_eventlist.split(' '),function(i,ev){evs.push(ev);if(/_/.test(ev)){evs.push(ev.replace(/_/g,''));}});return evs;}()),_legacyOptions=function(options){var n;if(typeof options!=='object'){return options;}
$.each(options,function(key,value){if(/^[a-z]+_/.test(key)){n='';$.each(key.split('_'),function(i,k){n+=i>0?k.substr(0,1).toUpperCase()+k.substr(1):k;});options[n]=value;delete options[key];}});return options;},_patchEvent=function(type){if($.inArray(type,_events)>-1){return Galleria[type.toUpperCase()];}
return type;},_timeouts={trunk:{},add:function(id,fn,delay,loop){loop=loop||false;this.clear(id);if(loop){var old=fn;fn=function(){old();_timeouts.add(id,fn,delay);};}
this.trunk[id]=window.setTimeout(fn,delay);},clear:function(id){var del=function(i){window.clearTimeout(this.trunk[i]);delete this.trunk[i];},i;if(!!id&&id in this.trunk){del.call(_timeouts,id);}else if(typeof id==='undefined'){for(i in this.trunk){if(this.trunk.hasOwnProperty(i)){del.call(_timeouts,i);}}}}},_galleries=[],Utils=(function(){return{array:function(obj){return Array.prototype.slice.call(obj);},create:function(className,nodeName){nodeName=nodeName||'div';var elem=doc.createElement(nodeName);elem.className=className;return elem;},forceStyles:function(elem,styles){elem=$(elem);if(elem.attr('style')){elem.data('styles',elem.attr('style')).removeAttr('style');}
elem.css(styles);},revertStyles:function(){$.each(Utils.array(arguments),function(i,elem){elem=$(elem).removeAttr('style');if(elem.data('styles')){elem.attr('style',elem.data('styles')).data('styles',null);}});},moveOut:function(elem){Utils.forceStyles(elem,{position:'absolute',left:-10000});},moveIn:function(){Utils.revertStyles.apply(Utils,Utils.array(arguments));},hide:function(elem,speed,callback){elem=$(elem);if(!elem.data('opacity')){elem.data('opacity',elem.css('opacity'));}
var style={opacity:0};if(speed){elem.stop().animate(style,speed,callback);}else{elem.css(style);}},show:function(elem,speed,callback){elem=$(elem);var saved=parseFloat(elem.data('opacity'))||1,style={opacity:saved};if(speed){elem.stop().animate(style,speed,callback);}else{elem.css(style);}},addTimer:function(){_timeouts.add.apply(_timeouts,Utils.array(arguments));return this;},clearTimer:function(){_timeouts.clear.apply(_timeouts,Utils.array(arguments));return this;},wait:function(options){options=$.extend({until:function(){return false;},success:function(){},error:function(){Galleria.raise('Could not complete wait function.');},timeout:3000},options);var start=Utils.timestamp(),elapsed,now,fn=function(){now=Utils.timestamp();elapsed=now-start;if(options.until(elapsed)){options.success();return false;}
if(now>=start+options.timeout){options.error();return false;}
window.setTimeout(fn,2);};window.setTimeout(fn,2);},toggleQuality:function(img,force){if((IE!==7&&IE!==8)||!img){return;}
if(typeof force==='undefined'){force=img.style.msInterpolationMode==='nearest-neighbor';}
img.style.msInterpolationMode=force?'bicubic':'nearest-neighbor';},insertStyleTag:function(styles){var style=doc.createElement('style');DOM().head.appendChild(style);if(style.styleSheet){style.styleSheet.cssText=styles;}else{var cssText=doc.createTextNode(styles);style.appendChild(cssText);}},loadScript:function(url,callback){var done=false,script=$('<scr'+'ipt>').attr({src:url,async:true}).get(0);script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState==='loaded'||this.readyState==='complete')){done=true;script.onload=script.onreadystatechange=null;if(typeof callback==='function'){callback.call(this,this);}}};DOM().head.appendChild(script);},parseValue:function(val){if(typeof val==='number'){return val;}else if(typeof val==='string'){var arr=val.match(/\-?\d/g);return arr&&arr.constructor===Array?parseInt(arr.join(''),10):0;}else{return 0;}},timestamp:function(){return new Date().getTime();},loadCSS:function(href,id,callback){var link,ready=false,length;$('link[rel=stylesheet]').each(function(){if(new RegExp(href).test(this.href)){link=this;return false;}});if(typeof id==='function'){callback=id;id=undef;}
callback=callback||function(){};if(link){callback.call(link,link);return link;}
length=doc.styleSheets.length;if(DEBUG){href+='?'+Utils.timestamp();}
if($('#'+id).length){$('#'+id).attr('href',href);length--;ready=true;}else{link=$('<link>').attr({rel:'stylesheet',href:href,id:id}).get(0);window.setTimeout(function(){var styles=$('link[rel="stylesheet"], style');if(styles.length){styles.get(0).parentNode.insertBefore(link,styles[0]);}else{DOM().head.appendChild(link);}
if(IE){link.attachEvent('onreadystatechange',function(e){if(link.readyState==='complete'){ready=true;}});}else{ready=true;}},10);}
if(typeof callback==='function'){Utils.wait({until:function(){return ready&&doc.styleSheets.length>length;},success:function(){Utils.addTimer('css',function(){callback.call(link,link);},100);},error:function(){Galleria.raise('Theme CSS could not load');},timeout:10000});}
return link;}};}()),_transitions={fade:function(params,complete){$(params.next).css('opacity',0).show().animate({opacity:1},params.speed,complete);if(params.prev){$(params.prev).css('opacity',1).show().animate({opacity:0},params.speed);}},flash:function(params,complete){$(params.next).css('opacity',0);if(params.prev){$(params.prev).animate({opacity:0},(params.speed/2),function(){$(params.next).animate({opacity:1},params.speed,complete);});}else{$(params.next).animate({opacity:1},params.speed,complete);}},pulse:function(params,complete){if(params.prev){$(params.prev).hide();}
$(params.next).css('opacity',0).animate({opacity:1},params.speed,complete);},slide:function(params,complete){var image=$(params.next).parent(),images=this.$('images'),width=this._stageWidth,easing=this.getOptions('easing');image.css({left:width*(params.rewind?-1:1)});images.animate({left:width*(params.rewind?1:-1)},{duration:params.speed,queue:false,easing:easing,complete:function(){images.css('left',0);image.css('left',0);complete();}});},fadeslide:function(params,complete){var x=0,easing=this.getOptions('easing'),distance=this.getStageWidth();if(params.prev){x=Utils.parseValue($(params.prev).css('left'));$(params.prev).css({opacity:1,left:x}).animate({opacity:0,left:x+(distance*(params.rewind?1:-1))},{duration:params.speed,queue:false,easing:easing});}
x=Utils.parseValue($(params.next).css('left'));$(params.next).css({left:x+(distance*(params.rewind?-1:1)),opacity:0}).animate({opacity:1,left:x},{duration:params.speed,complete:complete,queue:false,easing:easing});}};var Consts=Consts||{};Consts.FOOTER_OFFSET_IN_PIXELS=31;var Galleria=function(){var self=this;this.__scaleFactor=null;this.setPictureResizingWithWindow=function(){var fullArticleHeight=function(){var
windowHeight=$(window).height(),galleriaOffset=$('div.gallery').offset(),galleriaHeight=windowHeight-galleriaOffset.top-Consts.FOOTER_OFFSET_IN_PIXELS;$('#container.gallery_post article').css('height',windowHeight+'px');$('div.gallery').css('height',galleriaHeight+'px');}
fullArticleHeight();}
this._theme=undef;this._options={};this._playing=false;this._playtime=5000;this._active=null;this._queue={length:0};this._data=[];this._dom={};this._thumbnails=[];this._initialized=false;this._stageWidth=0;this._stageHeight=0;this._target=undef;this._id=Math.random();var divs='container stage images image-nav image-nav-left image-nav-right '+'info info-text info-title info-description '+'thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right '+'loader counter tooltip',spans='current total';$.each(divs.split(' '),function(i,elemId){self._dom[elemId]=Utils.create('galleria-'+elemId);});$.each(spans.split(' '),function(i,elemId){self._dom[elemId]=Utils.create('galleria-'+elemId,'span');});var keyboard=this._keyboard={keys:{'UP':38,'DOWN':40,'LEFT':37,'RIGHT':39,'RETURN':13,'ESCAPE':27,'BACKSPACE':8,'SPACE':32},map:{},bound:false,press:function(e){var key=e.keyCode||e.which;if(key in keyboard.map&&typeof keyboard.map[key]==='function'){keyboard.map[key].call(self,e);}},attach:function(map){var key,up;for(key in map){if(map.hasOwnProperty(key)){up=key.toUpperCase();if(up in keyboard.keys){keyboard.map[keyboard.keys[up]]=map[key];}else{keyboard.map[up]=map[key];}}}
if(!keyboard.bound){keyboard.bound=true;$doc.bind('keydown',keyboard.press);}},detach:function(){keyboard.bound=false;keyboard.map={};$doc.unbind('keydown',keyboard.press);}};var controls=this._controls={0:undef,1:undef,active:0,swap:function(){controls.active=controls.active?0:1;},getActive:function(){return controls[controls.active];},getNext:function(){return controls[1-controls.active];}};var carousel=this._carousel={next:self.$('thumb-nav-right'),prev:self.$('thumb-nav-left'),width:0,current:0,max:0,hooks:[],update:function(){var w=0,h=0,hooks=[0];$.each(self._thumbnails,function(i,thumb){if(thumb.ready){w+=thumb.outerWidth||$(thumb.container).outerWidth(true);hooks[i+1]=w;h=Math.max(h,thumb.outerHeight||$(thumb.container).outerHeight(true));}});self.$('thumbnails').css({width:w,height:h});carousel.max=w;carousel.hooks=hooks;carousel.width=self.$('thumbnails-list').width();carousel.setClasses();self.$('thumbnails-container').toggleClass('galleria-carousel',w>carousel.width);carousel.width=self.$('thumbnails-list').width();},bindControls:function(){var i;carousel.next.bind(CLICK(),function(e){e.preventDefault();if(self._options.carouselSteps==='auto'){for(i=carousel.current;i<carousel.hooks.length;i++){if(carousel.hooks[i]-carousel.hooks[carousel.current]>carousel.width){carousel.set(i-2);break;}}}else{carousel.set(carousel.current+self._options.carouselSteps);}});carousel.prev.bind(CLICK(),function(e){e.preventDefault();if(self._options.carouselSteps==='auto'){for(i=carousel.current;i>=0;i--){if(carousel.hooks[carousel.current]-carousel.hooks[i]>carousel.width){carousel.set(i+2);break;}else if(i===0){carousel.set(0);break;}}}else{carousel.set(carousel.current-self._options.carouselSteps);}});},set:function(i){i=Math.max(i,0);while(carousel.hooks[i-1]+carousel.width>=carousel.max&&i>=0){i--;}
carousel.current=i;carousel.animate();},getLast:function(i){return(i||carousel.current)-1;},follow:function(i){if(i===0||i===carousel.hooks.length-2){carousel.set(i);return;}
var last=carousel.current;while(carousel.hooks[last]-carousel.hooks[carousel.current]<carousel.width&&last<=carousel.hooks.length){last++;}
if(i-1<carousel.current){carousel.set(i-1);}else if(i+2>last){carousel.set(i-last+carousel.current+2);}},setClasses:function(){carousel.prev.toggleClass('disabled',!carousel.current);carousel.next.toggleClass('disabled',carousel.hooks[carousel.current]+carousel.width>=carousel.max);},animate:function(to){carousel.setClasses();var num=carousel.hooks[carousel.current]*-1;if(isNaN(num)){return;}
self.$('thumbnails').animate({left:num},{duration:self._options.carouselSpeed,easing:self._options.easing,queue:false});}};var tooltip=this._tooltip={initialized:false,open:false,init:function(){tooltip.initialized=true;var css='.galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3'+'opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}';Utils.insertStyleTag(css);self.$('tooltip').css('opacity',0.8);Utils.hide(self.get('tooltip'));},move:function(e){var mouseX=self.getMousePosition(e).x,mouseY=self.getMousePosition(e).y,$elem=self.$('tooltip'),x=mouseX,y=mouseY,height=$elem.outerHeight(true)+1,width=$elem.outerWidth(true),limitY=height+15;var maxX=self.$('container').width()-width-2,maxY=self.$('container').height()-height-2;if(!isNaN(x)&&!isNaN(y)){x+=10;y-=30;x=Math.max(0,Math.min(maxX,x));y=Math.max(0,Math.min(maxY,y));if(mouseY<limitY){y=limitY;}
$elem.css({left:x,top:y});}},bind:function(elem,value){if(!tooltip.initialized){tooltip.init();}
var hover=function(elem,value){tooltip.define(elem,value);$(elem).hover(function(){Utils.clearTimer('switch_tooltip');self.$('container').unbind('mousemove',tooltip.move).bind('mousemove',tooltip.move).trigger('mousemove');tooltip.show(elem);Galleria.utils.addTimer('tooltip',function(){self.$('tooltip').stop().show();Utils.show(self.get('tooltip'),400);tooltip.open=true;},tooltip.open?0:500);},function(){self.$('container').unbind('mousemove',tooltip.move);Utils.clearTimer('tooltip');self.$('tooltip').stop();Utils.hide(self.get('tooltip'),200,function(){self.$('tooltip').hide();Utils.addTimer('switch_tooltip',function(){tooltip.open=false;},1000);});});};if(typeof value==='string'){hover((elem in self._dom?self.get(elem):elem),value);}else{$.each(elem,function(elemID,val){hover(self.get(elemID),val);});}},show:function(elem){elem=$(elem in self._dom?self.get(elem):elem);var text=elem.data('tt'),mouseup=function(e){window.setTimeout((function(ev){return function(){tooltip.move(ev);};}(e)),10);elem.unbind('mouseup',mouseup);};text=typeof text==='function'?text():text;if(!text){return;}
self.$('tooltip').html(text.replace(/\s/,'&nbsp;'));elem.bind('mouseup',mouseup);},define:function(elem,value){if(typeof value!=='function'){var s=value;value=function(){return s;};}
elem=$(elem in self._dom?self.get(elem):elem).data('tt',value);tooltip.show(elem);}};var fullscreen=this._fullscreen={scrolled:0,active:false,keymap:self._keyboard.map,enter:function(callback){fullscreen.active=true;Utils.hide(self.getActiveImage());self.$('container').addClass('fullscreen');fullscreen.scrolled=$(window).scrollTop();var titleHeight=$('#container.gallery_post article h2.title').outerHeight(true);$(window).resize(function(){titleHeight=$('#container.gallery_post article h2.title').outerHeight(true);Utils.forceStyles(self.get('container'),{position:'fixed',top:titleHeight+'px',left:0,width:'100%',bottom:'30px',zIndex:1000});});Utils.forceStyles(self.get('container'),{position:'fixed',top:titleHeight+'px',left:0,width:'100%',bottom:'30px',zIndex:1000});var htmlbody={height:'100%',overflow:'hidden',margin:0,padding:0},data=self.getData();Utils.forceStyles(DOM().html,htmlbody);Utils.forceStyles(DOM().body,htmlbody);fullscreen.keymap=$.extend({},self._keyboard.map);self.attachKeyboard({escape:self.exitFullscreen,right:self.next,left:self.prev});if(data&&data.big&&data.image!==data.big){var big=new Galleria.Picture(),cached=big.isCached(data.big),index=self.getIndex(),thumb=self._thumbnails[index]
self.trigger({type:Galleria.LOADSTART,cached:cached,index:index,imageTarget:self.getActiveImage(),thumbTarget:thumb});big.load(data.big,function(big){self._scaleImage(big,{complete:function(big){self.trigger({type:Galleria.LOADFINISH,cached:cached,index:index,imageTarget:big.image,thumbTarget:thumb});var image=self._controls.getActive().image;if(image){$(image).width(big.image.width).height(big.image.height).attr('style',$(big.image).attr('style')).attr('src',big.image.src);}}});});}
self.rescale(function(){Utils.addTimer('fullscreen_enter',function(){Utils.show(self.getActiveImage());if(typeof callback==='function'){callback.call(self);}},100);self.trigger(Galleria.FULLSCREEN_ENTER);});$(window).resize(function(){fullscreen.scale();});},scale:function(){self.rescale();},exit:function(callback){fullscreen.active=false;Utils.hide(self.getActiveImage());self.$('container').removeClass('fullscreen');Utils.revertStyles(self.get('container'),DOM().html,DOM().body);window.scrollTo(0,fullscreen.scrolled);self.detachKeyboard();self.attachKeyboard(fullscreen.keymap);self.rescale(function(){Utils.addTimer('fullscreen_exit',function(){Utils.show(self.getActiveImage());if(typeof callback==='function'){callback.call(self);}},50);self.trigger(Galleria.FULLSCREEN_EXIT);});$(window).unbind('resize',fullscreen.scale);}};var idle=this._idle={trunk:[],bound:false,add:function(elem,to){if(!elem){return;}
if(!idle.bound){idle.addEvent();}
elem=$(elem);var from={},style;for(style in to){if(to.hasOwnProperty(style)){from[style]=elem.css(style);}}
elem.data('idle',{from:from,to:to,complete:true,busy:false});idle.addTimer();idle.trunk.push(elem);},remove:function(elem){elem=jQuery(elem);$.each(idle.trunk,function(i,el){if(el.length&&!el.not(elem).length){self._idle.show(elem);self._idle.trunk.splice(i,1);}});if(!idle.trunk.length){idle.removeEvent();Utils.clearTimer('idle');}},addEvent:function(){idle.bound=true;self.$('container').bind('mousemove click',idle.showAll);},removeEvent:function(){idle.bound=false;self.$('container').unbind('mousemove click',idle.showAll);},addTimer:function(){Utils.addTimer('idle',function(){self._idle.hide();},self._options.idleTime);},hide:function(){self.trigger(Galleria.IDLE_ENTER);$.each(idle.trunk,function(i,elem){var data=elem.data('idle');if(!data){return;}
elem.data('idle').complete=false;elem.stop().animate(data.to,{duration:self._options.idleSpeed,queue:false,easing:'swing'});});},showAll:function(){Utils.clearTimer('idle');$.each(self._idle.trunk,function(i,elem){self._idle.show(elem);});},show:function(elem){var data=elem.data('idle');if(!data.busy&&!data.complete){data.busy=true;self.trigger(Galleria.IDLE_EXIT);Utils.clearTimer('idle');elem.stop().animate(data.from,{duration:self._options.idleSpeed/2,queue:false,easing:'swing',complete:function(){$(this).data('idle').busy=false;$(this).data('idle').complete=true;}});}
idle.addTimer();}};var lightbox=this._lightbox={width:0,height:0,initialized:false,active:null,image:null,elems:{},init:function(){self.trigger(Galleria.LIGHTBOX_OPEN);if(lightbox.initialized){return;}
lightbox.initialized=true;var elems='overlay box content shadow title info close prevholder prev nextholder next counter image',el={},op=self._options,css='',abs='position:absolute;',prefix='lightbox-',cssMap={overlay:'position:fixed;display:none;opacity:'+op.overlayOpacity+';filter:alpha(opacity='+(op.overlayOpacity*100)+');top:0;left:0;width:100%;height:100%;background:'+op.overlayBackground+';z-index:99990',box:'position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991',shadow:abs+'background:#000;width:100%;height:100%;',content:abs+'background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden',info:abs+'bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px',close:abs+'top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999',image:abs+'top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;',prevholder:abs+'width:50%;top:0;bottom:40px;cursor:pointer;',nextholder:abs+'width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;',prev:abs+'top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif',next:abs+'top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000',title:'float:left',counter:'float:right;margin-left:8px;'},hover=function(elem){return elem.hover(function(){$(this).css('color','#bbb');},function(){$(this).css('color','#444');});},appends={};if(IE===8){cssMap.nextholder+='background:#000;filter:alpha(opacity=0);';cssMap.prevholder+='background:#000;filter:alpha(opacity=0);';}
$.each(cssMap,function(key,value){css+='.galleria-'+prefix+key+'{'+value+'}';});Utils.insertStyleTag(css);$.each(elems.split(' '),function(i,elemId){self.addElement('lightbox-'+elemId);el[elemId]=lightbox.elems[elemId]=self.get('lightbox-'+elemId);});lightbox.image=new Galleria.Picture();$.each({box:'shadow content close prevholder nextholder',info:'title counter',content:'info image',prevholder:'prev',nextholder:'next'},function(key,val){var arr=[];$.each(val.split(' '),function(i,prop){arr.push(prefix+prop);});appends[prefix+key]=arr;});self.append(appends);$(el.image).append(lightbox.image.container);$(DOM().body).append(el.overlay,el.box);hover($(el.close).bind(CLICK(),lightbox.hide).html('&#215;'));$.each(['Prev','Next'],function(i,dir){var $d=$(el[dir.toLowerCase()]).html(/v/.test(dir)?'&#8249;&nbsp;':'&nbsp;&#8250;'),$e=$(el[dir.toLowerCase()+'holder']);$e.bind(CLICK(),function(){lightbox['show'+dir]();});if(IE<8){$d.show();return;}
$e.hover(function(){$d.show();},function(e){$d.stop().fadeOut(200);});});$(el.overlay).bind(CLICK(),lightbox.hide);},rescale:function(event){var width=Math.min($(window).width()-40,lightbox.width),height=Math.min($(window).height()-60,lightbox.height),ratio=Math.min(width/lightbox.width,height/lightbox.height),destWidth=(lightbox.width*ratio)+40,destHeight=(lightbox.height*ratio)+60,to={width:destWidth,height:destHeight,marginTop:Math.ceil(destHeight/2)*-1,marginLeft:Math.ceil(destWidth/2)*-1};if(event){$(lightbox.elems.box).css(to);}else{$(lightbox.elems.box).animate(to,self._options.lightboxTransitionSpeed,self._options.easing,function(){var image=lightbox.image,speed=self._options.lightboxFadeSpeed;self.trigger({type:Galleria.LIGHTBOX_IMAGE,imageTarget:image.image});$(image.container).show();Utils.show(image.image,speed);Utils.show(lightbox.elems.info,speed);});}},hide:function(){lightbox.image.image=null;$(window).unbind('resize',lightbox.rescale);$(lightbox.elems.box).hide();Utils.hide(lightbox.elems.info);Utils.hide(lightbox.elems.overlay,200,function(){$(this).hide().css('opacity',self._options.overlayOpacity);self.trigger(Galleria.LIGHTBOX_CLOSE);});},showNext:function(){lightbox.show(self.getNext(lightbox.active));},showPrev:function(){lightbox.show(self.getPrev(lightbox.active));},show:function(index){lightbox.active=index=typeof index==='number'?index:self.getIndex();if(!lightbox.initialized){lightbox.init();}
$(window).unbind('resize',lightbox.rescale);var data=self.getData(index),total=self.getDataLength();Utils.hide(lightbox.elems.info);lightbox.image.load(data.image,function(image){lightbox.width=image.original.width;lightbox.height=image.original.height;$(image.image).css({width:'100.5%',height:'100.5%',top:0,zIndex:99998});Utils.hide(image.image);lightbox.elems.title.innerHTML=data.title;lightbox.elems.counter.innerHTML=(index+1)+' / '+total;$(window).resize(lightbox.rescale);lightbox.rescale();});$(lightbox.elems.overlay).show();$(lightbox.elems.box).show();}};return this;};Galleria.prototype={constructor:Galleria,init:function(target,options){var self=this;options=_legacyOptions(options);_galleries.push(this);this._original={target:target,options:options,data:null};this._target=this._dom.target=target.nodeName?target:$(target).get(0);if(!this._target){Galleria.raise('Target not found.');return;}
this._options={autoplay:false,carousel:true,carouselFollow:true,carouselSpeed:400,carouselSteps:'auto',clicknext:false,dataConfig:function(elem){return{}},dataSelector:'img',dataSource:this._target,debug:undef,easing:'galleria',extend:function(options){},height:'auto',idleTime:3000,idleSpeed:200,imageCrop:false,imageMargin:0,imagePan:false,imagePanSmoothness:12,imagePosition:'50%',keepSource:false,lightbox:false,lightboxFadeSpeed:200,lightboxTransitionSpeed:400,linkSourceTmages:true,maxScaleRatio:undef,minScaleRatio:undef,overlayOpacity:0.85,overlayBackground:'#0b0b0b',pauseOnInteraction:true,popupLinks:false,preload:2,queue:true,show:0,showInfo:true,showCounter:true,showImagenav:true,thumbCrop:true,thumbEventType:CLICK(),thumbFit:true,thumbMargin:0,thumbQuality:'auto',thumbnails:true,transition:'fade',transitionInitial:undef,transitionSpeed:400,width:'auto'};if(options&&options.debug===true){DEBUG=true;}
$(this._target).children().hide();if(typeof Galleria.theme==='object'){this._init();}else{Utils.wait({until:function(){return typeof Galleria.theme==='object';},success:function(){self._init.call(self);},error:function(){Galleria.raise('No theme found.',true);},timeout:5000});}},_init:function(){var self=this;if(this._initialized){Galleria.raise('Init failed: Gallery instance already initialized.');return this;}
this._initialized=true;if(!Galleria.theme){Galleria.raise('Init failed: No theme found.');return this;}
$.extend(true,this._options,Galleria.theme.defaults,this._original.options);this.bind(Galleria.DATA,function(){this._original.data=this._data;this.get('total').innerHTML=this.getDataLength();var $container=this.$('container');var num={width:0,height:0};var testElem=Utils.create('galleria-image');Utils.wait({until:function(){$.each(['width','height'],function(i,m){if(self._options[m]&&typeof self._options[m]==='number'){num[m]=self._options[m];}else{num[m]=Math.max(Utils.parseValue($container.css(m)),Utils.parseValue(self.$('target').css(m)),$container[m](),self.$('target')[m]());}});var thumbHeight=function(){return true;};if(self._options.thumbnails){self.$('thumbnails').append(testElem);thumbHeight=function(){return!!$(testElem).height();};}
return thumbHeight()&&num.width&&num.height>10;},success:function(){$(testElem).remove();$container.width(num.width);$container.height(num.height);if(Galleria.WEBKIT){window.setTimeout(function(){self._run();},1);}else{self._run();}},error:function(){Galleria.raise('Width & Height not found.',true);},timeout:2000});});var one=false;this.bind(Galleria.READY,(function(one){return function(){Utils.show(this.get('counter'));if(this._options.carousel){this._carousel.bindControls();}
if(this._options.autoplay){this.pause();if(typeof this._options.autoplay==='number'){this._playtime=this._options.autoplay;}
this.trigger(Galleria.PLAY);this._playing=true;}
if(one){if(typeof this._options.show==='number'){this.show(this._options.show);}
return;}
one=true;if(this._options.clicknext){$.each(this._data,function(i,data){delete data.link;});this.$('stage').css({cursor:'pointer'}).bind(CLICK(),function(e){if(self._options.pauseOnInteraction){self.pause();}
self.next();});}
if(Galleria.History){Galleria.History.change(function(e){var val=parseInt(e.value.replace(/\//,''),10);if(isNaN(val)){window.history.go(-1);}else{self.show(val,undef,true);}});}
Galleria.theme.init.call(this,this._options);this._options.extend.call(this,this._options);if(/^[0-9]{1,4}$/.test(HASH)&&Galleria.History){this.show(HASH,undef,true);}else if(this._data[this._options.show]){this.show(this._options.show);}};}(one)));this.append({'info-text':['info-title','info-description'],'info':['info-text'],'image-nav':['image-nav-right','image-nav-left'],'stage':['images','loader','counter','image-nav'],'thumbnails-list':['thumbnails'],'thumbnails-container':['thumb-nav-left','thumbnails-list','thumb-nav-right'],'container':['stage','thumbnails-container','info','tooltip']});Utils.hide(this.$('counter').append(this.get('current'),' / ',this.get('total')));this.setCounter('&#8211;');Utils.hide(self.get('tooltip'));$.each(new Array(2),function(i){var image=new Galleria.Picture();$(image.container).css({position:'absolute',top:0,left:0});self.$('images').append(image.container);self._controls[i]=image;});this.$('images').css({position:'relative',top:0,left:0,width:'100%',height:'100%'});this.$('thumbnails, thumbnails-list').css({overflow:'hidden',position:'relative'});this.$('image-nav-right, image-nav-left').bind(CLICK(),function(e){if(self._options.clicknext){e.stopPropagation();}
if(self._options.pauseOnInteraction){self.pause();}
var fn=/right/.test(this.className)?'next':'prev';self[fn]();});$.each(['info','counter','image-nav'],function(i,el){if(self._options['show'+el.substr(0,1).toUpperCase()+el.substr(1).replace(/-/,'')]===false){Utils.moveOut(self.get(el.toLowerCase()));}});this.load();if(!this._options.keep_source&&!IE){this._target.innerHTML='';}
this.$('target').append(this.get('container'));if(this._options.carousel){this.bind(Galleria.THUMBNAIL,function(){this.updateCarousel();});}
return this;},_createThumbnails:function(){this.get('total').innerHTML=this.getDataLength();var i,src,thumb,data,creator=null,$container,self=this,o=this._options,active=(function(){var a=self.$('thumbnails').find('.active');if(!a.length){return false;}
return a.find('img').attr('src');}()),optval=typeof o.thumbnails==='string'?o.thumbnails.toLowerCase():null,getStyle=function(prop){return doc.defaultView&&doc.defaultView.getComputedStyle?doc.defaultView.getComputedStyle(thumb.container,null)[prop]:$container.css(prop);},fake=function(image,index,container){return function(){$(container).append(image);self.trigger({type:Galleria.THUMBNAIL,thumbTarget:image,index:index});};},onThumbEvent=function(e){if(o.pauseOnInteraction){self.pause();}
var index=$(e.currentTarget).data('index');if(self.getIndex()!==index){self.show(index);}
e.preventDefault();},onThumbLoad=function(thumb){thumb.scale({width:thumb.data.width,height:thumb.data.height,crop:o.thumbCrop,margin:o.thumbMargin,complete:function(thumb){var top=['left','top'],arr=['Width','Height'],m,css;$.each(arr,function(i,measure){m=measure.toLowerCase();if((o.thumbCrop!==true||o.thumbCrop===m)&&o.thumbFit){css={};css[m]=thumb[m];$(thumb.container).css(css);css={};css[top[i]]=0;$(thumb.image).css(css);}
thumb['outer'+measure]=$(thumb.container)['outer'+measure](true);});Utils.toggleQuality(thumb.image,o.thumbQuality===true||(o.thumbQuality==='auto'&&thumb.original.width<thumb.width*3));self.trigger({type:Galleria.THUMBNAIL,thumbTarget:thumb.image,index:thumb.data.order});}});};this._thumbnails=[];this.$('thumbnails').empty();for(i=0;this._data[i];i++){data=this._data[i];if(typeof this._original.options.authorNameAttribute!='undefined'){var attr=this._original.options.authorNameAttribute;creator=$(data.original).attr(attr);}
if(o.thumbnails===true){thumb=new Galleria.Picture(i);src=data.thumb||data.image;this.$('thumbnails').append(thumb.container);$container=$(thumb.container);thumb.data={width:Utils.parseValue(getStyle('width')),height:Utils.parseValue(getStyle('height')),order:i,creator:creator};if(o.thumbFit&&o.thumbCrop!==true){$container.css({width:0,height:0});}else{$container.css({width:thumb.data.width,height:thumb.data.height});}
thumb.load(src,onThumbLoad);if(o.preload==='all'){thumb.add(data.image);}}else if(optval==='empty'||optval==='numbers'){thumb={container:Utils.create('galleria-image'),image:Utils.create('img','span'),ready:true};if(optval==='numbers'){$(thumb.image).text(i+1);}
this.$('thumbnails').append(thumb.container);window.setTimeout((fake)(thumb.image,i,thumb.container),50+(i*20));}else{thumb={container:null,image:null};}
$(thumb.container).add(o.keepSource&&o.linkSourceImages?data.original:null).data('index',i).bind(o.thumbEventType,onThumbEvent);if(active===src){$(thumb.container).addClass('active');}
this._thumbnails.push(thumb);}},_run:function(){var self=this;self._createThumbnails();Utils.wait({until:function(){if(Galleria.OPERA){self.$('stage').css('display','inline-block');}
self._stageWidth=self.$('stage').width();self._stageHeight=self.$('stage').height();return(self._stageWidth&&self._stageHeight>50);},success:function(){self.trigger(Galleria.READY);},error:function(){Galleria.raise('Stage measures not found',true);}});},load:function(source,selector,config){var self=this;this._data=[];this._thumbnails=[];this.$('thumbnails').empty();if(typeof selector==='function'){config=selector;selector=null;}
source=source||this._options.dataSource;selector=selector||this._options.dataSelector;config=config||this._options.dataConfig;if(source.constructor===Array){if(this.validate(source)){this._data=source;this._parseData().trigger(Galleria.DATA);}else{Galleria.raise('Load failed: JSON Array not valid.');}
return this;}
$(source).find(selector).each(function(i,img){img=$(img);var data={},parent=img.parent(),href=parent.attr('href');if(/\.(png|gif|jpg|jpeg)(\?.*)?$/i.test(href)){data.image=data.big=href;}else if(href){data.link=href;}
self._data.push($.extend({title:img.attr('title'),thumb:img.attr('src'),image:img.attr('src'),big:img.attr('src'),description:img.attr('data-caption'),link:img.attr('longdesc'),original:img.get(0)},data,config(img)));});if(this.getDataLength()){this.trigger(Galleria.DATA);}else{Galleria.raise('Load failed: no data found.');}
return this;},_parseData:function(){var self=this;$.each(this._data,function(i,data){if('thumb'in data===false){self._data[i].thumb=data.image;}
if(!'big'in data){self._data[i].big=data.image;}});return this;},splice:function(){Array.prototype.splice.apply(this._data,Utils.array(arguments));return this._parseData()._createThumbnails();},push:function(){Array.prototype.push.apply(this._data,Utils.array(arguments));return this._parseData()._createThumbnails();},_getActive:function(){return this._controls.getActive();},validate:function(data){return true;},bind:function(type,fn){type=_patchEvent(type);this.$('container').bind(type,this.proxy(fn));return this;},unbind:function(type){type=_patchEvent(type);this.$('container').unbind(type);return this;},trigger:function(type){type=typeof type==='object'?$.extend(type,{scope:this}):{type:_patchEvent(type),scope:this};this.$('container').trigger(type);return this;},addIdleState:function(elem,styles){this._idle.add.apply(this._idle,Utils.array(arguments));return this;},removeIdleState:function(elem){this._idle.remove.apply(this._idle,Utils.array(arguments));return this;},enterIdleMode:function(){this._idle.hide();return this;},exitIdleMode:function(){this._idle.showAll();return this;},enterFullscreen:function(callback){this._fullscreen.enter.apply(this,Utils.array(arguments));return this;},exitFullscreen:function(callback){this._fullscreen.exit.apply(this,Utils.array(arguments));return this;},toggleFullscreen:function(callback){this._fullscreen[this.isFullscreen()?'exit':'enter'].apply(this,Utils.array(arguments));return this;},bindTooltip:function(elem,value){this._tooltip.bind.apply(this._tooltip,Utils.array(arguments));return this;},defineTooltip:function(elem,value){this._tooltip.define.apply(this._tooltip,Utils.array(arguments));return this;},refreshTooltip:function(elem){this._tooltip.show.apply(this._tooltip,Utils.array(arguments));return this;},openLightbox:function(){this._lightbox.show.apply(this._lightbox,Utils.array(arguments));return this;},closeLightbox:function(){this._lightbox.hide.apply(this._lightbox,Utils.array(arguments));return this;},getActiveImage:function(){return this._getActive().image||undef;},getActiveThumb:function(){return this._thumbnails[this._active].image||undef;},getMousePosition:function(e){return{x:e.pageX-this.$('container').offset().left,y:e.pageY-this.$('container').offset().top};},addPan:function(img){if(this._options.imageCrop===false){return;}
img=$(img||this.getActiveImage());var self=this,x=img.width()/2,y=img.height()/2,destX=parseInt(img.css('left'),10),destY=parseInt(img.css('top'),10),curX=destX||0,curY=destY||0,distX=0,distY=0,active=false,ts=Utils.timestamp(),cache=0,move=0,position=function(dist,cur,pos){if(dist>0){move=Math.round(Math.max(dist*-1,Math.min(0,cur)));if(cache!==move){cache=move;if(IE===8){img.parent()['scroll'+pos](move*-1);}else{var css={};css[pos.toLowerCase()]=move;img.css(css);}}}},calculate=function(e){if(Utils.timestamp()-ts<50){return;}
active=true;x=self.getMousePosition(e).x;y=self.getMousePosition(e).y;},loop=function(e){if(!active){return;}
distX=img.width()-self._stageWidth;distY=img.height()-self._stageHeight;destX=x/self._stageWidth*distX*-1;destY=y/self._stageHeight*distY*-1;curX+=(destX-curX)/self._options.imagePanSmoothness;curY+=(destY-curY)/self._options.imagePanSmoothness;position(distY,curY,'Top');position(distX,curX,'Left');};if(IE===8){img.parent().scrollTop(curY*-1).scrollLeft(curX*-1);img.css({top:0,left:0});}
this.$('stage').unbind('mousemove',calculate).bind('mousemove',calculate);Utils.addTimer('pan',loop,50,true);return this;},proxy:function(fn,scope){if(typeof fn!=='function'){return function(){};}
scope=scope||this;return function(){return fn.apply(scope,Utils.array(arguments));};},removePan:function(){this.$('stage').unbind('mousemove');Utils.clearTimer('pan');return this;},addElement:function(id){var dom=this._dom;$.each(Utils.array(arguments),function(i,blueprint){dom[blueprint]=Utils.create('galleria-'+blueprint);});return this;},attachKeyboard:function(map){this._keyboard.attach.apply(this._keyboard,Utils.array(arguments));return this;},detachKeyboard:function(){this._keyboard.detach.apply(this._keyboard,Utils.array(arguments));return this;},appendChild:function(parentID,childID){this.$(parentID).append(this.get(childID)||childID);return this;},prependChild:function(parentID,childID){this.$(parentID).prepend(this.get(childID)||childID);return this;},remove:function(elemID){this.$(Utils.array(arguments).join(',')).remove();return this;},append:function(data){var i,j;for(i in data){if(data.hasOwnProperty(i)){if(data[i].constructor===Array){for(j=0;data[i][j];j++){this.appendChild(i,data[i][j]);}}else{this.appendChild(i,data[i]);}}}
return this;},_scaleImage:function(image,options){options=$.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition},options);(image||this._controls.getActive()).scale(options);return this;},updateCarousel:function(){this._carousel.update();return this;},rescale:function(width,height,complete){var self=this;if(typeof width==='function'){complete=width;width=undef;}
var scale=function(){self._stageWidth=width||self.$('stage').width();self._stageHeight=height||self.$('stage').height();self._scaleImage();if(self._options.carousel){self.updateCarousel();}
self.trigger(Galleria.RESCALE);if(typeof complete==='function'){complete.call(self);}};if(Galleria.WEBKIT&&!width&&!height){Utils.addTimer('scale',scale,5);}else{scale.call(self);}
return this;},refreshImage:function(){this._scaleImage();if(this._options.imagePan){this.addPan();}
return this;},show:function(index,rewind,_history){if(index===false||(!this._options.queue&&this._queue.stalled)){return;}
index=Math.max(0,Math.min(parseInt(index,10),this.getDataLength()-1));rewind=typeof rewind!=='undefined'?!!rewind:index<this.getIndex();_history=_history||false;if(!_history&&Galleria.History){Galleria.History.value(index.toString());return;}
this._active=index;Array.prototype.push.call(this._queue,{index:index,rewind:rewind});if(!this._queue.stalled){this._show();}
return this;},_show:function(){var self=this,queue=this._queue[0],data=this.getData(queue.index);if(!data){return;}
if((typeof this._options.creatorNameContainer!='undefined')&&(typeof this._thumbnails[this._active].data.creator!='undefined')){var authorContainer=this._options.creatorNameContainer;var creator=this._thumbnails[this._active].data.creator;if(!(authorContainer instanceof jQuery)){authorContainer=$(authorContainer);}
var jq_GalleryCredit=$('#gallery_credit');var actualCreator=authorContainer.html();if(creator==''){jq_GalleryCredit.fadeOut('fast');}else{if(actualCreator!=creator){authorContainer.fadeOut('fast',function(){authorContainer.html(creator);authorContainer.fadeIn('fast');});setTimeout(function(){jq_GalleryCredit.fadeIn('fast');},200);}else{jq_GalleryCredit.fadeIn('fast');}}}
var src=this.isFullscreen()&&'big'in data?data.big:data.image,active=this._controls.getActive(),next=this._controls.getNext(),cached=next.isCached(src),thumb=this._thumbnails[queue.index];var complete=function(){var win;self._queue.stalled=false;Utils.toggleQuality(next.image,self._options.imageQuality);$(active.container).css({zIndex:0,opacity:0});$(next.container).css({zIndex:1,opacity:1});self._controls.swap();if(self._options.imagePan){self.addPan(next.image);}
if(data.link||self._options.lightbox){$(next.image).css({cursor:'pointer'}).bind(CLICK(),function(){if(data.link){if(self._options.popupLinks){win=window.open(data.link,'_blank');}else{window.location.href=data.link;}
return;}
self.openLightbox();});}
Array.prototype.shift.call(self._queue);if(self._queue.length){self._show();}
self._playCheck();self.trigger({type:Galleria.IMAGE,index:queue.index,imageTarget:next.image,thumbTarget:thumb.image});};if(this._options.carousel&&this._options.carouselFollow){this._carousel.follow(queue.index);}
if(this._options.preload){var p,i,n=this.getNext(),data;try{for(i=this._options.preload;i>0;i--){p=new Galleria.Picture();data=self.getData(n);p.add(this.isFullscreen()&&'big'in data?data.big:data.image);n=self.getNext(n);}}catch(e){}}
Utils.show(next.container);$(self._thumbnails[queue.index].container).addClass('active').siblings('.active').removeClass('active');self.trigger({type:Galleria.LOADSTART,cached:cached,index:queue.index,imageTarget:next.image,thumbTarget:thumb.image});next.load(src,function(next){self._scaleImage(next,{complete:function(next){Utils.show(next.container);if('image'in active){Utils.toggleQuality(active.image,false);}
Utils.toggleQuality(next.image,false);self._queue.stalled=true;self.removePan();self.setInfo(queue.index);self.setCounter(queue.index);self.trigger({type:Galleria.LOADFINISH,cached:cached,index:queue.index,imageTarget:next.image,thumbTarget:self._thumbnails[queue.index].image});var transition=active.image===null&&self._options.transitionInitial?self._options.transitionInitial:self._options.transition;if(transition in _transitions===false){complete();}else{var params={prev:active.image,next:next.image,rewind:queue.rewind,speed:self._options.transitionSpeed||400};_transitions[transition].call(self,params,complete);}}});});},getNext:function(base){base=typeof base==='number'?base:this.getIndex();var result=base===this.getDataLength()-1?0:base+1;return result;},getPrev:function(base){base=typeof base==='number'?base:this.getIndex();var result=base===0?this.getDataLength()-1:base-1;return result;},next:function(){if(this.getDataLength()>1){var index=this.getNext();if(index===0){return this;}
this.show(index,false);}
return this;},prev:function(){if(this.getDataLength()>1){var index=this.getPrev();if(index===(this.getDataLength()-1)){return this;}
this.show(index,true);}
return this;},get:function(elemId){return elemId in this._dom?this._dom[elemId]:null;},getData:function(index){return index in this._data?this._data[index]:this._data[this._active];},getDataLength:function(){return this._data.length;},getIndex:function(){return typeof this._active==='number'?this._active:false;},getStageHeight:function(){return this._stageHeight;},getStageWidth:function(){return this._stageWidth;},getOptions:function(key){return typeof key==='undefined'?this._options:this._options[key];},setOptions:function(key,value){if(typeof key==='object'){$.extend(this._options,key);}else{this._options[key]=value;}
return this;},play:function(delay){this._playing=true;this._playtime=delay||this._playtime;this._playCheck();this.trigger(Galleria.PLAY);return this;},pause:function(){this._playing=false;this.trigger(Galleria.PAUSE);return this;},playToggle:function(delay){return(this._playing)?this.pause():this.play(delay);},isPlaying:function(){return this._playing;},isFullscreen:function(){return this._fullscreen.active;},_playCheck:function(){var self=this,played=0,interval=20,now=Utils.timestamp(),timer_id='play'+this._id;if(this._playing){Utils.clearTimer(timer_id);var fn=function(){played=Utils.timestamp()-now;if(played>=self._playtime&&self._playing){Utils.clearTimer(timer_id);self.next();return;}
if(self._playing){self.trigger({type:Galleria.PROGRESS,percent:Math.ceil(played/self._playtime*100),seconds:Math.floor(played/1000),milliseconds:played});Utils.addTimer(timer_id,fn,interval);}};Utils.addTimer(timer_id,fn,interval);}},setIndex:function(val){this._active=val;return this;},setCounter:function(index){if(typeof index==='number'){index++;}else if(typeof index==='undefined'){index=this.getIndex()+1;}
this.get('current').innerHTML=index;if(IE){var count=this.$('counter'),opacity=count.css('opacity'),style=count.attr('style');if(style&&parseInt(opacity,10)===1){count.attr('style',style.replace(/filter[^\;]+\;/i,''));}else{this.$('counter').css('opacity',opacity);}}
return this;},setInfo:function(index){var self=this,data=this.getData(index);$.each(['title','description'],function(i,type){var elem=self.$('info-'+type);if(!!data[type]){elem[data[type].length?'show':'hide']().html(data[type]);}else{elem.empty().hide();}});return this;},hasInfo:function(index){var check='title description'.split(' '),i;for(i=0;check[i];i++){if(!!this.getData(index)[check[i]]){return true;}}
return false;},jQuery:function(str){var self=this,ret=[];$.each(str.split(','),function(i,elemId){elemId=$.trim(elemId);if(self.get(elemId)){ret.push(elemId);}});var jQ=$(self.get(ret.shift()));$.each(ret,function(i,elemId){jQ=jQ.add(self.get(elemId));});return jQ;},$:function(str){return this.jQuery.apply(this,Utils.array(arguments));}};$.each(_events,function(i,ev){var type=/_/.test(ev)?ev.replace(/_/g,''):ev;Galleria[ev.toUpperCase()]='galleria.'+type;});$.extend(Galleria,{IE9:IE===9,IE8:IE===8,IE7:IE===7,IE6:IE===6,IE:!!IE,WEBKIT:/webkit/.test(NAV),SAFARI:/safari/.test(NAV),CHROME:/chrome/.test(NAV),QUIRK:(IE&&doc.compatMode&&doc.compatMode==="BackCompat"),MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!window.opera,IPHONE:/iphone/.test(NAV),IPAD:/ipad/.test(NAV),ANDROID:/android/.test(NAV),TOUCH:!!(/iphone/.test(NAV)||/ipad/.test(NAV)||/android/.test(NAV))});Galleria.addTheme=function(theme){if(!theme.name){Galleria.raise('No theme name specified');}
if(typeof theme.defaults!=='object'){theme.defaults={};}else{theme.defaults=_legacyOptions(theme.defaults);}
var css=false,reg;if(typeof theme.css==='string'){$('link').each(function(i,link){reg=new RegExp(theme.css);if(reg.test(link.href)){css=true;Galleria.theme=theme;return false;}});if(!css){$('script').each(function(i,script){reg=new RegExp('galleria\\.'+theme.name.toLowerCase()+'\\.');if(reg.test(script.src)){css=script.src.replace(/[^\/]*$/,'')+theme.css;Utils.addTimer("css",function(){Utils.loadCSS(css,'galleria-theme',function(){Galleria.theme=theme;});},1);}});}
if(!css){Galleria.raise('No theme CSS loaded');}}else{Galleria.theme=theme;}
return theme;};Galleria.loadTheme=function(src,options){var loaded=false,length=_galleries.length;Galleria.theme=undef;Utils.loadScript(src,function(){loaded=true;});Utils.wait({until:function(){return loaded;},error:function(){Galleria.raise("Theme at "+src+" could not load, check theme path.",true);},success:function(){if(length){var refreshed=[];$.each(Galleria.get(),function(i,instance){var op=$.extend(instance._original.options,{data_source:instance._data},options);instance.$('container').remove();var g=new Galleria();g._id=instance._id;g.init(instance._original.target,op);refreshed.push(g);});_galleries=refreshed;}},timeout:2000});};Galleria.get=function(index){if(!!_galleries[index]){return _galleries[index];}else if(typeof index!=='number'){return _galleries;}else{Galleria.raise('Gallery index '+index+' not found');}};Galleria.addTransition=function(name,fn){_transitions[name]=fn;};Galleria.utils=Utils;Galleria.log=function(){try{window.console.log.apply(window.console,Utils.array(arguments));}catch(e){try{window.opera.postError.apply(window.opera,arguments);}catch(er){window.alert(Utils.array(arguments).split(', '));}}};Galleria.raise=function(msg,fatal){if(DEBUG||fatal){var type=fatal?'Fatal error':'Error';throw new Error(type+': '+msg);}};Galleria.Picture=function(id){this.id=id||null;this.image=null;this.container=Utils.create('galleria-image');$(this.container).css({overflow:'hidden',position:'relative'});this.original={width:0,height:0};this.ready=false;this.loaded=false;};Galleria.Picture.prototype={cache:{},add:function(src){var i=0,self=this,image=new Image(),onload=function(){if((!this.width||!this.height)&&i<1000){i++;$(image).load(onload).attr('src',src+'?'+new Date().getTime());}
self.original={height:this.height,width:this.width};self.cache[src]=src;self.loaded=true;};$(image).css('display','block');try{if(typeof self.data.creator!='undefined'){$(image).attr('creator',self.data.creator);}}catch(er){}
if(self.cache[src]){image.src=src;onload.call(image);return image;}
$(image).load(onload).attr('src',src);return image;},show:function(){Utils.show(this.image);},hide:function(){Utils.moveOut(this.image);},clear:function(){this.image=null;},isCached:function(src){return!!this.cache[src];},load:function(src,callback){var self=this;$(this.container).empty(true);this.image=this.add(src);Utils.hide(this.image);$(this.container).append(this.image);Utils.wait({until:function(){return self.loaded&&self.image.complete&&self.original.width&&self.image.width;},success:function(){window.setTimeout(function(){callback.call(self,self);},50);},error:function(){window.setTimeout(function(){callback.call(self,self);},50);Galleria.raise('image not loaded in 30 seconds: '+src);},timeout:30000});return this.container;},scale:function(options){options=$.extend({width:0,height:0,min:undef,max:undef,margin:0,complete:function(){},position:'center',crop:false},options);if(!this.image){return this.container;}
var width,height,self=this,$container=$(self.container);Utils.wait({until:function(){width=options.width||$container.width()||Utils.parseValue($container.css('width'));height=options.height||$container.height()||Utils.parseValue($container.css('height'));return width&&height;},success:function(){var newWidth=(width-options.margin*2)/self.original.width,newHeight=(height-options.margin*2)/self.original.height,cropMap={'true':Math.max(newWidth,newHeight),'width':newWidth,'height':newHeight,'false':Math.min(newWidth,newHeight)},ratio=cropMap[options.crop.toString()];if(options.max){ratio=Math.min(options.max,ratio);}
if(options.min){ratio=Math.max(options.min,ratio);}
$(self.container).width(width).height(height);$.each(['width','height'],function(i,m){$(self.image)[m](self.image[m]=self[m]=Math.round(self.original[m]*ratio));});var pos={},mix={},getPosition=function(value,measure,margin){var result=0;if(/\%/.test(value)){var flt=parseInt(value,10)/100,m=self.image[measure]||$(self.image)[measure]();result=Math.ceil(m*-1*flt+margin*flt);}else{result=Utils.parseValue(value);}
return result;},positionMap={'top':{top:0},'left':{left:0},'right':{left:'100%'},'bottom':{top:'100%'}};$.each(options.position.toLowerCase().split(' '),function(i,value){if(value==='center'){value='50%';}
pos[i?'top':'left']=value;});$.each(pos,function(i,value){if(positionMap.hasOwnProperty(value)){$.extend(mix,positionMap[value]);}});pos=pos.top?$.extend(pos,mix):mix;pos=$.extend({top:'50%',left:'50%'},pos);$(self.image).css({position:'relative',top:getPosition(pos.top,'height',height),left:getPosition(pos.left,'width',width)});self.show();self.ready=true;options.complete.call(self,self);},error:function(){Galleria.raise('Could not scale image: '+self.image.src);},timeout:1000});return this;}};$.extend($.easing,{galleria:function(_,t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t*t+b;}
return-c/2*((t-=2)*t*t*t-2)+b;},galleriaIn:function(_,t,b,c,d){return c*(t/=d)*t*t*t+b;},galleriaOut:function(_,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;}});$.fn.galleria=function(options){return this.each(function(){var gallery=new Galleria();gallery.init(this,options);});};window.Galleria=Galleria;}(jQuery));var Site=window.Site||{};Site.gallery=Site.gallery||null;(function($){$(function(){var article_img=$("article a.lightbox");Site.gallery=$('div.gallery');article_img.fancybox({'speedIn':300,'speedOut':200,'overlayShow':true,'padding':0,'overlayColor':'#000','overlayOpacity':'.5','titleShow':true,'titlePosition':'inside','showCloseButton':true,'autoScale':true,'hideOnContentClick':true});$('article.ad a:has(img)').fancybox({'speedIn':300,'speedOut':200,'overlayShow':false,'padding':0,'overlayColor':'#000','overlayOpacity':'0','titleShow':false,'showCloseButton':false,'autoScale':true,'hideOnContentClick':true,'margin':'0'});Site.gallery.galleria({authorNameAttribute:'data-creator',creatorNameContainer:$('.credit-target')});var _setBoutiquePosition=function(){setTimeout(function(){var $boutiqueInfoWrap=$('.btq_info_wrap');var $activeImage=$(Galleria.get(0).getActiveImage());var fOffset=$activeImage.offset().left;$boutiqueInfoWrap.css({position:'absolute',right:fOffset});},100);}
var hasResizeBeenAdded=false;var galleria=Galleria.get(0);if(typeof galleria!='undefined'){setTimeout(function(){Galleria.get(0).enterFullscreen();},300);setTimeout(function(){galleria=Galleria.get(0);galleria.enterFullscreen();galleria.bind(Galleria.IMAGE,function(e){$('.btq_info_wrap').hide();var $originalImage=$(galleria._data[e.index].original),iImageId=$originalImage.attr('data-id'),parent=$(e.imageTarget).findParent('div'),boutiqueItem=$('.btq_info_wrap',parent);if(!hasResizeBeenAdded){$(window).resize(_setBoutiquePosition);hasResizeBeenAdded=true;}
if(boutiqueItem.length){boutiqueItem.fadeIn('fast');}else{Evisua.makeRequest({url:'/boutique/home/ajaxgetproducts/source/blog/image_id/'+iImageId+'/',handler:function(success,data){if(success){$(data.html).appendTo(parent);_setBoutiquePosition();}}});}});},600);}
var titleHeight=$('#container.gallery_post article h2.title').outerHeight(true);$("form#blog-search input#b-search-phrase").keyup(function(event){if(event.keyCode==13){$(this).findParent('form').submit();}});$("form#blog-search").submit(function(event){event.preventDefault();var search_phrase=$(this).find('input#b-search-phrase').val();document.location.href=$(this).attr('action')+search_phrase;});function openComments(){var comments_container=$("#disqus_thread");if(comments_container.length>0){var comments_link=$("#comments_show");if(comments_link.length>0){if(typeof(comments_link.data('events'))!='undefined'){comments_link.click();}
else{setTimeout(openComments,5000);}}}
else{setTimeout(openComments,5000);}}
var href_hash=window.location.hash.substr(1);if(href_hash=='disqus_thread'){openComments();}});})(jQuery);$(window).load(function(){$('#comments_show').fadeIn();$('#comments_show').fancybox({'padding':0,'overlayColor':'#000','overlayOpacity':'.3','titleShow':false,'showCloseButton':false,'hideOnContentClick':false,'type':'inline','width':750,'height':450,'autoDimensions':false});});

