$(document).ready(function(){
	$('#innerfade-top').innerfade({
		animationtype: 'fade',
		speed: 'slow',
		timeout: 4000,
		type: 'random',
		containerheight: '143px'
	});
	
	$('#commercial-slides-container').innerfade({
		animationtype: 'fade',
		speed: 'slow',
		timeout: 6000,
		type: 'random',
		containerheight: '295px'
	});
	
	$('#residential-slides-container').innerfade({
		animationtype: 'fade',
		speed: 'slow',
		timeout: 6000,
		type: 'random',
		containerheight: '295px'
	});
		
	 $("#innerfade-container").fadeIn("slow");					 
});


function defaultfieldenter(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function defaultfieldblur(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

	var geocoder;
	var map;
	var address;
	
	function initialize() {
			
			
			
			var myOptions = {
			  zoom: 13,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			}
				
			map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		
			geocoder = new google.maps.Geocoder();
			  geocoder.geocode( { 'address': address}, function(results, status) {
				if (status == google.maps.GeocoderStatus.OK) {
				  map.setCenter(results[0].geometry.location);
				  var marker = new google.maps.Marker({
					  map: map, 
					  position: results[0].geometry.location
				  });
				} else {
				  alert("Geocode was not successful for the following reason: " + status);
				}
			  });
		}


		function ajaxFileUpload(upload_field, slot, hash)
		{
		// Checking file type
		var re_text = /\.jpg|\.jpeg/i;
		var filename = upload_field.value;
		if (filename.search(re_text) == -1) {
		alert("File must be .JPG or .JPEG");
		upload_field.form.reset();
		return false;
		}
			document.getElementById('picture_preview'+slot).innerHTML = '<div><img src="images/progressbar.gif" border="0" /></div>';
			document.getElementById('Image'+slot).value = hash;
			upload_field.form.action = 'listasset-control.php?slot='+slot+'&hash='+hash;
			upload_field.form.target = 'upload_iframe'+slot;
			upload_field.form.submit();
			upload_field.form.action = '';
			upload_field.form.target = '';
		return true;
		}
		
		function ajaxFileUploadWipe(upload_field, slot, hash) {
			document.getElementById('picture_preview'+slot).innerHTML = '<div><img src="images/nophoto.jpg" width="160" height="120" border="0" /></div>';
			document.getElementById('Image'+slot).value = '';
			upload_field.form.action = 'listasset-control.php?hash='+hash+'&delete=1';
			upload_field.form.target = 'upload_iframe'+slot;
			upload_field.form.submit();
			upload_field.form.action = '';
			upload_field.form.target = '';
		}
		

		function switchTo(i) {
			  $('#switches li').css('color','#666').eq(i).css('color','#F00');
			  $('#slides div').css('display','none').eq(i).css('display','block');
			  $('#agent-photos div').css('display','none').eq(i).css('display','block');

			}
			$(document).ready(function(){
			  $('#switches li').mouseover(function(event){
				switchTo($('#switches li').index(event.target));
			  });
			  switchTo(0);
		});
