/*
 * Version :$Id: scripts.js 607 2012-01-11 01:40:14Z robertw $
 */

function displayMessage($message){
	$('.loading').show();
	$('.overlay_text').html($message);
}
$(".saving_alert").submit(function() {
	displayMessage('Saving, please wait...');
});

$(".search_alert").submit(function() {
	displayMessage('Searching for your properties, please wait...');
});
	

//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function(){
    $("ul.tabs li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active content
    return false;
});

//Default Action
$(".tab_content2").hide(); //Hide all content
$("ul.tabs2 li:first").addClass("active").show(); //Activate first tab
$(".tab_content2:first").show(); //Show first tab content
//On Click Event
$("ul.tabs2 li").click(function(){
    $("ul.tabs2 li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content2").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active content
    return false;
});

//Default Action
$(".tab_content3").hide(); //Hide all content
$("ul.tabs3 li:first").addClass("active").show(); //Activate first tab
$(".tab_content3:first").show(); //Show first tab content
//On Click Event
$("ul.tabs3 li").click(function(){
    $("ul.tabs3 li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content3").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active content
    return false;
});

// IMAGE GALLERY
$(".img_thumb").hover(function(){
    var imgID = 'img' + $(this).attr('id');
    var imgLINK = 'imglink' + $(this).attr('id');
    var imgHREF = $(this).attr('href');
    var imgMED = imgHREF;
		$("#"+imgID).attr("src",imgMED);
		$("#"+imgLINK).attr("href",imgHREF);
	});
	
	// PRETTY PHOTO
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_rounded',slideshow:2000, autoplay_slideshow: true});
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',theme:'light_rounded',slideshow:10000});		
        
        // placeholder : "/img/loader_lrg.gif",
	$(".property_thumb img").lazyload({
         placeholder : "/img/loading_icon.jpg",
         effect      : "fadeIn"
    });
               
    $.preLoadImages = function(){
		var args_len = arguments.length;
		for (var i = args_len; i--;) {
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			//cache.push(cacheImage); //commented out. this line is throwing a js error
		}
    }
				  
	$.preLoadImages("/img/smoke_poof.gif");
	//$('.scroll-pane').jScrollPane({showArrows: true});
