$(document).ready(function() {
	if(document.getElementById("imgmapImage")) {
		$('#inner_content').css('position', 'relative');
		var contentTop = $('#inner_content').offset().top;
		var imgTop = $('#imgmapImage').offset().top;
		var soldAreas = $('.sold');
		for(var i = 0; i < soldAreas.length; i++) {
			var position = $(soldAreas[i]).attr('coords').split(',');
			var width = position[2] - position[0];
			var height = position[3] - position[1];
			var x = parseInt(position[0]) + ((width - 30) / 2);
			var y = parseInt(position[1]) + (imgTop - contentTop) + ((height - 20) / 2);

			$('#inner_content').append('<img class="soldSign" src="http://homesnwinc.com/core/img/sold.gif" alt="Sold" style="top: ' + y + 'px;left: ' + x + 'px;" />');
		}

		$("area").each(function() {
			if(!$(this).hasClass('sold')) {
				$(this).qtip({
					content : {
						url : 'lotPreview.php',
						data : {
							id : this.id.replace('map-area-', '')
						},
						method : 'get'
					},
					style : {
						width : 440,
						padding : 10,
						border : {
							width : 8,
							color : '#b0b781'
						},
						background : '#ece6ce'
					},
					position : {
						adjust : {
							screen : true
						},
						corner : {
							target : 'topRight',
							tooltip : 'leftMiddle'
						}
					}
				});
			}
		});
	}
});
function displayRackData(id) {
	var rack = this.getRack(id);
	$('#rack_' + id).tooltip();
}

function showMessage(message, id) {
	ol_height = 30
	getWindow(id);
	$('#lot_preview').html(message);
	/*$('#overDiv table').attr('height','50');
	 var top = parseInt($('#overDiv').css('top').replace('px',''))+250;

	 $('#overDiv').css('top',top+'px');
	 alert($('#overDiv').css('top'));*/

}

/*function showPreview(lotNumber, id) {
 ol_height = 300
 getWindow(id);
 getLot(lotNumber, id);
 }*/

function showPreview(lotNumber, id) {
	ol_height = 300
	getWindow(id);
	getLot(lotNumber, id);
}

function getWindow(id) {
	var content = "<div id=\"lot_preview\" style=\"cursor:pointer;\" onclick=\"javascript:parent.document.location='lot.php?id=" + id + "';\">\n";
	content += "<div id=\"HttpClientStatus\"></div>\n";
	content += "</div>\n";
	//return overlib(content, ABOVE, HAUTO);
}

function setLot(id, tooltip) {
	$.ajax({
		url : 'lotPreview.php?id=' + id,
		success : function(result) {
			return result;
		}
	});
}

/*function getLot(lotNumber, id, root) {
 $.ajax({
 url : 'lotPreview.php?id=' + id + '&lotNumber=' + lotNumber,
 success : function(result) {
 $('#overDiv table').attr('height', '300');
 $('#lot_preview').html(result);
 }
 });
 }*/
