/*---[ Details ]---------------------------------------
Basic Style Sheet - Older Browsers
Site: www.foobar.com
Author: Lee Powell
Contact: lee.powell@soup.co.uk
-------------------------------------------------------*/

/*-----------------------------------------------------
jQuery
-------------------------------------------------------*/
// BROWSER

/*
var _browser = {
	'msie7': ( $.browser.msie && parseFloat($.browser.version) >= 7 && parseFloat($.browser.version) < 8 ) ? true : false,
	'msie6': ( $.browser.msie && parseFloat($.browser.version) >= 6 && parseFloat($.browser.version) < 7 ) ? true : false,
	'firefox3': ( $.browser.mozilla && parseFloat($.browser.version) >= 1.9 && parseFloat($.browser.version) < 2 ) ? true : false,
	'firefox2': ( $.browser.mozilla && parseFloat($.browser.version) >= 1.8 && parseFloat($.browser.version) < 1.9 ) ? true : false,
	'safari3': ( $.browser.safari && parseFloat($.browser.version) > 500) ? true : false,
	'safari2': ( $.browser.safari && parseFloat($.browser.version) < 500) ? true : false,
	'opera9': ( $.browser.opera && parseFloat($.browser.version) >= 9 && parseFloat($.browser.version) < 10 ) ? true : false,
	'opera8': ( $.browser.opera && parseFloat($.browser.version) >= 8 && parseFloat($.browser.version) < 9 ) ? true : false
}
*/


jQuery(function(){
	
	// SHADOWBOX INIT
	Shadowbox.init({
		initialHeight: 52,
		initialWidth: 52,
		overlayColor: '#131602'
	});

	// CSS HOOK
	$('html').addClass('js');
	
	// EXTERNAL LINKS
	$('a[rel="external"]').attr('target', '_blank');
	
	// Header Link
	$('#branding-logo').wrap('<a href="/" id="branding-logo-link"></a>');
	
	// Open Close
	$('dl.openclose').each(
		function()
		{
			$('dd', $(this)).hide();
			
			$('dt', $(this)).toggle(
				function()
				{
					$(this).addClass('open');
					$(this).next('dd').show();
				},
				function()
				{
					$(this).removeClass('open');
					$(this).next('dd').hide();
				}
			);
		}
	);
	
	// Contact Form
	$('#content.contact form input[type="text"], #content.contact form select, #content.contact form textarea, #content.contact form input[type="checkbox"]').focus(
		function()
		{
			$(this).parent().addClass('selected');
		}
	);
	$('#content.contact form input[type="text"], #content.contact form select, #content.contact form textarea, #content.contact form input[type="checkbox"]').blur(
		function()
		{
			$(this).parent().removeClass('selected');
		}
	);
	
	$('.contact #content-main .form-area-of-interest legend').each(function(){
		$(this).replaceWith('<span>' + $(this).text() + '</span>');
	});
	
	// Tooltips
	$('.product .icons img').addClass('tooltip');
	
		
	$('img.tooltip').each(function(){
		
		var tooltipTxt = $(this).attr('title');
		var tooltipAlt = $(this).attr('alt');
		
		$(this).mouseover(function(){
			$(this).attr('title', '');
			$(this).attr('alt', '');
			
			$('body').append('<div id="js-tooltip"><div>' + tooltipTxt + '</div></div>');			
		});
		
		$(this).mouseout(function(){
			$('div#js-tooltip').remove();
			
			$(this).attr('title', 'tooltipTxt');
			$(this).attr('alt', 'tooltipAlt');
		});
		
		$(this).mousemove(function(e){
			//alert('Page Top: ' + e.pageY + ', Page left: ' + e.pageX);
			$('div#js-tooltip').css({ left: e.pageX - 50, top: (e.pageY + 3) });
		});
	});
		
	// Video Launch
	$('a.view-video').click(function(){
	
		var target = $(this).attr('href');
		
		target = target.split('video=');
		
		target = target[1];
		
		Shadowbox.open({
			player: 'html',
			content: '',
			width: 384,
			height: 288,
			options: {
				onFinish: function()
				{				
					// Alternative Content to be replaced by swfobject
					$('#sb-player.html').append('<div id="video-viewer">Flash 9 is required to view this video.</div>');
					
					var flashvars = {
						file: target,
						autostart: true
					}
					
					var flashparams = {
						allowfullscreen: 'true',
						allowscriptaccess: 'always'
					}
					
					var flashattrs = {
						name: 'video-viewer'
					}
					
					swfobject.embedSWF("/media/site/video/player.swf", "video-viewer", "384", "288", "9.0.0","/media/site/video/expressInstall.swf", flashvars, flashparams, flashattrs);
				}
			}
		});
		
		return false;
	});
	
	// Gallery Launch
	$('.product #product-gallery a img').each(function(){
		
		$(this).parent('a').append('<span class="enlarge"></span>');
		
		$(this).parent('a').click(function(){
			Shadowbox.open({
				player: 'img',
				content: $(this).attr('href'),
				title: $(this).children('img:eq(0)').attr('title')
			});
			
			return false;
		});	
	});
	
	(function(){
		if($.browser.msie && $.browser.version == 6){
			
			/* First Child Fixes */
			var cssFirstChild = new Array(
				'#content div.content-block > *:first-child',
				'.product #product-types > h2:first-child'
			);
			
			$(cssFirstChild.join()).addClass('css-first-child');
			$('.product #content-main .column-2 > .section:eq(0)').addClass('css-first-child');
			
			/* Last Child Fixes */
			var cssLastChild = new Array(
				'#content div.content-block > *:last-child'
			);
						
			$(cssLastChild.join()).addClass('css-last-child');
		
		}
	})();
	
	
});

/*-----------------------------------------------------
sIFR
-------------------------------------------------------*/
var futura = {
	src: '/media/site/fonts/futura.swf'
}
	
sIFR.fitExactly = true;
	
sIFR.activate( futura );

sIFR.replace( futura, {
	selector: 'h1.page-title',
	css: [
	  '.sIFR-root { text-transform: lowercase; }'
	],
	tuneHeight: -3,
	offsetTop: 2,
	wmode: 'transparent',
	ratios: [9, 1.27, 14, 1.19, 21, 1.16, 28, 1.13, 38, 1.12, 53, 1.11, 60, 1.1, 61, 1.11, 94, 1.1, 96, 1.09, 101, 1.1, 102, 1.09, 103, 1.1, 108, 1.09, 110, 1.1, 1.09]
});

sIFR.replace( futura, {
	selector: '#portal h1',
	css: [
	  '.sIFR-root { text-transform: lowercase; }'
	],
	offsetTop: 3,
	wmode: 'transparent',
	ratios: [9, 1.27, 14, 1.19, 21, 1.16, 28, 1.13, 38, 1.12, 53, 1.11, 60, 1.1, 61, 1.11, 94, 1.1, 96, 1.09, 101, 1.1, 102, 1.09, 103, 1.1, 108, 1.09, 110, 1.1, 1.09]
});


//sIFR.debug.ratios( futura, { selector: 'h1.page-title' });