/**
 * 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) {
			$(window).load(function(){
				$('#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();
			
			//var _Array ;
			//_Array = new Array(3);
			//_Array[0]='kouki';
			//_Array[1]='kiko';
			//_Array[2]='karkar';
			//_Array[3]='karkoura';
			
			//Add the dots
			$('.slide').each(function(i){
				$("#dots").append('<a href=""  id="dot_'+i+'"><img src="images/blank.gif" alt="'+$('#slide_'+(i+1)).attr('title')+'"/></a>');
			});
			//alert($('#slide_1').attr('title'))
			//alert();
			//
			// 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();
	});
};
(function(window){
	if(typeof(window.MooTools)=='undefined') return;
	var Clipgrid = new Class({
		Implements: [Events,Options]
		, options: {
			clip_gutter: 30
			, items_per_row: 6
			, item_selector: '.item'
			, img_selector: 'img'
			, placeover_selector: '.details'
			, placeover_offset: {x:10,y:10}
			, z_top: 25
			, z_bottom: 20
			, z_placeover: 30
			, fill_gaps: true
			, fx_duration: 250
			, fx_link_policy: 'cancel'
			/* POSSIBLE EVENT CALLBACKS
			 * 
			 * onBegin
			 * init_placeover
			 * onComplete
			 */
		}
		, imgs: []
		, initialize: function(element,options) {
			var self = this;
			self.el = $(element);
			if(self.el==null) return;
			self.setOptions(options);
			self.fireEvent('begin');
			self.items = self.el.getElements(self.options.item_selector);
			Array.each(self.items,function(el,i){
				var img = el.getElement(self.options.img_selector)
					, placeover = el.getElement(self.options.placeover_selector)
					, size = img.getSize()
					, cg = self.options.clip_gutter
					, crop = { 
						x: (size.x - cg)
						, y: (size.y - cg) 
					}
					, cropped = [cg,crop.x,crop.y,cg]
					, uncropped	= [0,size.x,size.y,0]	
					;
				
				// Run initPlaceover hook
				if(placeover!=null) { self.fireEvent('initPlaceover',[placeover,img]); }
				
				el.setStyles({
					width: (crop.x - cg)
					, height: (crop.y - cg)
				});
				
				img.setStyles({
					position: 'absolute'
					, clip:	cropped
					, marginTop: 	(cg * -1)
					, marginLeft: (cg * -1)
					, zIndex:	self.options.z_bottom	
				});
				
				self.imgs.push(img);
				self.add_crop_events(cropped,uncropped);
				if(el===self.items.getLast() && self.options.fill_gaps) {
					self.fill_gaps(crop,cg);
				}
			});
			self.fireEvent('complete');
		}
		, add_crop_events: function(cropped,uncropped)
		{
			var self = this;
			Array.each(self.imgs,function(img){
				var morph = new Fx.Morph(img,{
					duration: self.options.fx_duration
					, link: self.options.fx_link_policy
				});
				img.addEvents({
						mouseenter: function(e) {
						morph.start({
							clip: 	[cropped,uncropped]
							, zIndex:	self.options.z_top
						});
					},
					mouseleave: function() {
						morph.start({
							clip: [uncropped,cropped]
							, zIndex:	self.options.z_bottom
						});
					}
				});
			});
		}
		, add_placeover_events: function(placeover,img)
		{
			var self = this;
			img.addEvents({
				mouseenter: function(e) {
					var pos = self.target_placeover_pos(e,placeover);
					placeover.setStyles({
						top: pos.y
						, left: pos.x
					}).fade('show');
				},
				mouseleave: function() {
					placeover.fade('hide');
				},
				mousemove: function(e) {
					var pos = self.target_placeover_pos(e,placeover);
					placeover.setStyles({
						top: pos.y
						, left: pos.x
					});
				}
			});
		}
		, target_placeover_pos: function(e,placeover)
		{
			var self = this
				, offset = self.options.placeover_offset
				, size = placeover.getSize()
				, coords = self.el.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 -= placeover.getStyle('width').toInt() - offset.x;
				placeover.addClass('right');
			}else{
				placeover.removeClass('right');
			}
			
			return pos;
		}
		, fill_gaps: function(crop,gutter)
		{
			var self = this
				, itemFloat = 1 / self.options.items_per_row
				, count = self.items.length
				, rowsFloat = count / self.options.items_per_row
				, rowsCeil = Math.ceil(rowsFloat)
				, remaining = Math.round((rowsCeil - rowsFloat) / itemFloat)
				;
			for(var i=0;i<remaining;i++) {
				self.el.adopt(
					new Element('div').setStyles({
						width: (crop.x - gutter)
						, height: (crop.y - gutter)
					}).addClass('empty')
				);
			}
		}
	});
	// Expose to window
	window.Clipgrid = Clipgrid;
})(window);
// @depend clipgrid.js
Icon.staff_grid = function() {
	if(Icon.defined('Clipgrid',window)) {
		window.addEvent('domready', function(){
		new Clipgrid($$('.grid')[0],{
			item_selector: '.staff'
			, img_selector: '.thumb'
			, placeover_selector: '.details'
			, placeover_offset: {x:17,y:30}
			, onInitPlaceover: function(placeover,img)
			{
				// Fired if an element designated as placeover is found ie a details
				// bubble etc. available arguments are:
				// placeover (element), img (element) 
				// this (refers to the Clipgrid instance)
				placeover.setStyles({
					position: 	'absolute',
					top:		-9999,
					left:		-9999,
					visibility: 'hidden',
					zIndex:		this.options.z_placeover,
					width:		268,
					padding:	[3,18,23,7]
				});
				// To use inbuilt placeover events
				this.add_placeover_events(placeover,img);
			}
		});
		});
	}
}
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.8105,144.9614);
		map.setCenter(office, 17);
		map.setUIToDefault();
		
		var pin = new GIcon();
		pin.image = '../images/icon-map-icon.png';
		pin.imageSize = new GSize(65,41);
		pin.iconAnchor = new GPoint(13,41);
		pin.shadow = '../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	namespace-global.js	
* @depend 	home.js
* @depend	pauls-quicksand.js
* @depend	folio.js
* @depend	team.js
* @depend	icon-map.js
* @depend	icon-phone.js
*/


