
	$(document).ready( function() {

		$('ul#navigate_simple').replaceWith($('ul#navigate'));
		$('ul#navigate').dynamItDrop();

		$('#clientlogin').css('height', '32px')
			.find('#login_submit').hide().end()
			.find('#hit_area')
			.click( function() {
				var $cl = $('#clientlogin');
				var isOpen = ( parseInt( $cl.height(), 10 ) > 32 );

				if(isOpen) {
					$cl.find('#login_submit').hide();
					$cl.children().css('background-image', 'url(img/clientlogin.gif)');
				} else {
					$cl.find('#login_submit').show();
					$cl.children().css('background-image', 'url(img/clientlogin-on.gif)');
				}

				var newHeight = (isOpen) ? 32 : 100;
				$cl.animate({ height: newHeight + 'px' });

			});


		$('ul.tab>li').live('click', function() {
			var index = $(this).parent().children('li').index(this);
			$content = $(this).parent().next('ul.tab-content');
			$content.children('li').hide();
			$content.children('li').eq(index).show();
			$(this).parent().children('li').removeClass('on').children('a').removeClass('on');
			$(this).addClass('on').children('a').addClass('on');
			return false;
		});

		$('ul.voice-tab>li').live('click', function() {
			var index = $(this).parent().children('li').index(this);
			$content = $(this).parent().next('ul.voice-tab-content');
			$content.children('li').hide();
			$content.children('li').eq(index).show();
			$(this).parent().children('li').removeClass('on').children('a').removeClass('on');
			$(this).addClass('on').children('a').addClass('on');
			return false;
		});

		$('ul.subnav li.sp').prev().addClass('last');

		$("#subnav-menu").accordion({
			header: '> li > h3.subtitle',
			autoHeight: false,
			navigation: true
		});

		$('h1').each( function() {
			var title = $(this).html();
			$(this).html( '<span>' + title + '<small>' + title + '</small></span>' );
		});


		// setup the lightbox.
		$(".lightbox").lightbox();
		
		$('#search_query').focus(function () {
			if ($(this).val() == '<enter search terms>') $(this).val('');
		}).blur(function () {
			if ($(this).val() == '') $(this).val('<enter search terms>');
		})
			
		$('a img').parent().css('border', '0 none');



		// initiate the datepicker
		$('.dateselect').datepicker();



		// fix subnav
		if( $('ul.subnav a.ui-accordion-content-active').length == 0 ) {
			var urlcomponents = location.href.split('/');
			var parentlink = '';
			for( var j = 3; j <= 5; j++ )
				parentlink += '/' + urlcomponents[j];

			var $parentlinkobj = $("ul.subnav a[href='" + parentlink + "']");
			$parentlinkobj.addClass('ui-accordion-content-active');
			$parentlinkobj.closest('ul').prev('h3').children('a').click();
		}

	} );

function setJS() {
	document.QuestionEntry.JavaScript.value = "true";
}

function callcopyOpenDialog(html) {
	dynamItOpenDialog( dialogTop('') + html + dialogBottom(), 300, 'auto' );
}

function formSubmit(elt) {
	return Mkto.formSubmit(elt);
}

function formReset(elt) {
	return Mkto.formReset(elt);
}
