// jQuery config
$(document).ready(function(){
	// Adds a class of "lastchild" to the last <li> in a list
	$("li:last-child").addClass("last-child");
	$("dd:last-child").addClass("last-child");
	$(".external").attr("target","_blank");
	
	// Constructs the classes used to position #secnav
	$('#secnav').find('li').slice(0,3).addClass("col1");
	$('#secnav').find('li').slice(3,6).addClass("col2");
	$('#secnav').find('li').slice(6,9).addClass("col3");
	$('#secnav').find('li').slice(9,12).addClass("col4");
	$('#secnav').find('li').slice(12,15).addClass("col5");
	$('#secnav li:eq(3),#secnav li:eq(6),#secnav li:eq(9),#secnav li:eq(12)').addClass("reset");

	// Places the <label> from <form id="searchform"> inside the text input and makes it show/hide on blur/focus
	$("#searchform label").each(function() {
		var label = $(this);
		var input = $('#' + label.attr('for'));
		var initial = label.hide().text().replace(':', '');
		input.focus(function() {
			input.css('color', '#77787b');
			if (input.val() == initial) {
				input.val('');
			}
		}).blur(function() {
			if (input.val() == '') {
				input.val(initial).css('color', '#bebfc4');
			}
		}).css('color', '#bebfc4').val(initial);
	});

	// Show/hide sliding content
	$(".faq dd:not(:first)").hide();
	$(".faq dt a").click(function(){
		$("dd:visible").slideUp("fast");
		$(this).parent().next().slideDown("fast");
		return false;
	});

	$('#splash').cycle({ 
    timeout: 4000
	})
	
	// Initialize Shadowbox
	Shadowbox.init({flvPlayer:'/media/flvplayer.swf'});
	
});


	

// sIFR config
var din = {src: '/assets/js/din.swf'};

sIFR.useStyleCheck = true;
sIFR.activate(din);

sIFR.replace(din, {
selector: 'body.homepage #pri h2'
,ratios: [9, 1.16, 16, 1.09, 29, 1.05, 34, 1.02, 49, 1.01, 72, 1, 0.99]
,css: [
  '.sIFR-root { color:#77787b; background-color:#ffffff; font-size:26px; font-weight:normal; text-transform:lowercase; }'
]
});

sIFR.replace(din, {
selector: 'body.leveltwo #pri .pagetitle h1'
,ratios: [9, 1.16, 16, 1.09, 29, 1.05, 34, 1.02, 49, 1.01, 72, 1, 0.99]
,css: [
  '.sIFR-root { color:#77787b; background-color:#ffffff; font-size:24px; font-weight:normal; text-transform:lowercase; }'
]
});

sIFR.replace(din, {
selector: '#pri .pagetitle h1'
,ratios: [9, 1.16, 16, 1.09, 29, 1.05, 34, 1.02, 49, 1.01, 72, 1, 0.99]
,css: [
  '.sIFR-root { color:#77787b; background-color:#e4e4de; font-size:24px; font-weight:normal; text-transform:lowercase; }'
]
});


// Fix for IE6 background image flicker bug
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}