/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();
/**
 * Icon namespace
 */
var Icon = {
	defined: function(w,s) { return typeof((s||this)[w])!='undefined'; }
	, run: function(w) { if(Icon.defined(w)){ Icon[w](); } }
	, el_fonts: {
		light: [
	         'h1'
	         , 'p.section'
	         , 'h2[class$=-heading]'
	         , '#team h3'
	         , '.blurb'
	         , '.blog #right_column h2'
	         , '#comments_area h2'
	         , '#leave_comment h2'
	         , '.red-heading'
         ]
		, medium: [
	          '#nav'
	          , '#nav_sub'
	          , '#nav_sub .selected a'
	          , '.mini-nav'
          ]
		, hovers_medium: [
	          '#nav a'
	          , '#nav_sub a'
	          , '.mini-nav a'
          ]
	}
	, isPhone: false
	, detectRetina: function() {
		return (Icon.defined('devicePixelRatio',window) && window.devicePixelRatio >= 2);
	}
};

if(typeof(Array.prototype.remove)=='undefined') {
	// Array Remove - By John Resig (MIT Licensed)
	Array.prototype.remove = function(from, to) {
	  var rest = this.slice((to || from) + 1 || this.length);
	  this.length = from < 0 ? this.length + from : from;
	  return this.push.apply(this, rest);
	};
}

Icon.font_unreplace = function(selector,list) {
	if(!Icon.defined(list,Icon.el_fonts)) return;
	var i = $.inArray(selector,Icon.el_fonts[list]);
	if(i>-1) {
		Icon.el_fonts[list].remove(i);
	}
};

Icon.comment_validation = function() {
	jQuery(function($){ $('#comment_form').validate(); });
};
Icon.contact_validation = function() {
	jQuery(function($){ $('#contact_form').validate(); });
};
/**
 * The following runs all all pages auotmatically if jQuery is defined
 */
if(Icon.defined('jQuery',window)) {
	// GLOBAL ENHANCEMENTS
	jQuery(function($){
		
		Icon._isIE = jQuery.browser.msie;
		Icon._isIE6 = (Icon._isIE && parseInt(jQuery.browser.version) == 6);
		/**
		 * IE6 PNG FIXES
		 */
		if(Icon._isIE6 && Icon.defined('DD_belatedPNG',window)) {
			var els = [
			           'img',
			           '#nav_sub .selected a span',
			           '#nav_sub .back a span',
			           'p.full-story a span',
			           '#twitter_feed p'
			           ];
			
			DD_belatedPNG.fix(els.join(','));
		}
		
		
		//Remove the value from the email subscribe box when it has focus
		$('.register_tb').focus(function(){
			if($(this).val() == "Email"){
				$(this).val("")
			}
			$('#subscribe_error').hide();
		})
		//put it back if it's empty
		$('.register_tb').blur(function(){
			if($(this).val() == ""){
				$(this).val("Email")
			}
		})
		
		$('#search_text_box').focus(function(){
			if($(this).val() == "Looking for something?"){
				$(this).val("")
			}
		})
		//put it back if it's empty
		$('#search_text_box').blur(function(){
			if($(this).val() == ""){
				$(this).val("Looking for something?")
			}
		})
		
		// Validate the subscribe form
		$('#subscribe_error').hide()
		
		$('#subscribe_btn').click(function(){
			if(!$("#register_form").valid() || $('#jruduu-jruduu').val().indexOf("@")<=-1){
				
				$('#subscribe_error').show()
				
				return false
			}
		})
		
		
		//The privacy link
		if(!Icon.isPhone) {
			$('#privacy_policy a').click(function(e){
				e.preventDefault();
				var domain = 'http://'+window.location.host,
					segments = $(this).attr('href').replace(domain,''),
					path = domain+'/index.php?default/shadowbox-frame'+segments
					;
				Shadowbox.open({
				        content:    path,
				        player:     "iframe",
				        title:      "Privacy Policy",
				        height:     '600px',
				        width:      '600px'
				    });
				
				return false;
			});
		}
		
	});
	// end: GLOBAL ENHANCEMENTS
} // end: if jQuery is defined
/**
 * Script is annonomous.
 * Adds a method 'home' to Icon namespace for home specific enhancements
 * call via: Icon.run('home');
 */
(function(){
	var $ = jQuery;
	var slide_time_out = "";
	var count = 0;
	
	function change_slide(){
		$("#dot_"+count).removeClass("selected");
		count++;
		if(count==slides.length){
			count = 0;
		}
		
		$("#dot_"+count).addClass("selected");
		$(".slide").eq(count - 1).fadeOut("slow").removeClass("selected_slide");
		$(".slide").eq(count).fadeIn("slow", function() {
			slide_time_out = setTimeout(function() {
				clearTimeout(slide_time_out);
				change_slide();
			}, time);
		}).addClass("selected_slide");
		
	}
	Icon.home = function() {
		$(function(){
			time = 5000;
			slides = $('.slide');
			
			//Hide all but the first slide
			$(".slide").not(":first").hide();
			
			//Add the dots
			$('.slide').each(function(i){
				$("#dots").append('<a href="#" id="dot_'+i+'"><img src="/assets/images/blank.gif" alt="'+i+'"/></a>');
			});
			
			// icon.pr center dots
			var width = $("#dots").outerWidth();
			$("#dots").css({
				left: '50%',
				marginLeft: (0 - width/2)+'px'
			});
			
			// PNG fix dots
			if(Icon._isIE6 && Icon.defined('DD_belatedPNG',window)) {
				DD_belatedPNG.fix('#dots a');
			}
			
			//Make the first dot active
			$("#dots :first").addClass("selected");
			//Make the first Slide Active
			$(".slide:first").addClass("selected_slide");
			
			
			
			//Set up the trigger for the dots
			$("#dots a").click(function(){
				
				//Clear the timeout
				clearTimeout(slide_time_out);		
						
				$(".selected_slide").stop().fadeOut(function(){
					$(this).removeClass("selected_slide");
				});
				$(".slide").eq($(this).index()).fadeIn().addClass("selected_slide");
				
				$("#dots a").removeClass("selected").eq($(this).index()).addClass("selected");
				
				return false;
				
			});
			
			start_animation = function() {
				slide_time_out = setTimeout(function(){
					clearTimeout(slide_time_out);
					change_slide();
				}, time);
			}
			
			/**
			 * Slightly different behaviour on phone
			 */
			if(Icon.isPhone) {
				var hit_l = document.createElement('div');
				var hit_r = document.createElement('div');
				$(hit_l).addClass('hit-spot left');
				$(hit_r).addClass('hit-spot right');
				$('#banner').append(hit_l);
				$('#banner').append(hit_r);
				var banner_touch = function(event) {
				    
					for(var i=0,c=event.touches.length;i<c;i++) {
				    	var el = event.touches[i].target;
				    	if(el==hit_l) {
				    		// View
			    			
				    		if($('#slide_wrapper').hasClass('screen-2')) {
				    			// View
				    			var slide = $('#slide_wrapper .selected_slide a');
				    			if(slide.length){
				    				document.location = slide[0].href;
				    			}
				    		}else{
				    			// Info - screen 2
				    			clearTimeout(slide_time_out);
				    			// make sure its still visible
				    			$('#slide_'+count).fadeIn();
				    			$('#dots_wrapper').fadeOut();
				    			$('#slide_wrapper').addClass('screen-2');
				    			$('#slide_wrapper').animate({left:'0'},function(){
				    				var slide = $('#slide_wrapper .selected_slide a');
					    			if(slide.length){
					    				$(el).addClass('view');
					    			}
				    			});
				    		}
				    	}
				    	if(el==hit_r) {
				    		
				    		if($('#slide_wrapper').hasClass('screen-2')) {
			    				// Back
				    			$(hit_l).removeClass('view');
				    			$('#slide_wrapper').animate({left:'-320px'},function(){
				    				$('#dots_wrapper').fadeIn();
				    				start_animation();
				    				$('#slide_wrapper').removeClass('screen-2');
				    			});
			    			}
				    	}
				    	
				    }
					
				}
				document.addEventListener('touchstart', banner_touch, false);
				
			}
			
			//Start the animation
			start_animation();
			
		});
	};
	
})();
/**
 * Pauls custom mod of quicksand
 */
(function($) {
	// Cufon needs to be replaced again after clone
	$.fn.sorted = function(customOptions) {
		var options = {
			reversed: false,
			by: function(a) {
				return a.text();
			}
		};
		$.extend(options, customOptions);
	
		$data = $(this);
		arr = $data.get();
		arr.sort(function(a, b) {
			
		   	var valA = options.by($(a));
		   	var valB = options.by($(b));
			if (options.reversed) {
				return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;				
			} else {		
				return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;	
			}
		});
		return $(arr);
	};
	
	Icon.pauls_quicksand = function() {
		$(function() {
		 
			 var $list = $('#folio_list .image-grid');
			 var $data = $list.clone();
			 
			  var read_button = function(class_names) {
			    var r = {
			      selected: false,
			      type: 0
			    };
			    for (var i=0; i < class_names.length; i++) {
			      if (class_names[i].indexOf('selected-') == 0) {
			        r.selected = true;
			      }
			      if (class_names[i].indexOf('segment-') == 0) {
			        r.segment = class_names[i].split('-')[1];
			      }
			    };
			    return r;
			  };
			  
			  var determine_sort = function($buttons) {
			    var $selected = $buttons.parent().filter('[class*="selected-"]');
			    return $selected.find('a').attr('data-value');
			  };
			  
			  var determine_kind = function($buttons) {
			    var $selected = $buttons.parent().filter('[class*="selected-"]');
			    return $selected.find('a').attr('data-value');
			  };
			  
			  var $preferences = {
			    duration: 800,
			    easing: 'easeInOutQuad',
			    adjustHeight: 'dynamic'
			  };
			  
			  
			  var $controls = $('.splitter ul');
			  
			  $controls.each(function(i) {
			    
			    var $control = $(this);
			    var $buttons = $control.find('a');
			    
			    $buttons.bind('click', function(e) {
			      
			      var $button = $(this);
			      var $button_container = $button.parent();
			      var button_properties = read_button($button_container.attr('class').split(' '));      
			      var selected = button_properties.selected;
			      var button_segment = button_properties.segment;
			
			      if (!selected) {
			
			        $buttons.parent().removeClass('selected-0').removeClass('selected-1').removeClass('selected-2');
			        $button_container.addClass('selected-' + button_segment);
			        
			        var sorting_type = determine_sort($controls.eq(1).find('a'));
			        var sorting_kind = determine_kind($controls.eq(0).find('a'));
			        
			        if (sorting_kind == 'all') {
			          var $filtered_data = $data.find('li');
			        } else {
			          var $filtered_data = $data.find('li[class~=' + sorting_kind +']');
			        }
			        
			        if (sorting_type == 'size') {
			          var $sorted_data = $filtered_data.sorted({
			            by: function(v) {
			              return parseFloat($(v).find('span').text());
			            }
			          });
			        } else {
			          var $sorted_data = $filtered_data.sorted({
			            by: function(v) {
			              //return $(v).find('strong').text().toLowerCase();
			        	  return $(v).attr('data-id');
			            }
			          });
			        }
			        
			        $list.quicksand($sorted_data, $preferences);
			        
			      }
			      
			      e.preventDefault();
			    });
			    
			  }); 
			  
			  
			  var high_performance = true;  
			  var $performance_container = $('#performance-toggle');
			  var $original_html = $performance_container.html();
			  
			  $performance_container.find('a').live('click', function(e) {
			    if (high_performance) {
			      $preferences.useScaling = false;
			      $performance_container.html('CSS3 scaling turned off. Try the demo again. <a href="#toggle">Reverse</a>.');
			      high_performance = false;
			    } else {
			      $preferences.useScaling = true;
			      $performance_container.html($original_html);
			      high_performance = true;
			    }
			    e.preventDefault();
			  });
			  
		});
		
	};
	
})(jQuery);


Icon.folio_list = function() {
	var $ = jQuery;
	
	var hasCufon = Icon.defined('Cufon',window);
	
	$(function(){
		
		if(Icon.isPhone) {
			Icon.folio_list_compact();
		}
		
		//Set up the triggers for the filter
		
		$("#nav_sub li a").hover(function(){
			f = $(this).attr("data-value");
			$("."+f + " .folio_category").addClass('highlight');
		},function(){
			$(".folio_category").removeClass('highlight');
		});
		
		//Move the selected state
		$("#nav_sub li a").click(function(){
			
			$("#nav_sub .selected").removeClass("selected");
			
			$(this).parent().addClass("selected");
			// fix cufon if not mobile version
			if(hasCufon && !Icon.isPhone) {
				Cufon.replace('#nav_sub a');
			}
		});
		
		//Click the first one to initiate the load
		$(".splitter a:first").click();
		
		Icon.run('pauls_quicksand');
		
	});
	
};

Icon.folio_list_compact = function() {
	
	var nav = $("#nav_sub ul");
	if(nav==null) return;
	var filter = $('<div class="filter"/>').insertBefore(nav);
	var inner = $('<div class="inner"/>');
	var toggle = $('<a class="toggle open" href="#">All</a>');
	var speachmark = $('<div class="speach-mark"/>');
	filter.append(toggle).append(inner).append(speachmark);
	inner.append(nav);
	
	var openNav = function() {
		var h = $(nav).innerHeight();
		$(nav).css({top:(0-h)});
		$(inner).css({height:h});
		$(nav).animate({top:0},function(){
			$(toggle).addClass('open');
		});
	};
	
	var closeNav = function() {
		var h = $(nav).innerHeight();
		$(nav).animate({top:(0-h)},function(){
			$(inner).css({height:0});
			$(toggle).removeClass('open');
		});
	};
	
	$(toggle).click(function(e){
		e.preventDefault();
		if($(toggle).hasClass('open')) {
			closeNav();
		}else{
			openNav();
		}
	});
	var hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	$(nav).find('a').click(function(e){
		toggle.text($(this).text());
		closeNav();
	});
}
Icon.staff_grid = function() {
	if(Icon.defined('MooTools',window)) {
		
		window.addEvent('domready', function(){
			
			var edge		= (!Icon.isPhone ? 35 : 10),
				itemsPerRow	= (!Icon.isPhone ? 6 : 2),
				team		= $$('#team .grid')[0],
				staff 		= $$('#team .staff'),
				thumbs		= $$('#team .thumb').setStyles({
					position: 	'absolute',
					padding:	10
				});
			if(team==undefined) return;
			if(Icon.isPhone) {	
				thumbs.each(function(el){
					el.setStyles({
						width: (el.getStyle('width').toInt() + (edge*2)),
						height: (el.getStyle('height').toInt() + (edge*2)),
						padding: 0
					});
				});
			}
			var z			= {
					bottom: 	20,
					top:		25,
					details:	30
				},
				size			= thumbs[0].getSize(),
				crop			= { 
					x: 			(size.x - edge), 
					y: 			(size.y - edge) 
				},
				cropped			= [edge,crop.x,crop.y,edge],
				uncropped		= [0,size.x,size.y,0],
				details			= $$('#team .details').setStyles({
					position: 	'absolute',
					top:		-9999,
					left:		-9999,
					visibility: 'hidden',
					zIndex:		z.details,
					width:		268,
					padding:	[3,18,23,7]
				}),
				calculate_position = function(e,i) {
					var offset	= {x:17,y:30},
						size 	= details[i].getSize(),
						coords	= team.getCoordinates(),
						winScroll = window.getScroll(),
						pos		= {
								x: e.client.x - coords.left - offset.x + winScroll.x,
							
								y: e.client.y - coords.top - size.y - offset.y + winScroll.y
							}
						;
					
					if((pos.x+size.x) > coords.right) {
						pos.x -= details[i].getStyle('width').toInt() - offset.x;
						details[i].addClass('right');
					}else{
						details[i].removeClass('right');
					}
					
					if(Icon.isPhone) {
						details.setStyles({
							width: 258,
							padding: 0
						});
						pos = {
							x: 0,
							y: (-14 - size.y)
						}
						if(i%2) {
							pos.x = 0 - ((size.x/2)+4);
							details[i].addClass('right');
						}else{
							details[i].removeClass('right');
						}
					}
					
					return pos;
				}
				;
			// ----------------------------------------------------------------
			staff.setStyles({
				width: (crop.x - edge),
				height: (crop.y - edge)
			});
			
			thumbs.setStyles({
				clip:	cropped,
				marginTop: 	(edge * -1),
				marginLeft: (edge * -1),
				zIndex:	z.bottom	
			}).each(function(thumb,i){
				var morph = new Fx.Morph(thumb,{
					duration: 250,
					link: 'cancel'
				});
				thumb.addEvents({
					mouseenter: function(e) {
						morph.start({
							clip: 	[cropped,uncropped],
							zIndex:	z.top
						});
						
						var pos = calculate_position(e,i);
						details[i].setStyles({
							top: pos.y,
							left: pos.x
						}).fade('show');
						
					},
					mouseleave: function() {
						details[i].fade('hide')
						morph.start({
							clip: [uncropped,cropped],
							zIndex:	z.bottom
						});
					},
					mousemove: function(e) {
						var pos = calculate_position(e,i);
						details[i].setStyles({
							top: pos.y,
							left: pos.x
						});
					}
				});
				details[i].addEvent('click',function(){
					this.fade('hide');
					morph.start({
						clip: 	[uncropped,cropped],
						zIndex:	z.bottom
					});
				});
			});
			
			// fill empty row spaces
			var itemFloat = 1 / itemsPerRow,
				count = thumbs.length,
				rowsFloat = count / itemsPerRow,
				rowsCeil = Math.ceil(rowsFloat),
				remaining = Math.round((rowsCeil - rowsFloat) / itemFloat)
				;
			for(var i=0;i<remaining;i++) {
				team.adopt(
						new Element('div').setStyles({
							width: (crop.x - edge),
							height: (crop.y - edge)
						}).addClass('staff empty')
				);
			}
			
		});
	}
}
Icon.icon_map = function() {
	jQuery(window).load(function(){
		var mapArea = document.getElementById('gmap');
		if(!Icon.defined('GMap2',window)) {
			return;
		}
		var map = new GMap2(mapArea);
		var office = new GLatLng(-37.831742,144.992557);
		map.setCenter(office, 17);
		map.setUIToDefault();
		
		var pin = new GIcon();
		pin.image = '/assets/images/icon-map-icon.png';
		pin.imageSize = new GSize(65,41);
		pin.iconAnchor = new GPoint(13,41);
		pin.shadow = '/assets/images/icon-map-icon-shadow.png';
		pin.shadowSize = new GSize(91,41);
		
		map.addOverlay(new GMarker(office,{icon:pin}));
	}).unload(function(){
		GUnload();
	});
};

/************************************************
	jquery.animate-enhanced plugin v0.49
	Author: www.benbarnett.net || @benpbarnett
*************************************************/
/*(function(q){var t=false,u=jQuery.fn.animate,w="WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix,x=["top","left","opacity","height","width"],h=["","-webkit-","-moz-","-o-"],y=["avoidTransforms","useTranslate3d","leaveTransforms"],z=/^([+-]=)?([\d+-.]+)(.*)$/,m=(document.body||document.documentElement).style,r=m.WebkitTransition!==undefined?"webkitTransitionEnd":m.OTransition!==undefined?"oTransitionEnd":"transitionend";t=m.WebkitTransition!==undefined||m.MozTransition!==undefined||m.OTransition!==
undefined||m.transition!==undefined;jQuery.fn.interpretValue=function(a,b,i,j){var c=z.exec(b),d=a.css(i)==="auto"?0:a.css(i);d=typeof d=="string"?d.replace(/px/g,""):d;typeof b=="string"&&b.replace(/px/g,"");j=j===true?0:d;var l=jQuery(a).is(":hidden");if(i=="left"&&a.data("translateX"))j=d+a.data("translateX");if(i=="top"&&a.data("translateY"))j=d+a.data("translateY");if(!c&&b=="show"){j=1;l&&a.css({display:"block",opacity:0})}if(c){a=parseFloat(c[2]);if(c[1])a=(c[1]==="-="?-1:1)*a+parseInt(j,10);
return a}else return j};jQuery.fn.getTranslation=function(a,b,i){return i===true&&w?"translate3d("+a+"px,"+b+"px,0)":"translate("+a+"px,"+b+"px)"};jQuery.fn.applyCSSTransition=function(a,b,i,j,c,d,l){a.data("cssEnhanced")||a.data("cssEnhanced",{secondary:{},meta:{left:0,top:0}});if(b=="left"||b=="top"){var f=a.data("cssEnhanced").meta;f[b]=c;f[b+"_o"]=a.css(b)=="auto"?0+c:parseInt(a.css(b).replace(/px/g,""),10)+c||0;a.data("cssEnhanced").meta=f;if(d&&c===0){c=0-f[b+"_o"];f[b]=c;f[b+"_o"]=0}}return a.data("cssEnhanced",
jQuery.fn.applyCSSWithPrefix(a.data("cssEnhanced"),b,i,j,c,d,l))};jQuery.fn.applyCSSWithPrefix=function(a,b,i,j,c,d,l){a=typeof a==="undefined"?{}:a;a.secondary=typeof a.secondary==="undefined"?{}:a.secondary;for(var f=h.length-1;f>=0;f--){if(typeof a[h[f]+"transition-property"]==="undefined")a[h[f]+"transition-property"]="";a[h[f]+"transition-property"]+=", "+(d===true?h[f]+"transform":b);a[h[f]+"transition-duration"]=i+"ms";a[h[f]+"transition-timing-function"]=j;a.secondary[d===true?h[f]+"transform":
b]=d===true?jQuery.fn.getTranslation(a.meta.left,a.meta.top,l):c}return a};jQuery.fn.isBoxShortcut=function(a,b){return(b=="width"||b=="height")&&(a=="show"||a=="hide"||a=="toggle")};jQuery.fn.animate=function(a,b,i,j){if(!t||jQuery.isEmptyObject(a))return u.apply(this,arguments);d=0;b=typeof b==="undefined"?"_default":b;if(typeof jQuery.fx.speeds[b]!=="undefined")b=jQuery.fx.speeds[b];var c=b&&typeof b==="object"?b:{complete:j||!j&&i||jQuery.isFunction(b)&&b,duration:b,easing:j&&i||i&&!jQuery.isFunction(i)&&
i},d=0,l=function(){d--;if(d<=0)if(typeof c.complete==="function")return c.complete.call()},f=function(){for(var g={},e=h.length-1;e>=0;e--){g[h[e]+"transition-property"]="none";g[h[e]+"transition-duration"]="";g[h[e]+"transition-timing-function"]=""}if(!a.leaveTransforms===true){e=q(this);var k=e.data("cssEnhanced")||{},s={"-webkit-transform":"","-moz-transform":"","-o-transform":"",transform:""};if(typeof k.meta!=="undefined"){s.left=k.meta.left_o+"px";s.top=k.meta.top_o+"px"}e.unbind(r).css(g).css(s).data("translateX",
0).data("translateY",0).data("cssEnhanced",null)}l()},v={bounce:"cubic-bezier(0.0, 0.35, .5, 1.3)",linear:"linear",swing:"ease-in-out",easeInOutQuint:"cubic-bezier(0.5, 0, 0, 0.8)"},n=null,o="";o=c.easing||"swing";o=v[o]?v[o]:o;for(p in a)jQuery.inArray(p,y)===-1&&this.each(function(){var g=q(this),e=jQuery.fn.interpretValue(g,a[p],p,(p=="left"||p=="top")&&a.avoidTransforms!==true?true:false);if(jQuery.inArray(p,x)>-1&&g.css(p).replace(/px/g,"")!==e&&!jQuery.fn.isBoxShortcut(a[p],p))jQuery.fn.applyCSSTransition(g,
p,c.duration,o,(p=="left"||p=="top")&&a.avoidTransforms===true?e+"px":e,(p=="left"||p=="top")&&a.avoidTransforms!==true?true:false,a.useTranslate3d===true?true:false);else{n=!n?{}:n;n[p]=a[p]}});this.each(function(){for(var g=q(this),e=g.data("cssEnhanced")||{},k=h.length-1;k>=0;k--)if(typeof e[h[k]+"transition-property"]!=="undefined")e[h[k]+"transition-property"]=e[h[k]+"transition-property"].substr(2);g.data("cssEnhanced",e)});if(n){d++;u.apply(this,[n,c.duration,c.easing,l])}this.each(function(){var g=
q(this).unbind(r);if(!jQuery.isEmptyObject(g.data("cssEnhanced")))if(!jQuery.isEmptyObject(g.data("cssEnhanced").secondary)){d++;var e=g.data("cssEnhanced").secondary||{};g.css(g.data("cssEnhanced"));setTimeout(function(){g.bind(r,f).css(e)})}});return this}})(jQuery);
*/

// jQuery.support.transition
// to verify that CSS3 transition is supported (or any of its browser-specific implementations)
/*jQuery.support.transition = (function(){
    var thisBody = document.body || document.documentElement,
    thisStyle = thisBody.style,
    support = thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.OTransition !== undefined || thisStyle.transition !== undefined;
    
    return support;
})();*/

(function($) {
	
	if(!Icon.defined('Shadowbox',window)) {
		window.Shadowbox = { init: function() {} };
	}
	
	Icon.phone = function() {
		
		$(document).ready(function(){
			var btn_menu = $('<a href="#" class="btn-menu">Menu</a>');
			var nav = $('#nav');
			var menu = nav.find('ul');
			var subs = nav.find('ul ul').slideUp();
			nav.after(btn_menu);
			
			
			var doPulse = true;
			var userKnowsMenu = false;
			var cookie = document.cookie;
			if(cookie) {
				var ca = cookie.split(';');
				for(var i=0;i < ca.length;i++) {
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if (c.indexOf('userKnowsMenu=') == 0){
						doPulse = false;
					}
				}
			}
			
			if(doPulse) {
				var pulsate = function() {
					$(btn_menu).animate({
						opacity: .6
					},500).animate({
						opacity: 1
					},2000,null,pulsate);
				}
				var killPulse = function() {
					window.clearTimeout(pulse);
					pulsate = $.noop();
					$(btn_menu).stop(true,true).css({opacity:1});
					document.cookie = 'userKnowsMenu=1;'+cookie;
				}
				var pulse = window.setTimeout(pulsate,2000);
			}
			btn_menu.click(function(e){
				e.preventDefault();
				if(doPulse) {
					killPulse();
				}
				if($(nav).hasClass('open')) {
					$(nav).animate({height:0},function(){
						$(nav).removeClass('open');
						nav.find('ul ul').slideUp();
					});
				}else{
					var h = $(menu).outerHeight();
					$(nav).animate({height:h},function(){
						$(nav).css({height: 'auto'});
					});
					$(nav).addClass('open');
				}
			});
			
			
			$(menu).find('> li > a').click(function(e){
				var sub = $(this).next('ul');
				if(sub.length>0) {
					e.preventDefault();
					sub.slideToggle(250,function(){
						$(e.target).toggleClass('open');
					});
				}
			});
			$(menu).find('li li a').unbind('click');
			
			var clone = $('#nav').clone().prependTo($('#footer'));
			$(clone).find('ul > li > a').click(function(e){
				var sub = $(this).next('ul');
				if(sub.length>0) {
					e.preventDefault();
					sub.slideToggle(250,function(){
						$(e.target).toggleClass('open');
					});
				}
			});
			$(clone).find('ul > li li a').unbind('click');
			$(clone).find('ul ul').slideUp();
		});
		
		
	};
	
})(jQuery);
/**
* Icon.inc	Enhancements
* @depend	../3p/DD_belatedPNG.js
* @depend	namespace-global.js	
* @depend 	home.js
* @depend	pauls-quicksand.js
* @depend	folio.js
* @depend	team.js
* @depend	icon-map.js
* @depend	icon-phone.js
*/


