$SL=0;

$(window).ready(function() { 
	if (location.pathname && (location.pathname == '/' || location.pathname == '/Home')) {
		BuildSlider();
	} else {
		BuildTopMenu(1);
	}
});
$(window).load(function() {
	//if ($('#ContentRight').height() > $('#ContentLeft').height()) {
	//	$('#ContentLeft').height($('#ContentRight').height());
	//}
});

function BuildSlider() {
	if ($SL>0) {
		return;
	}
	$SL=1;

	$('#Slider').append(
		$('<img>').addClass('SliderMain').attr({src:'/images/SliderMain.jpg'}).css({position:'absolute',width:'850'}).load(function() {
			$(this).animate({top:'-200'},1500, function() {
				$(this).animate({top:'-220',left:'-100'},500, function() {
					$(this).animate({top:'-275',left:'-0',width:'745'},1000, function() {
					
						$('#Slider').append(
							$('<ul>').append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW1',src:'/images/SliderRealEstateBW.jpg'}).css({position:'absolute',top:'-175px'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC1',src:'/images/SliderRealEstate.jpg'}).css({position:'absolute',top:'0px',opacity:'0'})
								).append(
									$('<h1>').html('REAL ESTATE')
								).click(function() {
									location.href = '/Real_Estate';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW2',src:'/images/SliderCommercialBW.jpg'}).css({position:'absolute',top:'-175px'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC2',src:'/images/SliderCommercial.jpg'}).css({position:'absolute',top:'0px',opacity:'0'})
								).append(
									$('<h1>').html('COMMERCIAL LITIGATION')
								).click(function() {
									location.href = '/Commercial_Litigation';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW3',src:'/images/SliderCorporateBW.jpg'}).css({position:'absolute',top:'-175px'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC3',src:'/images/SliderCorporate.jpg'}).css({position:'absolute',top:'0px',opacity:'0'})
								).append(
									$('<h1>').html('CORPORATE LAW')
								).click(function() {
									location.href = '/Corporate_Law';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW4',src:'/images/SliderFamilyBW.jpg'}).css({position:'absolute',top:'-175px'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC4',src:'/images/SliderFamily.jpg'}).css({position:'absolute',top:'0px',opacity:'0'})
								).append(
									$('<h1>').html('PROBATE AND FAMILY LAW')
								).click(function() {
									location.href = '/Probate_Wills_and_Trusts';
								})
							)
						);
						
						
						$('#SliderBW1').animate({top:'0'},500,function() {
							$('#SliderBW2').ready(function() {
								$('#SliderBW2').animate({top:'0'},500,function() {
									$('#SliderBW3').ready(function() {
										$('#SliderBW3').animate({top:'0'},500,function() {
											$('#SliderBW4').ready(function() {
												$('#SliderBW4').animate({top:'0'},500,function() {
													$('.SliderColor').animate({opacity:'1'},1000,function() {
														$('#Slider li:nth-child(1) h1').animate({top:'10'},250,function() {
															$('#Slider li:nth-child(2) h1').animate({top:'10'},250,function() {
																$('#Slider li:nth-child(3) h1').animate({top:'10'},250,function() {
																	$('#Slider li:nth-child(4) h1').animate({top:'10'},250,function() {
																		BuildTopMenu(0);
																	});
																});
															});
														});
													});
												})
											});
										})
									});
								})
							});
						});
						
						
						
					})
				})
			})
		})
	).append(
		$('<img>').attr({src:'/images/SliderShadow.png'}).css({position:'absolute',bottom:'0',zIndex:'1000'})
	);
}

function BuildTopMenu(M) {
	
	if (M) {
		$('#Slider').append(
							$('<ul>').append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW1',src:'/images/SliderRealEstateBW.jpg'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC1',src:'/images/SliderRealEstate.jpg'})
								).append(
									$('<h1>').html('REAL ESTATE')
								).click(function() {
									location.href = '/Real_Estate';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW2',src:'/images/SliderCommercialBW.jpg'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC2',src:'/images/SliderCommercial.jpg'})
								).append(
									$('<h1>').html('COMMERCIAL LITIGATION')
								).click(function() {
									location.href = '/Commercial_Litigation';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW3',src:'/images/SliderCorporateBW.jpg'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC3',src:'/images/SliderCorporate.jpg'})
								).append(
									$('<h1>').html('CORPORATE LAW')
								).click(function() {
									location.href = '/Corporate_Law';
								})
							).append(
								$('<li>').append(
									$('<img>').addClass('SliderBW').attr({id:'SliderBW4',src:'/images/SliderFamilyBW.jpg'})
								).append(
									$('<img>').addClass('SliderColor').attr({id:'SliderC4',src:'/images/SliderFamily.jpg'})
								).append(
									$('<h1>').html('PROBATE AND FAMILY LAW')
								).click(function() {
									location.href = '/Probate_Wills_and_Trusts';
								})
							)
		).append(
			$('<img>').attr({src:'/images/SliderShadow.png'}).css({position:'absolute',bottom:'0',zIndex:'1000'})
		);
	}
	
		
	$('.SliderColor').css({position:'absolute',top:'0px',left:'0px'}).hover(function() {
		$(this).animate({opacity:'0'},200);
	},function() {
		$(this).animate({opacity:'1'},100);
	});
	
	$('#Slider h1').css({top:'10px'});
	
	
}

