// if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
// 	var viewportmeta = document.querySelectorAll('meta[name="viewport"]')[0];
// 	if (viewportmeta) {
// 		viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
// 		document.body.addEventListener('gesturestart', function() {
// 			viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
// 			}, false);
// 		}
// 	}


	// $('#map_canvas').hide();
	// $('#map a.toggle, #map a.close').click(function() {
	// $("#map_canvas").css({'width':'100%', 'height':'30em'})
	// $("#map_canvas").fadeToggle('slow');
	// });

	
	$('#dg-video').click(function(e) {
		$('#videocontainer').lightbox_me({
        centered: true, 
		closeSelector: ".close"
        });
    e.preventDefault();
	});
	

	(function(){
		var $button = $('#address-details .toggle'),
		$mapCanvas = $('#map_canvas'),
		visible = false;
		$button.click(function(event){
			event.preventDefault();
			if ( visible ) {
				$mapCanvas.slideUp('fast',function(){
					$mapCanvas.addClass('visuallyhidden')
					.slideDown(0);
				});
			} else {
				$mapCanvas.slideUp(0,function(){
					$mapCanvas.removeClass('visuallyhidden')
					.slideDown('fast');
				});
			}
			visible = ! visible;
		});
		})();

	(function(){
		var $button = $('#project_info .toggle'),
		$projectfields = $('#project_fields'),
		visible = false;
		$button.click(function(event){
			event.preventDefault();
			if ( visible ) {
				$projectfields.slideUp('fast',function(){
					$projectfields.addClass('visuallyhidden')
					.slideDown(0);
				});
			} else {
				$projectfields.slideUp(0,function(){
					$projectfields.removeClass('visuallyhidden')
					.slideDown('fast');
				});
			}
			visible = ! visible;
		});
		})();
	function addDOMLoadEvent(func) {
	   if (!window.__load_events) {
	      var init = function () {
	          // quit if this function has already been called
	          if (arguments.callee.done) return;

	          // flag this function so we don't do the same thing twice
	          arguments.callee.done = true;

	          // kill the timer
	          if (window.__load_timer) {
	              clearInterval(window.__load_timer);
	              window.__load_timer = null;
	          }

	          // execute each function in the stack in the order they were added
	          for (var i=0;i < window.__load_events.length;i++) {
	              window.__load_events[i]();
	          }
	          window.__load_events = null;
	      };

	      // for Mozilla/Opera9
	      if (document.addEventListener) {
	          document.addEventListener("DOMContentLoaded", init, false);
	      }

	      // for Internet Explorer
	      /*@cc_on @*/
	      /*@if (@_win32)
	          document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");
	          var script = document.getElementById("__ie_onload");
	          script.onreadystatechange = function() {
	              if (this.readyState == "complete") {
	                  init(); // call the onload handler
	              }
	          };
	      /*@end @*/

	      // for Safari
	      if (/WebKit/i.test(navigator.userAgent)) { // sniff
	          window.__load_timer = setInterval(function() {
	              if (/loaded|complete/.test(document.readyState)) {
	                  init(); // call the onload handler
	              }
	          }, 10);
	      }

	      // for other browsers
	      window.onload = init;

	      // create event function stack
	      window.__load_events = [];
	   }

	   // add function to event stack
	   window.__load_events.push(func);
	}

	// Load up TabInterface
	if( document.getElementById &&
	    document.getElementsByTagName &&
	    document.createElement ){
	  var cabinets = Array();
	  addDOMLoadEvent( function(){
	    var collection = document.getElementsByTagName( '*' );
	    var cLen = collection.length;
	    for( var i=0; i<cLen; i++ ){
	      if( collection[i] &&
	          /\s*tabbed\s*/.test( collection[i].className ) ){
	        cabinets.push( new TabInterface( collection[i], i ) );
	      }
	    }
	  } );
	}
