var winHref = window.location;
var topPage = false;
var navLinks,navHrefs,navUls,accordTrigHrefs,modal,h,accordOpen;
/* ************************************************************************************* *\
 * The MIT License * Copyright (c) 2007 Fabio Zendhi Nagao - http://zend.lojcomm.com.br* Permission is hereby granted, free of charge, to any person obtaining a copy of this* software and associated documentation files (the "Software"), to deal in the Software* without restriction, including without limitation the rights to use, copy, modify,* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to* permit persons to whom the Software is furnished to do so, subject to the following* conditions:* The above copyright notice and this permission notice shall be included in all copies* or substantial portions of the Software.
\* ************************************************************************************* */
var iCarousel = new Class({options: { animation: {type: "scroll",/* fadeNscroll, scroll, fade*/ direction: "left",/*if type = scroll, set: top || left*/ amount: 1,/*if type = scroll, set the amount to scroll*/ transition: Fx.Transitions.Cubic.easeInOut, duration: 500, rotate: {type: "manual",/* auto || manual*/interval: 1000,/* if type = auto, set the interval (ms)*/onMouseOver: "stop"/* if type = auto, set the onmouseover behavior: stop || proceed*/} },item: {klass: "item",size: 100},idPrevious: "previous",idNext: "next",idToggle: "toggle",onClickPrevious: Class.empty,onClickNext: Class.empty,onPrevious: Class.empty,onNext: Class.empty,onGoTo: Class.empty },initialize: function(container, options) {this.setOptions(options);this.container = $(container);this.aItems = $A($$('.'+ this.options.item.klass));if(this.aItems.length<5)return;this.isMouseOver = false;
if(this.options.idPrevious != "undefined" && $(this.options.idPrevious))$(this.options.idPrevious).addEvent("click", function(event) {new Event(event).stop(); this._previous();this.fireEvent("onClickPrevious", this, 20);}.bind(this));if(this.options.idNext != "undefined" && $(this.options.idNext))$(this.options.idNext).addEvent("click", function(event) {new Event(event).stop();this._next();this.fireEvent("onClickNext", this, 20);}.bind(this));if(this.options.idToggle != "undefined" && $(this.options.idToggle))$(this.options.idToggle).addEvent("click", function(event) {new Event(event).stop(); this._toggle()}.bind(this));var oAn = this.options.animation;switch(this.options.animation.type.toLowerCase()) {case "fade":this.aItems.each(function(item) {item.fx = item.effect("opacity", {duration: oAn.duration, transition: oAn.transition});item.setStyle("opacity", 0);item.addEvents({"mouseenter": function() {this.isMouseOver = true;if(this.options.animation.rotate.type == "auto") this.timer = $clear(this.timer);}.bind(this),"mouseleave": function() {this.isMouseOver = false;if(this.options.animation.rotate.type == "auto") this.timer = this._autoRotate.periodical(this.options.animation.rotate.interval, this);}.bind(this)});}.bind(this));this.height = this.container.getStyle("height").toInt();this.atScreen = 0;this._animate(this.atScreen);break;default:(2).times(function() {this.aItems.each(function(item) {item.clone().injectInside(this.container);}.bind(this));}.bind(this));this.aItems = $A($$('.'+ this.options.item.klass));this.aItems.each(function(item) {item.addEvents({"mouseenter": function() {this.isMouseOver = true;if(this.options.animation.rotate.type == "auto") this.timer = $clear(this.timer);}.bind(this),"mouseleave": function() {this.isMouseOver = false;if(this.options.animation.rotate.type == "auto") this.timer = this._autoRotate.periodical(this.options.animation.rotate.interval, this);}.bind(this)});}.bind(this));this.fx = new Fx.Morph(this.container,{duration: oAn.duration, transition: oAn.transition, wait: false});this.atScreen = this.aItems.length / 3;this.container.setStyle(oAn.direction, - this.atScreen * this.options.item.size);break;}if(this.options.animation.rotate.type == "auto") this.timer = this._autoRotate.periodical(this.options.animation.rotate.interval, this);},goTo: function(n) {switch(this.options.animation.type.toLowerCase()) {case "fade":var lastIndex = this.atScreen;this.atScreen = Math.abs(n % (this.aItems.length / 3));this._animate(this.atScreen, lastIndex);break;default:this.atScreen = Math.abs(n % (this.aItems.length / 3));this.atScreen += this.aItems.length / 3;this._animate(this.atScreen);break;}this.fireEvent("onGoTo", this, 20);},_previous: function() {switch(this.options.animation.type.toLowerCase()) {case "fade":var lastIndex = this.atScreen;this.atScreen -= this.options.animation.amount;if(this.atScreen < 0) this.atScreen = (this.aItems.length - 1);this._animate(this.atScreen, lastIndex);break;default:this.atScreen -= this.options.animation.amount;if(this.atScreen < this.aItems.length / 3) {this.container.setStyle(this.options.animation.direction, - this.options.item.size * this.aItems.length * 2 / 3);this.atScreen = this.aItems.length * 2 / 3 - this.options.animation.amount;}this._animate(this.atScreen);break;}this.fireEvent("onPrevious", this, 20);},_next: function() {switch(this.options.animation.type.toLowerCase()) {case "fade":var lastIndex = this.atScreen;this.atScreen += this.options.animation.amount;if(this.atScreen >= this.aItems.length) this.atScreen = 0;this._animate(this.atScreen, lastIndex);break;default:this.atScreen += this.options.animation.amount;if(this.atScreen > this.aItems.length * 2 / 3) {this.container.setStyle(this.options.animation.direction, - this.options.item.size * this.aItems.length / 3);this.atScreen = this.aItems.length / 3 + this.options.animation.amount;}this._animate(this.atScreen);break;}this.fireEvent("onNext", this, 20);},_toggle: function() {(this.container.getStyle("height").toInt() == 0) ?this.container.effect("height", { duration:1000, transition: Fx.Transitions.Sine.easeInOut }).start(this.height):this.container.effect("height", { duration:1000, transition: Fx.Transitions.Sine.easeInOut }).start(0);},_autoRotate: function() {if(this.options.animation.rotate.onMouseOver == "stop" && !this.isMouseOver) this._next();},_animate: function(a, b) {switch(this.options.animation.type) {case "fade":if($defined(b)) {this.aItems[b].fx.start(0).chain(function() {this.aItems[a].fx.start(1);}.bind(this));} else {this.aItems[a].fx.start(1);}break;case "scroll":var that = this;if(that.options.animation.direction == "top") {that.fx.start({"top" : - a * that.options.item.size});} else {that.fx.start({"left" : - a * that.options.item.size});}break;case "fadeNscroll":var that = this;if(that.options.animation.direction == "top") {that.fx.start({"opacity":0.75}).chain(function() {that.fx.start({"top" : - a * that.options.item.size}).chain(function() {that.fx.start({"opacity": 1});});});} else {that.fx.start({"opacity":0.75}).chain(function() {that.fx.start({"left" : - a * that.options.item.size}).chain(function() {that.fx.start({"opacity": 1});});});}break;}}
});iCarousel.implement(new Events);iCarousel.implement(new Options);

/*MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.||Clientcide Copyright (c) 2006-2008, http://www.clientcide.com/wiki/cnet-libraries#license*/
var Modalizer=new Class({defaultModalStyle:{display:'block',position:'fixed',top:0,left:0,'z-index':5000,'background-color':'#333',opacity:0.8},setModalOptions:function(options){this.modalOptions=$merge({width:(window.getScrollSize().x+300),height:(window.getScrollSize().y+300),elementsToHide:'select',hideOnClick:true,modalStyle:{},updateOnResize:true,layerId:'modalOverlay',onModalHide:$empty,onModalShow:$empty},this.modalOptions,options);return this},toElement:function(){if(!this.modalOptions.layerId)this.setModalOptions();return $(this.modalOptions.layerId)||new Element('div',{id:this.modalOptions.layerId}).inject(document.body)},resize:function(){if($(this)){$(this).setStyles({width:(window.getScrollSize().x+300),height:(window.getScrollSize().y+300)})}},setModalStyle:function(styleObject){this.modalOptions.modalStyle=styleObject;this.modalStyle=$merge(this.defaultModalStyle,{width:this.modalOptions.width,height:this.modalOptions.height},styleObject);if($(this))$(this).setStyles(this.modalStyle);return(this.modalStyle)},modalShow:function(options){this.setModalOptions(options);$(this).setStyles(this.setModalStyle(this.modalOptions.modalStyle));if(Browser.Engine.trident4)$(this).setStyle('position','absolute');$(this).removeEvents('click').addEvent('click',function(){this.modalHide(this.modalOptions.hideOnClick)}.bind(this));this.bound=this.bound||{};if(!this.bound.resize&&this.modalOptions.updateOnResize){this.bound.resize=this.resize.bind(this);window.addEvent('resize',this.bound.resize)}if($type(this.modalOptions.onModalShow)=="function")this.modalOptions.onModalShow();this.togglePopThroughElements(0);$(this).setStyle('display','block');return this},modalHide:function(override,force){if(override===false)return false;this.togglePopThroughElements(1);if($type(this.modalOptions.onModalHide)=="function")this.modalOptions.onModalHide();$(this).setStyle('display','none');if(this.modalOptions.updateOnResize){this.bound=this.bound||{};if(!this.bound.resize)this.bound.resize=this.resize.bind(this);window.removeEvent('resize',this.bound.resize)}return this},togglePopThroughElements:function(opacity){if(Browser.Engine.trident4||(Browser.Engine.gecko&&Browser.Platform.mac)){$$(this.modalOptions.elementsToHide).each(function(sel){sel.setStyle('opacity',opacity)})}}});

/*** HistoryManager * Mootools 1.2 compatible version, updated by aNobii Ltd. (anobii.com) * @version 1.2  * @license MIT License * @author Harald Kirschner <mail [at] digitarald.de> * @1.2author aNobii Ltd. <contact [at] anobii.com> * @copyright 2008 Author */
var History = new Class ( {
	options: {observeDelay: 100,stateSeparator: ';',iframeSrc: 'blank.html',onStart: Class.empty,onRegister:Class.empty,onUnregister: Class.empty,onStart: Class.empty,onUpdate: Class.empty,onStateChange: Class.empty,onObserverChange: Class.empty},
	dataOptions: {skipDefaultMatch: true,defaults: [],regexpParams: ''},
	initialize: function(options) {if (this.modules) return this;this.setOptions(options);this.modules = $H({});this.count = history.length;this.states = [];this.states[this.count] = this.getHash();this.state = null;return this;},
	start: function() {this.observe.periodical(this.options.observeDelay, this);this.started = true;this.observe();this.update();this.fireEvent('onStart', [this.state]);return this;},
	register: function(key, defaults, onMatch, onGenerate, regexp, options) {if (!this.modules) this.initialize();var data = $merge(this.dataOptions, options || {}, {defaults: defaults,onMatch: onMatch,onGenerate: onGenerate,regexp: regexp});data.regexp = data.regexp || key + '-([\\w_-]*)';if (typeof data.regexp == 'string') data.regexp = new RegExp(data.regexp, data.regexpParams);data.onGenerate = data.onGenerate || function(values) { return key + '-' + values[0]; };data.values = $A(data.defaults);this.modules.set(key, data);this.fireEvent('onUnregister', [key, data]);return {setValues: function(values) {return this.setValues(key, values);}.bind(this),setValue: function(index, value) {return this.setValue(key, index, value);}.bind(this),generate: function(values) {return this.generate(key, values);}.bind(this),unregister: function() {return this.unregister(key);}.bind(this)};},
	unregister: function(key) {this.fireEvent('onRegister', [key]);this.modules.remove(key);},
	setValues: function(key, values) {var data = this.modules.get(key);if (!data || data.values.isSimilar(values)) return this;data.values = values;this.update();return this;},
	setValue: function(key, index, value) {var data = this.modules.get(key);if (!data || data.values[index] == value) return this;data.values[index] = value;this.update();return this;},
	generate: function(key, values) {var data = this.modules.get(key);var current = $A(data.values);data.values = values;var state = this.generateState();data.values = current;return '#' + state;},
	observe: function() {if (this.timeout) return;var state = this.getState();if (this.state == state) return;if ((Browser.Engine.trident || Browser.Engine.webkit419) && (this.state !== null)) this.setState(state, true);else this.state = state;this.modules.each(function(data, key) {var bits = state.match(data.regexp);if (bits) {bits.splice(0, 1);bits.complement(data.defaults);if (!bits.isSimilar(data.defaults)) data.values = bits;} else data.values = $A(data.defaults);data.onMatch(data.values, data.defaults);});this.fireEvent('onStateChange', [state]).fireEvent('onObserverChange', [state]);},
	generateState: function() {var state = [];this.modules.each(function(data, key) {if (data.skipDefaultMatch && data.values.isSimilar(data.defaults)) return;state.push(data.onGenerate(data.values));});return state.join(this.options.stateSeparator);},
	update: function() {if (!this.started) return this;var state = this.generateState();if ((!this.state && !state) || (this.state == state)) return this;this.setState(state);this.fireEvent('onStateChange', [state]).fireEvent('onUpdate', [state]);return this;},
	observeTimeout: function() {if (this.timeout) this.timeout = $clear(this.timeout);else this.timeout = this.observeTimeout.delay(200, this);},
	getHash: function() {var href = top.location.href;var pos = href.indexOf('#') + 1;return (pos) ? href.substr(pos) : '';},
	getState: function() {var state = this.getHash();if (this.iframe) {var doc = this.iframe.contentWindow.document;if (doc && doc.body.id == 'state') {var istate = doc.body.innerText;if (this.state == state) return istate;this.istateOld = true;} else return this.istate;}if (Browser.Engine.webkit419 && history.length != this.count) {this.count = history.length;return $pick(this.states[this.count - 1], state);}return state;},
	setState: function(state, fix) {state = $pick(state, '');if (Browser.Engine.webkit419) {if (!this.form) this.form = new Element('form', {method: 'get'}).injectInside(document.body);this.count = history.length;this.states[this.count] = state;this.observeTimeout();this.form.setProperty('action', '#' + state).submit();} else top.location.hash = state || '#';if (Browser.Engine.trident && (!fix || this.istateOld)) {if (!this.iframe) {this.iframe = new Element('iframe', {src: this.options.iframeSrc,id: 'historyFrame', styles: 'visibility: hidden;'}).injectInside(document.body);this.istate = this.state;}try {var doc = this.iframe.contentWindow.document;doc.open();doc.write('<html><body id="state">' + state + '</body></html>');doc.close();this.istateOld = false;} catch(e) {};}this.state = state;},
	extend: $extend,
	Implements : [Events, Options]
});
var HistoryManager = new History();
Array.prototype.isSimilar = function (array){return (this.toString() == array.toString());}
Array.prototype.complement = function (array){for (var i = 0, j = this.length; i < j; i++) this[i] = $pick(this[i], array[i] || null);return this;}
/* end history manager */


// START SIMPLEFORM CLASS //
var simpleForm = new Class({
	Implements: [Options, Events],
	options: {},
	
	initialize: function(options){
		this.setOptions(options),
		this.page = '/about/contact.php',
		this.footer = $('footer')||null,
		this.fHeight = '450',
		this.formContainer=$('cForm')||null,
		this.origBottom = this.footer.offsetTop + this.footer.offsetHeight,
		this.origHeight = this.footer.offsetHeight,
		this.origTop = this.footer.offsetTop,
		this.link=$('cFormLink'),
		this.init()
	},
	
	init: function(){
		this.open=this.showForm.bind(this);
		this.close=this.closeForm.bind(this);
		this.close2=this.closeForm.bind(this,1);
		this.link.addEvent('click',this.open);
	},
	
	showForm: function(e){ 
		e.stop();
		this.link.removeEvent('click',this.open);
		this.footer.setStyles({position:'absolute'});
		var fxOpen = new Fx.Morph(this.footer, {duration: 1000, transition: Fx.Transitions.Quad.easeOut});
 		fxOpen.start({'height':[this.fHeight], top:this.origBottom-this.fHeight, 'opacity':[1]}).chain(
			function(){this.formContainer.getPageNow('/about/contact.php',{container: 'cForm'});}.bind(this)
		)
		this.formContainer.setStyles({padding:'10px'});
		this.link.addEvent('click',this.close);
		this.link.set('html','[x] Close');
		this.arrow=this.link.style.backgroundImage;
		this.link.style.backgroundImage="url(/images/arw_dwn_cntct.png)";
		navLinks.each(function(a){a.addEvent('click',this.close)},this);
	},
	
	closeForm: function(e){ 
		var c=e.target.className;
		if(c.indexOf('ajax')>-1||c.indexOf('cform')>-1) e.stop();
		if(c.indexOf('cform')<0) e.target.removeEvent('click',this.close);
		this.link.removeEvent('click',this.close);
		var top = this.origBottom - this.origHeight - 2;
		this.footer.setStyles({bottom:this.origBottom-this.origHeight, top:'auto'});
		var fxClose = new Fx.Morph(this.footer, {duration: 1000, transition: Fx.Transitions.Quad.easeOut});
 		fxClose.start({'height':[this.origHeight - 2], 'opacity':[1]}).chain(function(){
 				this.footer.setStyles({position:'relative', top:this.origTop, bottom:'auto'});
 				this.formContainer.setStyles({padding:'0 10px'});
 			}.bind(this))
		this.formContainer.set('html','');
		this.link.addEvent('click',this.open);
		this.link.set('html','Contact Us');
		this.link.style.backgroundImage=this.arrow;
	}
});

// END SIMPLEFORM CLASS //

// START GETAJAXPAGE CLASS //
var getAjaxPage = new Class({
	Implements: [Options, Events],
	options: {container: 'mainContent', loadingBG:'true', afterScript:false},
	
	initialize: function(el,options){
		this.setOptions(options),
		this.link=el||false,
		this.container=$(this.options.container),
		this.containerH=0,
		this.containerH=0,
		this.loadingBG=this.options.loadingBG,
		this.afterScript=this.options.afterScript || false,
		this.aStart='<!--startAjaxContent-->',
		this.aEnd='<!--endAjaxContent-->',
		this.init()
	},
	
	init: function(){
		if(this.link){
			if($type(this.link)=='element'){
				if(this.link.tagName.toLowerCase()=='a')this.getAjax(this.link.href);
				if(this.link.tagName.toLowerCase()=='form')this.getAjax(this.link.action);
			}
			else if($type(this.link)=='string'){this.getAjax(this.link)}
		} // if individual links are passed in
		else{$$('a.ajax').each(function(link,i){this.setEvents(link,i)},this);} // if class is instantiated ondomready
	},
	
	setEvents: function(link){
		link.addEvent('click',(function(e){ e.stop(); this.getAjax(link.href); }).bind(this));
	},

	getAjax: function(url){
		this.ajaxURL=url;
		if(this.ajax){if (this.ajax.url==url)return;}
		this.ajax = new Request({
			url: url, 
			method: 'get', 
			evalScripts: true,
			autoCancel: true,
			onRequest: this.ajaxLoading(),
			onSuccess: this.Callback.bind(this)
		}).send();
	 },
	 
	 ajaxLoading: function(){
	 	if(!this.loadingBG)return;
	 	this.containerH =this.container.style.height;
		var topPad = this.container.getStyle('padding-top').replace('px','')*1
		var btmPad = this.container.getStyle('padding-bottom').replace('px','')*1
	 	this.container.setStyle('height',this.container.offsetHeight-topPad-btmPad);
	 	this.container.set('html','');
	 	var div1 = new Element('div',{'id':'ajaxLoading','class':'loading'}).inject(this.container);
	 },
	 
	 Callback: function(ResponseText){
	 	this.container.setStyle('height',this.container.offsetHeight);
	 	ieFix();
	 	var start =(ResponseText.indexOf(this.aStart)>-1)?ResponseText.indexOf(this.aStart)+23:0;
		var end =(ResponseText.indexOf(this.aEnd)>-1)?ResponseText.indexOf(this.aEnd):1000000;	
		var content = ResponseText.substring(start, end);
		this.showContent(content); // inject the content between the two comment tags above
		this.ajax = null;
		if(this.loadingBG)this.container.setStyle('height',this.containerH);
	 	//trackAjax(this.ajaxURL.split('springstudio.com')[1]);
	},

	showContent: function(content){
		this.container.set('html',content); if(this.afterScript)afterScript();}	
});
Element.implement({getPageNow:function(l,options){return new getAjaxPage(l,options);}});
// END GETAJAXPAGE CLASS //

// START UTILITY FUNCTIONS //
function openWin(url,name,w,h){
	var name=(name)?name:'newWin';var w=(w)?w:400;var h=(h)?h:400;
	var win=window.open(url,name,"status=no,scrollbars=yes,resizable=yes, toolbar=no,location=no,menu=no,height="+h+",width="+w);
	win.focus();//win.resizeTo(w,h);win.moveTo(0,0);
	return false;
}

function HideShow(state,id){
	id=$(id);if($type(id)!='element') return;
	if(state=='hide'){id.removeClass('block')}
	else if(state=='show'){id.addClass('block')}
}
// END UTILITY FUNCTIONS //

function clientLayer(trigs,els){
	if (!trigs||!els) return;
	if(els.length>3)$$('#springScroller-frame img').setStyle('display','inline');
	trigs.addEvent('click',function(e){
			e.stop();
			var i = trigs.indexOf(this);
			var factor = parseInt(i/els.length);
			num= i-(els.length*factor);
			els.each(function(el){HideShow('hide',el); trigs.removeClass('semiTrans'); });
			HideShow('show',els[num]);
			trigs[num].addClass('semiTrans');
			swapContent(this);
	});
}


function sendCform(form){ 
	var form = $(form);
	//form.getPageNow(form,{container: 'cFormFS'});
	form.set('send', {onComplete: function(response) { 
			$('cFormFS').set('html', response);
		}});
	form.send();
}

function swapContent(c){
	if(!c)return;
	var ajax=($type(c)=='string' || c.hasClass('ajax'))?true:false;
	if(!ajax)return;
	if ($type(c)=='element'){$(c).getPageNow($(c),{container:'portContent'});}
	//else if ($type(c)=='string'){newDiv.set('html',c);}
}

function ieFix(){
	if(!Browser.Engine.trident || Browser.Engine.version>4.9999)return;
	var pngs = $$('.png');
	$$('.portI img').each(function(i){if(i.src.indexOf(".png")>0)i.src=i.src.replace(".png",".jpg");});
}

function initScroller(){
	if(!$('springScroller-content'))return;
	new iCarousel("springScroller-content", {
	   idPrevious: "springScroller-previous",
	   idNext: "springScroller-next",
	   idToggle: "undefined",
	   item: {
		   klass: "springScroller-item",
		   size: 110
	   },
	   animation: {
		   duration: 600,
		   amount: 1
	   }
	});
}

function initPortScroller(){
	if(!$('portScroller-content'))return;
	new iCarousel("portScroller-content", {
	   idPrevious: "portScroller-previous",
	   idNext: "portScroller-next",
	   idToggle: "undefined",
	   item: {
		   klass: "portScroller-item",
		   size: 177
	   },
	   animation: {
		   duration: 600,
		   amount: 1
	   }
	});
}

var setBg=function(){
	setTimeout(function(){addBackground()},500);
	window.removeEvent('resize',setBg);
}

function addBackground(){
	var bgImg = (!Browser.Engine.trident || Browser.Engine.version>4.9999)?'/images/mainBg.png': '/images/mainBg.gif';
	var b = $(document.body);
	var w = b.offsetWidth;
	window.addEvent('resize',setBg);
	if(w<1200)return;
	b.setStyle('background-image','url('+bgImg+')');	
}
	
function springAccord(el){
	if(accordOpen)return;
	var i = navTrigHrefs=$$('#accordion a.T').indexOf(el);
	var h = navUls[i].offsetHeight;
	if(Browser.Platform.mac)h=h+10;
	navUls[i].setStyles({height:'1px', position:'relative'});
	new Fx.Morph(navUls[i],{duration: 600}).start({'height':[1,h],'opacity':[1]});
	accordOpen=true;
}

// moves the sidenav arrow
function sideNav(el){
	navLinks.each(function(el){el.removeClass('on')});
	var i=navHrefs.indexOf(winHref.pathname.replace("index.php",""));
	var hash=(winHref.hash.indexOf("#ajax_")>-1)?winHref.hash.replace('#ajax_',''):false;
	var hashIndex=(!hash)?0:navHrefs.indexOf(hash);
	
	
	var aLink = (el)?el:( (!hash)?navLinks[i]:navLinks[hashIndex] ); // current link
	if(!aLink)return;
	if(el)el.addClass('on');
	var parent =$(aLink.parentNode); // parent of current link
	var topDiv = (parent.hasClass('topNav'))?aLink.parentNode:$(parent.parentNode.parentNode);
	springAccord(topDiv.getElements('a')[0]);
	var url=winHref+"";
	if(el==url.replace("index.php","")){/*springAccord(topDiv.getElements('a')[0]);*/}
	else{topDiv.setStyle('backgroundPosition','-1000px -1000px');}
	topDiv.addClass("trigger");
	var topY=topDiv.offsetTop;
	var activeY=parent.offsetTop;
	var pos = '152px ' + (activeY*1+40) + 'px';
	if(aLink.hasClass('subNav')){$(topDiv).setStyle('backgroundPosition',pos);}
}

function startHistManager(el){ 
	var origPath=window.location.pathname;
	var origPageContent = $('mainContent').innerHTML;
	var pageUpdateClass = new Class({ 
		initialize: function(firstPage){ 
			this.historyKey = 'ajax_';  
			this.history = HistoryManager.register(
				this.historyKey, 
				[firstPage], 
				function(values){this.to(values[0]);}.bind(this),  
				function(values){ return [this.historyKey, values[0]].join('');}.bind(this),
				this.historyKey + '(.+)' 
			); 
		},
		to: function(page){ 
			if (page === undefined || page === null /*|| dCond*/) return; 
			page = page.replace(/^http:\/\/[^\/]+/, ''); 
			this.page = page;  
			el=navLinks[navHrefs.indexOf(this.page)];
			var scriptOn = (el&&el.rel.indexOf('afterScript')>-1)?true:false;
			if(this.page.replace("#","")== origPath){$('mainContent').set('html',origPageContent)}
			else{el.getPageNow(el,{afterScript:scriptOn});}
			sideNav(el); // reset seidenav arrow
			setTimeout('ieFix()',200);
			this.history.setValue(0, this.page); 
		}  
	});   
	var firstPage = window.location.pathname; 
	var pageUpdate = new pageUpdateClass(firstPage);
	$$('a.ajax').addEvent('click', function(e){ e.stop(); pageUpdate.to(this.href,this);}); 
	if(el){pageUpdate.to(el.href,el);}
	HistoryManager.start();
}

function tooltip(e,el){
	var TTs=$$('div.tt_bg');
	TTs.each(function(t){t.setStyle('display','none')});
	if(el){
		var tt=el.getElements('div.tt_bg')[0];
		el.setStyle('z-index',1000);
	}
	if(tt){
		tt.setStyle('display','block');
		var w=$(document.body).offsetWidth+100;
		var m=e.page.x;
		var p=(m>w/2)?'right':'left';
		tt.setStyle(p,30);
	}
	if(el && tt)el.addEvent('mouseleave',function(){tt.setStyles({display:'none'});el.setStyle('z-index','');})
}

function nextLink(el){
	el=$(el);
	var href=el.href.replace(winHref.hostname,'').replace('http://','');
	var i=navHrefs.indexOf(href);
	var next = navLinks[i]
	startHistManager(next)
	//next.getPageNow(next);
	sideNav(next);
	return false;
}

window.addEvent('domready', function(){
	accordOpen=false;
	navLinks = $$('#accordion a');
	navHrefs = navLinks.getProperty('href');
	navUls = $$('#accordion ul');
	navTrigHrefs=$$('#accordion a.T').getProperty('href');
	modal = new Modalizer();
	HistoryManager.initialize(); 
	startHistManager();
	new simpleForm({}); 
	navLinks.each(function(el){el.addEvent('click',function(e){sideNav(el);})});
	if($('springScroller'))initScroller();
	if($('portScroller'))initPortScroller();
	
	// set portfolio icons to trigger layer change
	clientLayer($$('.springScroller-item a'),$$('div.portI'));
	
	$$('#portScroller-content li').each(function(el){el.addEvent('mouseenter',function(e){tooltip(e,el);})});
	
	//ie fixes
	ieFix();	
	addBackground();
});