
var origPlate;

var detailPanel1 = new YAHOO.widget.Panel("panel1", { width:"410px", 
													  height:"200px",
														  visible:false, 
														  close:true, 
														  fixedcenter:true,
														  modal: true,
														  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:.7} 
														} );
detailPanel1.render(document.body);

var plateCallBack = {
	success: function(transaction) {
		//alert("got a response " +transaction.responseText);
		//document.getElementById("panel1Content").innerHTML = transaction.responseText;
		var plateResults = transaction.responseText;
		var plateHtml = '';
		
		try { 
			var plateJson = YAHOO.lang.JSON.parse(plateResults); 
		} 
		catch (e) {
			plateHtml = 'The plate checker service is currently unavailable';
		}
		//alert(plateJson.Plate);
		var thePlate = plateJson.Plate;
		//alert(plateJson.Reason);
		var theReason = plateJson.Reason;
		//alert(plateJson.InDistrict);
		var inOrOut = plateJson.InDistrict;
		//alert(plateJson.ReasonNum);
		var reasonNum = plateJson.ReasonNum;
		
		var resultImg;
		switch (reasonNum)
		{
			case 0:
				resultImg = "NO.GIF";
				break;
			case 1:
				resultImg = "YES.gif";
				break;
			case 2:
				resultImg = "PROVISON.gif";
				break;
			case 3:
				resultImg = "NO.GIF";
				break;
			case 4:
				resultImg = "question.gif";
				break;
			case 5:
				resultImg = "question.gif";
				break;
			case 6:
				resultImg = "question.gif";
				break;
			case 7:
				resultImg = "NO.GIF";
				break;
			default:
				resultImg = "question.gif";
		}
		
		plateHtml = '<div style="padding: 10px;"><div style="vertical-align: middle; float: left;"><image vspace="10" src="../images/parkingManagement/'+ resultImg +'" alt="Plate Result" /></div>';
		plateHtml += '<div style="position: absolute; left:140px; display: table-row; text-align: center; float: right; height: 100%; width: 246px; background-image:url(../images/parkingManagement/plate.jpg); background-repeat: no-repeat;"><div class="plateNum " style="margin-top: 20%; margin-bottom: 5%; vertical-align: middle; padding: 3px;">'+ origPlate +'</div></div></div>';
		
		document.getElementById("panel1Content").innerHTML = plateHtml;
		
		if (!detailPanel1.visible) {
			detailPanel1.bringToTop();
			detailPanel1.show();
		}
	},
	failure: function(transaction) {
		alert("communication with the service failed");
	}

}

function getThePlate(plate) {
	origPlate = plate;
	makePlateCall(plate);
}

function makePlateCall(plate) {
	var transaction = YAHOO.util.Connect.asyncRequest('GET', '/elbert/plateChecker/ParkingManagement.cfm?plate='+plate, plateCallBack, null);
}

