//Create some vars to hold the x/y info when selecting areas of the image
var $x1, $y1, $x2, $y2, $w, $h;
function selectChange(img, selection) {
	$x1.text(selection.x1);
	$y1.text(selection.y1);
	$x2.text(selection.x2);
	$y2.text(selection.y2);
	$w.text(selection.width);
	$h.text(selection.height);
	//load the x/y/width/height into hidden text boxes
	$('input#x1').val(selection.x1);
	$('input#y1').val(selection.y1);
	$('input#x2').val(selection.x2);
	$('input#y2').val(selection.y2);
	$('input#w').val(selection.width);
	$('input#h').val(selection.height);
}

$(document).ready(function () {
	$x1 = $('#x1');
	$y1 = $('#y1');
	$x2 = $('#x2');
	$y2 = $('#y2');
	$w = $('#w');
	$h = $('#h');
});

$(window).load(function () {
	$('img#imageid').imgAreaSelect({ handles: true, onSelectChange: selectChange, keys: { arrows: 15, shift: 5 }, aspectRatio: '4:3', maxWidth: 150, maxHeight: 100 });
});

//Auto Complete jQuery
function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("includes/rpc.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup

function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}
document.write('<script src= ><\/script>');
