$(document).ready(function() {
	/* open links with rel="external" in new window and amend link title */
	$('a[rel*="external"]').each(function() {
		var title = $(this).attr('title') ? $(this).attr('title') + ' (opens in a new tab or window)' : 'This link will open in a new tab or window';
		$(this).attr('title',title).click(function() {
			window.open($(this).attr('href'));
			return false;
		});
	});
	
	/*Cufon.replace('h1, h3, #what_you_say p, #banner_content p', { fontFamily: 'Nilland' });
	Cufon.replace('h2', { fontFamily: 'Nilland-Black' });
	Cufon.replace('#home_search form fieldset p, #search_staff, a.home_slider, #header_right p', { fontFamily: 'AvantGarde LT Medium' });*/
	Cufon.replace('h1, h3, #what_you_say p, #banner_content p', { fontFamily: 'Verdana' });
	Cufon.replace('h2', { fontFamily: 'VerdanaBold' });
	//Cufon.replace('#home_search form fieldset p, #search_staff, a.home_slider, #header_right p', { fontFamily: 'Verdana' });
	Cufon.replace('#home_search form fieldset p, #search_staff, a.home_slider', { fontFamily: 'Verdana' });
	Cufon.now();
	
	$('#q').focus(function() {
		if($(this).val() == 'Search') {
			$(this).val('');
		};
	}).blur(function() {
		if($(this).val() == '') {
			$(this).val('Search');
		};
	});
	
	var num = $('#main_content ul li').length;
	
	$('#main_content ul li').eq(parseInt(num) - 2).find('a').addClass('last');
	$('#main_content ul li').eq(parseInt(num) - 1).find('a').addClass('last');
	
	
	$('#home_search form').hide();
	
	$('a.home_slider:first').addClass('selected').parent().find('form').show();
	
	$('a.home_slider').click(function() {
		if(!$(this).hasClass('selected')) {
			$('a.home_slider.selected').removeClass('selected');
			$(this).addClass('selected');
			$('#home_search form').slideUp();
			$(this).parent().find('form').slideDown();
		};

		return false;
	});
	
	$('#what_you_say p.left').hide().eq(0).addClass('selected').show();
	$('#what_you_say p.right').hide().eq(0).addClass('selected').show();
	
	setInterval(function() {
		var _l_cur = $('#what_you_say p.left.selected');
		var _r_cur = $('#what_you_say p.right.selected');
		
		if(_l_cur.next('p.left').hasClass('left')) {
			var _l_next = _l_cur.next('p.left');
		} else {
			var _l_next = $('#what_you_say p.left').eq(0);
		};
		
		if(_r_cur.next('p.right').hasClass('right')) {
			var _r_next = _r_cur.next('p.right');
		} else {
			var _r_next = $('#what_you_say p.right').eq(0);
		};
		
		_l_cur.removeClass('selected').fadeOut(500, function() {
			_l_next.addClass('selected').fadeIn(500);
		});
		
		_r_cur.removeClass('selected').fadeOut(500, function() {
			_r_next.addClass('selected').fadeIn(500);
		});
	}, 5000);
	
	
	$('#main_content ul li ul').hide();
	
	$('#main_content ul li a').click(function() {
		if($(this).parent().find('ul').hasClass('sub')) {
			$('#main_content ul li ul.selected').removeClass('selected').slideUp();
			$(this).parent().find('ul').addClass('selected').slideDown();
			return false;
		};
	});
	
	 $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: '/_images/rec_tab.jpg', //path to the image for the tab //Optionally can be set using css
            imageHeight: '122px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '58px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'left',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 300,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '200px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '20px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
        });
	
	
	
});

function addBookmark(){
	if (document.all) {window.external.AddFavorite(location.href, document.title);}
	else if (window.sidebar){window.sidebar.addPanel(document.title, location.href, "");}
}




