google.load("maps", "2.x"); google.load("jquery", "1.2.6"); //google.load("jquery", "1.3.2"); //google.load("swfobject", "2.2"); google.setOnLoadCallback(appInit); var debug = true; function appInit() { //if(debug) console.debug('appInit - called'); initController("mapInit"); initMenu(); initUnitsController(); } function appPause() {} function appStart() { // if(debug) console.debug('appStart - fading in everything'); } function appReset() {} // would actually be a main app controller class that interacts with the respective controller classes for each object function initController(eventName) { switch (eventName) { case "validatorInit": validatorInit(); break; case "validatorInited": sectionsInit(); break; case "sectionsInited": menuInit(); break; case "menuInited": locationMenuInit(); break; case "locationMenuInited": locationFormInit(); break; case "locationFormInited": appStart(); break; case "mapInit": mapInit(); break; case "mapInited": initController("slideshowInit"); break; case "slideshowInit": slideShowInit(); break; case "slideshowInited": appStart(); break; } } //////////////////// side menu ajax logic function initMenu() { $(".nav > li").hover( function() { $(this).css("backgroundColor", "#59553c"); }, function() { $(this).css("backgroundColor", "transparent"); } ); $("#menu ul li").hover( function() { $(this).css("backgroundColor", "#59553c"); }, function() { $(this).css("backgroundColor", "transparent"); } ); } function initUnitsController () { $('div.controlsContainer div.rightControls > div a').click( function () { // take the url of the link // change the src of the #imageHolder img $('#imageHolder #floorplan').attr('src', this.href); //alert('hi'); return false; } ); } var slideshowTimer = ""; var path = ".slideshow"; function slideShowInit (){ if($('.slideshow').length){ slideShowInitControls(); slideShowInitThumbnailController(); initController("slideshowInited"); slideShowPlay(); } } function slideShowInitControls () { $('.slideshow .images').show(); var $active = $(path + ' .images IMG.active'); if ($active.length == 0) $active = $(path + ' .images IMG:first'); $('.slideshowControls .pause').bind("click", slideShowPause); $('.slideshowControls .play').bind("click", slideShowPlay); $('.slideshowControls .next').bind("click", slideShowNextImage); $('.slideshowControls .previous').bind("click", slideShowPreviousImage); $('.slideshowControls .pause').hide(); $('.slideshowControls .play').show(); } function slideShowInitThumbnailController () { $('ul#thumbnailController li:eq(0)').addClass("current_page_item"); $('.mainColumn .post h2.dark').text($('ul#thumbnailController li:eq(0) a').text()); $('#thumbnailController li').hover( function () { var id = $('#thumbnailController li').index(this) + 1; //alert('hey this is a rooll: ' + id) ; var image = ''; $('#thumbnailHolder').html(image); }, function () { } ); $('#thumbnailController li a').click( function () { var index = $('#thumbnailController li').index($(this).parent()); slideShowPause(); slideShowGoToSlide(index); return false; } ); } function slideShowGoToSlide (num) { var next = $(path + ' .images IMG:eq(' + num + ')'); slideShowSwitchImage (next); } function slideShowIsPlaying (){ return (slideshowTimer)? true : false; } function slideShowPlay () { slideshowTimer = setInterval("slideShowSwitchImage()", 4000); $('.slideshowControls .pause').show(); $('.slideshowControls .play').hide(); slideShowSwitchImage (); } function slideShowPause (){ clearInterval(slideshowTimer); $('.slideshowControls .pause').hide(); $('.slideshowControls .play').show(); } function slideShowPreviousImage(){ if(slideShowIsPlaying()) slideShowPause(); var active = $(path + ' .images IMG.active'); var next = (active.prev().length) ? active.prev() : $(path + ' .images IMG:last'); slideShowSwitchImage (next); } function slideShowNextImage (){ if(slideShowIsPlaying()) slideShowPause(); var active = $(path + ' .images IMG.active'); var next = (active.next().length) ? active.next() : $(path + ' .images IMG:first'); slideShowSwitchImage (next); } function slideShowSwitchImage (next){ var active = $(path + ' .images IMG.active'); active.addClass('last-active'); if (!next) var next = (active.next().length) ? active.next() : $(path + ' .images IMG:first'); var index = $(path + ' .images IMG').index(next); var title = $('ul#thumbnailController li:eq(' + index + ') a').text(); $('.mainColumn .post h2.dark').text(title); $('ul#thumbnailController li.current_page_item').removeClass("current_page_item"); $('ul#thumbnailController li:eq(' + index + ')').addClass("current_page_item"); //alert('nextIMage is: ' + index); next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() { active.removeClass('active last-active'); }); } function slideShowRandomImage() { var active = $(path + ' .images IMG.active'); var rndNum = Math.floor(Math.random() * active.siblings().length); var next = $(active.siblings()[ rndNum ] ); slideShowSwitchImage (next); } function mapInit() { if ($('#map').length) { mapInitControls(); geocoder = new GClientGeocoder(); findLocation(); } initController('mapInited'); } function findLocation(address) { if (!address) { var address = '10585 Santa Monica Boulevard Los Angeles, CA 90025'; } geocoder.getLocations(address, addAddressToMap); } function addAddressToMap(response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } else { var place = response.Placemark[0]; var point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); } if (typeof gmap == 'undefined') { var map = new google.maps.Map2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GOverviewMapControl()); $('.mapControls #zoomIn').bind("click", mapZoomIn); $('.mapControls #zoomOut').bind("click", mapZoomOut); $('.mapControls #center').bind("click", mapReset); gmap = map; } gmap.clearOverlays(); gmap.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 19); //map.setMapType(G_HYBRID_MAP); marker = new GMarker(point); gmap.addOverlay(marker); marker.openInfoWindowHtml(place.address); } function mapInitControls() { $('.mapControls div').hover( function() { $(this).css("color", "#ffffff"); }, function() { $(this).css("color", "#64958f"); } ); } function mapReset() { findLocation(); } function mapZoomIn() { gmap.zoomIn(); } function mapZoomOut() { gmap.zoomOut(); } function mapShow() { $('#map').show(); $('.mapControls').show(); } function mapHide() { $('#map').hide(); $('.mapControls').hide(); }