AjaxPlugins.CursorLocation = {
    /* HTML element's id definitions */

    handleResponse: function(pluginOutput) {
        /* Plugin general behaviour */
        /* calls all SRS elements to update their content */
        /* generated JS variable is a parsable string with the following syntax:
         * var = '<SRS>|<SRS>|<SRS|...'
         * where <SRS> represent the minimal information for a defined SRS, with fields
         * separated by semi columns:
         * <SRS> = id;x_coord;y_coord
         * id = the SRS identifier (as defined in the properties file)
         * x_coord = reprojected X coord value,
         * y_coor, reprojected Y coord value
         */
        var srsString = pluginOutput.variables.srsString;
        if (srsString.length == 0) {
        	//alert("no SRS info sent back from the server !");
        } else {
        	srsArray = srsString.split('|');
        	for (var i = 0; i < srsArray.length; i++) {
        		var oneSRS = srsArray[i].split(';');
        		var srsID = 'cursorLocationSRS_' + oneSRS[0];
        		document.getElementById(srsID + '_x').innerHTML = oneSRS[1];
        		document.getElementById(srsID + '_y').innerHTML = oneSRS[2];
        	}
        }
    }
};


/*
 * Cursor plugin's Actions
 */
 
AjaxPlugins.CursorLocation.Actions = {};

AjaxPlugins.CursorLocation.Actions.computeCoords = {
	
	/**
	 * returns a query string containing all the POST parameters 
	 * sent to the Cartoclient when this actions is triggered.
	 * For this plugin, no parameter is required as useful information:
	 * the map clicked point is already contained in the request
	 */
    buildPostRequest: function(argObject) {
        return AjaxHandler.buildPostRequest();
    },
    
    onBeforeAjaxCall: function(argObject) {
        //Logger.note('Before ajax for CursorLocation');
    },
     
    onAfterAjaxCall: function(argObject) {
        Logger.note('Clearing cursor location dhtml layers...');
        mainmap.getDisplay('map').clearLayer('CursorLocation');
    }
};
