// -----------------------------------------------------------------
//						Redland Shire Council 
// -----------------------------------------------------------------
// Class    : Acetate 
// Purpose  : Handlers for the client side functionality of Adding 
//				Text.
// -----------------------------------------------------------------
// Calls    :
// Called by: mouse events within default.aspx
// -----------------------------------------------------------------
// Arguments:
// Globals  :
// Returns  :
// -----------------------------------------------------------------
// Notes    : This JavaScript file contains client side code to
//			  handle the position and display of acetate text layers.
// -----------------------------------------------------------------
// History  :
// =================================================================


function ieMouseUpAddText(event)
{
	//Calculate where the map window actually is, and store this in the offset variables
	var imgMapXOffset = parseInt(document.getElementById('divImgMap').style.left) + 2;
	var imgMapYOffset = parseInt(document.getElementById('divImgMap').style.top) + 2;

	//Remember the image coordinates
	var imageX=event.clientX - imgMapXOffset;
	var imageY=document.getElementById('imgMap').height - event.clientY + imgMapYOffset;

	// set the cursor position into the text fields for access by the server
	document.getElementById('txtX1').value=imageX;
	document.getElementById('txtY1').value=imageY;
	
	var iFrameDoc = getIframeDoc();
	
	if (iFrameDoc) {
		// set the text values into the main form so when submitted they can be accessed and displayed on the map
		document.getElementById('txtAcetateText').value=iFrameDoc.getElementById('txtAcetateText').value;
		document.getElementById('txtAcetateFontColour').value=iFrameDoc.getElementById('ddlAcetateFontColour')[iFrameDoc.getElementById('ddlAcetateFontColour').selectedIndex].value;
		document.getElementById('txtAcetateFontSize').value=iFrameDoc.getElementById('ddlAcetateFontSize')[iFrameDoc.getElementById('ddlAcetateFontSize').selectedIndex].value;
		
		// hide the Add Text tools
		hideCommonDiv();
		
		//Show the loading splash picture
		LoadNextImage();
		
		//Submit the page to the server for processing
		document.getElementById('frmMapPage').submit();
	} else {
		// show the error.
		document.getElementById('divError').style.visibility='visible';
		document.getElementById('divErrorText').innerHTML="Text needs to be entered in the 'Text: ' field prior to clicking on the map.<br><br><a href='#' onclick=help('addText.htm');>Click here</a> for help Adding Text to the map.";
	}
}