var YUD = YAHOO.util.Dom;
var YUE = YAHOO.util.Event;
var $ = YUD.get;
var DB = {
	init: function() {
		var logos = $('linkcat-2');
		if (logos) {
			logos = logos.getElementsByTagName('img');
			YUE.on(logos, 'mouseover', function() { 
				var anim = new YAHOO.util.Anim(this, {opacity:{to:1}}, .25, YAHOO.util.Easing.easeOut);
				anim.animate();
			});
			YUE.on(logos, 'mouseout', function() { 
				var anim = new YAHOO.util.Anim(this, {opacity:{to:.5}}, .25, YAHOO.util.Easing.easeOut);
				anim.animate();
			});
		}
		
		var clients = YUD.getElementsByClassName('client', 'div', 'work_col2');
		if (clients) {
			YUE.on(clients, 'mouseover', function() {
				YUD.addClass(this, 'hover');
			});	
			YUE.on(clients, 'mouseout', function() {
				YUD.removeClass(this, 'hover');
			});
		}
		
		YUE.onAvailable('slideshow', function() { 
			DB.kParade.init(4.5); 
		});
	},
	// This beautiful code conceived by my hero, Kelly Robinson.
	kParade : {
		elements : [],
		controls : [],
		length : 0,
		showing : 0,
		reverse : 0,
		duration : 1000,
		init : function ( seconds, reverse ) {
			if (!($('slides')&&$('controls'))) return false;
			this.duration = seconds * 1000;
			this.reverse = reverse || null;
			this.elements = $('slides').getElementsByTagName('li');
			this.controls = $('controls').getElementsByTagName('a');
			this.length = this.elements.length;
			for ( var i = 0; i < this.controls.length; i++) {
				DB.kParade.controls[i].onclick = function () {
					DB.kParade.goToAndStop(this);
					return false;
				};
			}
			this.show (0);
			this.interval = setInterval ('DB.kParade.advance()', this.duration);
		},
		advance : function () {
			this.hide ( this.showing );
			if ( this.showing == this.length-1 ) {
				this.showing = 0,
				this.show ( 0 );
			} else{
				this.show ( ++this.showing );
			}
		},
		hide : function ( index ) { 
			var slide = new YAHOO.util.Anim(this.elements[index], { opacity: {to: 0} }, .6, YAHOO.util.Easing.easeIn);
			slide.animate();
			YUD.removeClass(this.controls[index], 'on');
		},
		show : function ( index ) { 
			var slide = new YAHOO.util.Anim(this.elements[index], { opacity: {to: 1} }, .4, YAHOO.util.Easing.easeIn);
			slide.animate();
			YUD.addClass(this.controls[index], 'on');
		},
		goToAndStop : function (el) {
			clearInterval(this.interval);
			for ( var i = 0; i < DB.kParade.controls.length; i++ ) {
				if ( el != DB.kParade.controls[i] ) continue;
				if ( DB.kParade.showing != i ) {
					DB.kParade.hide ( DB.kParade.showing );
					DB.kParade.showing = i,
					DB.kParade.show ( i );
				}
			}
		}
	}
};

YUE.onDOMReady(DB.init);

sIFR.fonts = {
	caslon : {
		src: '/flash/adobe_caslon_pro.swf'
	}
};
sIFR.activate(sIFR.fonts.caslon);
/*sIFR.replace(sIFR.fonts.caslon, {
	selector: 'h1',
	wmode: 'transparent',
	css: [
		  '.sIFR-root { color: #433d36; leading: -10; line-height:20px; font-size:24px }'
	]
});
sIFR.replace(sIFR.fonts.caslon, {
	selector: 'h2',
	css: [
	  'a:link { color: #404e58; text-decoration:underline; }',
	  'a:hover { color: #50697b; text-decoration:none }'
	],
	wmode: 'transparent'
});
sIFR.replace(sIFR.fonts.caslon, {
	selector: 'h3',
	wmode: 'transparent'
});*/
sIFR.replace(sIFR.fonts.caslon, {
	selector: '#col2 h4',
	wmode: 'transparent',
	css: [
		  '.sIFR-root { color: #D1C1B4; text-transform:uppercase; font-size:13px }'
	]
});
sIFR.replace(sIFR.fonts.caslon, {
	selector: '#col3 h4',
	wmode: 'transparent',
	css: [
		  '.sIFR-root { color: #D1C1B4; text-transform:uppercase; font-size:11px }'
	]
});