
Cufon.replace('#header .nav-main A', { fontFamily: 'Myriad Pro', fontWeight: '400' });
Cufon.replace('#content .column-left .nav-sub A', { fontFamily: 'Myriad Pro', fontWeight: '400' });
Cufon.replace('#content .column-main H1', { fontFamily: 'Myriad Pro', fontWeight: '300' });
Cufon.replace('#content .column-front H2', { fontFamily: 'Myriad Pro', fontWeight: '300' });


/*
rotator.js
http://www.josephfinsterwald.com
*/

(function($) {
    $.rotate = function(s) {
        return $.rotate13($.rotate5(s));
    }

    $.rotate5 = function(s) {
        var b = [],c,i = s.length,a = '0'.charCodeAt(),z = a + 10;
        while (i--) { 
            c = s.charCodeAt(i);
            if (c >= a && c < z) { b[i] = String.fromCharCode(((c - a + 5) % (10)) + a); }
            else { b[i] = s.charAt(i); }
        }
        return b.join('');
    };

    $.rotate13 = function(s) {
        var b = [],c,i = s.length,a = 'a'.charCodeAt(),z = a + 26,A = 'A'.charCodeAt(),Z = A + 26;
        while (i--) {
            c = s.charCodeAt(i);
            if (c >= a && c < z) { b[i] = String.fromCharCode(((c - a + 13) % (26)) + a); }
            else if (c >= A && c < Z) { b[i] = String.fromCharCode(((c - A + 13) % (26)) + A); }
            else { b[i] = s.charAt(i); }
        }
        return b.join('');
    };
})(jQuery)

$(document).ready(function() {

	
	/* IE6 */
	if ($.browser.msie && parseFloat($.browser.version) < 7) {
		$('INPUT[type=text]').addClass('text');
	}

	/* IE7 */
	if ($.browser.msie && parseFloat($.browser.version) < 8) {

		$('LI:first-child').addClass('first-child');
		$('LI:last-child').addClass('last-child');
		$('TABLE TR:nth-child(odd)').addClass('nth-child-odd');
		$('TABLE TD:first-child').addClass('first-child');
		$('TABLE TH:first-child').addClass('first-child');
	}
	
	// Open external links into new window
	$('A[href^=http://], A[href^=https://]').each(function() {
		$(this).attr('target', '_blank');
	});
	
	$('#footer .print').click(function(e) {
		e.preventDefault();
		window.print();
	});

	// De-obfuscate emails
	$('A[href^=mailto:][href$=.example.com]').each(function() {
		var email = $(this).attr('href').substr(7).split('').reverse().join('').substr(12);
		$(this).attr('href', 'mailto:' + email);
		if ($(this).text().indexOf('@') == -1 && ! $(this).hasClass('keep-text'))
			$(this).text(email);
		$(this).css('visibility', 'visible');
	});
	
	if ($('#carousel').length > 0)
		var carousel = new Carousel('#carousel', 5000, 1000);
		
	$('#content .column FORM INPUT[type=text]:first').not('.no-autofocus').focus();
	
	$('FORM .autoclear').focus(function () {
		if ($(this).hasClass('autoclear-default')) {
			$(this).removeClass('autoclear-default');
			$(this).addClass('autoclear-edited');
			$(this).attr('default_value', $(this).val());
			$(this).val('');
		}
	});

	$('FORM .autoclear').blur(function () {
		if ($(this).val() == '') {
			$(this).addClass('autoclear-default');
			$(this).removeClass('autoclear-edited');
			$(this).val($(this).attr('default_value'));
		}
	});
	
	$('#route-search').submit(function() {
		$('.autoclear-defalt', this).val('');
	});
	
});

