/* Copyright (c) 2008 Kean Loong Tan http://www.gimiti.com/kltan
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * Copyright notice and license must remain intact for legal use
 * jFade
 * Version: 1.0 (Jun 30, 2008)
 * Requires: jQuery 1.2.6+
 * 
 *
 * Original Code Copyright (c) 2008 by Michael Leigeber
 * Website: http://www.leigeber.com
 * 
 *
 */ 
(function(A){A.fn.jFade=function(N){var B=A.extend({},A.fn.jFade.defaults,N);var F,C,K,E,H,J,I,M,D;var G=this;var L=function(){var Q=G;B.steps=B.steps||20;B.duration=B.duration||20;clearInterval(Q.timer);C=O(B.end);K=C[0];E=C[1];H=C[2];if(!Q.r){F=O(B.start);r=F[0];g=F[1];b=F[2];Q.r=r;Q.g=g;Q.b=b}J=Math.round(Math.abs(Q.r-K)/B.steps);I=Math.round(Math.abs(Q.g-E)/B.steps);M=Math.round(Math.abs(Q.b-H)/B.steps);if(J==0){J=1}if(I==0){I=1}if(M==0){M=1}Q.step=1;Q.timer=setInterval(function(){P(Q,B.property,B.steps,K,E,H,J,I,M)},B.duration);function P(V,d,a,e,U,X,c,Y,f){var T=V;var S;if(T.step<=a){var R=T.r;var W=T.g;var Z=T.b;if(R>=e){R=R-c}else{R=parseInt(R)+parseInt(c)}if(W>=U){W=W-Y}else{W=parseInt(W)+parseInt(Y)}if(Z>=X){Z=Z-f}else{Z=parseInt(Z)+parseInt(f)}S="rgb("+R+","+W+","+Z+")";A(V).css(d,S);T.r=R;T.g=W;T.b=Z;T.step=T.step+1}else{clearInterval(T.timer);S="rgb("+e+","+U+","+X+")";A(V).css(d,S)}}function O(R){var S=[parseInt(R.substring(0,2),16),parseInt(R.substring(2,4),16),parseInt(R.substring(4,6),16)];return S}};if(B.trigger=="load"){L()}else{A(this).bind(B.trigger,function(){G=this;L()})}return this};A.fn.jFade.defaults={trigger:"load",property:"background",start:"FFFFFF",end:"000000",steps:5,duration:30}})(jQuery);
function badBrowser(){
    if($.browser.msie && parseInt($.browser.version) <= 6){ return true;}
    
    return false;
}

function getBadBrowser(c_name)
{
    if (document.cookie.length>0)
    {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}   

function setBadBrowser(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
    $(function(){
        $("<div id='browserWarning'>You are using an unsupported browser. Please switch to <a href='http://getfirefox.com'>FireFox</a> or <a href='http://www.apple.com/safari/'>Safari</a>&nbsp;&nbsp;&nbsp;[<a href='#' id='warningClose'>close</a>] </div> ")
            .css({
                backgroundColor: '#fcfdde',
                'width': '100%',
                'border-top': 'solid 1px #000',
                'border-bottom': 'solid 1px #000',
                'text-align': 'center',
                padding:'5px 0px 5px 0px'
            })
            .prependTo("body");
        
        $('#warningClose').click(function(){
            setBadBrowser('browserWarning','seen');
            $('#browserWarning').slideUp('slow');
            return false;
        });
    }); 
}

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/*************************************************
**  jQuery Masonry version 1.3.2
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g=
{getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=
d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);
a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);
if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=!!d.data("masonry");var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=c&&
g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=!!d.data("masonry");var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults={singleMode:false,
columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

/*      SWFObject v2.2 <http://code.google.com/p/swfobject/> 
        is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();


/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/* SHOW CORRECT PERSON STATE */
//      personId = window.location.hash;
//      if(personId != '') showPerson(personId, $('a#'+personId).attr('href'));
//}

var hashId = window.location.hash;

if(hashId != ''){
        var gallery = /^#slide([0-9]+)/.test(hashId);
}

var geocoder;
var map;
var map = null;
var marker = null;
var directionDisplay;
var directionsService;
var directions = null;
var markers = [];   
var nearest;   


carat = { 
    buildArray : new Array(),
    
    init: function (){
        var id = $(document.body).attr('id');
        
        if (this[id]) {
            this[id](); 
        }
        this.all();
    },
    
    //on every page do this
    all : function(){
        this.loadin();
        this.geo_button();
        this.launchMap();
    },

    
    //page load
    loadin : function(){
				$('.nojs').removeClass('nojs');

        $('.region .countries, .details').hide();
        
        $('.details').each(function(index, element){
    //      $(this).find('.name').attr({'id' : index+1 });
            $(this).prev().attr({'id' : index+1 });                         
        });
        
        $('#map_wrap')
            .append('<div id="detail">'
                + '         <a href="#closeBox" id="detail_close" >x close </a>'
                + '     <div id="details">'
                + '         <div id="detail_content"></div>'
                + '         <!--div class="hold_b">'
                + '             <a href="#getDirections" id="show_direction"> Get Directions to here</a>'
                + '             <div id="d_form" class="hide">'
                + '                 <a href="#getDirections" id="get_directions" class="geo" >Directions from your Location</a>'
                + '                 <div class="clearfix"><label for="enterlocation">Directions From</label><input type="text" value="POSTODE" id="enterlocation" /><input type="submit" value="Go" id="go" /></div>'
                + '             </div>'
                + '         </div-->'
                + '     </div>'
                + '     <div id="directions">'
                + '        <div class="clearfix">'
                + '         <label for="mode">Mode of Travel: </label>'
                + '         <select id="mode" onchange="carat.calcRoute();">'
                + '           <option value="DRIVING">Driving</option>'
                + '           <option value="WALKING">Walking</option>'
                + '           <option value="BICYCLING">Bicycling</option>'
                + '         </select>'
                + '         </div>'
                + '         <div id="directionsPanel">'
                + '         </div>'
                + '         <a href="#closeBox" id="direction_close" >back to details</a>'
                + '     </div>'
                +'</div>');
        
        $('#detail_close').live('click',function(e){
            e.preventDefault();
             carat.resetMap();
         });
        
        $('#direction_close').live('click',function(e){
            e.preventDefault();
             carat.hideDirections();
         });
        
        $('#show_direction').live('click',function(e){
            e.preventDefault();
            $('#d_form').stop().slideToggle(400);
         });
        
        $('input[type="text"]').focus(function() {
            $(this).addClass("focus")
            if( this.value == this.defaultValue ) {
                this.value = "";
            }
        }).blur(function() {
            $(this).removeClass("focus")
            if( !this.value.length ) {
                this.value = this.defaultValue;
            }
        });
        
        $('#go').click(function(e){
             e.preventDefault();
             here = document.getElementById("enterlocation").value
             carat.calcRoute(here);
        });
        
        $('#enterlocation').keypress(function(event) {
          if (event.which == '13') {
              $('#go').click();
              event.preventDefault();
           }
        });
        
        
    },
    
    geo_button : function() { 
	
		$('<input type="hidden" value="" id="mylocation" />'
			+'<input type="hidden" value="" id="theirlocation" />')
			.insertBefore('#google_map');
		
	
        if (!!navigator.geolocation == true ) {
            $('#regions').prepend('<li class="local"><a href="#mylocation" id="geolocate" >find your nearest Carat</a></li>');
                        
            
            $('#geolocate').live('click', function(e){ 
												   
					if ($(this).hasClass('found') ) {
						var target =  $(this).attr('rel');
						$('#'+target).click();
						
					} else {
						$('#mylocation').addClass('closest');
						$('#geolocate').text('. ').addClass('searching');
						carat.geo_innit();
					}
					
					e.preventDefault();
            });
            
            $('#regions').css({'padding-right' : 0})
        } else { 
            $('.geo').remove();
        }
    },

    geo_innit : function () {  
        navigator.geolocation.getCurrentPosition(carat.geoClosest,carat.geoErrors,{enableHighAccuracy:true});  
    }, 

    geoErrors :function (error)  
    {  
        carat.resetGeoBtn();
        switch(error.code)  
        {  
            case error.PERMISSION_DENIED: alert("Please accept the Geolocation request.");  
            break;  

            case error.POSITION_UNAVAILABLE: alert("Sorry we could not detect your position, please try again.");  
            break;  

            case error.TIMEOUT: alert("The request has timed out, please try again.");  
            break;  

            default: alert("An unexpected error has occured, please reload the page and try again.");  
            break;  
        }  
    },  
    
    geoClosest :function (position){  
                    
            var lat = position.coords.latitude,
                lon = position.coords.longitude;
            
            var latlong = lat+','+lon ;
            
            var me = new google.maps.LatLng(lat, lon) //for the maps
            $('#mylocation').val(me); //save it for later
            
            if ($('#mylocation').hasClass('request')) {
                here = document.getElementById("mylocation").value;
                carat.calcRoute(here);
				carat.resetGeoBtn();
            }
            
            if ($('#mylocation').hasClass('closest')) {
                here = document.getElementById("mylocation").value;

				var  closest = carat.findClosest(lat,lon);   
				
                var text = $('#'+closest ).text();
                // needs to be extended
                $('#geolocate').text(text).attr('rel', closest);
                $('#geolocate').addClass('found').removeClass('searching');
                
            }
        
    }, 
	resetGeoBtn : function() {
		
		$('#geolocate').removeClass('searching');
		var target =  $('#geolocate').attr('rel');
		
		if (target) {
 			var text = $('#'+target ).text();
			$('#geolocate').text(text);
		} else { 
			$('#geolocate').text('find your nearest Carat');
		}
		
	},
    //drop down navigation
    regionNav : function(){
		
			$('.countryname').each(function(){
				var el = $(this).parent()							
				var check = el.find('.country').length;								
				if (check  == 0) { 
					el.remove();
				}
			})
		
        
            var regionCount = $('.region').length;
            $('.region').each(function(index,element){
                
                var p = $(this).position();
                
                var cols = $(this).find('.separator').length, 
                    col_w = $('.separator').css('width'),
                    w = cols*170,
                    ml = w/-2
                    el = $(this).find('.countries')
                    el.css({width : w});
                
                if ( (cols == 1) || (cols == 2)) { 
                    el.css({left : p.left });
                } else if (cols == 3) {
                    // something with 3 colums
                } else if (cols == 4) { 
                    el.css({left : -150 })
                }
            /*  
                if (index == 0)  { 
                    el.css({left : 'auto', right : 0});
                }*/
            
            }); 
            
            $('.handle').mouseover(function(){
                
                $(this).parent().find(".countries").slideDown(400); 
    
                $(this).parent().hover(function() {
                                                
                }, function(){  
                    $(this).parent().find(".countries").hide(); 
                });
                
            });
            
            $('.name').click(function(e){
                e.preventDefault();                   
                $(".countries").hide();
            });
            
            
            $('.region .handle, .region .countryname').click(function(e){
                e.preventDefault();
                
                var region = $(this).text();
                
                geocoder.geocode({'address': region}, function(results, status) {                         
                      if (status == google.maps.GeocoderStatus.OK) {
                            var latlng = results[0].geometry.location;
                            map.setCenter(latlng);
                            map.setZoom(3);
                      } 
                });
            });
        
		
				
		$('.name').click(function(e){
			
				e.preventDefault();
				var el =$(this).parents('.country')
				var id = $(this).attr('id');
				var html = el.find('.details').html();
				var marker = null;
				
				var lat = el.find('.latitude').val();
                var lon = el.find('.longitude').val();
				
				var latlong = lat+','+lon;
            	var latlng = new google.maps.LatLng(lat, lon);
				
				carat.locationZoom(marker, html,id, latlng)
			
		});
		
        
    },
    
    //start the map
    launchMap : function () {
		
            directionsService = new google.maps.DirectionsService();
            directionsDisplay = new google.maps.DirectionsRenderer({ draggable: true});
    
            var latlng = new google.maps.LatLng(25,30);
            
            var mapOptions = {
              zoom:2,
              center: latlng,
              icon : '/static/assets/image/network/marker_green.png',
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            
            map = new google.maps.Map(document.getElementById("google_map"), mapOptions);
            
            directionsDisplay.setMap(map);
            directionsDisplay.setPanel(document.getElementById("directionsPanel"));
            
			google.maps.event.addListener(map, 'tilesloaded', function(){
				carat.buildCountries();		
				google.maps.event.clearListeners(map, 'tilesloaded');
			}); 

      },
    
    //build array  of locations and  fire the markers   
    buildCountries : function () {
        
            geocoder = new google.maps.Geocoder();
        
            var offices = []; 
    
            $('.details').each(function(i, element){
                                        
                var office = {};  
				
                office.country = $(this).find('.country').html();
                office.region = $(this).find('.region').text();
                office.index = i;
				office.html = $(this).html();
				
				var lat = $(this).find('.latitude').val();
                var lon = $(this).find('.longitude').val();
				
				var latlong = lat+','+lon;
            	office.latlng = new google.maps.LatLng(lat, lon);
				
                var o = $(this).siblings('.name');
				
                if (o.hasClass('true')) {
                    office.colour = 999
                } else { 
                    office.colour = $(this).parents('.region').find('.handle').attr('rel');
                }
				
                offices[i] = office;
				
				 if (i == $('.details').length-1) {
                    carat.createMarker(offices);
                }
                
            });
      },
	
    
    //create a marker
    createMarker : function (offices) {
		
		for (i = 0; i < offices.length; i++) { 
		
			(function (offices) {
			var o 		= offices[i],
				country = o.country,
				latlng = o.latlng,
				region 	= o.region,
				id 		= o.index,
				col 	= o.colour,
				html  	= o.html;
				
	
				if( col ==1 ) {
					var colour = "orange";
				} else if ( col ==2 ) {
					var colour = "blue";
				} else if ( col ==3 ) {
					var colour = "pink";
				} else if ( col ==4 ) {
					var colour = "green";
				} else  if ( col ==999 ) {
					var colour = "lead";
				} else {
					var colour = "orange";
				}
				
				
				
					var marker = new google.maps.Marker({
						position: latlng,
						map: map,
						animation: google.maps.Animation.DROP,
						icon : '/static/assets/image/network/marker_'+colour+'.png',
						zIndex: Math.round(latlng.lat()*-100000)<<5,
						title : country+'',
						id : id
					});
					
					//marker click event
					google.maps.event.addListener(marker, 'click', function() {
						$('#detail_content').empty();
						carat.locationZoom(marker,html,id);
					});
					markers[id] = marker;
				})(offices);
		}
		
		this.regionNav();
            
       	//return marker;
    },

    findClosest : function (lat,lon) {
        
			
			function rad(x) {return x*Math.PI/180;}
			
			var lat = lat;
            var lng = lon;
			
			var R = 6371;
			var distances = [];
			var closest = -1;
			
			for( i=1;i<markers.length; i++ ) {
				if (markers[i] ) { 
					var mlat = markers[i].position.lat();
					var mlng = markers[i].position.lng();
					var dLat = rad(mlat - lat);
					var dLong = rad(mlng - lng);
					var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong/2) * Math.sin(dLong/2);
					var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
					var d = R * c;
					distances[i] = d;
					if ( closest == -1 || d < distances[closest] ) {
						closest = i;
					}
				}
			}
			
			 //alert(markers[closest].title);
			 
			 markers[closest].setAnimation(google.maps.Animation.BOUNCE);
             setTimeout(function() {
                markers[closest].setAnimation(google.maps.Animation.NULL);
             }, 5000);
			 
			 nearest = markers[closest].id+1;

             return nearest
			
			
			
    },
    
    //location detail
    locationZoom : function(marker,html,id,latlng) { 
            
            carat.hideDirections(); //remove directions 
            
          	
			if (marker != null) {
			
				var pos = marker.position;
				//do the map
				map.setCenter(pos);
				map.setZoom(16);
			} else  {
				map.setCenter(latlng);
				map.setZoom(16);
			}
            
            //load in the content
            $('#detail_content').html(html);
            
             //save the location
            $('#theirlocation').val(pos);
            
            //offset map for info panel
            var pan = ($('#detail').width())/2
            map.panBy(pan, 0);
            
            //slide the info panel out
            $('#detail').animate({right : 0}, 400);
            
            // for navigation
            $('.countries').addClass('detailon');
            
            $('#get_directions').live('click',function(e){
                 e.preventDefault();
                 $('#geolocate').text('. ').addClass('searching');

                 
                 here = document.getElementById("mylocation").value
                 carat.calcRoute(here);
            });
            
    },
    
    //set map back to original load state
    resetMap : function() {
        
            directionsDisplay.setMap(null);
            
            $('#theirlocation').val('');
            $('#d_form').hide();
            $('#detail').animate({right : -300}, 400,function(){
                
                var latlng = new google.maps.LatLng(25,30);
                map.setCenter(latlng);
                map.setZoom(2);
                //$(this).remove(); 
                $('#detail_content').empty();   

            });
            $('.detailon').removeClass('detailon');
    },

    
    calcRoute: function(here) {
         
         $('#mylocation').removeClass('request');
         
          var there = document.getElementById("theirlocation").value,
              transport = document.getElementById("mode"),
              selectedMode = transport.value;

		   if( here =="" ) {

				 $('#mylocation').addClass('request');
				carat.geo_innit(directions);
			  
			} else { 
			
				 var request = {
					  origin: here,
					  destination: there,
					  travelMode: google.maps.TravelMode[selectedMode]
				  };
				
				
				directionsDisplay.setMap(map);
				
				directionsService.route(request, function(response, status) {
				
				if (status == google.maps.DirectionsStatus.OK) {
				  directionsDisplay.setDirections(response);
				  carat.showDirections();
				} else if (status == google.maps.DirectionsStatus.NOT_FOUND ) {
					alert('Sorry were unable to find you directions');
				} else if (status == google.maps.DirectionsStatus.ZERO_RESULTS ) {
					alert('Sorry, there were no results for your directions');
				}
				
				carat.resetGeoBtn();
				
			  });
		  
		  }
    
    },
    
    showDirections : function() {
        $('#directions').animate({left : 0},400);
        $('#details').animate({left : 300},400);
        var pan = ($('#detail').width())/2
            map.panBy(pan, 0);
    },
    
    hideDirections : function() {
        $('#directions').animate({left : 300},400);
        $('#details').animate({left : 0},400);
    }
    


};





/* INITIALISE MASONRY */
//$(window).ready(function(){
//        $('#our-work #case-studies, #our-work #awards').masonry({ columnWidth: 230, itemSelector: 'article' });
//        $('#our-work #clients').masonry({ columnWidth: 233, itemSelector: 'article' });
//});

/* SCRIPTS */
$(document).ready(function(){

		// Dirty, dirty hack to get rid of "None" web addresses in Network...
		$('a[href=http://None]').parent('span').remove();

        //network Fire
        if ($('#network_page').length > 0) { 
                carat.init(carat);  //innits whole thing. last called so all is loaded.
        }

        // Forms
        $('input.focus').mouseenter(function(){
                if($(this).attr('value') == $(this).attr('placeholder')) $(this).val('');
                $(this).focus();
        });
        $('input.focus').mouseleave(function(){
                if($(this).attr('value') == '') {
                        $(this).val($(this).attr('placeholder'));
                        $(this).blur();
                }
        });
        
        // Left-nav drawers
        $('nav.left-nav nav.drawer').not('.open').hide();
        $('nav.left-nav a.handle').click(function(){
                //if($(this.attr('href') != '#')) return true;
                if($(this).next('nav.drawer').is(':visible')) {
                        // Collapse
                        $('nav.left-nav nav.drawer').slideUp(300);
                        $('nav.left-nav a.handle').removeClass('open');
                } else {
                        // Collapse and Expand
                        $('nav.left-nav a.handle').removeClass('open');
                        $('nav.left-nav nav.drawer').slideUp(300);
                        $(this).next('nav.drawer').slideDown(300);
                        $(this).addClass('open');
                }
                return false;
        });
        
        // FAQ drawers
        $('article.question section.drawer').not('.open').hide();
        $('article.question  h1.handle').click(function(){
                if($(this).siblings('section.drawer').is(':visible')) {
                        // Collapse
                        $('article.question  section.drawer').slideUp(300);
                        $('article.question  h1.handle').removeClass('active');
                } else {
                        // Collapse and Expand
                        $('article.question  h1.handle').removeClass('active');
                        $('article.question  section.drawer').slideUp(300);
                        $(this).siblings('section.drawer').slideDown(300);
                        $(this).addClass('active');
                }
                return false;
        });

        


        // News Carousel
        $('#news-slideshow div').cycle({ 
            fx:     'fade', 
            speed:  300, 
            timeout: 0,
            pager:  '#news-slideshow nav', 
            pagerAnchorBuilder: function(idx, slide) { 
                // return selector string for existing anchor 
                return '#news-slideshow nav a:eq(' + idx + ')'; 
            } 
        });
        
        // Gallery Carousel
        $('a.gallery-overlay').click(function(){
                slide = parseInt($(this).attr('slide'));
                $('#overlay').load($(this).attr('href')+' #gallery-wrap', function(){
                        $('iframe').hide();
                        $('#overlay').fadeIn(300, function(){
                                $('#gallery .slides').cycle({
                                    fx:     'fade', 
                                    speed:  300, 
                                    timeout: 0,
                                    next: '#gallery .slides article',
                                    startingSlide: slide,
                                    pager:  '#gallery nav',
                                    pagerAnchorBuilder: function(idx, slide) { 
                                    // return selector string for existing anchor 
                                    return '#gallery nav a:eq(' + idx + ')'; 
                                }
                                });
                        });
                });
                return false;
        });
        $('#overlay').click(function(e){
                if (e.target === this) {
                    $('#overlay').fadeOut(300).html('');
                    $('iframe').show();
                } return false;
        });
                
        if(gallery === true){
                var slide = parseInt(hashId.replace(/#slide/, ''));
        } else{
                var slide = 0;
        }       
        $('#gallery .slides').cycle({
            fx:     'fade', 
            speed:  300, 
            timeout: 0,
            next: '#gallery .slides article',
            startingSlide: slide,
            pager:  '#gallery nav',
            pagerAnchorBuilder: function(idx, slide) { 
                        // return selector string for existing anchor 
                return '#gallery nav a:eq(' + idx + ')'; 
            }
        });
        
        // Homepage Carousel
        $('#home-slides').cycle({
			fx: 'custom',
			cssBefore: {
				left: 620,
				display: 'block'
			},
			animIn: {
				left: 0
			},
			animOut: {
				left: -620
			},
			cssAfter: {
				display: 'none'
			},
			timeout: 8000,
			delay: -300,
			speed: 300,
			pager: '#carousel nav',
			after: onAfter
		});
			
			$('#home-slides article .play-button').click(function(){
				$('#home-slides').cycle('pause');
				videoId = $(this).parents('.video-wrap').attr('data-video-id')
				$(this).parents('.video-wrap').append('<iframe type="text/html" src="http://www.youtube.com/embed/' + videoId + '?showinfo=0&modestbranding=0&rel=0&autoplay=1" width="620px" height="412px" frameborder="0" allowfullscreen></iframe>');
			});
        
        // Homepage order
        $('section#blog-previews header nav').show();
        
        var blogOrderCookie = $.cookie('blog-order'),
        	$mostReadLink = $('nav#blog-order a[href=#most-read]'),
        	$mostRecentLink = $('nav#blog-order a[href=#most-recent]'),
        	$mostReadPosts = $('section#most-read-wrap'),
        	$mostRecentPosts = $('section#most-recent-wrap');

        if(blogOrderCookie == 'most-read') {
        	$mostRecentPosts.hide();
        	$mostReadPosts.show();
        	$mostRecentLink.removeClass('active');
        	$mostReadLink.addClass('active');
        } else if(blogOrderCookie == 'most-recent' || blogOrderCookie == null) {
        	$mostRecentPosts.show();
        	$mostReadPosts.hide();
        	$mostReadLink.removeClass('active');
        	$mostRecentLink.addClass('active');
        }
	
		$mostReadLink.click( function() {
		    $mostRecentLink.removeClass("active");
		    $mostReadLink.addClass("active");
		    $mostRecentPosts.fadeOut("200", function() {
		   		$mostReadPosts.fadeIn("200");
		    });
		    $.cookie("blog-order", "most-read", { expires: 0, path: "/" });
		    return false;
		});
		
		$mostRecentLink.click( function() {
		    $mostReadLink.removeClass("active");
		    $mostRecentLink.addClass("active");
		    $mostReadPosts.fadeOut("200", function() {
		   		$mostRecentPosts.fadeIn("200");	
		    });
		    $.cookie("blog-order", "most-recent", { expires: 0, path: "/" });
		    return false;
		});

        // People Thumbs Hover
        $(function() {
          var moveLeft = 5;
          var moveDown = -25;

          $('.people-list .person a').hover(function(e) {
            $(this).next('.label').show();
          }, function() {
            $(this).next('.label').hide();
          });

          $('.people-list .person a').mousemove(function(e) {
            $(this).next('.label').css({
		"top": e.pageY + moveDown - $(window).scrollTop(),
		"left": e.pageX + moveLeft
		});
          });

        });
        
        // Services Widget
        $('section#services section#articles article').not(':first-child').hide();
        $('section#services nav#services-list a:first-child').addClass('active');
        $('section#services nav#services-list a').click(function(){
                articleId = $(this).attr('href');
                link = $(this);
                if($('article#'+articleId).is(':visible')) {
                        // Do nothing
                        return false;
                } else {
                        // Hide and show the new article
                        $('section#services nav#services-list a').removeClass('active');
                        $('article#'+articleId).slideDown();
                        $('section#services section#articles article').not('#'+articleId).slideUp();
                        link.addClass('active');
                        return false;
                }
        });
        
        // Our Story Widget
        $('article.milestone').removeClass('vert');
        startDate = $('article.milestone:first-child time').text();
        endDate = $('article.milestone:last-child time').text();
        years = endDate - startDate;
        spacing = 650/years;
        $('article.milestone').each(function(i){
                articleDate = $(this).children('time').text();                  
                $(this).css('left', ((articleDate-startDate)*spacing)+'px');
        });
        $('article.milestone time').hover(function(){
                $(this).siblings('figure').fadeIn(200);
        }, function(){
                $(this).siblings('figure').fadeOut(200);
        });
        
        // Budget Range
        $('span#budget-range').html($('select#budget-start').find(':selected').text()+' &ndash; '+$('select#budget-end').find(':selected').text());
        $('#budget select').change(function(){
                start = $('select#budget-start').find(':selected');
                end = $('select#budget-end').find(':selected');
                if(start.val() > end.val()){
                        $(this).val($(this).siblings('select').val());
                        start = $('select#budget-start').find(':selected');
                        end = $('select#budget-end').find(':selected');
                }
                $('span#budget-range').html(start.text()+' &ndash; '+end.text());
        });
        
        // Expanding Footer
        //$('#map iframe, #hidden-address').hide();
        //$('footer.global').mouseenter(function(){
        //        $('#map iframe').slideDown(300, function(){
        //            $('#hidden-address').fadeIn();
        //        });
        //});
        
});

function onAfter(currSlideElement) {
	$('#home-slides article iframe').remove();
}




