function behaviors(){
	Event.observe(window,"load",function(){

		$$("input.input-clear, textarea.input-clear").each(function(e){
			var val = e.readAttribute("value");
			Event.observe(e,"focus",function(){
				e.writeAttribute("value","");
			});
			Event.observe(e,"blur",function(){
				if (e.readAttribute("value") ==""){
					e.writeAttribute("value",val);
				};
			})
		})
		//content area tabs
		if ($$("div.content-tab").first()){
			$$("div.content-tab").first().setStyle({display:"block"});
		}
		
		//prev-next links on content tabs
		if ($$("div.content-tab").first()){
			tabs = $$("div.content-tab");
			tabc = $$("div.tab-container").first().select("div.tab");
			tabs.each(function(e,i){
				if (e.select("div.content-next-prev").first()){
					var links = e.select("div.content-next-prev").first();
					var next = links.select("div.next").first();
					var prev = links.select("div.prev").first();
					
					//next link
					Event.observe(next,"click",function(){
						tabs.invoke("hide");
						tabc.invoke("removeClassName","active");
						tabs[(i+1)%tabs.size()].setStyle({display:"block"});
						tabc[(i+1)%tabc.size()].addClassName("active");
					});
					
					//prev link
					Event.observe(prev,"click",function(){
						var ind = i-1;
						if (ind < 0){
							ind = tabs.size()-1;
						}
						tabs.invoke("hide");
						tabc.invoke("removeClassName","active");
						tabs[ind].setStyle({display:"block"});
						tabc[ind].addClassName("active");
					});
				}
			})
		}
		
		
		//show content tabs
		//tabs trigger a content div matched by "rel" attribute - see "customer service" template
		$$("div.tab-container").each(function(t){
			t.select("div.tab").each(function(e){
        // var o = new Element("img");
        // o.src = webroot + "img/overlay.png";
        // e.insert(o);
        // o.absolutize();
        // o.clonePosition(e);
        // o.setStyle({height:e.getHeight()+"px",width:e.getWidth()+"px"})

				if (IE7){
					//o.setStyle({marginTop: (e.getHeight()/2)+"px"})
						new PeriodicalExecuter(function(pe){
							pe.stop();
							e.select(".hide").first().hide();
						},0.2);
				} else {
					e.select(".hide").first().hide();
				}
				
//			  e.select("img.hide").first().hide();
				
				Event.observe(e,"click",function(){
					t.select("div.tab").each(function(tt){
						tt.select(".active").first().hide();
						tt.select(".inactive").first().show();
						if (tt.hasClassName("active")){
							tt.removeClassName("active");
						}
						tt.addClassName("inactive");
					})
					e.removeClassName("inactive");
					e.addClassName("active");
					e.select(".active").first().show();
					e.select(".inactive").first().hide();

					$$("div.content-tab").each(function(ct){
						ct.setStyle({display:"none"});
						if(ct.readAttribute("rel")==e.readAttribute("rel"))
							ct.setStyle({display:"block"});
					})					
				})		
			})
		})
		
		//rollover tabs
		//tabs trigger a content div matched by "rel" attribute - see "customer service" template
		$$("div.rollover-tab-container").each(function(t){
			t.select("*.rollover-tab").each(function(e){
				Event.observe(e,"mouseover",function(){
					t.select("*.rollover-tab").each(function(tt){
            tt.addClassName("inactive");
            if (tt.hasClassName("active")){
              tt.removeClassName("active");
            }
					})
					
					e.removeClassName("inactive");
					e.addClassName("active");
					
					$$("*.rollover-panel").each(function(ct){
						ct.setStyle({display:"none"});
						if(ct.readAttribute("rel")==e.readAttribute("rel")){
							ct.setStyle({display:"block"});
						}
					});					
					
				})
				
			})
		})


		/*
		button rollovers.  assumes that the rollover state of the button is image-name-rollover.  
		will use the value of the rel attribute for the button name if set
		*/
		$$("img.rollover").each(function(e){
			var replace = e.src;
			var inactive = e.src.split("/").last();
			var dir = e.src.split("/").without(inactive).join("/");
			var active = null;
			if (e.hasAttribute("rel")){
				active = e.readAttribute("rel");
			} else {
				active = inactive.split(".").first() + "-rollover." + inactive.split(".").last();
			}
			Event.observe(e,"mouseover",function(){
				e.src = dir + "/" + active;
			})
			Event.observe(e,"mouseout",function(){
				e.src = replace;
			})
		})
		activateProjects();

		$$("div.dropdown").each(function(e){
			//this needs to create or associate with a hidden form value			
			var arrow = e.select("img.dropdown-arrow").first();
			var menu = new Element("div");
      var jobMenu = e.hasClassName("jobs");

			//hide the menu on creation so ! _.visible() will trigger it the first time
			menu.hide();

			Event.observe(e,"click",function(){
				if ( ! menu.visible()){
					e.up().insert(menu);
					menu.innerHTML = "";					
					e.select("div.menu-option").each(function(item){
						var val  = new Element("div");
						val.innerHTML = item.innerHTML;
						val.addClassName("menu-item");
						menu.insert(val);
						val.setStyle({paddingLeft:"10px"});
						Event.observe(val,"mouseover",function(){
							val.addClassName("active");
						})
						Event.observe(val,"mouseout",function(){
							val.removeClassName("active");
						})
						Event.observe(val,"click",function(){
							e.select("span.value").first().innerHTML = val.innerHTML;
							
							if(jobMenu) {
							  document.location = "/content/locations?loc="+escape(val.innerHTML);
							}
							menu.hide();
						})
					});

					menu.followOnResize(window,e);					
					menu.addClassName("dropdown-menu");
					menu.setStyle({height:(24 * (e.select("div.menu-option").size()))+"px"});

					Effect.BlindDown(menu,{duration:0.1,transition:Effect.Transitions.sinoidal});
					menu.setStyle({marginTop:e.getHeight()+"px", width:e.getWidth()+"px"});
					Event.observe(menu,"mouseout",function(){
  			    Effect.BlindUp(menu,{duration:0.1});
    			});					
				} else {
					Effect.BlindUp(menu,{duration:0.1});
				}
			})
		})
		//select all div's with class of "overlay"
		$$("a.overlay-trigger").each(function(e){
			//we automatically assign an overlay div to a trigger div by matching values of the "rel" attribute
			var o = $$("*.overlay-content").find(
				function(r){
					return r.readAttribute("rel")==e.readAttribute("rel")
					}
				);
			//fail if no match is found
			if (!o) return false;
			if(e.readAttribute("rel") == "documentary") {
			  documentary_overlay = new Overlay(o); 
			  documentary_overlay.setTrigger(e);
			  documentary_overlay.closeOnScrim = false;
			}
			else {
			  o = new Overlay(o);
			  //set event handlers for element e internally
			  o.setTrigger(e);
			  o.closeOnScrim = false;
			}
		});

		$$("div.header").each(function(h){
			var divs = h.select("div");
			divs.each(function(e){
				Event.observe(e,"click",function(){
					divs.each(function(r){
						r.removeClassName("active");
						r.addClassName("inactive");
						if (r.select("img.down-arrow").first()){
							r.select("img.down-arrow").first().setStyle({display:"none"});
						}
					});
				e.removeClassName("inactive");
				e.addClassName("active");
				if (e.select("img.down-arrow").first()){
					e.select("img.down-arrow").first().setStyle({display:"inline"});
				}
				})
			})
			if(divs.first() && divs.first().select("img.down-arrow").first()) {
  			divs.first().removeClassName("inactive");
  			divs.first().addClassName("active");
  			divs.first().select("img.down-arrow").first().setStyle({display:"inline"});
      }
		})

		$$("div.sliding").each(function(e){
			e.makeClipping();
			s = new Sliding(e);
			s.slideOnClick = false;
			e.select("div.crossfade").each(function(m){
				//n = new Masking(m);
			//	n.followElement = m;
				//set animations
				//n.queue = ["bounce","followOnMouseover"];
				//start animations
				//n.startQueue();
			})
		})

		$$(".label").each(function(e){
      Event.observe(e,"mouseover",function(){
				e.addClassName("mousedover");
			});
      Event.observe(e,"mouseout",function(){
				e.removeClassName("mousedover");
			});			
    })
	
	
	//ajax login form
	if ($("UserLoginForm")){
		var f = $("UserLoginForm");
		var submit = f.select("img.submit-button").first();
		Event.observe(submit,"click",function(){
			f.submit();
		})
		$("UserPassword").observe('keypress', function(event){
    if(event.keyCode == Event.KEY_RETURN) {
			  f.submit();
        Event.stop(event);
    }});
	}

	if ($("clipping-box")){
		$("clipping-box").makeClipping();
	}
	
	})
}

behaviors();

function activateProjects(){
	
	$$("div.projects").each(function(p){
		p.select("div.row").each(function(e){
			var d = e.up().select("div.details").first();
			Event.observe(e,"mouseover",function(){
			  //e.addClassName("active");
			})
			Event.observe(e,"mouseout",function(){
		    //e.removeClassName("active");
			})
			Event.observe(e,"click",function(){
			  if(d.visible()) {
			    e.removeClassName('active');
			    e.select('div.arrow').first().select('img.right').first().show();
			    e.select('div.arrow').first().select('img.down').first().hide();
			  }
        else {
			    e.addClassName('active');
			    e.select('div.arrow').first().select('img.right').first().hide();
			    e.select('div.arrow').first().select('img.down').first().show();
				}
        Effect.toggle(d,'blind',{duration:0.5, transition:Effect.Transitions.sinoidal });
			})
		})
	})

}

function fixTabs(){
		$$("div.tab-container").each(function(t){
			t.select("div.tab").each(function(e){
				var o = e.select("img").first();
				o.absolutize();
				o.clonePosition(e);
				o.setStyle({height:e.getHeight()+"px",width:e.getWidth()+"px"})

				if (IE7){
					//o.setStyle({marginTop: (e.getHeight()/2)+"px"})
						new PeriodicalExecuter(function(pe){
							pe.stop();
						},0.2);
				} else {
				}
		})
	})
}

var Browser = Class.create({
  initialize: function() {
    var userAgent = navigator.userAgent.toLowerCase();
    this.version = (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1];
    this.safari = /webkit/.test( userAgent );
    this.opera = /opera/.test( userAgent );
    this.msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
    this.mozilla = /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent );
  }
});

var browser = new Browser();


(function(){
  
  var eventMatchers = {
    'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
    'MouseEvents': /^(?:click|mouse(?:down|up|over|move|out))$/
  }
  var defaultOptions = {
    pointerX: 0,
    pointerY: 0,
    button: 0,
    ctrlKey: false,
    altKey: false,
    shiftKey: false,
    metaKey: false,
    bubbles: true,
    cancelable: true
  }
  
  Event.simulate = function(element, eventName) {
    var options = Object.extend(defaultOptions, arguments[2] || { });
    var oEvent, eventType = null;
    
    element = $(element);
    
    for (var name in eventMatchers) {
      if (eventMatchers[name].test(eventName)) { eventType = name; break; }
    }
 
    if (!eventType)
      throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
 
    if (document.createEvent) {
      oEvent = document.createEvent(eventType);
      if (eventType == 'HTMLEvents') {
        oEvent.initEvent(eventName, options.bubbles, options.cancelable);
      }
      else {
        oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
          options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
          options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
      }
      element.dispatchEvent(oEvent);
    }
    else {
      options.clientX = options.pointerX;
      options.clientY = options.pointerY;
      oEvent = Object.extend(document.createEventObject(), options);
      element.fireEvent('on' + eventName, oEvent);
    }
    return element;
  }
  
  Element.addMethods({ simulate: Event.simulate });
})()