// Browser sniffing
if ( Prototype.Browser.Gecko )
{			
	// Firefox 3
	if (typeof(Array.prototype.reduceRight) == 'function')
	{
		$('stylesheetIE6', 'stylesheetIE7', 'stylesheetFF2').invoke('remove');
	} 
	else // Firefox 2
	{
		$('stylesheetIE6', 'stylesheetIE7').invoke('remove');			
	}
}
else if (!Prototype.Browser.IE || (document.documentMode && document.documentMode >= 8) ) 		
	// All CSS 2.1 compliant browsers - including IE 8.
{
	$('stylesheetIE6', 'stylesheetIE7', 'stylesheetFF2').invoke('remove');		
}
else if ( window.XMLHttpRequest ) // IE 7 
{
		$('stylesheetIE6', 'stylesheetFF2').invoke('remove');
}
else // IE 6
{
		$( 'stylesheetIE7', 'stylesheetFF2').invoke('remove');
}


function lgaScrollTo( pos )
{
	new Effect.ScrollTo( pos + 'Spacer' );	
}

iDeal.debug = true;

Event.observe( window, 'load', function(){
										
	if ($('home1SSP'))
	{
		if (!Prototype.Browser.IE || window.XMLHttpRequest)
		{
			$$('#portfolio a')[0].href = 'javascript: {}';
			$$('#people a')[0].href = 'javascript: {}';			
			$$('#expertise a')[0].href = 'javascript: {}';		
		}
		
		UFO.create({ 
			movie:"/template_assets/swf/home1SSP.swf", 
			width:"972", 
			height:"350", 
			majorversion:"8", 
			build:"0", 
			xi:"true", 
			flashvars:"xmlfile=/generalgalleryphotos.xml?catID=7", 
			wmode:"transparent" }, "home1SSP");		
		
		// We'll assume that if one is present all are.
		UFO.create({ 
			movie:"/template_assets/swf/home2SSP.swf", 
			width:"972", 
			height:"350", 
			majorversion:"8", 
			build:"0", 
			xi:"true", 
			flashvars:"xmlfile=/generalgalleryphotos.xml?catID=8", 
			wmode:"transparent" }, "home2SSP");
			
		UFO.create({ 
			movie:"/template_assets/swf/home3SSP.swf", 
			width:"972", 
			height:"350", 
			majorversion:"8", 
			build:"0", 
			xi:"true", 
			flashvars:"xmlfile=/generalgalleryphotos.xml?catID=9", 
			wmode:"transparent" }, "home3SSP");	
		
		new iDeal.Slides({
			target: 'Slides',
			fadeIn: 1,
			fadeOut: 1,
			timeOut: 5,
			enterTween: 'BlindDown',
			exitTween: 'Fade' }
		);
		
		switch(location.hash)
		{
			case '#top': lgaScrollTo( 'top' ); break;
			case '#bottom': lgaScrollTo( 'bottom' ); break;
			case '#middle': lgaScrollTo( 'middle' ); break;
		}
		
	}
	
	if ($('case-studySSP'))
	{
		UFO.create({ 
        	movie:"/template_assets/swf/case-studySSP3.swf",
        	width:"972",
        	height:"394",
        	majorversion:"8",
        	build:"0",
        	i:"true",
        	flashvars: "xmlfile=/xml/flashplayer.xml?catID="+caseCategory,
        	wmode:"transparent"
      	}, "case-studySSP");
	}
	
	if ($('Accordian'))
	{
		new iDeal.Accordian({
			target: 'Accordian'
		});	
	}
	
	if ($('filmstripSSP'))
	{
		UFO.create({ 
			movie:"/template_assets/swf/afterfiveSSP.swf", 
			width:"972", 
			height:"394", 
			wmode: "transparent", 
			majorversion:"8", 
			build:"0", 
			xi:"true", 
			flashvars:"xmlfile=/template_assets/xml/afterfiveSSP.xml" 
		}, "filmstripSSP");	
	}
	
	$$('.thumb').each(function(s)
	{	
		new iDeal.PopUp({
			target: s,
			cssClass: 'Popup',
			fadeIn: .5,
			fadeOut: .5,
			timeOut: .5,
			position: 'infront'
		});
	});
});	

var caseState = 'closed';

function caseToggle() {
	switch(caseState)
	{
		case 'closed':
			new Effect.SlideDown('welcome-bd', { afterFinish: function(){ $('welcome-hd').addClassName('open'); }});
			caseState = 'open';
		break;
		case 'open':
			new Effect.SlideUp('welcome-bd', { afterFinish: function(){ $('welcome-hd').removeClassName('open'); }});
			caseState = 'closed';
		break;
	}
}