var webroot = '/';

// var webroot = '/clients/baker/site/pass7b/';

var scalabold = {
	src: webroot + 'swf/scalasans-bold.swf',
	wmode: 'transparent',
	fitExactly: true
}

var scalalight = {
	src: webroot + 'swf/scalasans-light.swf',
	wmode: 'transparent',
	fitExactly: true
}

var scala = {
	src: webroot + 'swf/scalasans.swf',
	wmode: 'transparent',
	fitExactly: true,
	css: [
		'.sIFR-root { color: #000; text-transform: uppercase; }',
		'a { color: #ef000e; text-decoration: none; }',
		'a:hover { color: #00653a }'
	]
}

// sIFR.debug.ratios({
// 	src: webroot + 'swf/scalasans.swf',
// 	fitExactly: true,
// 	selector: '#banner h1',
// 	// tuneHeight: -5,
// 			css: [
// 				'.sIFR-root { color: #ffffff; text-transform: uppercase; letter-spacing: 1 }'
// 			]
// 	
// });
// 
sIFR.activate(scalalight, scala);

sIFR.replace(scalalight, {
	selector: '#intro',
	css: [
		'.sIFR-root { color: #ffffff; leading: 8; }',
		'a { color: #ffffff; text-decoration: underline; }',
		'a:hover { color: #7E1200; text-decoration: underline; }'
	]
});

sIFR.replace(scalabold, {
	selector: 'h2',
	css: [
		'.sIFR-root { color: #000000; text-transform: uppercase; letter-spacing: 1 }',
		'a { color: #000000; text-decoration: none; }',
		'a:hover { color: #000000; text-decoration: underline; }'
	]
	
});

sIFR.replace(scala, {
	selector: '#banner h1',
	// tuneHeight: -5,
	css: [
		'.sIFR-root { color: #ffffff; text-transform: uppercase; letter-spacing: 1 }'
	],
	ratios: [6,1.41,7,1.35,8,1.32,9,1.31,10,1.28,11,1.27,12,1.29,13,1.27,14,1.25,15,1.25,16,1.24,17,1.23,18,1.25,19,1.23,20,1.23,21,1.23,22,1.22,23,1.21,24,1.23,25,1.22,26,1.21,27,1.21,28,1.21,29,1.2,30,1.22,31,1.21,32,1.2,33,1.21,34,1.2,35,1.2,36,1.21,37,1.2,38,1.2,39,1.2,40,1.19,41,1.19,42,1.2,43,1.2,44,1.19,45,1.2,46,1.19,47,1.19,48,1.2,49,1.19,50,1.19,51,1.19,52,1.19,53,1.19,54,1.19,55,1.19,56,1.19,57,1.19,58,1.19,59,1.19,60,1.19,61,1.19,62,1.19,63,1.19,64,1.18,65,1.18,66,1.19,67,1.19,68,1.18,69,1.19,70,1.18,71,1.18,72,1.19,73,1.18,74,1.18,75,1.18,76,1.18,77,1.18,78,1.19,79,1.18,80,1.18,81,1.18,82,1.18,83,1.18,84,1.18,85,1.18,86,1.18,87,1.18,88,1.18,89,1.18,90,1.18,91,1.18,92,1.18,93,1.18,94,1.18,95,1.18,96,1.18,97,1.18,98,1.18,99,1.18,100,1.18,101,1.18,102,1.18,103,1.18,104,1.18,105,1.18,106,1.18,107,1.18,108,1.18,109,1.18,110,1.18,111,1.18,112,1.18,113,1.18,114,1.18,115,1.18,116,1.18,117,1.18,118,1.18,119,1.18,120,1.18,121,1.18,122,1.18,123,1.18,124,1.18,1.18]
});


$(document).ready(function() {
	chromeH = 0;
	paddingH = 0;
	sizeCache = [];
	setFooter();
	$(window).resize(setFooter);
	
	if ($('#homenews').length > 0) {		
		var so = new SWFObject( webroot + "swf/homeslides2.swf", "homenews", "350", "200", "7", "#cddadd");
		so.addVariable("imagesXml", webroot + "xml/homeslides2.xml");
	    so.write("homenews");	
	}
	
	if ($('#gallery').length > 0) {		
		var so = new SWFObject( webroot + "swf/gallery.swf", "gallery", "600", "400", "7", "#cddadd");
		so.addVariable("imagesXml", webroot + "xml/gallery.xml");
	    so.write("gallery");	
	}
});


function setFooter()
{
	$('body').css('height','100%')
	var windowH = getWindowHeight();
	
	if (chromeH == 0)
	{
		$('#main').css('height','auto');
		
		$('#hdr, #nav, #main, #banner-c, #ftr').each(function(){
			var t = $(this);
			var thisH = t.get(0).clientHeight;
			var thisP = parseInt(t.css('padding-top')) + parseInt(t.css('padding-bottom'));
			
			chromeH += (thisH );
			sizeCache[$(this).attr('id')] = thisH - thisP;
			paddingH += thisP;
		});
				
	}

	if ( chromeH > windowH )
	{ 
		var newH = sizeCache['main'];
		$('#main').css('height','auto');		
	}
	else
	{
		var newH = (windowH - chromeH) + sizeCache['main'];

		if ($.browser.msie) newH -= 30;
		if ($('body').attr('id') == 'home') newH += 4;
		$('#main').css('height', newH );
	}

	var sideP = parseInt($('#side').css('padding-top')) + parseInt($('#side').css('padding-bottom'));
	
	if ($('body').attr('id') != 'home')
		$('#side').css('height', newH + parseInt(sizeCache['ftr']) - sideP );
}
// $(function(){
// 	var iframe = $('#GCal')[0];
// 	// gCal.find('.view-container-border').css('background-color', '#f99d31');
// 
// 	var doc = iframe.document || iframe.contentDocument ||
// 	iframe.contentWindow && iframe.contentWindow.document || null;
// 	var doc2 = $(doc);
// 	// console.log(doc2);
// 	
// })


function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight)=='number') {
windowHeight=window.innerHeight;
}
else {
if (document.documentElement&&
document.documentElement.clientHeight) {
windowHeight=
document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight=document.body.clientHeight;
}
}
}
return windowHeight;
}