// JavaScript Document
$(document).ready(function(){
//featured listings
$(".featured_listings li").bind({mouseover: function(){
			var notThis = $(this).index();
			$(".featured_listings li").each(function(){
		var thisI = $(this).index();
		if(thisI != notThis){
		$(this).stop().fadeTo(200,0.5);
		}});
		},mouseleave:function(){
		$(".featured_listings li").stop().fadeTo(200,1);
			}
	});

//home agents
$(".home_realty_agent_info").bind({mouseover: function(){
			var notThis = $(this).index();
			$(".home_realty_agent_info").each(function(){
		var thisI = $(this).index();
		if(thisI != notThis){
		$(this).stop().fadeTo(200,0.5);}
				});
		},mouseleave:function(){
		$(".home_realty_agent_info").stop().fadeTo(200,1)
			}
	});

//properties listings
$(".listing_property").bind({mouseover: function(){
			var notThis = $(this).index();
			$(".listing_property").each(function(){
		var thisI = $(this).index();
		if(thisI != notThis){
		$(this).stop().fadeTo(200,0.5);}
				});
		},mouseleave:function(){
		$(".listing_property").stop().fadeTo(200,1)
			}
	});

//searchbar
$("#home_search").focus(function(){
	if(($(this).attr("value") == "")||($(this).attr("value") == "SEARCH") ){
		$(this).attr("value","");}else{}
	});
$("#home_search").blur(function(){
	if(($(this).attr("value") == "") || ($(this).attr("value") == "SEARCH")){
		$(this).attr("value","SEARCH");
		}else{}
	
	});

$("#city_zip").focus(function(){
	if(($(this).attr("value") == "")||($(this).attr("value") == "Type in City or Zip") ){
		$(this).attr("value","");}else{}
	});
$("#city_zip").blur(function(){
	if(($(this).attr("value") == "") || ($(this).attr("value") == "Type in City or Zip")){
		$(this).attr("value","Type Zip Code");
		}else{}
	
	});

$(".text_input_lg input").focus(function(){
	if(($(this).attr("value") == "")||($(this).attr("value") == "") ){
		$(this).attr("value","");}else{}
	});
$(".text_input_lg input").blur(function(){
	if(($(this).attr("value") == "") || ($(this).attr("value") == "")){
		$(this).attr("value","");
		}else{}
	
	});
	
$(".property_thumbs img").bind("mouseover",function(){
	var src = $(this).attr("alt");
	var srcL = src.replace("thumb_","images/listing_photos/");
	//alert(srcL);
	

$(".property_main_img img").css({"opacity":0}).attr("src",srcL).stop().animate({"opacity":1},600);
		});
 function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
    });
}

// Usage:

preload([
    'template/lazuli/images/spot_light_imgs/1.jpg',
	'template/lazuli/images/spot_light_imgs/2.jpg',
	'template/lazuli/images/spot_light_imgs/3.jpg',
]);
function spotlight_cycle(){
	var curBG = Number($("#spotlight_num").val());
	var maxBG = 3;
	if(curBG < maxBG){
		$("#spotlight").animate({'opacity':'0'},600,function(){
			$("#spotlight").css("background-image", "url(template/lazuli/images/spot_light_imgs/"+(curBG++)+".jpg)").ready(function(){$("#spotlight").animate({'opacity':'1'},600);});
			$("#spotlight_num").val(curBG++);
		});
		
		}else if(curBG == maxBG){
		$("#spotlight").animate({'opacity':'0'},600,function(){
			$("#spotlight").css("background-image", "url(template/lazuli/images/spot_light_imgs/"+maxBG+".jpg)").ready(function(){$("#spotlight").delay(300).animate({'opacity':'1'},600);});
			$("#spotlight_num").val(1);
		});
			}
}
setInterval(function(){spotlight_cycle()}, 8000);
});
