// Insert flash banner
/*window.addEvent('domready', function() {

		var so = new SWFObject("/furniture/flash/banner.swf", "banner", "770", "150", "9", "#ffffff");
		so.useExpressInstall('/furniture/flash/swfobject1-5/expressinstall.swf');
		so.write("branding");	

});*/

// client image rollover
/*
window.addEvent('domready', function() {
	if($('clients')) {

		// Create this markup for the overlay
			//<div id="quoteContainer">
				//<div>
					//<div>
						//<div id="quoteContent" >
						  // Content
						//</div>
					//</div>
				//</div>
			//</div>
		
		var qC = new Element('div', {id: 'quoteContainer'}).grab(new Element('div',{'class':'outer'}).grab(new Element('div',{'class':'inner'}).grab(new Element('div', {id:'quoteContent'}))));
		document.body.grab(qC);
		//console.debug(qC);
		var contentElem = $('quoteContent');
		var contentContainer = $('quoteContainer');
		var imgs = $('logoList').getElements('img');
		var init = true;
		var firstImg = null;
				
		imgs.each(function(img, index) {

		   img.addEvents({
				'mouseenter': function(event) {
					contentElem.innerHTML = $(this.id + "Quote").innerHTML;
					if(init && index == 0) {
						contentContainer.setStyles({
							'top': this.getPosition().y + 10,
							'left': this.getPosition().x + this.getSize().x - 10
						});	
					}
					contentContainer.setStyle('display', 'block');
					this.className = "quoteOver";
					if(init && index>0) {
						firstImg.className = ""; 
						init = false;
					}
				},
				'mouseleave': function() {
					contentContainer.setStyle('display', 'none');
					this.className = '';
				}
			});

			if(index == 0) {
				firstImg = img;
				img.fireEvent('mouseenter', img, 50);
		   }
		});
		
		document.addEvent('mousemove', function(event) {

			var wY, mY, mX;
			if((event.client.y + contentContainer.getSize().y) > window.getSize().y) {
				//mY = (event.client.y + window.getScroll().y) - contentContainer.getSize().y;
				mY = (window.getScroll().y + window.getSize().y) - contentContainer.getSize().y;
			}
			else {
				mY = event.client.y + window.getScroll().y + 10;
			}
			
			if(event.client.x + contentContainer.getSize().x > window.getSize().x) {
				mX = (window.getScroll().x + window.getSize().x) - contentContainer.getSize().x;
			}
			else {
				mX = event.client.x + window.getScroll().x + 10;
			}
			
			if(!init) {
				contentContainer.setStyles({
					'top': mY,
					'left': mX
				});
			}
		});
	}
});
*/

var dataProds = [];
var currentDp = null;

window.addEvent('domready', function() {

	if(!$('locAccordion')) return;
	
	$('locAccordion').getElements('dd').each(
		function(dd){
			dataProds[dd.id] = {
				'infoHeight' : dd.getElement('span.dpIntro').getSize().y,
				'contentHeight' : dd.getElement('div.dpContent').getSize().y + dd.getElement('span.dpIntro').getSize().y + 10,
				'status' : 'closed',
				'dpTween' : new Fx.Tween(dd)
			}
			dd.setStyle('height', dataProds[dd.id].infoHeight);
			
			var dpLink = dd.getElement('a.dpLink');
			dpLink.store('dpId', dd.id);
			dpLink.addEvent('click', function(e){
				e.stop();
				
				// close open dp if exists and not equal to this dp
				var dpId = this.retrieve('dpId');
				if(currentDp && currentDp != dpId) toggleDp(currentDp);
				
				toggleDp(dpId);
			})
		}
	);
});

function toggleDp(dpId) {
	
	var status = dataProds[dpId].status;
	var h = (status == 'closed') ? dataProds[dpId].contentHeight : dataProds[dpId].infoHeight;
	dataProds[dpId].status = (status == 'closed') ? 'open' : 'closed';
	dataProds[dpId].dpTween.start('height', h);
	currentDp = (dataProds[dpId].status != 'closed') ? dpId : null;
}

//-->