   $(document).ready(function(){
							  
									
				var galleries = $('.ad-gallery').adGallery({
					  width:300,
					  height:200,
					  thumb_opacity: 0.7,
					  start_at_index: 0,
					  animate_first_image: true,
					  animation_speed: 1000,
					  display_next_and_prev: true, 
					  display_back_and_forward: true, 
					  scroll_jump: 0,
					  slideshow: {
						enable: true,
						autostart: true,
						speed: 3000,
						/*start_label: 'Start',*/
						stop_label: 'Stop',
						stop_on_scroll: true, 
						countdown_prefix: '(',
						countdown_sufix: ')',
						onStart: function() {
						},
						onStop: function() {
						}
					  },
					  effect: 'fade', //'slide-hori',  or 'slide-vert', 'resize', 'fade', 'none' or false
					  enable_keyboard_move: true,
					  cycle: true,
					  callbacks: {
                        init: function(obj){

						},
                        beforeImageVisible: function(obj) {
						  $(obj.element).click(function(){ 
                               $(".ad-thumb-list a").lightBox({
										autoLinkage: false,
										fixedNavigation: true,
										imageLoading: 'http://www.realestateactive.com/images/loading.gif',		
										imageBtnPrev: 'http://www.realestateactive.com/scripts/gallery/jquery-lightbox-0.5/images/lightbox-btn-prev2.png',		
										imageBtnNext: 'http://www.realestateactive.com/scripts/gallery/jquery-lightbox-0.5/images/lightbox-btn-next2.png',		
										imageBtnClose: 'http://www.realestateactive.com/scripts/gallery/jquery-lightbox-0.5/images/lightbox-btn-close1.png',		
										imageBlank: 'http://www.realestateactive.com/scripts/gallery/jquery-lightbox-0.5/images/lightbox-blank.gif',
										onclick_prev:function(obj){
											$(".ad-thumb"+obj.activeImage).trigger("click");
										},
										onclick_next:function(obj){
											$(".ad-thumb"+obj.activeImage).trigger("click");
										}
								},$(".ad-thumb"+obj.index));  
							   galleries[0].slideshow.stop();
						  }).css("cursor","pointer");
						  if(obj.images.length<=1){
							  galleries[0].slideshow.stop();
							  $(".ad-slideshow-start, ad-slideshow-stop").hide();
						  }
						},
						afterImageVisible: function(obj) {
						}
                     }


				});
/*				$('#switch-effect').change(
				  function() {
					galleries[0].settings.effect = $(this).val();
					return false;
				  }
				);
*/				/*$('#toggle-slideshow').click(
				  function() {
					galleries[0].slideshow.toggle();
					return false;
				  }
				);*/

				geoMap={};
				/*geoMap.initialize=function(lat,lng){
					if (GBrowserIsCompatible()) {
						  geoMap.map = new GMap2(document.getElementById("geoMap_map"));
						  geoMap.map.setMapType(G_HYBRID_MAP);
						  geoMap.map.setUIToDefault();
						  geoMap.map.setCenter(new GLatLng(lat,lng), 1);
						  geoMap.geocoder = new GClientGeocoder();
						  geoMap.mapType = geoMap.map.getCurrentMapType();
						  geoMap.map.clearOverlays();
						  var point = new GLatLng(lat,lng); 
						  var greenIcon = new GIcon(G_DEFAULT_ICON);
						  greenIcon.image = "marker_green.png";
			              var options = { title: "", icon:greenIcon };
						  geoMap.marker = new GMarker(point, options);
			              geoMap.map.addOverlay(geoMap.marker);
						  geoMap.zoomMap(point);
					}
				}*/
				geoMap.zoomMap=function(latlng){
					geoMap.map.getCurrentMapType().getMaxZoomAtLatLng(latlng, 
						function(response){ if (response && response['status']==G_GEO_SUCCESS) geoMap.map.setCenter(latlng, response["zoom"]-2); });
				}
				geoMap.initialize_address=function(address){
				          if($.trim(address)!=""){
								geoMap.map = new GMap2(document.getElementById("geoMap_map"));
								//geoMap.map.setMapType(G_HYBRID_MAP);
								//geoMap.map.setMapType(G_SATELLITE_MAP);
								geoMap.map.setUIToDefault();
								geoMap.geocoder = new GClientGeocoder();
								geoMap.mapType = geoMap.map.getCurrentMapType();
								geoMap.map.clearOverlays();
								geoMap.geocoder.getLocations(address,
									function(d){
										  if(typeof d=="object"&&typeof d.Status=="object"&&typeof d.Status.code=="number"&&d.Status.code==200){
												var c = d.Placemark[0].Point.coordinates; 
												var point = new GLatLng(c[1],c[0]); 
												var greenIcon = new GIcon(G_DEFAULT_ICON);
												greenIcon.image = "http://www.realestateactive.com/images/marker_green.png";
												var options = { title: "", icon:greenIcon };
												geoMap.marker = new GMarker(point, options);
												geoMap.map.addOverlay(geoMap.marker);
												geoMap.map.setCenter(point, 15);
												geoMap.zoomMap(point);
												//geoMap.map.setMapType(G_HYBRID_MAP);
										  }else{
											  GUnload();
											  $("#geoMap_map").html("<br><br><strong>No map avaliable!</strong>").attr("align","center").css("background","#fff"); 
										  }
									}
								);
						  }else{ 
						     $("#geoMap_map").html("<br><br><strong>No map avaliable!</strong>").attr("align","center").css("background","#fff");
						  }
				}
				
								      //geoMap.initialize('', ''); 
								      //$("#geoMap_map").html("No map avaliable!").attr("align","center");
								
				load_map=function(event){
				    if($('#link_map_container').css('display')=='none')
					{
						$("#link_map_container").show("slide", { direction: "down" }, 500);
						location.href="#map";
						//$('html,body').animate({scrollTop: $('#map').offset().top}, 1000);
					}
					else
					{
						$("#link_map_container").hide("slide", { direction: "up" }, 500);
					}
					if(typeof geoMap.map=="undefined")
					{ 
						geoMap.initialize_address("726 DAISY CROSSING, San Antonio, 78245, Texas, United States - US");
					}
					return false;
				}
				$("#link_map, #link_map_hide").bind("click", {button:'hide'}, load_map);
				$("#link_map_container").hide();
				
				
				load_contact=function(){
					$("#link_contact_container").slideToggle(800);
					return false;
				}
				$("#link_contact, #link_contact_hide").bind("click", load_contact);
				$("#link_contact_container").hide();
				
				/**
				* Favorites
				*/				
			    manageFavorites=function(){ 
					var i="18"; 
					$("#imgFavorites").attr({src:"http://www.realestateactive.com/images/ajax_preloader.gif", title:"saving...", alt:"saving..."});
					$.post("http://www.realestateactive.com/property/",{action:1, pid:i  },function(d){ 
						if(typeof d.s!="undefined"&&d.s==1){
							 $("#imgFavorites").attr({src:"http://www.realestateactive.com/images/star121.gif",title:"Remove From Favorites", alt:"Remove From Favorites"});
							 $("#textFavorites").html("Remove From Favorites");
						}
						else if(typeof d.s!="undefined"&&d.s==9) { 
							 $("#imgFavorites").attr({src:"http://www.realestateactive.com/images/star120.gif",title:"Add to Favorites", alt:"Add to Favorites"}); 
							 $("#textFavorites").html("Add to Favorites");
						}
						else if(typeof d.s!="undefined"&&d.s==2) {
							 alert("Log in or sign up"); 
							 $("#imgFavorites").attr({src:"http://www.realestateactive.com/images/x15.gif",title:"Log in or sign up", alt:"Log in or sign up"});
							 $("#textFavorites").html("Log in or sign up");
						}
						else{
							 $("#imgFavorites").attr({src:"http://www.realestateactive.com/images/x15.gif",title:"Failed, try again!", alt:"Failed, try again!"}); 
							 $("#textFavorites").html("Failed, try again!");
						}
					},"json")
					return false;
				}
				$("#fea_button_favoritesSite").bind("click",manageFavorites); 
				

				function addFav(e,url_,title_){ 
				    url_=(url_==null||$.trim(url_)=="")?document.URL:url_;
				    title_=(title_==null||$.trim(title_)=="")?document.title:title_;
					if (window.sidebar){
						$(e).bind("click",{url:url_,title:title_},function(e){ window.sidebar.addPanel(e.data.title, e.data.url,""); return false; }); }
					else if(window.opera && window.print){
						$(e).bind("click",{url:url_,title:title_},function(e){  
							var mbm = document.createElement('a');
							mbm.setAttribute('rel','sidebar');
							mbm.setAttribute('href',e.data.url);
							mbm.setAttribute('title',e.data.title);
							mbm.click();
							return false;
						})
					}
					else if(document.all){
						$(e).bind("click",{url:url_,title:title_},function(e){  window.external.AddFavorite(e.data.url, e.data.title); return false; }); }
					else{
						$(e).bind("click",function(e){  alert("Press the Control + d to add this site to your favorite browser."); return false; }); }
				}
				addFav("#fea_button_favoritesBrowser");
				
				
				function getCookie(c_name)
				{
					if (document.cookie.length>0)
					  {
						  c_start=document.cookie.indexOf(c_name + "=");
						  if (c_start!=-1)
								{
									c_start=c_start + c_name.length+1;
									c_end=document.cookie.indexOf(";",c_start);
									if (c_end==-1) c_end=document.cookie.length;
									return unescape(document.cookie.substring(c_start,c_end));
							}
					  }
					return "";
				}
				//alert(getCookie('loginPersist'));
				
  });
