/*
 * flowplayer.js 3.2.4. The Flowplayer API
 * Date: 2010-08-25 12:48:46 +0000 (Wed, 25 Aug 2010)
 * Revision: 551
 *
 * Copyright 2009 Flowplayer Oy
 * License: GNU GPLv3 or any later version.
 * http://www.opensource.org/licenses/gpl-3.0.html
 */
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.4";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){w.setPlaylist([H]);return w},getIndex:function(){return p},_swfHeight:function(){return v.clientHeight}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=w._swfHeight();m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;t.playerId=E;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var I=0;m(t.playlist,function(){var K=this;if(typeof K=="object"&&K.length){K={url:""+K}}m(t.clip,function(L,M){if(M!==undefined&&K[L]===undefined&&typeof M!="function"){K[L]=M}});t.playlist[I]=K;K=new h(K,I,w);F.push(K);I++});m(t,function(K,L){if(typeof L=="function"){if(s[K]){s[K](L)}else{j(x,K,L)}delete t[K]}});m(t.plugins,function(K,L){if(L){y[K]=new l(K,L,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function J(L){var K=w.hasiPadSupport&&w.hasiPadSupport();if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(F[0].url)&&!K){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(L)}function H(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",J,false)}else{if(q.attachEvent){q.attachEvent("onclick",J)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(H,0)}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}q=z;B()}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var m,f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(o){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=m&&m.GetVariable("$version")}catch(n){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");f=m&&m.GetVariable("$version")}catch(l){}}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.4"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();
/*
 * jQuery.centerInClient
 * Original author unkown.
 *
 * Modified version infos:
 * Author   Lucido Media GbR
 * Since    2008-12-14 14:35h
 * Version  2008-12-14 14:35h
 */
jQuery.fn.centerInClient=function(A){var B={forceAbsolute:false,container:window,completeHandler:null};$.extend(B,A);return this.each(function(E){var G=$(this);var F=$(B.container);var D=B.container==window;if(B.forceAbsolute){if(D){G.remove().appendTo("body")}else{G.remove().appendTo(F.get(0))}}G.css("position","absolute");var H=D?2:1.8;var C=(D?F.width():F.outerWidth())/2-G.outerWidth()/2;var I=(D?F.height():F.outerHeight())/H-G.outerHeight()/2;if(C<0){C=0}if(I<0){I=0}G.css("left",C+F.scrollLeft());G.css("top",I+F.scrollTop());if(B.completeHandler){B.completeHandler(this)}})};
/*
 * jQuery Nivo Slider v2.1
 * http://nivo.dev7studios.com
 *
 * Copyright 2010, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */
 (function(a){a.fn.nivoSlider=function(o){function l(c,d,b,i){var e=c.data("nivo:vars");if((!e||e.stop)&&!i)return false;b.beforeChange.call(this);if(i){i=="prev"&&c.css("background","url("+e.currentImage.attr("src")+") no-repeat");i=="next"&&c.css("background","url("+e.currentImage.attr("src")+") no-repeat")}else c.css("background","url("+e.currentImage.attr("src")+") no-repeat");e.currentSlide++;if(e.currentSlide==e.totalSlides){e.currentSlide=0;b.slideshowEnd.call(this)}if(e.currentSlide<0)e.currentSlide=e.totalSlides-1;e.currentImage=a(d[e.currentSlide]).is("img")?a(d[e.currentSlide]):a(d[e.currentSlide]).find("img:first");if(b.controlNav){a(".nivo-controlNav a",c).removeClass("active");a(".nivo-controlNav a:eq("+e.currentSlide+")",c).addClass("active")}if(e.currentImage.attr("title")){var k=e.currentImage.attr("title");if(k.substr(0,1)=="#")k=a(k).html();a(".nivo-caption",c).css("display")=="block"?a(".nivo-caption p",c).fadeOut(b.animSpeed,function(){a(this).html(k);a(this).fadeIn(b.animSpeed)}):a(".nivo-caption p",c).html(k);a(".nivo-caption",c).fadeIn(b.animSpeed)}else a(".nivo-caption",c).fadeOut(b.animSpeed);var j=0;a(".nivo-slice",c).each(function(){var h=Math.round(c.width()/b.slices);a(this).css({height:"0px",opacity:"0",background:"url("+e.currentImage.attr("src")+") no-repeat -"+(h+j*h-h)+"px 0%"});j++});if(b.effect=="random"){d=Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade");e.randAnim=d[Math.floor(Math.random()*(d.length+1))];if(e.randAnim==undefined)e.randAnim="fade"}if(b.effect.indexOf(",")!=-1){d=b.effect.split(",");e.randAnim=a.trim(d[Math.floor(Math.random()*d.length)])}e.running=true;if(b.effect=="sliceDown"||b.effect=="sliceDownRight"||e.randAnim=="sliceDownRight"||b.effect=="sliceDownLeft"||e.randAnim=="sliceDownLeft"){var g=0;j=0;d=a(".nivo-slice",c);if(b.effect=="sliceDownLeft"||e.randAnim=="sliceDownLeft")d=a(".nivo-slice",c)._reverse();d.each(function(){var h=a(this);h.css("top","0px");j==b.slices-1?setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+g):setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+g);g+=50;j++})}else if(b.effect=="sliceUp"||b.effect=="sliceUpRight"||e.randAnim=="sliceUpRight"||b.effect=="sliceUpLeft"||e.randAnim=="sliceUpLeft"){j=g=0;d=a(".nivo-slice",c);if(b.effect=="sliceUpLeft"||e.randAnim=="sliceUpLeft")d=a(".nivo-slice",c)._reverse();d.each(function(){var h=a(this);h.css("bottom","0px");j==b.slices-1?setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+g):setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+g);g+=50;j++})}else if(b.effect=="sliceUpDown"||b.effect=="sliceUpDownRight"||e.randAnim=="sliceUpDown"||b.effect=="sliceUpDownLeft"||e.randAnim=="sliceUpDownLeft"){var n=j=g=0;d=a(".nivo-slice",c);if(b.effect=="sliceUpDownLeft"||e.randAnim=="sliceUpDownLeft")d=a(".nivo-slice",c)._reverse();d.each(function(){var h=a(this);if(j==0){h.css("top","0px");j++}else{h.css("bottom","0px");j=0}n==b.slices-1?setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+g):setTimeout(function(){h.animate({height:"100%",opacity:"1.0"},b.animSpeed)},100+g);g+=50;n++})}else if(b.effect=="fold"||e.randAnim=="fold"){j=g=0;a(".nivo-slice",c).each(function(){var h=a(this),m=h.width();h.css({top:"0px",height:"100%",width:"0px"});j==b.slices-1?setTimeout(function(){h.animate({width:m,opacity:"1.0"},b.animSpeed,"",function(){c.trigger("nivo:animFinished")})},100+g):setTimeout(function(){h.animate({width:m,opacity:"1.0"},b.animSpeed)},100+g);g+=50;j++})}else if(b.effect=="fade"||e.randAnim=="fade"){j=0;a(".nivo-slice",c).each(function(){a(this).css("height","100%");j==b.slices-1?a(this).animate({opacity:"1.0"},b.animSpeed*2,"",function(){c.trigger("nivo:animFinished")}):a(this).animate({opacity:"1.0"},b.animSpeed*2);j++})}}var f=a.extend({},a.fn.nivoSlider.defaults,o);return this.each(function(){var c={currentSlide:0,currentImage:"",totalSlides:0,randAnim:"",running:false,paused:false,stop:false},d=a(this);d.data("nivo:vars",c);d.css("position","relative");d.addClass("nivoSlider");var b=d.children();b.each(function(){var g=a(this),n="";if(!g.is("img")){if(g.is("a")){g.addClass("nivo-imageLink");n=g}g=g.find("img:first")}var h=g.width();if(h==0)h=g.attr("width");var m=g.height();if(m==0)m=g.attr("height");h>d.width()&&d.width(h);m>d.height()&&d.height(m);n!=""&&n.css("display","none");g.css("display","none");c.totalSlides++});if(f.startSlide>0){if(f.startSlide>=c.totalSlides)f.startSlide=c.totalSlides-1;c.currentSlide=f.startSlide}c.currentImage=a(b[c.currentSlide]).is("img")?a(b[c.currentSlide]):a(b[c.currentSlide]).find("img:first");a(b[c.currentSlide]).is("a")&&a(b[c.currentSlide]).css("display","block");d.css("background","url("+c.currentImage.attr("src")+") no-repeat");for(var i=0;i<f.slices;i++){var e=Math.round(d.width()/f.slices);i==f.slices-1?d.append(a('<div class="nivo-slice"></div>').css({left:e*i+"px",width:d.width()-e*i+"px"})):d.append(a('<div class="nivo-slice"></div>').css({left:e*i+"px",width:e+"px"}))}d.append(a('<div class="nivo-caption"><p></p></div>').css({display:"none",opacity:f.captionOpacity}));if(c.currentImage.attr("title")!=""){i=c.currentImage.attr("title");if(i.substr(0,1)=="#")i=a(i).html();a(".nivo-caption p",d).html(i);a(".nivo-caption",d).fadeIn(f.animSpeed)}var k=0;if(!f.manualAdvance&&b.length>1)k=setInterval(function(){l(d,b,f,false)},f.pauseTime);if(f.directionNav){d.append('<div class="nivo-directionNav"><a class="nivo-prevNav">Prev</a><a class="nivo-nextNav">Next</a></div>');if(f.directionNavHide){a(".nivo-directionNav",d).hide();d.hover(function(){a(".nivo-directionNav",d).show()},function(){a(".nivo-directionNav",d).hide()})}a("a.nivo-prevNav",d).live("click",function(){if(c.running)return false;clearInterval(k);k="";c.currentSlide-=2;l(d,b,f,"prev")});a("a.nivo-nextNav",d).live("click",function(){if(c.running)return false;clearInterval(k);k="";l(d,b,f,"next")})}if(f.controlNav){e=a('<div class="nivo-controlNav"></div>');d.append(e);for(i=0;i<b.length;i++)if(f.controlNavThumbs){var j=b.eq(i);j.is("img")||(j=j.find("img:first"));f.controlNavThumbsFromRel?e.append('<a class="nivo-control" rel="'+i+'"><img src="'+j.attr("rel")+'" alt="" /></a>'):e.append('<a class="nivo-control" rel="'+i+'"><img src="'+j.attr("src").replace(f.controlNavThumbsSearch,f.controlNavThumbsReplace)+'" alt="" /></a>')}else e.append('<a class="nivo-control" rel="'+i+'">'+(i+1)+"</a>");a(".nivo-controlNav a:eq("+c.currentSlide+")",d).addClass("active");a(".nivo-controlNav a",d).live("click",function(){if(c.running)return false;if(a(this).hasClass("active"))return false;clearInterval(k);k="";d.css("background","url("+c.currentImage.attr("src")+") no-repeat");c.currentSlide=a(this).attr("rel")-1;l(d,b,f,"control")})}f.keyboardNav&&a(window).keypress(function(g){if(g.keyCode=="37"){if(c.running)return false;clearInterval(k);k="";c.currentSlide-=2;l(d,b,f,"prev")}if(g.keyCode=="39"){if(c.running)return false;clearInterval(k);k="";l(d,b,f,"next")}});f.pauseOnHover&&d.hover(function(){c.paused=true;clearInterval(k);k=""},function(){c.paused=false;if(k==""&&!f.manualAdvance)k=setInterval(function(){l(d,b,f,false)},f.pauseTime)});d.bind("nivo:animFinished",function(){c.running=false;a(b).each(function(){a(this).is("a")&&a(this).css("display","none")});a(b[c.currentSlide]).is("a")&&a(b[c.currentSlide]).css("display","block");if(k==""&&!c.paused&&!f.manualAdvance)k=setInterval(function(){l(d,b,f,false)},f.pauseTime);f.afterChange.call(this)})})};a.fn.nivoSlider.defaults={effect:"random",slices:15,animSpeed:500,pauseTime:3E3,startSlide:0,directionNav:true,directionNavHide:true,controlNav:true,controlNavThumbs:false,controlNavThumbsFromRel:false,controlNavThumbsSearch:".jpg",controlNavThumbsReplace:"_thumb.jpg",keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){}};a.fn._reverse=[].reverse})(jQuery);
/*
 * Dynamics for Template LM-Porofin-v1
 * Lucido Media GbR
 */
jQuery(function($)
{
  // GENERAL //////////////////////////////////////////////////////////

  //hide default textbox content on click
  $('input.text').each(function()
  {
    $(this).attr('alt',$(this).val())
    .focus(function()
    {
      if( $(this).val() == $(this).attr('alt') )
        $(this).val('');
    })
    .blur(function()
    {
      if( $(this).val() == '' )
        $(this).val($(this).attr('alt'));
    });
  });

  //hover for old browsers
  $('input.button').hover(
    function(){ $(this).addClass('hover');    },
    function(){ $(this).removeClass('hover'); }
  );

  //efficient global vars
  var location = window.location.href;

  //open pdfs in new tab
  $('a[href$=".pdf"]').click(function(){ this.target='_blank'; });

  //rounded corners
  function corners(el,rad)
  {
    rad = rad || '.3em';
    $(el).css(
    {
      'border-radius'         : rad,
      '-moz-border-radius'    : rad,
      '-webkit-border-radius' : rad,
      '-khtml-border-radius'  : rad
    });
  }
  corners('input.text,select,textarea');

  $('#side-1').append(
    '<div class="box partner">'+
      '<a href="http://porofin.de/vertriebspartner/index.html"><img src="http://porofin.de/img/side1-box-vertriebspartner.jpg" alt="Erhalten Sie Hilfe bei einem Vertriebspartner in Ihrer Nähe" /></a>'+
    '</div>'
  )


  // MAINPAGE /////////////////////////////////////////////////////////

  /*$('#info-1').nivoSlider(
  {
    effect        : 'sliceDownLeft',
    animSpeed     : 800,
    pauseTime     : 5000,
    pauseOnHover  : true,
    //directionNav  : true,
    //directionNavHide:false,
	//controlNav    : false,
    keyboardNav   : false
  });
  */

  // VERTRIEBSPARTNER /////////////////////////////////////////////////
  if( location.indexOf('/vertriebspartner/') !== -1 && $('#gmap').length )
    (function()
    {
      // GMAP //
      var $map        = $('#gmap').css({'width':'600px', 'height':'300px', 'border':'2px solid #d8d8d8'}),
          $destlist_a = $('.dest-list li a'),
          map         = new GMap2($map.get(0)),
          marker_icon = new GIcon(G_DEFAULT_ICON),
          init_dest   = new GLatLng(50.958427,9.052734), //middle of germany
          init_zoom   = 5;
      if( location.indexOf('weltweit.html') !== -1 )
      {
        init_dest = new GLatLng(45.7670199,35.0561346) //dont ask...
        init_zoom = 3;
      }
      map.setCenter(init_dest, init_zoom);


      $destlist_a.each(function()
      {
        var lat = lng = false,
            href      = $(this).attr('href').replace(/#([0-9.]+);([0-9.]+)/,function(all,a,b){lat=a; lng=b; return all;}),
            marker    = new GMarker(new GLatLng(lat,lng), marker_icon);

        map.addOverlay(marker);
        GEvent.addListener(marker,'click',function()
        {
          // why is this 0 ? :
          // var dest = this.getLatLng();
          // $destlist_a.find('[href$="#'+dest.y+';'+dest.x+'"]').length
          window.location.href = href;
        });
      });

      // SEARCH //
      if( location.indexOf('vertriebspartner/index.html') !== -1)
        (function()
        {
          $('.dest-list h3').addClass('clear spaced').before(
            '<form action="#" method="get"><p class="spaced">'+
             'Finden Sie einen Stützpunkt in Ihrer Nähe.<br />'+
             '<label for="search-plz">Ihre PLZ:</label> '+
             '<input class="text" id="frm-search-plz" name="frm-search-plz" value="" /> '+
             '<input class="button" style="margin-left:0.3em" type="submit" value="" alt="Suchen" /> '+
             '<span id="frm-search-reset-wrap">| <a href="#" id="frm-search-reset">Suche löschen</a></span>'+
            '</p></form>'
          ).after('<p class="search-info"></p>')
          .parent().find('#frm-search-reset-wrap').hide()
          .end().find('form').submit(function()
          {
            var $dest_list   = $(this).parent(),
                $input       = $('#frm-search-plz',this),
                $search_info = $dest_list.find('.search-info'),
                plz          = $input.val().trim(),
                plz_len      = plz.length,
                num_results  = 0,
                $a           = $dest_list.find('ul a').each(function()
                {
                  var list = $(this).html().match(/\<\!-- plz\:(.*?) --\>/)[1].split(';'),
                      i, i_max;
                  for(i=0,i_max=list.length; i<i_max; ++i)
                  {
                    if( list[i] && plz.indexOf(list[i].substr(0,plz_len)) === 0 )
                    {
                      $(this).parent('li').addClass('visible');
                      num_results++;
                      break;
                    }
                  }
                });

            $dest_list.find('li').show()
            .not('.visible').hide()
            .end().removeClass('visible');

            if( num_results )
            { $search_info.text( num_results + ' Ergebnisse gefunden.'); }
            else
            { $search_info.text('Leider nichts gefunden.'); }

            $('#frm-search-reset-wrap',this).show().click(function(){ $input.val(''); $search_info.text(''); $a.parent('li').show(); $(this).hide(); return false; });
            if( !plz_len )
            { $('#frm-search-reset-wrap',this).click(); }

            return false;
          });
          corners('.dest-list #frm-search-plz');
        })();

    })();

  // KURZANLEITUNG /////////////////////////////////////////////////////

  /* else if( location.indexOf('kurzanleitung.html') !== -1 )
    (function()
    {
      $('#main h2:first').after('<a href="http://porofin.de/video/porofin.swf" style="display:block;width:525px;height:334px;margin-bottom:1.5em;" id="player"></a>');
      //flowplayer('player', 'http://porofin.de/sys/flash/flowplayer-3.2.4.swf',{play:{opacity:0}});
      flowplayer('player', 'sys/flash/flowplayer-3.2.4.swf',{
        play:{opacity:0},
        clip:{
          autoPlay: false,
          autoBuffering: true,
          seekableOnBegin: true
        },
        plugins: {
          controls: {
            url: 'http://porofin.de/sys/flash/flowplayer.controls-3.2.2.swf',
            bottom:0,
            height:24,
            //z-index:1,
            //backgroundColor: '#2d3e46',
            //backgroundGradient: 'low',
            // controlbar-specific configuration
            //fontColor: '#ffffff'
            //timeFontColor: '#333333',
            //autoHide: 'never',
            //buttons
            play:true,
            volume:false,
            mute:false,
            time:true,
            stop:true,
            playlist:false,
            fullscreen:true,
            scrubber: true  // scrubber = timeline/playhead combination
          }
        }


      });
    })(); */
  // SPERRSYSTEME /////////////////////////////////////////////////////
  else if( location.indexOf('anderesperrsysteme.html') !== -1 )
    (function()
    {
      //FIXME: enable jump on pageload (via hash)
      var $els = $('.jumpable').not(':first').hide().end();
      $('.jumpmenu a').click(function()
      {
        $els.hide(500).filter( $(this).attr('href') ).show(500);
        return false;
      });
    })();
  // BEISPIELE /////////////////////////////////////////////////////
  else if( location.indexOf('beispiele.html') !== -1 )
    (function()
    {
      //FIXME: enable jump on pageload (via hash)
      var $els = $('.jumpable').not(':first').hide().end();
      $('.jumpmenu a').click(function()
      {
        $els.hide(500).filter( $(this).attr('href') ).show(500);
        return false;
      });
    })();
  // FOLGESCHÄDEN /////////////////////////////////////////////////////
  else if( location.indexOf('folgeschaeden.html') !== -1 )
    (function()
    {
      //FIXME: enable jump on pageload (via hash)
      var $els = $('.jumpable').not(':first').hide().end();
      $('.jumpmenu a').click(function()
      {
        $els.hide(500).filter( $(this).attr('href') ).show(500);
        return false;
      });
    })();
  // ERFAHRUNGEN //////////////////////////////////////////////////////
  else if( location.indexOf('erfahrungen.html') !== -1 )
    (function()
    {
      var $frm = $('#gb-form').hide();
      $('a[href=#gb-form]').click(function(){ $frm.slideToggle(400); return false; });
    })();

  // SHOP MAINPAGE ////////////////////////////////////////////////////

  if( $('#main.shop #info-1').length )
    (function()
    {
      /*
      * add transparent layer to infoboxes
      */
      $('.info-sub[id^=info-1]').wrapInner('<div class="trans"></div>')
      .find('.trans').css({'background':'#fff','opacity':'0.75','height':'276px','width':'37%','padding':'0 10px 0 10px','font-size':'12px','overflow':'hidden','border':'1px solid #ccc','border-top':'0','border-bottom':'0'})
      .find('a').css({'display':'block','width':'100%','text-align':'right'});
      $('#info-1-sub-1 .trans').css('margin-left','10px');
      $('#info-1-sub-2 .trans').css('margin-left','370px');
      $('#info-1-sub-3 .trans').css('margin-left','10px');
      $('#info-1-sub-4 .trans').css('margin-left','370px');

      /*
      * merge infoboxes & build carousel
      */
      var slide_start_timeout   = 0;     //additional time before 1st start
      var slide_interval        = 10000; //slide each msec (not including animation time)
      var slide_duration        = 1000;  //time for 1 slide
      var slide_debug           = false; //show all elements

      //prepare the holding element
      var w = $('.info-sub[id^=info-1]').length * $('.info-sub[id^=info-1]').width() + 'px';
      $('#info-1').wrapInner('<div class="js-wrap" style="width:'+w+'; position:relative;"></div>');
      if( !slide_debug )
        $('#info-1').css({'overflow':'hidden','position':'relative'})

      //insert children
      $('.info-sub[id^=info-1]').removeClass('info').addClass('left').appendTo('#info-1 .js-wrap');

      //animation
      var slideshow_timer = null;
      var slide_max_left  = w.replace(/px/,'') * -1;
      var slide_act_left  = 0;
      var slide_step      = $('.info-sub[id^=info-1]').width();
      var el_wrap         = $('#info-1 .js-wrap');
      //prevent flickerin at 1st slide
      el_wrap.stop().animate({'left' : 0},slide_duration,'swing', function(){});
      slide = function()
      {
        slide_stop();

        slide_act_left -= slide_step;
        if( slide_act_left <= slide_max_left )
        {
          slide_act_left = 0;

          el_wrap.stop()
          .fadeOut(
            slide_duration,
            function()
            {
              el_wrap.css('left','0px').fadeIn(
                slide_duration,
                function()
                {
                  if( $.browser.msie )
                    el_wrap.get(0).style.removeAttribute('filter'); //fix ie cleartype glitch
                  slide_start();
                }
              );
            }
          );
        }
        else
        {
          el_wrap.stop()
          .animate(
            {'left' : slide_act_left},
            slide_duration,
            'swing',
            function(){slide_start();}
          );
        }
        //alert(left + '|' + slide_max_left);
      }
      function slide_start()
      {
        slideshow_timer = window.setInterval('slide()',slide_interval);
      }
      function slide_stop()
      {
        window.clearInterval(slideshow_timer);
      }
      setTimeout(function(){slide_start()},slide_start_timeout);
      $('#info-1').hover( function(){slide_stop();}, function(){slide_start();} );
    })();

  // PRODUCTS PAGE ////////////////////////////////////////////////////
  else if( $('.buy.box').length )
    (function()
    {
      //dynamic price-headers
      $('.buy.box select').change(function()
      {
        var el_header = $(this).parent('.buy.box').find('.header');

        //prepare header for reset
        if( !el_header.find('.price_org').length )
          el_header.html('<span class="price_org">'+el_header.text()+'</span><span class="price"></span><span class="border"></span>');

        //get contents
        var price           = $(this).find('option:selected:contains("EUR")').text().replace(/^\s*.*?([0-9,]+\s*EUR\s*)$/,'$1');
        var header_txt      = el_header.find('span:visible').text();
        var header_txt_pre  = header_txt.replace(/^\s*(.*?)[0-9,]+\s*EUR\s*$/,'$1');

        //insert new price into header
        if( price == '' )
          el_header.find('.price_org').show().next('.price').hide().text('');
        else
          el_header.find('.price_org').hide().next('.price').show().text(header_txt_pre+price);
      });

      $('.buy.box small').after('<div class="js-loading" style="display:none; text-align:center; margin:.5em 0;"><img alt="bitte warten" src="http://porofin.de/shop/templates/lm-porofin-v1/img/ajax-loader.gif" /></div>');
      $('#main form').submit(function()
      {
        $.ajaxSetup(
        {
          'cache'       : false,
          'dataType'    : 'text',
          'processData' : false,
          'beforeSend'  : function(){$('.buy.box .js-loading').show();},
          'complete'    : function(){$('.buy.box .js-loading').hide();}
        });

        $.post( $(this).attr('action'), $(this).serialize(), function(data,status)
        {
          if( status === 'success' && (data = data.match(/<div id="basket"[^>]*>.*?<\/div>/)) )
          {
            if( $('#side-1 #basket').length )
              $('#side-1 #basket').replaceWith(data[0]);
            else
              $('#side-1 .box:eq(1)').after(data[0]);
          }
        });

        return false;
      });

      //add to card img
      if( !$.browser.msie || $.browser.msie && parseInt(jQuery.browser.version) > 6 )
      {
        $('.buy.box small').attr('style','width:110px; display:block; float:right; text-align:right; line-height:1.25em; margin-bottom:.5em;').before('<img class="left" src="http://porofin.de/shop/templates/lm-porofin-v1/img/middle-main-basket.png" />').after('<div class="clear"></div>').html( $('.buy.box small').html().replace(/(MwSt\.)/,'$1<br />') );
      }

      //begin : verbrauchs-calc
      $('#main a[href*="verbrauchstabelle.html"]').click(function()
      {
        if( $('#verbrauchs-calc').length )
          return false;

        $('#main').append(
          '<div id="verbrauchs-calc" style="width:25em; padding:.5em; background:#fafafa; border:1px solid #ae1217;">'+
            '<a class="right close" href="#">[schlie&szlig;en]</a>'+
            '<strong>Porofin-Verbrauchsrechner</strong><br /><br />'+
            '<label>Wandl&auml;nge :</label>  <input class="text" name="calc-wall-length"     value="" /><span class="left">&nbsp;cm</span>'+
            '<label>Wanddicke :</label>       <input class="text" name="calc-wall-thickness"  value="" /><span class="left">&nbsp;cm</span>'+
            '<label>Wandecken :</label>       <input class="text" name="calc-wall-corners"    value="" />'+
            '<label>Berechnen</label>         <div class="left" style="width:10em"><input class="refresh button" type="button" value="" /></div>'+
            '<div class="clear"></div><br />'+
            '<p class="result-wrapper" style="display:none">'+
              'Sie ben&ouml;tigen ca. <span class="result">XY</span> Flaschen.&nbsp;&nbsp;'+
              '<a href="#" class="proceed"><strong>&raquo;&uuml;bernehmen</strong></a>'+
            '</p>'+
          '</div>'
        )
        .find('#verbrauchs-calc').centerInClient()
        .find('input:first').focus()
        .end().find('.refresh').click(function()
        {
          var len     = $('#verbrauchs-calc input[name="calc-wall-length"]').val()    * 1;
          var thick   = $('#verbrauchs-calc input[name="calc-wall-thickness"]').val() * 1;
          var corners = $('#verbrauchs-calc input[name="calc-wall-corners"]').val()   * 1;

          var res_without_corners = thick * 0.1389 * len * 4 / 500;
          var res                 = thick * 13.89  * corners / 500 + res_without_corners;
          res = Math.floor(res * 100)/100;  //nachkommastellen > 2 abschneiden.
          res = Math.ceil(res)              //they say it has to be! oO

          if( isNaN(res) )
            res = '?';

          $('#verbrauchs-calc .result-wrapper').show().find('.result').text(res);

          return false;
        })
        .end().find('a.close').click(function()
        {
          $('#verbrauchs-calc').remove();
          return false;
        })
        .end().find('a.proceed').click(function()
        {
          $('#main input[name=products_qty]').val( $('#verbrauchs-calc .result').text() );
          $('#verbrauchs-calc a.close').click();
          return false;
        });
        corners('#verbrauchs-calc,#verbrauchs-calc input.text');

        return false;
      });
      //end : verbrauchs-calc

  })();


});
