var ie6 = ie7 = false;
$(document).ready( function () {
//console.time('whole');
	if(ie6 || ie7) {
		$('#quickLinks li:last a').css('background-image', 'none');
		$('#breadcrumb li:last').css('background-image', 'none');
		$('#secondaryMenu li.expandable').hover(
			function () {
				$(this).find('ul').fadeIn(400);
			},
			function () {
				$(this).find('ul').hide();
			}
		);
	}
	
	$('#secondaryMenu li.menuExpander>a', $('#navigation')).each( function () {
		var me = $(this),
				arrowDirection = 'down';
		me.bind('click', function () {
			arrowDirection = (arrowDirection == 'down') ? 'right' : 'down';
			// slideToggle not working in ie7... makes children disappear
			if(ie7) {
				me.next().toggle();
			} else {
				me.next().slideToggle('fast');
			}
			var ext = '.png';
			var path = 'images/styles/';
			if(ie6) {
				ext = '.gif';
				path = 'images/styles/opt/';
			}
			me.css('background-image', 'url(' + path + 'white_arrow_' + arrowDirection + ext + ')');
			return false;
		});
	});

	$('#primaryMenu>li', $('#mast')).hover(
		function () {
			$(this).find('ul').fadeIn(400);
		},
		function () {
			$(this).find('ul').hide();
		}
	);
	
	$("input[type='text']").focus( function() {
			if(this.value == this.defaultValue) {
				this.select();
			}
	});
//console.timeEnd('whole');
});

function slideSwitch() {
    var $active = $('#slideshow IMG.active', $('#content'));
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last', $('#content'));
    var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first', $('#content'));
    $active.addClass('last-active');
    $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
	    $active.removeClass('active last-active');
    });
}
$(function() {
    setInterval( "slideSwitch()",  4000);
});