	$(document).ready(function(){
		$('.styled select, .styled input').css('opacity', '0');
		// styled select boxes are actually hidden and they have a span positioned underneath them containing the current text. So just replace the text in the span once one of the select options is chosen
		//$('.styled option').click(function(){
		//	$(this).parents('select').prev().html($(this).text());
		$('.styled select').change(function(){
			$(this).prev().html($(this).val());
		});
		$('.styled_file input').change(function(){
			$(this).prev().html($(this).val());
		});
		//homepage slider hover
		$('.resources_block li a.image').hover( function() {
			$(this).next().addClass('mapit_hover')}, function() {
			$(this).next().removeClass('mapit_hover');
		});
		$(".slider").jCarouselLite({
			btnNext: ".slidenext",
			btnPrev: ".slideprev",
			circular: false,
			visible: 6,
			scroll: 1,
			speed: 600
		});
		$('#captcha2').click(function () {
			this.src = 'captcha/captcha.php?r='+Math.floor(Math.random()*1090893);
		});
		$('.more_plans img').hover(function() {
			if (!$(this).parent().parent().hasClass('active'))
			{
				this.src = this.src.replace('_01_', '_02_');
			}
		}, function() {
			if (!$(this).parent().parent().hasClass('active'))
			{
				this.src = this.src.replace('_02_', '_01_');
			}
		});
		
		$('.floorlevel').click(function(){
			click_level = this;
			cur_level = 0;
			new_level = 0;
			$('.floorlevel').each(function(i) {
				if ($(this).hasClass('current'))
				{
					cur_level = i + 1;
				}
				if (this == click_level)
				{
					new_level = i;
				}
			});
			
			if ($('.floorlevel:eq('+new_level+')').hasClass('current'))
			{
				return false;
			}
			
			var text = $('.floorlevel.current span').html();
			$('.floorlevel.current span').html('View ' + text);
			$('.floorlevel').removeClass('current');
			$('.floorlevel:eq('+new_level+')').addClass('current');
			var text = $('.floorlevel.current span').html();
			text = text.replace('View ','');
			$('.floorlevel.current span').html(text);
			new_level++;
			var src = $('#main_floor1').attr('src');

			src = src.replace('_0'+cur_level+'_', '_0'+new_level+'_');
			$('#main_floor1').attr('src', src);
			var src = src.replace('/lg/','/hg/');
			$('#main_floor1').parent().attr('href', src.replace('.png', '.jpg'));
			return false;
		});
		
		$('.floor_image .levels > span').each(function(){
			if (!$(this).hasClass('current'))
			{
				var text = $(this).children().html();
				$(this).children().html('View '+text);
			}
			else
			{
			
			}
		});
		$('.more_plans img.active').each(function(){
			this.src = this.src.replace('_01_', '_02_');
		});
		$("a[rel='popUpImg']").fancybox();
		$("a.mapit").fancybox({frameWidth:500,frameHeight:500});
		$('.styled option').each(function() {
			if (this.selected && $(this).text() != 'Undecided')
			{
				$(this).parents('select').prev().html($(this).text());
			}
		});
		$('.phone').keyup(function(){
			obj = this;
			this.value = this.value.replace(/([^0-9])/g, '');
			$('.phone').each(function(index, ele) {
				if (ele == obj && index != 2 && ele.maxLength == ele.value.length)
				{
					index++;
					$('.phone:eq('+index+')').focus();
				}
			});
		});
	});