$(function(){
	$('ol, ul').each(function(){
		$('li:first', this).addClass('first');
		$('li:last', this).addClass('last');
	});
	
	$('input[name="newsletterEmailAddress"]').click(function(){
		if(($(this).val())=="Newsletter Sign Up")
		{
			$(this).val('');
		}
	});
	
	$('li.theTeamImage > a:has(img)').lightBox({
		imageLoading: '/wp-content/themes/dlpTheme/images/lightbox-btn-loading.gif',
		imageBtnClose: '/wp-content/themes/dlpTheme/images/lightbox-btn-close.gif',
		imageBtnPrev: '/wp-content/themes/dlpTheme/images/lightbox-btn-prev.gif',
		imageBtnNext: '/wp-content/themes/dlpTheme/images/lightbox-btn-next.gif'
	});
	
	$('a#callYouLink').click(function(){
		$('body').append('<div id="callYouBoxUnderlay">&nbsp;</div>');
		$('#callYou').show();
		$('#callYouBoxUnderlay').click(function(){
			$('#callYou').hide();
			$('#callYouBoxUnderlay').remove();
			return false;
		});
		return false;
	});
	
	$("#twitter").getTwitter({
		userName: "DirectLawLeeds",
		numTweets: 2,
		loaderText: "Loading tweets...",
		slideIn: true,
		slideDuration: 750,
		showHeading: true,
		headingText: "Latest Tweets",
		showProfileLink: false,
		showTimestamp: false
	});
	$('#companyLogos > ul').css({
		'width': $('#companyLogos > ul > li').outerWidth(true)*$('#companyLogos > ul > li').size()
	});
	
	if($('#companyLogos > ul > li').length)
	{
		companyLogosSliderCount = 0;
		setInterval("companyLogosSlider()", 5000);
	}
	/*
	if($('#banner > .homePageContent').length)
	{
		contentSize = ($('#banner > .homePageContent').width()+$('#banner > .bannerImage > p').width()) + (parseInt($('#banner > .bannerImage').css('padding-left').replace('px','')) - $('#banner > .bannerImage > img').width());
		$('#banner > .bannerImage').css({
			'padding-left': $('#banner > .bannerImage > img').width()-$('#banner > .bannerImage > p').width()
		});
		$('#banner > .homePageContent').css({
			'width': contentSize
		});
	}
	*/
});

function companyLogosSlider()
{
	if(($('#companyLogos > ul > li').size()-(Math.floor($('#companyLogos').width()/$('#companyLogos > ul > li').outerWidth(true)))) == companyLogosSliderCount)
	{
		$('#companyLogos > ul').stop(true, true).animate({
			'left': 0
		});
		companyLogosSliderCount = 0;
	}
	else
	{
		$('#companyLogos > ul').stop(true, true).animate({
			'left': (($('#companyLogos > ul').css('left')).replace('px', '')-($('#companyLogos > ul > li').outerWidth(true)))
		});
		companyLogosSliderCount = companyLogosSliderCount+1;
	}
}
