property_map = {
	map:null,
	geocoder:null,
	init:function(){
	property_map.go(-32.811653,151.636004);
	},
	go:function(lat,lng){
		var latlng = new google.maps.LatLng(lat,lng);
	    var myOptions = {
	      zoom:15,
	      mapTypeControl: true,
	      mapTypeControlOptions:{style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
	      navigationControl:true,
	      navigationControlOptions:{style:google.maps.NavigationControlStyle.DEFAULT},
	      center:latlng,
	      mapTypeId:google.maps.MapTypeId.ROADMAP
	    };
	    property_map.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	    var marker = new google.maps.Marker({
	        position: latlng, 
	        map:property_map.map, 
	        title:"Property Marker"
	    }); 
	},
	pos:function(){
		var address = $("#property_title").text();
		geocoder = new google.maps.Geocoder();
		if(geocoder){
			geocoder.geocode({'address':address},function(results,status){
				if(status==google.maps.GeocoderStatus.OK){
					property_map.go(results[0].geometry.location['b'],results[0].geometry.location['c']);
				}else{
					alert("Geocode was not successful for the following reason: " + status);
				}
			});
		}
	}
}


home_slide = {
	a:null,
	n:null,
	o:null,
	t:null,
	next:function(){
		home_slide.a = home_slide.o.filter('.active');
		if (home_slide.a.length == 0 ){ home_slide.a = home_slide.o.filter(':last'); }
		home_slide.n =  home_slide.a.next().length ? home_slide.a.next() : home_slide.o.filter(':first');
		home_slide.a.addClass('last-active').animate({opacity:0}, 500, function() {
			home_slide.n.css({opacity: 0.0}).addClass('active').animate({opacity:1}, 500, function() { home_slide.a.removeClass('active last-active'); });
		});
	},
	start:function(){
		var $o = $("#agent_logos > ul li");
		home_slide.o = $o;
		$("#agent_logos").hover(function(){ window.clearInterval(home_slide.t); },function(){ home_slide.t = window.setInterval("home_slide.next()", 4000 ); });
		home_slide.t = window.setInterval("home_slide.next()", 4000 );
	}
};

$(function() {
 	$("body").addClass("js");
	
	if($("#container").hasClass('home')){
		swfobject.embedSWF("images.swf", "banner", 980, 295, "10.0.0", null, {max:7,imgDir:encodeURIComponent("images/banner/"),imgName:"slide_",imgSufx:"",imgStart:0,fadeTime:2,fadeDelay:2000,imgNamePad:10},{wmode:"transparent"});
	}
	
	home_slide.start();

	if($("#container").hasClass("home")){
		property_map.init();
	}
	
	$("#navigation > ul").supersubs({ minWidth: 12, maxWidth: 40, extraWidth: 1 }).superfish({delay: 500, speed: 'fast', dropShadows: false });
	

	$("div.photo a").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("New Window: ").length);
		$(this).attr({'title':newtitle,'rel':'photo'});
	});
	if($("#container").hasClass("agency")==false){
		$("div.photo a, a[rel='photo']").colorbox({transition:'fade',speed:500,slideshow:false});
	}
	
 });
