// JavaScript Document
var play = true;
function getListing() {
	ajaxOpts = {
		type:	"get",
		url:	"Scripts/moreListener.php?random=" + Math.random(99999999999999),
		dataType: "json",
		success: function(data){
			var img_src = data['img']['src'];
			$("#more_img").attr('src',img_src);
			$("#more_img").attr('width',data['img']['width']);
			$("#more_img").attr('height',data['img']['height']);
			var md = $("#more_details");
			md.html('');
			var details = "<ul id=\"more_bb\"><li>"+data['bedrooms']+" bedrooms</li><li>"+data['bathrooms']+" bathrooms</li></ul>\n";
			details += "<div id=\"more_addr\"><span class=\"smaller\">Address:</span><br />"+data['addr1']+"<br />"+data['citystate']+"<br /></div><br />\n";
			details += "<div id=\"more_price\">"+data['price']+"<\/div>\n";
			details += "<a id=\"more_link\" href=\""+data['src']+"\" title=\"view the full mls listing\">View Details</a><br class=\"clearfloat\" />\n";
			md.html(details);
		}
	};
	$.ajax(ajaxOpts);
}
/**
 *
 *	Unnamed function that executes on document ready state
 *
 */
$(document).ready(function(){
	/*
	$("#more_play").hide();
	getListing();
	$("#more_next").click(function() {
		getListing();
		if (play) {
			clearInterval(timer);
			timer = setInterval("getListing()",12000);
		}
	});
	var timer = setInterval("getListing()",12000);
	$("#more_pause").click(function() {
		clearInterval(timer);
		play = false;
		$("#more_pause").hide();
		$("#more_play").show();
		
	});
	$("#more_play").click(function() {
		clearInterval(timer);
		timer = setInterval("getListing()",12000);
		play = true;
		$("#more_play").hide();
		$("#more_pause").show();
		
	});
	$("#more_info").click(function() {
		$("#lstInfo-bg").show();
		$("#lstInfo").show();
		return false;
	});
	$("#li_close").click(function() {
		$("#lstInfo").hide();
		$("#lstInfo-bg").hide();
		return false;
	});
	$("#lstInfo-bg").click(function(){
		$("#lstInfo").hide();
		$("#lstInfo-bg").hide();								
	});
	$().keypress(function(e){
		if (e.keyCode == 27 ){
			$("#lstInfo").hide();
			$("#lstInfo-bg").hide();
		}
	});
	//*/
});
