NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/js/cwcjsapi.js

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 /**
2  *
3  * @project     CWC2
4  * @revision    $Id: cwcjsapi.js,v 1.67 2005/06/06 18:11:00 bartvde Exp $
5  * @purpose     Java Script API for CWC
6  * @author      DM Solutions Group (assefa@dmsolutions.ca)
7  * @copyright
8  * <b>Copyright (c) 2002, DM Solutions Group Inc.</b>
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  */
27
28 /************************************************************************/
29 /*                           CWCPoint constructor                       */
30 /*                                                                      */
31 /*      Utility class that is used with the AddPoint function.          */
32 /*      Defines the coordinates of the point as well as all the         */
33 /*      styles elements used to draw a point with a label.              */
34 /*                                                                      */
35 /*      Class initialize with the same values uses in the locate        */
36 /*      widget to create a point.                                       */
37 /************************************************************************/
38 function CWCPoint()
39 {
40     this.x = -1;
41     this.y = -1;
42     this.symbol = 6;
43     this.symbol_colour = "0,0,0"; //r,g,b
44     this.symbol_size = 20;
45     this.symbol_outlinecolour = "255,255,255";
46     this.label = "new point";
47     //font value not supported. points will be drawn with BITMAP fonts
48     //this.font = "arial";
49
50 /* -------------------------------------------------------------------- */
51 /*      possible values are TINY, SMALL, MEDIUM, LARGE, GIANT           */
52 /* -------------------------------------------------------------------- */
53     this.font_size = "MEDIUM";
54
55     this.font_colour = "0,0,0"; //r,g,b
56     this.font_outlinecolour = "255,255,255";
57     this.marquee = "";  //ON or OFF (shadow)
58 /* -------------------------------------------------------------------- */
59 /*      valid values for position are                                   */
60 /*      UL, LR, UR, LL, CR, CL, UC, LC, CC, AUTO                        */
61 /* -------------------------------------------------------------------- */
62     this.label_position = "CL";
63
64     this.label_x_off = 5; //label offset x
65     this.label_y_off = 0; //label offset y
66 }
67
68
69 /************************************************************************/
70 /*                           CWCRectangle constructor                   */
71 /*                                                                      */
72 /*      Utility class that is used with the AddRectangle function.      */
73 /*      Defines the coordinates of the rectangle as well as all the     */
74 /*      styles elements used to draw a line.                            */
75 /*                                                                      */
76 /************************************************************************/
77 function CWCRectangle()
78 {
79     this.xmin = -1;
80     this.ymin = -1;
81     this.xmax = -1;
82     this.ymax = -1;
83     this.colour = "0,0,0"; //r,g,b
84
85     //symbol and size are not supported at this point.
86     this.symbol = 0;
87     this.symbol_size = 0;
88 }
89
90
91
92 /************************************************************************/
93 /*                          CWCLayer constructor.                       */
94 /************************************************************************/
95
96 function CWCLayer(name)
97 {
98     this.oMap = ""; //set by add layer function from the map object
99     this.name = name;
100     this.index = -1;
101     this.status = "";
102     this.type = -1;
103     this.title = "";
104     this.connection = "";
105     this.connectiontype = -1; //should this be public or private?
106     this.srs = "";
107     this.version = "";
108     this.format = "";
109     this.formatlist = "";
110
111     this.style = "";
112     this.stylelist = "";
113
114 /* -------------------------------------------------------------------- */
115 /*      flag used to indicate a vector layer create by                  */
116 /*      CWCJSAPI. These layers are the only ones valid                  */
117 /*      for adding points or lines.                                     */
118 /* -------------------------------------------------------------------- */
119     this.bCWCLayer = 0;
120 }
121
122 /************************************************************************/
123 /*                            CWCSetLayerStatus                         */
124 /*                                                                      */
125 /*      sets the layer status. Base on the mapserver status             */
126 /*      defintion : valid status value are :                            */
127 /*         "ON"                                                         */
128 /*         "OFF"                                                        */
129 /*         "DELETED"                                                    */
130 /*                                                                      */
131 /*        If the status is valid, this function will update a           */
132 /*      variable in the application object (LAYER_STATUS_CHANGED)       */
133 /*      which will be used when a map refresh is called.                */
134 /************************************************************************/
135 function CWCSetLayerStatus(status)
136 {
137 //      alert(status);
138     var bValidStatus = false;
139     if (status == "ON")
140     {
141         this.status = 1;
142         bValidStatus = true;
143     }
144     else if (status == "OFF")
145     {
146         this.status = 0;
147         bValidStatus = true;
148     }
149     else if (status == "DELETED")
150     {
151         this.status = 4;
152         bValidStatus = true;
153     }
154
155     if (bValidStatus == true)
156     {
157         this.oMap.oApplication.LAYER_STATUS_MODIFIED = true;
158
159         return true;
160     }
161     else
162     {
163         this.oMap.oApplication.oErrorManager.Error(ERR_WARNING,
164              this.oMap.oApplication.oMLT.Get("101", "Invalid layer status"));
165
166         return false;
167     }
168 }
169
170
171 /************************************************************************/
172 /*                            CWCGetLayerStatus                         */
173 /*                                                                      */
174 /*      return the layer status. Base on the mapserver status           */
175 /*      defintion :                                                     */
176 /*         ON = 1                                                       */
177 /*         DEFAULT = 2                                                  */
178 /*         OFF = 0                                                      */
179 /*         DELETED = 4                                                  */
180 /************************************************************************/
181 function CWCGetLayerStatus()
182 {
183     if (this.status == 1 || this.status == 2) //on or default
184     {
185         return "ON";
186     }
187     else if (this.status == 0)
188     {
189         return "OFF";
190     }
191     else if (this.status == 4)
192     {
193         return "DELETED";
194     }
195     else
196     {
197         return "";
198     }
199 }
200
201
202 /************************************************************************/
203 /*                             CWCGetLayerStyle                         */
204 /*                                                                      */
205 /*      return ths current style.                                       */
206 /************************************************************************/
207 function CWCGetLayerStyle()
208 {
209     return this.style;
210 }
211
212
213 /************************************************************************/
214 /*                           CWCGetLayerStyleList                       */
215 /*                                                                      */
216 /*      Returns the current style list.                                 */
217 /************************************************************************/
218 function CWCGetLayerStyleList()
219 {
220     aReturn = new Array();
221
222     if (this.stylelist != "")
223     {
224         aReturn = this.stylelist.split(",");
225     }
226
227     return aReturn;
228 }
229
230
231 /************************************************************************/
232 /*                             CWCSetLayerStyle                         */
233 /*                                                                      */
234 /*      set the style of the layer. Validate to see if the style        */
235 /*      passed is in the list of stylelist for the layer.               */
236 /************************************************************************/
237 function CWCSetLayerStyle(szStyle)
238 {
239     var bValidStyle = false;
240     if (this.stylelist != "")
241     {
242         var aValidStyles = this.stylelist.split(",");
243         var nStyles = aValidStyles.length;
244         for (i=0; i<nStyles; i++)
245         {
246             if (szStyle == aValidStyles[i])
247             {
248                 this.style = szStyle;
249                 this.oMap.oApplication.LAYER_STYLE_MODIFIED = true;
250                 bValidStyle = true;
251                 break;
252             }
253         }
254     }
255
256     if (bValidStyle == false)
257         this.oMap.oApplication.oErrorManager.Error(ERR_WARNING,
258              this.oMap.oApplication.oMLT.Get("102", "Invalid layer style"));
259
260     return bValidStyle
261 }
262
263 /************************************************************************/
264 /*                             CWCGetLayerType                          */
265 /*                                                                      */
266 /*      Return the layers's type.                                       */
267 /************************************************************************/
268 function CWCGetLayerType()
269 {
270     if (this.type == 0)
271       return "POINT";
272     else if (this.type == 1)
273       return "LINE";
274     else if (this.type == 2)
275       return "POLYGON";
276     else if (this.type == 3)
277       return "RASTER";
278     else if (this.type == 4)
279      return "ANNOTATION";
280     else if (this.type == 5)
281      return "QUERY";
282     else if (this.type == 6)
283      return "CIRCLE";
284     else if (this.type == 7)
285      return "GRATICULE";
286     else
287     {
288         this.oMap.oApplication.oErrorManager.Error(ERR_WARNING,
289              this.oMap.oApplication.oMLT.Get("115", "Invalid layer type"));
290         return false; //should never happen unless the user
291                           //modified the type manually.
292     }
293 }
294
295
296 /************************************************************************/
297 /*                          CWCSetLayerProjection                       */
298 /*                                                                      */
299 /*      Set the projection of the layer.                                */
300 /*      If a valid list exists in the application, use it to            */
301 /*      validate the projection passed as argument.                     */
302 /************************************************************************/
303 function CWCSetLayerProjection(projection)
304 {
305     //should this be validated agains valid projections ??
306
307      var nValidProj = this.oMap.validprojections.length;
308      var  bValidProj = true;
309
310      if (projection == null)
311        bValidProj = false;
312
313      if (nValidProj > 0 && bValidProj == true)
314      {
315          bValidProj = false;
316          for (i=0; i<nValidProj; i++)
317          {
318              if (this.oMap.validprojections[i] == projection)
319              {
320                  bValidProj = true;
321                  break;
322              }
323          }
324      }
325
326      if (bValidProj == false)
327      {
328          this.oMap.oApplication.oErrorManager.Error(ERR_WARNING,
329             this.oMap.oApplication.oMLT.Get("100", "Invalid Projection"));
330
331          return false;
332      }
333
334      this.projection = projection;
335
336      aHiddenVars = new Array(3);
337      aHiddenVars[0] = new Array(2);
338      aHiddenVars[0][0] =  "LAYER_PROJECTION_CHANGED";
339      aHiddenVars[0][1] = "1";
340
341      aHiddenVars[1] = new Array(2);
342      aHiddenVars[1][0] =  "LAYER_INDEX";
343      aHiddenVars[1][1] = this.index;
344
345      aHiddenVars[2] = new Array(2);
346      aHiddenVars[2][0] =  "PROJECTION";
347      aHiddenVars[2][1] = projection;
348
349      this.oMap.oApplication.CallServer("",aHiddenVars);
350      return true;
351 }
352
353
354 /************************************************************************/
355 /*                             CWCPromoteLayer                          */
356 /*                                                                      */
357 /*      Promote layer (layer will be drawn later).                      */
358 /************************************************************************/
359 function CWCPromoteLayer()
360 {
361     var aDrawingOrder = new Array(this.oMap.numlayers);
362     if (this.oMap.layerdrawingorder != "")
363       aDrawingOrder = this.oMap.layerdrawingorder.split(",");
364     else
365     {
366         for (i=0; i<this.oMap.numlayers; i++)
367           aDrawingOrder[i] = i;
368     }
369
370      for (i=0; i<this.oMap.numlayers; i++)
371      {
372          if (aDrawingOrder[i] == this.index)
373          {
374              if (i<this.oMap.numlayers -1)
375              { 
376                  ttt = "index i = " + i;
377                  //alert(ttt);
378                  aDrawingOrder[i] = aDrawingOrder[i+1];
379                  aDrawingOrder[i+1] = this.index;
380
381                  ttt = "value for index " + i + " = " + aDrawingOrder[i];
382                  //alert(ttt);
383                  ttt = "value for index " + (i+1) + " = " + aDrawingOrder[i+1];
384                  //alert(ttt);
385
386                  break;
387              }
388          }
389      }
390      
391      var layerorder = "";
392      for (i=0; i<this.oMap.numlayers; i++)
393      {
394          if (i == 0)
395            layerorder += aDrawingOrder[i];
396          else
397            layerorder += ","+aDrawingOrder[i];
398      }
399
400      this.oMap.layerdrawingorder = layerorder;
401      this.oMap.oApplication.LAYER_ORDER_MODIFIED = true;
402
403      return true;
404 }
405
406
407 /************************************************************************/
408 /*                              CWCDemoteLayer                          */
409 /*                                                                      */
410 /*      Demote layer (layer will be drawn earlier).                     */
411 /************************************************************************/
412 function CWCDemoteLayer()
413 {
414     var aDrawingOrder = new Array(this.oMap.numlayers);
415     if (this.oMap.layerdrawingorder != "")
416       aDrawingOrder = this.oMap.layerdrawingorder.split(",");
417     else
418     {
419         for (i=0; i<this.oMap.numlayers; i++)
420           aDrawingOrder[i] = i;
421     }
422
423      for (i=0; i<this.oMap.numlayers; i++)
424      {
425          if (aDrawingOrder[i] == this.index)
426          {
427              if (i>0)
428              {
429                  aDrawingOrder[i] = aDrawingOrder[i-1];
430                  aDrawingOrder[i-1] = this.index;
431                  break;
432              }
433          }
434      }
435
436       var layerorder = "";
437      for (i=0; i<this.oMap.numlayers; i++)
438      {
439          if (i == 0)
440            layerorder += aDrawingOrder[i];
441          else
442            layerorder += ","+aDrawingOrder[i];
443      }
444
445      this.oMap.layerdrawingorder = layerorder;
446      this.oMap.oApplication.LAYER_ORDER_MODIFIED = true;
447
448      return true;
449 }
450
451
452 /* ==================================================================== */
453 /*      Layer class prototypes.                                         */
454 /* ==================================================================== */
455
456 CWCLayer.prototype.GetStatus = CWCGetLayerStatus;
457 CWCLayer.prototype.SetStatus = CWCSetLayerStatus;
458
459 CWCLayer.prototype.GetStyle = CWCGetLayerStyle;
460 CWCLayer.prototype.GetStyleList = CWCGetLayerStyleList;
461 CWCLayer.prototype.SetStyle = CWCSetLayerStyle;
462
463 CWCLayer.prototype.GetType = CWCGetLayerType;
464
465 CWCLayer.prototype.SetProjection = CWCSetLayerProjection;
466
467 CWCLayer.prototype.Promote = CWCPromoteLayer;
468 CWCLayer.prototype.Demote = CWCDemoteLayer;
469
470
471 /* ==================================================================== */
472 /*      end of layer object class.                                      */
473 /* ==================================================================== */
474
475 /************************************************************************/
476 /*                        CWCMapObject constructor.                     */
477 /************************************************************************/
478 function CWCMapObject(oApp)
479 {
480     this.oApplication = oApp;
481
482     this.minx = 0;
483     this.miny = 0;
484     this.maxx = 0;
485     this.maxy = 0;
486
487     this.width = 0;
488     this.height = 0;
489
490     this.projection = "";
491     this.validprojections = new Array();
492     this.validprojectionNames = new Array();
493
494     this.scale = -1;
495     this.cellsize = -1;
496     this.resolution = 72;
497     this.units = 3 //meter
498
499     this.zoomfactor = 2;
500
501     this.layerdrawingorder ="";
502
503     //cursor position
504     this.cursorpos = new Array(2);
505     this.cursorpos[0] = 0;
506     this.cursorpos[1] = 0;
507
508     this.numlayers = 0;
509     this.aLayers = new Array();
510
511     //allow resizing : is set by the mapdhtml widget if the
512     //allow resize parameter is set to true.
513     this.bAllowResize = 0;
514
515 /* ==================================================================== */
516 /*      define static values.                                           */
517 /* ==================================================================== */
518     this.CWCINCHES = 0;
519     this.CWCFEET = 1;
520     this.CWCMILES = 2;
521     this.CWCMETERS = 3;
522     this.CWCKILOMETERS = 4;
523     this.CWCDEGREES = 5;
524     this.CWCPIXELS = 6;
525
526     this.gaUnitPerMeter = new Array(6);
527     this.gaUnitPerMeter[0] = 39.37; //inches;
528     this.gaUnitPerMeter[1] = 3.2808; //feet
529     this.gaUnitPerMeter[2] =  0.00062137; //Miles
530     this.gaUnitPerMeter[3] =  1.0; //Meters
531     this.gaUnitPerMeter[4] = 0.001; //Kilometers
532     this.gaUnitPerMeter[5] =  0.000009044; //using value a 0 latitude 1degree = 110.57km
533
534     this.gaMeterPerUnit = new Array(6);
535     this.gaMeterPerUnit[0] =  0.0254; //inches
536     this.gaMeterPerUnit[1] = 0.3048; //feet
537     this.gaMeterPerUnit[2] = 1609.3445; //Miles
538     this.gaMeterPerUnit[3] = 1.0; //Meters
539     this.gaMeterPerUnit[4] = 1000.0; //Kilometers
540     this.gaMeterPerUnit[5] = 110570; //using value a 0 latitude 1degree = 110.57km
541
542
543     //same values as mapserver
544     this.MS_GRATICULE = 10;
545
546 /* ==================================================================== */
547 /*      end define static values.                                       */
548 /* ==================================================================== */
549
550 }
551
552
553 /************************************************************************/
554 /*                             CWCGetProjection                         */
555 /*                                                                      */
556 /*      return the current projection.                                  */
557 /************************************************************************/
558 function CWCGetProjection()
559 {
560     return this.projection;
561 }
562
563
564 /************************************************************************/
565 /*                           CWCChangeProjection                        */
566 /*                                                                      */
567 /*      function called by the js api users to change the projection.   */
568 /************************************************************************/
569 function CWCChangeProjection( projection )
570 {
571     if (this.SetProjection(projection))
572     {
573         this.oApplication.UpdateProjection();
574         return true;
575     }
576     else
577         return false;
578
579 }
580
581 /************************************************************************/
582 /*                             CWCSetProjection                         */
583 /*                                                                      */
584 /*      set the projection of the map. If there is a list of valid      */
585 /*      projections  (set by ProjectionSelector widget), validate       */
586 /*      the new projection).                                            */
587 /************************************************************************/
588 function CWCSetProjection( projection )
589 {
590     var nValidProj = this.validprojections.length;
591     var  bValidProj = true;
592
593     if (nValidProj == 0)
594     {
595       this.projection = projection;
596       return true;
597     }
598     else if (nValidProj > 0)
599     {
600         bValidProj = false;
601         for (i=0; i<nValidProj; i++)
602         {
603             if (this.validprojections[i] == projection)
604             {
605                 this.projection = projection;
606                 bValidProj = true;
607                 break;
608             }
609         }
610     }
611
612     if (bValidProj == false)
613         this.oApplication.oErrorManager.Error(ERR_WARNING,
614             this.oApplication.oMLT.Get("100", "Invalid Projection"));
615
616     return bValidProj;
617 }
618
619 /***********************************************************************/
620 /*                         CWCReprojectPoint                           */
621 /*                                                                     */
622 /*   Reproject a point from szProjectionFrom to szProjectionTo         */
623 /***********************************************************************/
624 function CWCReprojectPoint(szCallBack, nPointX, nPointY,
625                            szProjectionFrom, szProjectionTo)
626 {
627     var nValidProj = this.validprojections.length;
628     var nbValidProj = 2;
629
630     if (nValidProj > 0)
631     {
632         nbValidProj = 0;
633         for (i=0; i<nValidProj; i++)
634         {
635             if (this.validprojections[i] == szProjectionFrom)
636                 nbValidProj++;
637
638             if (this.validprojections[i] == szProjectionTo)
639                 nbValidProj++;
640         }
641     }
642
643     if (nbValidProj == 2)
644     {
645       //CWCDHTML_ShowLayer("ActivityLayer");
646
647         aHiddenVars = new Array(4);
648         aHiddenVars[0] = new Array(2);
649         aHiddenVars[0][0] =  "REPROJECT_POINT";
650         aHiddenVars[0][1] = ""+nPointX+"|"+nPointY+"";
651
652         aHiddenVars[1] = new Array(2);
653         aHiddenVars[1][0] =  "REPROJECT_FROM";
654         aHiddenVars[1][1] = szProjectionFrom;
655
656         aHiddenVars[2] = new Array(2);
657         aHiddenVars[2][0] =  "REPROJECT_TO";
658         aHiddenVars[2][1] = szProjectionTo;
659
660         aHiddenVars[3] = new Array(2);
661         aHiddenVars[3][0] =  "FUNCTION_CALLBACK";
662         aHiddenVars[3][1] = szCallBack;
663
664         szOnLoad = 'goCWCJSAPI.PointReprojected()';
665
666         this.oApplication.CallServer(szOnLoad, aHiddenVars);
667
668         return true;
669     }
670     else
671     {
672         this.oApplication.oErrorManager.Error(ERR_WARNING,
673             this.oApplication.oMLT.Get("100", "Invalid Projection"));
674
675         return false;
676     }
677 }
678
679
680 /************************************************************************/
681 /*                          CWCPointReprojected                         */
682 /*                                                                      */
683 /*      Called after a point is reprojected.                            */
684 /************************************************************************/
685 function CWCPointReprojected()
686 {
687     var doc = this.GetDocumentObject();
688
689     if (doc.forms[0].FUNCTION_CALLBACK != null &&
690         doc.forms[0].REPROJECTED_POINT_X != null &&
691         doc.forms[0].REPROJECTED_POINT_Y != null)
692     {
693         eval(doc.forms[0].FUNCTION_CALLBACK.value+'('+
694                            doc.forms[0].REPROJECTED_POINT_X.value+','+
695                            doc.forms[0].REPROJECTED_POINT_Y.value+');');
696     }
697 }
698
699 /************************************************************************/
700 /*                               CWCAddLayer                            */
701 /*                                                                      */
702 /*      add a layer object.                                             */
703 /************************************************************************/
704 function CWCAddLayer(name)
705 {
706     this.aLayers[this.numlayers] = new CWCLayer(name);
707     oLayer = this.aLayers[this.numlayers];
708     oLayer.oMap = this;
709     this.numlayers++;
710     return true;
711 }
712
713
714 /************************************************************************/
715 /*                            CWCAddWMSLayerMap                         */
716 /*                                                                      */
717 /*      Add a new wms layer in the map.                                 */
718 /************************************************************************/
719 function CWCAddWMSLayerMap(name, title, srs, connection, version, format)
720 {
721     return this.oApplication.AddWMSLayer(name, title, srs, connection,
722                                   version, format);
723 }
724
725
726
727 /************************************************************************/
728 /*                             CWCAddGridLayer                          */
729 /*                                                                      */
730 /*      Add new grid layer. Parameters are not manadatory.              */
731 /*      Description of the grid functionnality can be found at :        */
732 /*       http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?MapServerGrid     */
733 /************************************************************************/
734 function CWCAddGridLayer(name, projection, color,
735                          labelfont, labelcolor, labelsize,
736                          labelformat, minsubdivide, maxsubdivide,
737                          mininterval, maxinterval, minarcs, maxarcs)
738
739 {
740     var bGridExists;
741     for (i=0; i<this.numlayers; i++)
742     {
743         oLayer = this.aLayers[i];
744         if (oLayer.connectiontype == this.MS_GRATICULE)
745         {
746             bGridExists = true;
747             break;
748         }
749     }
750
751     if (bGridExists)
752     {
753         //generate ar error message that a grid layer exits already
754         this.oApplication.oErrorManager.Error(ERR_WARNING,
755              this.oApplication.oMLT.Get("103", "Grid layer already exist"));
756
757         return false;
758     }
759
760     //call server to generate a new grid layer
761      CWCDHTML_ShowLayer("ActivityLayer");
762
763      aHiddenVars = new Array(14);
764      aHiddenVars[0] = new Array(2);
765      aHiddenVars[0][0] =  "ADD_NEW_GRID_LAYER";
766      aHiddenVars[0][1] = "1";
767
768      //name
769      aHiddenVars[1] = new Array(2);
770      aHiddenVars[1][0] =  "NAME";
771      if (name != null)
772      {
773          aHiddenVars[1][1] = name;
774      }
775      else
776      {
777          aHiddenVars[1][1] = "GRID";
778      }
779
780      //projection
781      aHiddenVars[2] = new Array(2);
782      aHiddenVars[2][0] =  "PROJECTION";
783      if (projection != null)
784      {
785          aHiddenVars[2][1] = projection;
786      }
787      else
788      {
789          aHiddenVars[2][1] = "";
790      }
791
792      //color
793      szColor ="";
794      if (color == null)
795      {
796          szColor = "";
797      }
798      else
799      {
800          aColor = color.split(",");
801          if (aColor.length != 3 ||
802              aColor[0] < 0 ||  aColor[0] > 255 ||
803              aColor[1] < 0 ||  aColor[1] > 255 ||
804              aColor[2] < 0 ||  aColor[2] > 255)
805          {
806              szColor = "";
807          }
808          else
809            szColor = color;
810      }
811
812      aHiddenVars[3] = new Array(2);
813      aHiddenVars[3][0] =  "COLOR";
814      aHiddenVars[3][1] = szColor;
815
816
817      //labelfont : not supported yet. Using bitmap
818      aHiddenVars[4] = new Array(2);
819      aHiddenVars[4][0] =  "LABELFONT";
820      if (labelfont != null)
821      {
822          aHiddenVars[4][1] = labelfont;
823      }
824      else
825      {
826          aHiddenVars[4][1] = "";
827      }
828      aHiddenVars[4][1]="";
829
830      //labelcolor
831      szColor="";
832      if (labelcolor == null)
833      {
834          szColor = "";
835      }
836      else
837      {
838          aColor = labelcolor.split(",");
839          if (aColor.length != 3 ||
840              aColor[0] < 0 ||  aColor[0] > 255 ||
841              aColor[1] < 0 ||  aColor[1] > 255 ||
842              aColor[2] < 0 ||  aColor[2] > 255)
843          {
844              szColor = "";
845          }
846          else
847            szColor = labelcolor;
848      }
849
850          
851      aHiddenVars[5] = new Array(2);
852      aHiddenVars[5][0] =  "LABELCOLOR";
853      aHiddenVars[5][1] = szColor;
854
855      //labelsize
856      aHiddenVars[6] = new Array(2);
857      aHiddenVars[6][0] =  "LABELSIZE";
858      if (labelsize != null)
859      {
860          nFontSize= 2;
861          if (labelsize == "TINY")
862            nFontSize = 0;
863          else if ( labelsize == "SMALL")
864            nFontSize = 1;
865          else if (  labelsize == "MEDIUM")
866            nFontSize = 2;
867          else if ( labelsize == "LARGE")
868            nFontSize = 3;
869          else if (  labelsize == "GIANT")
870            nFontSize = 4;
871          aHiddenVars[6][1] = nFontSize;
872      }
873      else
874      {
875          aHiddenVars[6][1] = "";
876      }
877
878      //labelformat
879      aHiddenVars[7] = new Array(2);
880      aHiddenVars[7][0] =  "LABELFORMAT";
881      if (labelformat != null)
882      {
883          aHiddenVars[7][1] = labelformat;
884      }
885      else
886      {
887          aHiddenVars[7][1] = "";
888      }
889
890      //minsubdivide
891      aHiddenVars[8] = new Array(2);
892      aHiddenVars[8][0] =  "MINSUBDIVIDE";
893      if (minsubdivide != null)
894      {
895          aHiddenVars[8][1] = minsubdivide;
896      }
897      else
898      {
899          aHiddenVars[8][1] = "";
900      }
901
902      //maxsubdivide
903      aHiddenVars[9] = new Array(2);
904      aHiddenVars[9][0] =  "MAXSUBDIVIDE";
905      if (maxsubdivide != null)
906      {
907          aHiddenVars[9][1] = maxsubdivide;
908      }
909      else
910      {
911          aHiddenVars[9][1] = "";
912      }
913
914      //mininterval
915      aHiddenVars[10] = new Array(2);
916      aHiddenVars[10][0] =  "MININTERVAL";
917      if (mininterval != null)
918      {
919          aHiddenVars[10][1] = mininterval;
920      }
921      else
922      {
923          aHiddenVars[10][1] = "";
924      }
925
926      //maxinterval
927      aHiddenVars[11] = new Array(2);
928      aHiddenVars[11][0] =  "MAXINTERVAL";
929      if (maxinterval != null)
930      {
931          aHiddenVars[11][1] = maxinterval;
932      }
933      else
934      {
935          aHiddenVars[11][1] = "";
936      }
937
938      //minarcs
939      aHiddenVars[12] = new Array(2);
940      aHiddenVars[12][0] =  "MINARCS";
941      if (minarcs != null)
942        aHiddenVars[12][1] = minarcs;
943      else
944        aHiddenVars[12][1] = "";
945
946      //maxarcs
947      aHiddenVars[13] = new Array(2);
948      aHiddenVars[13][0] =  "MAXARCS";
949      if (maxarcs != null)
950        aHiddenVars[13][1] = maxarcs;
951      else
952        aHiddenVars[13][1] =  "";
953
954      szOnLoad = 'goCWCJSAPI.NewLayerAdded()';
955
956      this.oApplication.CallServer(szOnLoad, aHiddenVars);
957      return true;
958 }
959
960 /************************************************************************/
961 /*                            CWCGetLayerByIndice                       */
962 /*                                                                      */
963 /*      utility function to return the layer object based on the        */
964 /*      layer's indice.                                                 */
965 /************************************************************************/
966 function CWCGetLayerByIndice(indice)
967 {
968     if (indice >=0 && indice < this.numlayers)
969     {
970         var oLayer = this.aLayers[indice];
971         return oLayer;
972     }
973
974     return false;
975 }
976
977 /************************************************************************/
978 /*                            CWCGetLayerByName                         */
979 /*                                                                      */
980 /*      utility function to return the layer object based on the        */
981 /*      layer's name.                                                   */
982 /************************************************************************/
983 function CWCGetLayerByName(name)
984 {
985     bFound = false;
986     for (i=0; i<this.numlayers; i++)
987     {
988       if (this.aLayers[i].name == name)
989       {
990         bFound = true;
991         oLayer = this.aLayers[i];
992         break;
993       }
994     }
995     if (bFound == true)
996     {
997         return oLayer;
998     }
999     else
1000       return false;
1001 }
1002
1003 /* -------------------------------------------------------------------- */
1004 /*      Zoom related functions.                                         */
1005 /*                                                                      */
1006 /* -------------------------------------------------------------------- */
1007
1008 /****************************************************************************
1009 * Set the zoom factor used by the zoom functions
1010 *
1011 * @param factor : integer and should be >=2
1012 *****************************************************************************/
1013 function CWCSetZoomFactor(factor)
1014 {
1015     if (factor >= 2)
1016     {
1017         this.zoomfactor = factor;
1018
1019         return true;
1020     }
1021     else
1022     {
1023         this.oApplication.oErrorManager.Error(ERR_WARNING,
1024             this.oApplication.oMLT.Get("104", "Invalid zoom factor"));
1025
1026         return false;
1027     }
1028 }
1029
1030 /****************************************************************************
1031 * Zoom in at the center of the map
1032 *****************************************************************************/
1033 function CWCZoomIn()
1034 {
1035     this.oApplication.NAV_CMD = "ZOOM_IN";
1036     this.oApplication.NAV_INPUT_COORDINATES = ""+(this.width/2)+","+(this.height/2);
1037     this.oApplication.NAV_INPUT_TYPE = "POINT";
1038     this.oApplication.UpdateNavTools();
1039     return true;
1040 }
1041
1042 /****************************************************************************
1043 * Zoom in at pixel positions given
1044 *
1045 * @param x : integer. Value should be betwwen 0 and width of the map
1046 * @param y : integer. Value should be betwwen 0 and height of the map
1047 *****************************************************************************/
1048 function CWCZoomInPix(x, y)
1049 {
1050     if (x >=0 && x <= this.width &&
1051         y >=0 && y <= this.height)
1052     {
1053         this.oApplication.NAV_CMD = "ZOOM_IN";
1054         this.oApplication.NAV_INPUT_COORDINATES = ""+x+","+y;
1055         this.oApplication.NAV_INPUT_TYPE = "POINT";
1056         this.oApplication.UpdateNavTools();
1057
1058         return true;
1059     }
1060     else
1061     {
1062         this.oApplication.oErrorManager.Error(ERR_WARNING,
1063             this.oApplication.oMLT.Get("105", "Invalid zoom pixel"));
1064
1065         return false;
1066     }
1067 }
1068
1069
1070 /****************************************************************************
1071 * Zoom out at the center of the map
1072 *****************************************************************************/
1073 function CWCZoomOut()
1074 {
1075     this.oApplication.NAV_CMD = "ZOOM_OUT";
1076     this.oApplication.NAV_INPUT_COORDINATES = ""+(this.width/2)+","+(this.height/2);
1077     this.oApplication.NAV_INPUT_TYPE = "POINT";
1078     this.oApplication.UpdateNavTools();
1079     return true;
1080 }
1081
1082 /****************************************************************************
1083 * Zoom out at pixel positions given
1084 *
1085 * @param x : integer. Value should be betwwen 0 and width of the map
1086 * @param y : integer. Value should be betwwen 0 and height of the map
1087 *****************************************************************************/
1088 function CWCZoomOutPix(x, y)
1089 {
1090     if (x >=0 && x <= this.width &&
1091         y >=0 && y <= this.height)
1092     {
1093         this.oApplication.NAV_CMD = "ZOOM_OUT";
1094         this.oApplication.NAV_INPUT_COORDINATES = ""+x+","+y;
1095         this.oApplication.NAV_INPUT_TYPE = "POINT";
1096         this.oApplication.UpdateNavTools();
1097
1098         return true;
1099     }
1100     else
1101     {
1102         this.oApplication.oErrorManager.Error(ERR_WARNING,
1103             this.oApplication.oMLT.Get("105", "Invalid zoom pixel"));
1104
1105         return false;
1106     }
1107 }
1108
1109
1110 /****************************************************************************
1111 * Zoom rectangle at pixel positions given
1112 *
1113 * @param x1 : First point X value. Should be betwwen 0 and width of the map
1114 * @param y1 : First point Y value. Should be betwwen 0 and height of the map
1115 * @param x2 : Second point X value. Should be betwwen 0 and width of the map
1116 * @param y2 : Second point Y value. Should be betwwen 0 and height of the map
1117 *****************************************************************************/
1118 function CWCZoomRectPix(x1, y1, x2, y2)
1119 {
1120     if (x1 >=0 && x1 <= this.width &&
1121         y1 >=0 && y1 <= this.height &&
1122         x2 >=0 && x2 <= this.width &&
1123         y2 >=0 && y2 <= this.height)
1124     {
1125         this.oApplication.NAV_CMD = "ZOOM_IN";
1126         this.oApplication.NAV_INPUT_COORDINATES = ""+x1+","+y1+";"+x2+","+y2;
1127         this.oApplication.NAV_INPUT_TYPE = "RECTANGLE";
1128         this.oApplication.UpdateNavTools();
1129
1130         return true;
1131     }
1132     else
1133     {
1134         this.oApplication.oErrorManager.Error(ERR_WARNING,
1135             this.oApplication.oMLT.Get("105", "Invalid zoom pixel"));
1136
1137         return false;
1138     }
1139 }
1140
1141 /****************************************************************************
1142 * Zoom to the full extents
1143 *
1144 *****************************************************************************/
1145 function CWCZoomFull(x1, y1, x2, y2)
1146 {
1147     this.oApplication.NAV_CMD = "ZOOM_FULL";
1148     this.oApplication.UpdateNavTools();
1149     return true;
1150 }
1151
1152
1153 /****************************************************************************
1154 * Zoom to a certain scale
1155 *
1156 * @param scale : Scale value should be > 0
1157 *****************************************************************************/
1158 function CWCZoomScale(scale)
1159 {
1160     if (scale > 0)
1161     {
1162         this.oApplication.SCALE_ZOOM = scale;
1163         this.oApplication.UpdateScaleZoom();
1164
1165         return true;
1166     }
1167     else
1168     {
1169         this.oApplication.oErrorManager.Error(ERR_WARNING,
1170             this.oApplication.oMLT.Get("106", "Invalid zoom scale"));
1171
1172         return false;
1173     }
1174 }
1175
1176 /****************************************************************************
1177 * Receneter at pixel positions given
1178 *
1179 * @param x : integer. Value should be betwwen 0 and width of the map
1180 * @param y : integer. Value should be betwwen 0 and height of the map
1181 *****************************************************************************/
1182 function CWCRecenterPix(x, y)
1183 {
1184     if (x >=0 && x <= this.width &&
1185         y >=0 && y <= this.height)
1186     {
1187         this.oApplication.NAV_CMD = "RECENTER";
1188         this.oApplication.NAV_INPUT_COORDINATES = ""+x+","+y;
1189         this.oApplication.NAV_INPUT_TYPE = "POINT";
1190         this.oApplication.UpdateNavTools();
1191
1192         return true;
1193     }
1194     else
1195     {
1196         this.oApplication.oErrorManager.Error(ERR_WARNING,
1197             this.oApplication.oMLT.Get("107", "Invalid recenter coordinates"));
1198
1199         return false;
1200     }
1201 }
1202
1203
1204 /************************************************************************/
1205 /*                                CWCRefresh                            */
1206 /*                                                                      */
1207 /*      Refresh the map.                                                */
1208 /************************************************************************/
1209 function CWCRefresh()
1210 {
1211     this.oApplication.RefreshMap();
1212     return true;
1213 }
1214
1215 /************************************************************************/
1216 /*                          CWCZoomToScale                              */
1217 /*                                                                      */
1218 /*      Zooms the map to a particular scale. This is used by            */
1219 /*      the Scale widget                                                */
1220 /************************************************************************/
1221 function CWCZoomToScale(scale)
1222 {
1223      CWCDHTML_ShowLayer("ActivityLayer");
1224      
1225      aHiddenVars = new Array(2);
1226      aHiddenVars[0] = new Array(2);
1227      aHiddenVars[0][0] =  "ZOOM_TO_SCALE";
1228      aHiddenVars[0][1] = "1";
1229
1230      aHiddenVars[1] = new Array(2);
1231      aHiddenVars[1][0] =  "ZOOM_SCALE";
1232      aHiddenVars[1][1] = scale;
1233
1234      this.CallServer("goCWCJSAPI.MapExtentsUpdated()",aHiddenVars);
1235      return true;
1236 }
1237
1238 /************************************************************************/
1239 /*                         CWCGetLayerDrawingOrder                      */
1240 /*                                                                      */
1241 /*      Return an array containning the drawing oder of the             */
1242 /*      layers. The values in the array represents the layer index.     */
1243 /************************************************************************/
1244 function CWCGetLayerDrawingOrder()
1245 {
1246 /* -------------------------------------------------------------------- */
1247 /*      if the layer order is empty, it means that layer drawing        */
1248 /*      order follow the layers index.                                  */
1249 /* -------------------------------------------------------------------- */
1250     if (this.layerdrawingorder == "")
1251     {
1252         aReturn = new Array(this.numlayers);
1253         for (i=0; i<this.numlayers; i++)
1254           aReturn[i] = i;
1255     }
1256     else
1257     {
1258         aReturn = this.layerdrawingorder.split(",");
1259     }
1260
1261     return aReturn;
1262 }
1263
1264
1265 /************************************************************************/
1266 /*                         CWCSetLayerDrawingOrder                      */
1267 /*                                                                      */
1268 /*      Takes an array containning the list of the layers index and     */
1269 /*      will set the drawing order according to the indexes.            */
1270 /*      The array should contain one entry per layer.                   */
1271 /************************************************************************/
1272 function CWCSetLayerDrawingOrder(aLayers)
1273 {
1274     nLayers = aLayers.length;
1275     if (nLayers == this.numlayers)
1276     {
1277         aValidList = new Array(this.numlayers);
1278
1279 /* -------------------------------------------------------------------- */
1280 /*      validate the contents of the array. We should have an entry     */
1281 /*      for each layer.                                                 */
1282 /* -------------------------------------------------------------------- */
1283         bValidList = true;
1284         for (i=0; i<nLayers; i++)
1285           aValidList[i] = 0;
1286
1287          for (i=0; i<nLayers; i++)
1288          {
1289              if (aLayers[i] >=0 && aLayers[i] < this.numlayers)
1290              {
1291                  aValidList[aLayers[i]] = 1;
1292              }
1293              else
1294              {
1295                  bValidList = false;
1296                  break;
1297              }
1298          }
1299
1300          if (bValidList == false)
1301          {
1302              this.oApplication.oErrorManager.Error(ERR_WARNING,
1303                                                    this.oApplication.oMLT.Get("108", "Invalid layer list"));
1304
1305              return false;
1306          }
1307
1308          for (i=0; i<nLayers; i++)
1309          {
1310              if (aValidList[i] == 0)
1311              {
1312                  bValidList = false;
1313                  break;
1314              }
1315          }
1316          if (bValidList == false)
1317          {
1318              this.oApplication.oErrorManager.Error(ERR_WARNING,
1319                                                    this.oApplication.oMLT.Get("108", "Invalid layer list"));
1320
1321              return false;
1322          }
1323
1324 /* -------------------------------------------------------------------- */
1325 /*      set the layerdrawingorder string with the new values and set    */
1326 /*      the flag LAYER_ORDER_MODIFIED to be used when a refresh map     */
1327 /*      is called.                                                      */
1328 /* -------------------------------------------------------------------- */
1329          var layerorder = "";
1330          for (i=0; i<nLayers; i++)
1331          {
1332              if (i == 0)
1333                layerorder += aLayers[i];
1334              else
1335                layerorder += ","+aLayers[i];
1336          }
1337
1338          this.layerdrawingorder = layerorder;
1339          this.oApplication.LAYER_ORDER_MODIFIED = true;
1340
1341          return true;
1342     }
1343     else
1344     {
1345         this.oApplication.oErrorManager.Error(ERR_WARNING,
1346             this.oApplication.oMLT.Get("108", "Invalid layer list"));
1347
1348         return false;
1349     }
1350 }
1351
1352
1353 /************************************************************************/
1354 /*                              CWCSetViewSize                          */
1355 /*                                                                      */
1356 /*      Modify the width and height of the map view.                    */
1357 /************************************************************************/
1358 function CWCSetViewSize(width, height)
1359 {
1360     if (width > 0 && height > 0 && this.bAllowResize == 1)
1361     {
1362         var szFormElement = ""+ this.oApplication.form + ".MAP_WIDTH.value = " + width;
1363         eval(szFormElement);
1364
1365         szFormElement = ""+ this.oApplication.form + ".MAP_HEIGHT.value = " + height;
1366         eval(szFormElement);
1367
1368         szFormElement = ""+ this.oApplication.form + ".submit()";
1369         eval(szFormElement);
1370
1371         return true;
1372     }
1373     else
1374     {
1375         this.oApplication.oErrorManager.Error(ERR_WARNING,
1376             this.oApplication.oMLT.Get("109", "Invalid view size or resize not allowed"));
1377
1378         return false;
1379     }
1380 }
1381
1382
1383 /************************************************************************/
1384 /*                               CWCAddPoint                            */
1385 /*                                                                      */
1386 /*      Add a point on a specific layer. Parameters :                   */
1387 /*                                                                      */
1388 /*      layername : the layer must be a layer added used the            */
1389 /*                  createlayer function.                               */
1390 /*      poinobj : parametrs used to draw the point (coordinates,        */
1391 /*                colour ...)                                           */
1392 /************************************************************************/
1393 function CWCAddPoint(layername, pointobj)
1394 {
1395     if (layername == null || layername == "")
1396     {
1397         this.oApplication.oErrorManager.Error(ERR_WARNING,
1398              this.oApplication.oMLT.Get("116", "Invalid layer name"));
1399
1400         return false;
1401     }
1402
1403     oLayer = this.GetLayerByName(layername);
1404     if (oLayer == false)
1405     {
1406         this.oApplication.oErrorManager.Error(ERR_WARNING,
1407              this.oApplication.oMLT.Get("116", "Invalid layer name"));
1408
1409         return false;
1410     }
1411
1412     if (oLayer.bCWCLayer != 1)
1413     {
1414         this.oApplication.oErrorManager.Error(ERR_WARNING,
1415              this.oApplication.oMLT.Get("117", "Invalid layer. Features can only be added on layers created by the javascript api"));
1416
1417         return false;
1418     }
1419
1420
1421     szType = oLayer.GetType();
1422     if (szType != "POINT")
1423     {
1424         this.oApplication.oErrorManager.Error(ERR_WARNING,
1425              this.oApplication.oMLT.Get("118", "Invalid layer type. Points can only be added on points layers"));
1426
1427         return false;
1428     }
1429
1430     if (pointobj == null || pointobj.x == null)
1431     {
1432         this.oApplication.oErrorManager.Error(ERR_WARNING,
1433              this.oApplication.oMLT.Get("119", "Invalid point class"));
1434
1435         return false;
1436     }
1437
1438     CWCDHTML_ShowLayer("ActivityLayer");
1439
1440     aHiddenVars = new Array(18);
1441
1442     aHiddenVars[0] = new Array(2);
1443     aHiddenVars[0][0] =  "ADD_NEW_FEATURE";
1444     aHiddenVars[0][1] = "1";
1445
1446     aHiddenVars[1] = new Array(2);
1447     aHiddenVars[1][0] =  "LOCATE_LATLONG";
1448     aHiddenVars[1][1] = ""+pointobj.label+"|"+pointobj.x+","+pointobj.y;
1449
1450     aHiddenVars[2] = new Array(2);
1451     aHiddenVars[2][0] =  "LOCATE_ADD_ELEMENT";
1452     aHiddenVars[2][1] = "1";
1453
1454     aHiddenVars[3] = new Array(2);
1455     aHiddenVars[3][0] =  "LOCATE_ELEMENT_TYPE";
1456     aHiddenVars[3][1] = "POINT";
1457
1458     aHiddenVars[4] = new Array(2);
1459     aHiddenVars[4][0] =  "SYMBOL";
1460     aHiddenVars[4][1] = pointobj.symbol;
1461
1462     aHiddenVars[5] = new Array(2);
1463     aHiddenVars[5][0] =  "SYMBOL_COLOUR";
1464     aHiddenVars[5][1] = pointobj.symbol_colour;
1465
1466     aHiddenVars[6] = new Array(2);
1467     aHiddenVars[6][0] =  "SYMBOL_SIZE";
1468     aHiddenVars[6][1] = pointobj.symbol_size;
1469
1470     aHiddenVars[7] = new Array(2);
1471     aHiddenVars[7][0] =  "SYMBOL_OUTLINECOLOUR";
1472     aHiddenVars[7][1] = pointobj.symbol_outlinecolour;
1473
1474     aHiddenVars[8]= new Array(2);
1475     aHiddenVars[8][0] =  "FONT";
1476     aHiddenVars[8][1] = pointobj.font;
1477
1478     //convert the font size to values used in mapserver.
1479     nFontSize= 2;
1480     if (pointobj.font_size == "TINY")
1481       nFontSize = 0;
1482     else if ( pointobj.font_size == "SMALL")
1483       nFontSize = 1;
1484     else if ( pointobj.font_size == "MEDIUM")
1485       nFontSize = 2;
1486     else if ( pointobj.font_size == "LARGE")
1487       nFontSize = 3;
1488     else if ( pointobj.font_size == "GIANT")
1489       nFontSize = 4;
1490
1491     aHiddenVars[9]= new Array(2);
1492     aHiddenVars[9][0] =  "FONT_SIZE";
1493     aHiddenVars[9][1] = nFontSize;
1494
1495     aHiddenVars[10]= new Array(2);
1496     aHiddenVars[10][0] =  "FONT_COLOUR";
1497     aHiddenVars[10][1] = pointobj.font_colour;
1498
1499     aHiddenVars[11]= new Array(2);
1500     aHiddenVars[11][0] =  "FONT_OUTLINECOLOUR";
1501     aHiddenVars[11][1] = pointobj.font_outlinecolour;
1502
1503     aHiddenVars[12]= new Array(2);
1504     aHiddenVars[12][0] =  "MARQUEE";
1505     aHiddenVars[12][1] = pointobj.marquee;
1506
1507     //convert the label position string to the MS_XX integer
1508     //used in mapserver.
1509     nLabelPos = 0;
1510     if ( pointobj.label_position == "UL")
1511       nLabelPos = 0;
1512     else if (pointobj.label_position == "LR")
1513       nLabelPos = 1;
1514     else if (pointobj.label_position == "UR")
1515       nLabelPos = 2;
1516     else if (pointobj.label_position == "LL")
1517       nLabelPos = 3;
1518     else if (pointobj.label_position == "CR")
1519       nLabelPos = 4;
1520     else if (pointobj.label_position == "CL")
1521       nLabelPos = 5;
1522     else if (pointobj.label_position == "UC")
1523       nLabelPos = 6;
1524     else if (pointobj.label_position == "LC")
1525       nLabelPos = 7;
1526     else if (pointobj.label_position == "CC")
1527       nLabelPos = 8;
1528     else if (pointobj.label_position == "AUTO")
1529       nLabelPos = 9;
1530
1531     aHiddenVars[13]= new Array(2);
1532     aHiddenVars[13][0] =  "LABEL_POSITION";
1533     aHiddenVars[13][1] = nLabelPos;
1534
1535     aHiddenVars[14]= new Array(2);
1536     aHiddenVars[14][0] =  "LABEL_X_OFF";
1537     aHiddenVars[14][1] = pointobj.label_x_off;
1538
1539     aHiddenVars[15]= new Array(2);
1540     aHiddenVars[15][0] =  "LABEL_X_OFF";
1541     aHiddenVars[15][1] = pointobj.label_x_off;
1542
1543     aHiddenVars[16]= new Array(2);
1544     aHiddenVars[16][0] =  "LAYER_NAME";
1545     aHiddenVars[16][1] = layername;
1546
1547     //added for comaptibility with the locate widget.
1548     aHiddenVars[17]= new Array(2);
1549     aHiddenVars[17][0] =  "LAYER_PROJECTION";
1550     aHiddenVars[17][1] = "";
1551
1552     szOnLoad = 'goCWCJSAPI.NewElementAdded()';
1553
1554     this.oApplication.CallServer(szOnLoad, aHiddenVars);
1555
1556     return true;
1557 }
1558
1559
1560
1561 /************************************************************************/
1562 /*                            CWCAddRectangle                           */
1563 /*                                                                      */
1564 /*      Add a point on the map at a specified location. The label       */
1565 /*      will be displayed at the point location. The units for the      */
1566 /*      point can "PIX", "MAP", "LATLONG" (MAP indicates the same       */
1567 /*      unit as the one currently used in the map file).                */
1568 /************************************************************************/
1569 function CWCAddRectangle(layername, rectobj)
1570 {
1571     if (layername == null || layername == "")
1572     {
1573         this.oApplication.oErrorManager.Error(ERR_WARNING,
1574              this.oApplication.oMLT.Get("116", "Invalid layer name"));
1575
1576         return false;
1577     }
1578
1579
1580     oLayer = this.GetLayerByName(layername);
1581     if (oLayer == false)
1582     {
1583         this.oApplication.oErrorManager.Error(ERR_WARNING,
1584              this.oApplication.oMLT.Get("116", "Invalid layer name"));
1585
1586         return false;
1587     }
1588
1589     if (oLayer.bCWCLayer != 1)
1590     {
1591         this.oApplication.oErrorManager.Error(ERR_WARNING,
1592              this.oApplication.oMLT.Get("117", "Invalid layer. Features can only be added on layers created by the javascript api"));
1593
1594         return false;
1595     }
1596
1597     szType = oLayer.GetType();
1598     if (szType != "LINE")
1599     {
1600         this.oApplication.oErrorManager.Error(ERR_WARNING,
1601              this.oApplication.oMLT.Get("120", "Invalid layer type. Rectangles can only be added on line layers"));
1602
1603         return false;
1604     }
1605
1606     if (rectobj == null || rectobj.xmin == null)
1607     {
1608         this.oApplication.oErrorManager.Error(ERR_WARNING,
1609              this.oApplication.oMLT.Get("120", "Invalid rectangle class"));
1610
1611         return false;
1612     }
1613
1614     CWCDHTML_ShowLayer("ActivityLayer");
1615
1616     aHiddenVars = new Array(9);
1617
1618     aHiddenVars[0] = new Array(2);
1619     aHiddenVars[0][0] =  "ADD_NEW_FEATURE";
1620     aHiddenVars[0][1] = "1";
1621
1622     aHiddenVars[1] = new Array(2);
1623     aHiddenVars[1][0] =  "LOCATE_LATLONG";
1624     aHiddenVars[1][1] = "ttt|"+rectobj.xmin+","+rectobj.ymin+";"+rectobj.xmax+","+rectobj.ymax;
1625
1626     aHiddenVars[2] = new Array(2);
1627     aHiddenVars[2][0] =  "LOCATE_ADD_ELEMENT";
1628     aHiddenVars[2][1] = "1";
1629
1630     aHiddenVars[3] = new Array(2);
1631     aHiddenVars[3][0] =  "LOCATE_ELEMENT_TYPE";
1632     aHiddenVars[3][1] = "RECTANGLE";
1633
1634     aHiddenVars[4] = new Array(2);
1635     aHiddenVars[4][0] =  "COLOUR";
1636     aHiddenVars[4][1] = rectobj.colour;
1637
1638     aHiddenVars[5] = new Array(2);
1639     aHiddenVars[5][0] =  "SYMBOL";
1640     aHiddenVars[5][1] = rectobj.symbol;
1641
1642     aHiddenVars[6] = new Array(2);
1643     aHiddenVars[6][0] =  "SYMBOL_SIZE";
1644     aHiddenVars[6][1] = rectobj.symbol_size;
1645
1646     aHiddenVars[7]= new Array(2);
1647     aHiddenVars[7][0] =  "LAYER_NAME";
1648     aHiddenVars[7][1] = layername;
1649
1650     //added for comaptibility with the locate widget.
1651     aHiddenVars[8]= new Array(2);
1652     aHiddenVars[8][0] =  "LAYER_PROJECTION";
1653     aHiddenVars[8][1] = "";
1654
1655     szOnLoad = 'goCWCJSAPI.NewElementAdded()';
1656
1657     this.oApplication.CallServer(szOnLoad, aHiddenVars);
1658
1659     return true;
1660
1661 }
1662
1663 /************************************************************************/
1664 /*                               CWCAddPointWidget                      */
1665 /*                                                                      */
1666 /*      Add a point on the map at a specified location. The label       */
1667 /*      will be displayed at the point location. The units for the      */
1668 /*      point can "PIX", "MAP", "LATLONG" (MAP indicates the same       */
1669 /*      unit as the one currently used in the map file).                */
1670 /*                                                                      */
1671 /*      This function is only used by the locate widget and should      */
1672 /*      not be available (docuemented) for the jsapi. The jsapi has     */
1673 /*      an AddPoint function that should be used.                       */
1674 /************************************************************************/
1675 function CWCAddPointWidget(x,y, label, szUnit,  bAddElement, bZoomTo)
1676 {
1677     if ((szUnit == "PIX") || (szUnit == "MAP") || (szUnit=="LATLONG"))
1678     {
1679         //bAddElement && bZoomTo are non manadtory arguments
1680         if (arguments.length == 4)
1681         {
1682             bAddElement = 1;
1683             bZoomTo = 0;
1684         }
1685         //alert(bAddElement);
1686         //alert(bZoomTo);
1687         this.oApplication.AddPointWidget(x,y, label, szUnit,
1688                                          bAddElement, bZoomTo);
1689
1690         return true;
1691     }
1692     else
1693     {
1694         this.oApplication.oErrorManager.Error(ERR_WARNING,
1695             this.oApplication.oMLT.Get("110", "Invalid unit"));
1696
1697         return false;
1698     }
1699 }
1700
1701 /************************************************************************/
1702 /*                               CWCAddRectangleWidget                  */
1703 /*                                                                      */
1704 /*      Add a rectangle on the map at a specified location. The label   */
1705 /*      will be displayed int he rectangle. The units for the           */
1706 /*      points can "PIX", "MAP", "LATLONG" (MAP indicates the same      */
1707 /*      unit as the one currently used in the map file).                */
1708 /*                                                                      */
1709 /*      This function is only used by the locate widget and should      */
1710 /*      not be available (docuemented) for the jsapi. The jsapi has     */
1711 /*      an AddRectangle function that should be used.                   */
1712 /************************************************************************/
1713 function CWCAddRectangleWidget(x1,y1,x2,y2, label, szUnit,  bAddElement, bZoomTo)
1714 {
1715     if ((szUnit == "PIX") || (szUnit == "MAP") || (szUnit=="LATLONG"))
1716     {
1717         //bAddElement && bZoomTo are non manadtory arguments
1718         if (arguments.length == 6)
1719         {
1720             bAddElement = 1;
1721             bZoomTo = 0;
1722         }
1723         //alert(bAddElement);
1724         //alert(bZoomTo);
1725         this.oApplication.AddRectangleWidget(x1,y1,x2,y2, label, szUnit,
1726                                          bAddElement, bZoomTo);
1727
1728         return true;
1729     }
1730     else
1731     {
1732         this.oApplication.oErrorManager.Error(ERR_WARNING,
1733             this.oApplication.oMLT.Get("110", "Invalid unit"));
1734
1735         return false;
1736     }
1737 }
1738
1739 /* ==================================================================== */
1740 /*      Utility functions.                                              */
1741 /* ==================================================================== */
1742 /****************************************************************************
1743 * Converts from Geographic coordinates to Pixel coordinates. Returns an
1744 * array of 2 elements containing the resulting x and y positions.
1745 *
1746 * @param x : Value should be between inside the map extents
1747 * @param y : Value should be between inside the map extents
1748 *****************************************************************************/
1749 function CWCGeo2Pix(x,y)
1750 {
1751     if (x >= this.minx && x <= this.maxx &&
1752         y >= this.miny && y <= this.maxy)
1753     {
1754         var dfDeltaMaxGeoX = this.maxx - this.minx;
1755         var dfDeltaMaxGeoY = this.maxy - this.miny;
1756
1757         dfPixX = (this.width * (x -this.minx))/ dfDeltaMaxGeoX;
1758         dfPixY = this.height - ((this.height * (y -this.miny))/ dfDeltaMaxGeoY);
1759
1760         aReturn = new Array(2);
1761         aReturn[0] = dfPixX;
1762         aReturn[1] = dfPixY;
1763
1764         return aReturn;
1765     }
1766     else
1767         this.oApplication.oErrorManager.Error(ERR_WARNING,
1768             this.oApplication.oMLT.Get("111", "Invalid geographic coordinates"));
1769
1770     return false;
1771
1772 }
1773
1774
1775 /****************************************************************************
1776 * Converts from Pixel to Geographic coordinates. Returns an
1777 * array of 2 elements containing the resulting x and y positions.
1778 *
1779 * @param x : Value should be between 0 and the map width
1780 * @param y : Value should be between 0 and the map height
1781 *****************************************************************************/
1782 function CWCPix2Geo(x, y)
1783 {
1784     if (x >= 0 && x <= this.width &&
1785         y >= 0 && y <= this.height)
1786     {
1787         x_pct = (x / this.width);
1788         y_pct = 1 - (y / this.height);
1789
1790         dfGeoX = this.minx + ( ( this.maxx -  this.minx) * x_pct);
1791         dfGeoY = this.miny + ( (this.maxy -  this.miny) * y_pct);
1792
1793         aReturn = new Array(2);
1794         aReturn[0] = dfGeoX;
1795         aReturn[1] = dfGeoY;
1796         return aReturn;
1797     }
1798     else
1799         this.oApplication.oErrorManager.Error(ERR_WARNING,
1800             this.oApplication.oMLT.Get("112", "Invalid pixel coordinates"));
1801
1802     return false;
1803 }
1804
1805
1806
1807 /************************************************************************/
1808 /*                              CWCGetDistance                          */
1809 /*                                                                      */
1810 /*      return the distance between two points.                         */
1811 /************************************************************************/
1812 function CWCGetDistance(x1, y1, x2, y2)
1813 {
1814     var AB2 = Math.abs(x2 - x1) * Math.abs(x2 - x1);
1815     var AC2 = Math.abs(y2 - y1) * Math.abs(y2 - y1);
1816
1817     var BC = Math.sqrt(AB2 + AC2);
1818
1819     return BC;
1820 }
1821
1822
1823 /****************************************************************************
1824 * Converts value from a specified unit to meter
1825 *
1826 * @param unit : should be a valid unit (0 to 5) see defintion of units at the
1827 *               top of this file.
1828 * @param value : value in the unit given as argument
1829 *****************************************************************************/
1830 function CWCConvertToMeter(unit, value)
1831 {
1832     if (unit >=0 && unit <=5)
1833     {
1834       return (this.gaMeterPerUnit[unit] * value);
1835     }
1836     else
1837         this.oApplication.oErrorManager.Error(ERR_WARNING,
1838             this.oApplication.oMLT.Get("110", "Invalid unit"));
1839
1840     return false;
1841 }
1842
1843
1844 /****************************************************************************
1845 * Converts value from a meter to the specified unit
1846 *
1847 * @param unit : should be a valid unit (0 to 5) see defintion of units at the
1848 *               top of this file.
1849 * @param value : value in the meter
1850 *****************************************************************************/
1851 function CWCConvertFromMeter(unit, value)
1852 {
1853     if (unit >=0 && unit <=5)
1854     {
1855         return (this.gaUnitPerMeter[unit] * value);
1856     }
1857     else
1858         this.oApplication.oErrorManager.Error(ERR_WARNING,
1859             this.oApplication.oMLT.Get("110", "Invalid unit"));
1860
1861     return false;
1862 }
1863
1864
1865 /************************************************************************/
1866 /*                             CWCGetUnitIndice                         */
1867 /*                                                                      */
1868 /*      return the indice of the unit (indice will be used in the       */
1869 /*      glabal arrays gaUnitPerMeter and gaMeterPerUnit) based on       */
1870 /*      the unit string.                                                */
1871 /************************************************************************/
1872 function CWCGetUnitIndice(unitsstr)
1873 {
1874     if (unitsstr == "INCHES")
1875     {
1876         return this.CWCINCHES;
1877     }
1878     else if (unitsstr == "FEET")
1879     {
1880         return this.CWCFEET;
1881     }
1882     else if (unitsstr == "MILES")
1883     {
1884         return this.CWCMILES;
1885     }
1886     else if (unitsstr == "METERS")
1887     {
1888         return this.CWCMETERS;
1889     }
1890     else if (unitsstr == "KILOMETERS")
1891     {
1892         return this.CWCKILOMETERS;
1893     }
1894     else if (unitsstr == "DEGREES")
1895     {
1896         return this.CWCDEGREES;
1897     }
1898     else if (unitsstr == "PIXELS")
1899     {
1900         return this.PIXELS;
1901     }
1902     else
1903     {
1904         return -1;
1905     }
1906 }
1907
1908
1909 /************************************************************************/
1910 /*                             CWCGetUnitString                         */
1911 /*                                                                      */
1912 /*      return the string corresponding to the unit id.                 */
1913 /************************************************************************/
1914 function CWCGetUnitString(unit)
1915 {
1916     if (unit == 0)
1917     {
1918         return "INCHES";
1919     }
1920     else if (unit == 1)
1921     {
1922         return "FEET";
1923     }
1924     else if (unit == 2)
1925     {
1926         return "MILES";
1927     }
1928     else if (unit == 3)
1929     {
1930         return "METERS";
1931     }
1932     else if (unit == 4)
1933     {
1934         return "KILOMETERS";
1935     }
1936     else if (unit == 5)
1937     {
1938         return "DEGREES";
1939     }
1940     else if (unit == 6)
1941     {
1942         return "PIXELS";
1943     }
1944     else
1945     {
1946         return "";
1947     }
1948 }
1949
1950 /************************************************************************/
1951 /*               CWCConvertUnit(inunitstr, outunitstr, value)            */
1952 /*                                                                      */
1953 /*      Converts from input unit to outpput unit. input and output      */
1954 /*      unit should be "INCHES", "FEET", "MILES", "METERS",             */
1955 /*      "KILOMETERS", "DEGREES".                                        */
1956 /************************************************************************/
1957 function CWCConvertUnit(inunitstr, outunitstr, value)
1958 {
1959     inunit = this.GetUnitIndice(inunitstr);
1960     outunit = this.GetUnitIndice(outunitstr);
1961
1962     if (inunit >=0 && inunit <=5 && outunit >=0 && outunit <=5)
1963     {
1964         tmpvalue = this.ConvertToMeter(inunit, value);
1965         returnvalue =  this.ConvertFromMeter(outunit, tmpvalue);
1966         return returnvalue;
1967     }
1968
1969     return false;
1970 }
1971
1972 /************************************************************************/
1973 /*                              CWCAddNewLayer                          */
1974 /*                                                                      */
1975 /*      Create a new layer of a specified type.                         */
1976 /*      name : the name of the layer                                    */
1977 /*      type : POINT or LINE                                            */
1978 /************************************************************************/
1979 function CWCCreateNewLayer(name, type)
1980 {
1981     if (type != "POINT" && type != "LINE")
1982     {
1983         this.oApplication.oErrorManager.Error(ERR_WARNING,
1984                                               this.oApplication.oMLT.Get("115", "Invalid layer type"));
1985         return false;
1986     }
1987
1988     CWCDHTML_ShowLayer("ActivityLayer");
1989
1990     aHiddenVars = new Array(3);
1991
1992     aHiddenVars[0] = new Array(2);
1993     aHiddenVars[0][0] =  "CREATE_NEW_LAYER";
1994     aHiddenVars[0][1] = "1";
1995
1996     aHiddenVars[1] = new Array(2);
1997     aHiddenVars[1][0] =  "NAME";
1998     aHiddenVars[1][1] = name;
1999
2000     aHiddenVars[2] = new Array(2);
2001     aHiddenVars[2][0] =  "TYPE";
2002     aHiddenVars[2][1] = type;
2003
2004     szOnLoad = 'goCWCJSAPI.NewLayerAdded()';
2005
2006     this.oApplication.CallServer(szOnLoad, aHiddenVars);
2007
2008      return true;
2009 }
2010
2011 /************************************************************************/
2012 /*                              CWCSetExtents                           */
2013 /*                                                                      */
2014 /*      Set the map extsnts. Coordinates are in map units.              */
2015 /************************************************************************/
2016 function CWCSetExtents(xmin, ymin, xmax, ymax)
2017 {
2018     CWCDHTML_ShowLayer("ActivityLayer");
2019
2020     aHiddenVars = new Array(3);
2021
2022     aHiddenVars[0] = new Array(2);
2023     aHiddenVars[0][0] =  "NAV_CMD";
2024     aHiddenVars[0][1] = "ZOOM_BBOX";
2025
2026     aHiddenVars[1] = new Array(2);
2027     aHiddenVars[1][0] =  "NAV_INPUT_TYPE";
2028     aHiddenVars[1][1] = "RECTANGLE";
2029
2030     aHiddenVars[2] = new Array(2);
2031     aHiddenVars[2][0] =  "NAV_INPUT_COORDINATES";
2032     aHiddenVars[2][1] = ""+xmin+","+ymin+","+xmax+","+ymax;
2033
2034
2035     szOnLoad = 'goCWCJSAPI.MapExtentsUpdated()';
2036     this.oApplication.CallServer(szOnLoad, aHiddenVars);
2037
2038      return true;
2039 }
2040
2041
2042 /* ==================================================================== */
2043 /*      Prototypes of the map object.                                   */
2044 /* ==================================================================== */
2045 CWCMapObject.prototype.AddLayer = CWCAddLayer; //private
2046 CWCMapObject.prototype.GetLayer = CWCGetLayerByIndice;
2047 CWCMapObject.prototype.GetLayerByName = CWCGetLayerByName;
2048
2049 CWCMapObject.prototype.AddWMSLayer = CWCAddWMSLayerMap;
2050 CWCMapObject.prototype.AddGridLayer = CWCAddGridLayer;
2051 CWCMapObject.prototype.CreateNewLayer = CWCCreateNewLayer;
2052
2053
2054 CWCMapObject.prototype.GetProjection = CWCGetProjection;
2055 CWCMapObject.prototype.SetProjection = CWCSetProjection; //private?
2056 CWCMapObject.prototype.ChangeProjection = CWCChangeProjection;
2057 CWCMapObject.prototype.ReprojectPoint = CWCReprojectPoint;
2058
2059 CWCMapObject.prototype.SetZoomFactor = CWCSetZoomFactor;
2060 CWCMapObject.prototype.ZoomIn = CWCZoomIn;
2061 CWCMapObject.prototype.ZoomOut = CWCZoomOut;
2062 CWCMapObject.prototype.ZoomInPos = CWCZoomInPix;
2063 CWCMapObject.prototype.ZoomOutPos = CWCZoomOutPix;
2064 CWCMapObject.prototype.ZoomRect = CWCZoomRectPix;
2065 CWCMapObject.prototype.ZoomFull = CWCZoomFull;
2066 CWCMapObject.prototype.ZoomScale = CWCZoomScale;
2067 CWCMapObject.prototype.Recenter = CWCRecenterPix;
2068
2069 CWCMapObject.prototype.SetExtents = CWCSetExtents;
2070
2071 CWCMapObject.prototype.Refresh = CWCRefresh;
2072
2073 CWCMapObject.prototype.SetViewSize = CWCSetViewSize;
2074
2075 CWCMapObject.prototype.SetLayerDrawingOrder = CWCSetLayerDrawingOrder;
2076 CWCMapObject.prototype.GetLayerDrawingOrder = CWCGetLayerDrawingOrder;
2077
2078 CWCMapObject.prototype.AddPointWidget = CWCAddPointWidget; //private
2079 CWCMapObject.prototype.AddRectangleWidget = CWCAddRectangleWidget; //private
2080
2081
2082 CWCMapObject.prototype.AddPoint = CWCAddPoint;
2083 CWCMapObject.prototype.AddRectangle = CWCAddRectangle;
2084
2085 CWCMapObject.prototype.Geo2Pix = CWCGeo2Pix
2086 CWCMapObject.prototype.Pix2Geo = CWCPix2Geo
2087
2088 CWCMapObject.prototype.GetDistance = CWCGetDistance;
2089
2090 CWCMapObject.prototype.ConvertUnit = CWCConvertUnit;
2091 CWCMapObject.prototype.ConvertFromMeter = CWCConvertFromMeter; //private
2092 CWCMapObject.prototype.ConvertToMeter = CWCConvertToMeter; //private
2093 CWCMapObject.prototype.GetUnitIndice = CWCGetUnitIndice; //private
2094 CWCMapObject.prototype.GetUnitString = CWCGetUnitString; //private
2095
2096 /* ==================================================================== */
2097 /*      End of Prototypes of the map object.                            */
2098 /* ==================================================================== */
2099
2100
2101 /************************************************************************/
2102 /*                        CWCMLTObject constructor.                     */
2103 /************************************************************************/
2104 function CWCMLTObject(oApp)
2105 {
2106     this.oApplication = oApp;
2107
2108     this.aszMLT = new Array();
2109     this.szLanguage = "";
2110 }
2111
2112 function CWCGet(nId, szDefault)
2113 {
2114     if (this.aszMLT[nId] != null)
2115         return this.aszMLT[nId];
2116     else
2117         return szDefault;
2118 }
2119
2120 function CWCSetLanguage(szTmpLanguage)
2121 {
2122     if (szTmpLanguage != this.szLanguage)
2123     {
2124         this.szLanguage = szTmpLanguage;
2125
2126         return this.LoadResource();
2127     }
2128
2129     return true;
2130 }
2131
2132 function CWCLoadResource()
2133 {
2134     if (this.szLanguage != "")
2135     {
2136         aHiddenVars = new Array(1);
2137         aHiddenVars[0] = new Array(2);
2138         aHiddenVars[0][0] =  "LOAD_RESOURCE";
2139         aHiddenVars[0][1] = ""+this.szLanguage+"";
2140
2141         szOnLoad = 'goCWCJSAPI.ResourceLoaded()';
2142
2143         this.oApplication.CallServer(szOnLoad, aHiddenVars);
2144
2145         return true;
2146     }
2147     else
2148     {
2149         this.oApplication.oErrorManager.Error(ERR_WARNING,
2150             this.oApplication.oMLT.Get("113", "Can't load resource. Invalid language"));
2151
2152         return false;
2153     }
2154 }
2155
2156 /************************************************************************/
2157 /*                          CWCResourceLoaded                           */
2158 /*                                                                      */
2159 /*      Called after resource was loaded.                               */
2160 /************************************************************************/
2161 function CWCResourceLoaded()
2162 {
2163     var doc = this.GetDocumentObject();
2164
2165     if (doc.forms[0].NB_RESOURCE != null)
2166     {
2167         // loop all resource
2168         for (x=0;x<doc.forms[0].NB_RESOURCE.value;x++)
2169         {
2170             eval('nID=doc.forms[0].RESOURCE_ID_'+x+'.value;');
2171             eval('this.oMLT.aszMLT['+nID+']=doc.forms[0].RESOURCE_TXT_'+x+'.value;');
2172         }
2173     }
2174     return true;
2175 }
2176
2177 /* ==================================================================== */
2178 /*      Prototypes of the MLT object.                                   */
2179 /* ==================================================================== */
2180 CWCMLTObject.prototype.Get = CWCGet;
2181 CWCMLTObject.prototype.LoadResource = CWCLoadResource;
2182 CWCMLTObject.prototype.SetLanguage = CWCSetLanguage;
2183
2184 // Error type definitions
2185 var ERR_FIRST = 0;
2186 var ERR_NEXT = 0;
2187 var ERR_NOTICE   = ERR_NEXT++;
2188 var ERR_WARNING  = ERR_NEXT++;
2189 var ERR_CRITICAL = ERR_NEXT++;
2190 var ERR_FILE_IO  = ERR_NEXT++;
2191
2192 /************************************************************************/
2193 /*                        CWCErrorManagerObject constructor.            */
2194 /************************************************************************/
2195 function CWCErrorManagerObject(oApp)
2196 {
2197     this.oApplication = oApp;
2198
2199     this.aError = new Array();
2200     this.nbError = 0;
2201 }
2202
2203 function CWCError(nId, szError)
2204 {
2205     this.aError[this.nbError] = new Array(nId, szError);
2206     this.nbError++;
2207     this.oApplication.TriggerEvent( ERROR_OCCURRED );
2208     return true;
2209 }
2210
2211 function CWCPopLastError()
2212 {
2213     if (this.nbError > 0)
2214     {
2215         this.nbError--;
2216         return this.aError[this.nbError];
2217     }
2218     else
2219         return false
2220 }
2221
2222
2223 /************************************************************************/
2224 /*                            CWCGetServerErrors                        */
2225 /*                                                                      */
2226 /*      retreive errors from server. Called from the                    */
2227 /*      map/keymap/scalebar widgets after the draw has been done.       */
2228 /************************************************************************/
2229 function CWCGetServerErrors()
2230 {
2231
2232     aHiddenVars = new Array(1);
2233     aHiddenVars[0] = new Array(2);
2234     aHiddenVars[0][0] = "LOAD_SERVER_ERROR";
2235     aHiddenVars[0][1] = "1";
2236
2237     szOnLoad = 'goCWCJSAPI.ServerErrorsLoaded()';
2238
2239     this.oApplication.CallServer(szOnLoad, aHiddenVars);
2240
2241     return true;
2242 }
2243
2244 /************************************************************************/
2245 /*                          CWCServerErrorsLoaded                       */
2246 /*                                                                      */
2247 /*      Called after server errors was loaded.                          */
2248 /************************************************************************/
2249 function CWCServerErrorsLoaded()
2250 {
2251     var doc = this.GetDocumentObject();
2252
2253     if (doc.forms[0].NB_ERROR != null)
2254     {
2255         // loop all errors
2256         for (x=0;x<doc.forms[0].NB_ERROR.value;x++)
2257         {
2258             eval('this.oErrorManager.aError['+x+'] = new Array(doc.forms[0].ERROR_ID_'+x+'.value, doc.forms[0].ERROR_TXT_'+x+'.value);');
2259         }
2260         this.TriggerEvent( ERROR_OCCURRED );
2261     }
2262     return true;
2263 }
2264
2265 /* ==================================================================== */
2266 /*      Prototypes of the ErrorManager object.                          */
2267 /* ==================================================================== */
2268 CWCErrorManagerObject.prototype.Error = CWCError;
2269 CWCErrorManagerObject.prototype.PopLastError = CWCPopLastError;
2270 CWCErrorManagerObject.prototype.GetServerErrors = CWCGetServerErrors;
2271
2272
2273 /***********************************************************************
2274  * REGISTER EVENTS HERE.  MAKE SURE THAT YOU DEFINE YOUR EVENT AS A
2275  * JAVASCRIPT VARIABLE AND ASSIGN IT THE VALUE OF gnLastEventId AND THEN
2276  * INCREMENT gnLastEventId
2277  **********************************************************************/
2278
2279 gnLastEventId = 0;
2280
2281 MAP_EXTENT_CHANGED = gnLastEventId ++;
2282 MAP_PROJECTION_CHANGED = gnLastEventId ++;
2283 MAP_NEW_LAYER_ADDED = gnLastEventId ++;
2284 MAP_NEW_ELEMENT_ADDED =  gnLastEventId ++;
2285
2286 LAYER_STATUS_CHANGED = gnLastEventId ++;
2287 LAYER_STYLE_CHANGED = gnLastEventId ++;
2288 LAYER_ORDER_CHANGED = gnLastEventId ++;
2289
2290
2291 MOUSE_CLICKED =  gnLastEventId ++;
2292
2293 ERROR_OCCURRED = gnLastEventId ++;
2294
2295 /************************************************************************/
2296 /*                       CWCApplication constructor.                    */
2297 /************************************************************************/
2298 function CWCApplication()
2299 {
2300     this.oMap = new CWCMapObject(this);
2301     this.oMLT = new CWCMLTObject(this);
2302     this.oErrorManager = new CWCErrorManagerObject(this);
2303
2304     //browser settings
2305     this.bNetscape4 = 0;
2306     this.bNetscape6 = 0;
2307     this.bIE = 0;
2308
2309     this.aCallStack = new Array();
2310     this.nCallStackLength = 0;
2311     this.nCallStackPos = 0;
2312     this.bCall = false;
2313
2314     if (navigator.appName == "Netscape")
2315     {
2316         if (navigator.appVersion[0] <= 4)
2317         {
2318             this.bNetscape4 = 1;
2319         }
2320         else
2321         {
2322             this.bNetscape6 =1;
2323         }
2324     }
2325     else if (navigator.appName == "Microsoft Internet Explorer")
2326     {
2327         this.bIE = 1;
2328     }
2329     else
2330         this.oErrorManager.Error(ERR_WARNING,
2331             this.oMLT.Get("114", "Browser not supported"));
2332
2333 /* ==================================================================== */
2334 /*      a special flag used by Netscape 4 to create the Layer object    */
2335 /*      the first time the GetDocuemntObject is called.                 */
2336 /*                                                                      */
2337 /* ==================================================================== */
2338     this.bFirstCallToContainer = true;
2339
2340     //session id;
2341     this.sid = "";
2342
2343     //doument form
2344     this.form = "document.forms[0]"; //TODO set for js api.
2345
2346     //Navigation variables
2347     this.NAV_CMD = "";
2348     this.NAV_INPUT_COORDINATES = "";
2349     this.NAV_INPUT_TYPE = "";
2350
2351     //Zoom scale
2352     this.SCALE_ZOOM = "";
2353
2354     //compass panning
2355     this.NAV_PAN = "";
2356
2357     //quickzoom
2358     this.NAV_QUICKZOOM = "";
2359
2360     //mouse click position
2361     this.mouseclick = new Array(2);
2362     this.mouseclick[0] = 0;
2363     this.mouseclick[1] = 0;
2364
2365
2366     //layer status changed tracker.
2367     this.LAYER_STATUS_MODIFIED = false;
2368
2369     //layer style changed tracker.
2370     this.LAYER_STYLE_MODIFIED = false;
2371
2372     //layer order changed tracker.
2373     this.LAYER_ORDER_MODIFIED = false;
2374
2375     //event registering functions
2376     this.CWCEvents = new Array();
2377     for (i=0; i<gnLastEventId; i++)
2378     {
2379         this.CWCEvents[i] = new Array();
2380     }
2381
2382     //container that have the invisible layer or frame used to
2383     //communicate with the server.
2384     this.szContainerName = "";
2385     this.oContainer = "";
2386
2387     //this is the URL that points to the directory that UpdateMap.php is in
2388     this.szURL = "";
2389
2390     //variables use by netscape4
2391     this.bDebug = false;
2392     this.szLanguage = "";
2393
2394 /* -------------------------------------------------------------------- */
2395 /*      properties. Initalized from cwcjsapi.widget.php.                */
2396 /* -------------------------------------------------------------------- */
2397     this.aProperties = "";
2398 }
2399
2400
2401 /************************************************************************/
2402 /*                              CWCGetProperty                          */
2403 /*                                                                      */
2404 /*      return the value of the property passes as argument.            */
2405 /************************************************************************/
2406 function CWCGetProperty(szProperty)
2407 {
2408     var szValue = false;
2409     if (szProperty != null && szProperty != "" && this.aProperties != "" &&
2410         this.aProperties.length > 0)
2411     {
2412         var szTmp = szProperty.toLowerCase(szProperty);
2413         var nProperties = this.aProperties.length;
2414         for (i=0; i<nProperties; i++)
2415         {
2416             if ( this.aProperties[i][0] == szTmp)
2417             {
2418                 szValue = this.aProperties[i][1];
2419                 break;
2420             }
2421         }
2422     }
2423     return szValue;
2424 }
2425
2426
2427
2428 /************************************************************************/
2429 /*                             CWCMouseClicked                          */
2430 /*                                                                      */
2431 /*      Called map the mapdhtml when the user clicks on the map.        */
2432 /************************************************************************/
2433 function CWCMouseClicked(x,y)
2434 {
2435     //alert("CWCMouseClicked");
2436     this.mouseclick[0] = x;
2437     this.mouseclick[1] =y;
2438
2439     this.TriggerEvent(MOUSE_CLICKED);
2440     return true;
2441 }
2442
2443
2444 /************************************************************************/
2445 /*                             CWCRegisterEvent                         */
2446 /************************************************************************/
2447 function CWCRegisterEvent(event, function_name)
2448 {
2449     lastEvent = (this.CWCEvents[event]).length;
2450     this.CWCEvents[ event ][ lastEvent ] = function_name;
2451     return true;
2452 }
2453
2454 function CWCDeregisterEvent( event, function_name )
2455 {
2456     bFound = false
2457     events = this.CWCEvents[event];
2458     for( i=0; i<events.length; i++ )
2459     {
2460         if (this.CWCEvents[i] == function_name )
2461         {
2462             this.CWCEvents[i] = "";
2463             bFound = true;
2464         }
2465     }
2466     return  bFound;
2467 }
2468
2469 function CWCTriggerEvent( event )
2470 {
2471     var i = 0;
2472     var nEvents = (this.CWCEvents[ event ]).length;
2473     for (i=0; i<nEvents; i++)
2474     {
2475         szFunction =  this.CWCEvents[ event ][ i ];
2476         if (szFunction != "")
2477         {
2478             szFunction = szFunction + '()';
2479             eval(szFunction);
2480         }
2481     }
2482     return true;
2483 }
2484
2485
2486 function CWCAddWMSLayerApp(name, title, srs, connection, version, format)
2487 {
2488     CWCDHTML_ShowLayer("ActivityLayer");
2489
2490     aHiddenVars = new Array(7);
2491     aHiddenVars[0] = new Array(2);
2492     aHiddenVars[0][0] =  "ADD_NEW_WMS_LAYER";
2493     aHiddenVars[0][1] = "1";
2494
2495     aHiddenVars[1] = new Array(2);
2496     aHiddenVars[1][0] =  "LAYER_NAME";
2497     aHiddenVars[1][1] = name;
2498
2499     aHiddenVars[2] = new Array(2);
2500     aHiddenVars[2][0] =  "LAYER_TITLE";
2501     aHiddenVars[2][1] = escape(title);
2502
2503     aHiddenVars[3] = new Array(2);
2504     aHiddenVars[3][0] =  "LAYER_SRS";
2505     aHiddenVars[3][1] = srs;
2506
2507     aHiddenVars[4] = new Array(2);
2508     aHiddenVars[4][0] =  "LAYER_CONNECTION";
2509     aHiddenVars[4][1] = connection;
2510
2511     aHiddenVars[5] = new Array(2);
2512     aHiddenVars[5][0] =  "LAYER_VERSION";
2513     aHiddenVars[5][1] = version;
2514
2515     aHiddenVars[6] = new Array(2);
2516     aHiddenVars[6][0] =  "LAYER_FORMAT";
2517     aHiddenVars[6][1] = format;
2518
2519     szOnLoad = 'goCWCJSAPI.NewLayerAdded()';
2520
2521     this.CallServer(szOnLoad, aHiddenVars);
2522     return true;
2523 }
2524
2525
2526
2527 /************************************************************************/
2528 /*                             CWCNewLayerAdded                         */
2529 /*                                                                      */
2530 /*      Called after a new wms layer was added.                         */
2531 /*      Updates the internal map object with the new layer.             */
2532 /************************************************************************/
2533 function CWCNewLayerAdded()
2534 {
2535     var doc = this.GetDocumentObject();
2536
2537     if (doc.forms[0].LAYER_NAME != null)
2538     {
2539         this.oMap.AddLayer(doc.forms[0].LAYER_NAME.value);
2540         oLayer = this.oMap.GetLayer(this.oMap.numlayers -1);
2541         oLayer.index = doc.forms[0].LAYER_INDEX.value;
2542         oLayer.status = doc.forms[0].LAYER_STATUS.value;
2543         oLayer.type = doc.forms[0].LAYER_TYPE.value;
2544         oLayer.title = doc.forms[0].LAYER_TITLE.value;
2545         oLayer.connection = doc.forms[0].LAYER_CONNECTION.value;
2546         oLayer.connectiontype = doc.forms[0].LAYER_CONNECTIONTYPE.value;
2547         oLayer.onlineresource = doc.forms[0].LAYER_ONLINERESOURCE.value;
2548         oLayer.srs = doc.forms[0].LAYER_SRS.value;
2549         oLayer.version = doc.forms[0].LAYER_VERSION.value;
2550         oLayer.format = doc.forms[0].LAYER_FORMAT.value;
2551         oLayer.formatlist = doc.forms[0].LAYER_FORMATLIST.value;
2552         oLayer.style = doc.forms[0].LAYER_STYLE.value;
2553         oLayer.stylelist = doc.forms[0].LAYER_STYLELIST.value;
2554
2555 /* -------------------------------------------------------------------- */
2556 /*      flag used to indicate a vector layer create by                  */
2557 /*      CWCJSAPI. These layers are the only ones valid                  */
2558 /*      for adding points or lines.                                     */
2559 /* -------------------------------------------------------------------- */
2560         oLayer.bCWCLayer = 1;
2561
2562         this.TriggerEvent(MAP_NEW_LAYER_ADDED);
2563     }
2564     return true;
2565
2566 }
2567
2568
2569 /************************************************************************/
2570 /*                              CWCAddPointWigdteApp                    */
2571 /************************************************************************/
2572 function CWCAddPointWidgetApp(x,y,szLabel,szUnit, bAddElement, bZoomTo)
2573 {
2574     CWCDHTML_ShowLayer("ActivityLayer");
2575
2576     aHiddenVars = new Array(6);
2577
2578     aHiddenVars[0] = new Array(2);
2579     aHiddenVars[0][0] =  "ADD_POINT_WIDGET";
2580     aHiddenVars[0][1] = "1";
2581
2582     aHiddenVars[1] = new Array(2);
2583     aHiddenVars[1][0] =  "LOCATE_LATLONG";
2584     aHiddenVars[1][1] = ""+szLabel+"|"+x+","+y;
2585
2586     aHiddenVars[2] = new Array(2);
2587     aHiddenVars[2][0] =  "LOCATE_ADD_ELEMENT";
2588     aHiddenVars[2][1] = bAddElement;
2589
2590     aHiddenVars[3] = new Array(2);
2591     aHiddenVars[3][0] =  "LOCATE_COORD_UNIT";
2592     aHiddenVars[3][1] = szUnit;
2593
2594     aHiddenVars[4] = new Array(2);
2595     aHiddenVars[4][0] =  "LOCATE_ELEMENT_TYPE";
2596     aHiddenVars[4][1] = "POINT";
2597
2598     aHiddenVars[5] = new Array(2);
2599     aHiddenVars[5][0] =  "LOCATE_ZOOM_TO";
2600     aHiddenVars[5][1] = bZoomTo;
2601
2602     szOnLoad = 'goCWCJSAPI.NewElementAdded()';
2603     if (bZoomTo)
2604     {
2605         szOnLoad += ";goCWCJSAPI.MapExtentsUpdated()";
2606     }
2607     this.CallServer(szOnLoad, aHiddenVars);
2608     return true;
2609 }
2610
2611 /************************************************************************/
2612 /*                              CWCAddRectangleWidgetApp                */
2613 /************************************************************************/
2614 function CWCAddRectangleWidgetApp(x1,y1,x2,y2,szLabel,szUnit, bAddElement, bZoomTo)
2615 {
2616     CWCDHTML_ShowLayer("ActivityLayer");
2617
2618     aHiddenVars = new Array(6);
2619
2620     aHiddenVars[0] = new Array(2);
2621     aHiddenVars[0][0] =  "ADD_RECTANGLE_WIDGET";
2622     aHiddenVars[0][1] = "1";
2623
2624     aHiddenVars[1] = new Array(2);
2625     aHiddenVars[1][0] =  "LOCATE_LATLONG";
2626     aHiddenVars[1][1] = ""+szLabel+"|"+x1+","+y1+";"+x2+","+y2;
2627
2628     aHiddenVars[2] = new Array(2);
2629     aHiddenVars[2][0] =  "LOCATE_ADD_ELEMENT";
2630     aHiddenVars[2][1] = bAddElement;
2631
2632     aHiddenVars[3] = new Array(2);
2633     aHiddenVars[3][0] =  "LOCATE_COORD_UNIT";
2634     aHiddenVars[3][1] = szUnit;
2635
2636     aHiddenVars[4] = new Array(2);
2637     aHiddenVars[4][0] =  "LOCATE_ELEMENT_TYPE";
2638     aHiddenVars[4][1] = "RECTANGLE";
2639
2640     aHiddenVars[5] = new Array(2);
2641     aHiddenVars[5][0] =  "LOCATE_ZOOM_TO";
2642     aHiddenVars[5][1] = bZoomTo;
2643
2644     szOnLoad = 'goCWCJSAPI.NewElementAdded()';
2645     if (bZoomTo)
2646     {
2647         szOnLoad += ";goCWCJSAPI.MapExtentsUpdated()";
2648     }
2649     this.CallServer(szOnLoad, aHiddenVars);
2650     return true;
2651 }
2652
2653
2654 /************************************************************************/
2655 /*                             CWNewElementAdded                        */
2656 /*                                                                      */
2657 /*      Generates an event when a new point or line is added.           */
2658 /************************************************************************/
2659 function CWNewElementAdded()
2660 {
2661      this.TriggerEvent(MAP_NEW_ELEMENT_ADDED);
2662      return true;
2663 }
2664
2665 function CWCJSAPIContainerSetVisibility(vis)
2666 {
2667
2668   if (this.bNetscape4)
2669     this.oContainer.visibility = (vis)? 'show' : 'hidden';
2670   else if (this.bIE)
2671   {
2672       document.all(this.szContainerName ).style.display = (vis)? '' : 'none';
2673   }
2674   else if (this.bNetscape6)
2675   {
2676       document.getElementById(this.szContainerName).style.visibility = (vis)? '' : 'hidden';
2677       this.oContainer.width = (vis)? 250 : 0;
2678       this.oContainer.height = (vis)? 100 : 0;
2679   }
2680   return true;
2681 }
2682
2683
2684 /************************************************************************/
2685 /*                           CWCCreateDHTMLLayer                        */
2686 /*                                                                      */
2687 /*      Create a dhml layer : used only for netscape 4.                 */
2688 /************************************************************************/
2689 function CWCCreateDHTMLLayer()
2690 {
2691     oLayer = new Layer(100);
2692     this.oContainer = oLayer;
2693     if (this.bDebug == true)
2694     {
2695         oLayer.visibility = 'show';
2696     }
2697     else
2698     {
2699         oLayer.visibility = 'hide';
2700     }
2701     return true;
2702 }
2703 /************************************************************************/
2704 /*                           CWCGetDocumentObject                       */
2705 /*                                                                      */
2706 /*      return the document object.                                     */
2707 /************************************************************************/
2708 function CWCGetDocumentObject()
2709 {
2710     //alert("CWCGetDocumentObject");
2711     if (this.bIE)
2712       return this.oContainer.document;
2713     else if (this.bNetscape6)
2714       return this.oContainer.contentDocument;
2715     else if (this.bNetscape4)
2716     {
2717         if (this.bFirstCallToContainer == true)
2718         {
2719             this.bFirstCallToContainer = false;
2720
2721             //this.oContainer = new Layer(100);
2722             this.CreateDHTMLLayer();
2723             //alert("CreateCWCLayer call in CWCGetDocumentObject");
2724             //this.oContainer.name = "CWCJSAPILayer";
2725             this.oMLT.SetLanguage(this.szLanguage);
2726         }
2727         return this.oContainer.document;
2728     }
2729     else
2730         return null;
2731 }
2732
2733 /************************************************************************/
2734 /*                      CWCUpdateExtentsFromContainer                   */
2735 /*                                                                      */
2736 /*      Update the extents in the jsapi using values from the container.*/
2737 /************************************************************************/
2738 function CWCUpdateExtentsFromContainer()
2739 {
2740     var doc = this.GetDocumentObject();//(this.bIE ) ? this.oContainer.document : this.oContainer.contentDocument;
2741     if(doc.forms[0].MAP_EXTENT_MINX)
2742     {
2743         this.oMap.minx = doc.forms[0].MAP_EXTENT_MINX.value;
2744         this.oMap.miny = doc.forms[0].MAP_EXTENT_MINY.value;
2745         this.oMap.maxx = doc.forms[0].MAP_EXTENT_MAXX.value;
2746         this.oMap.maxy = doc.forms[0].MAP_EXTENT_MAXY.value;
2747     }
2748     if (doc.forms[0].MAP_SCALE != null)
2749     {
2750          this.oMap.scale = doc.forms[0].MAP_SCALE.value;
2751     }
2752     if (doc.forms[0].MAP_CELLSIZE != null)
2753       this.oMap.cellsize = doc.forms[0].MAP_CELLSIZE.value;
2754
2755     if (doc.forms[0].MAP_WIDTH != null)
2756       this.oMap.width = doc.forms[0].MAP_WIDTH.value;
2757     if (doc.forms[0].MAP_HEIGHT != null)
2758       this.oMap.height = doc.forms[0].MAP_HEIGHT.value;
2759
2760     return true;
2761 }
2762
2763 /************************************************************************/
2764 /*                           CWCMapExtentsUpdated                       */
2765 /************************************************************************/
2766 function CWCMapExtentsUpdated()
2767 {
2768     this.UpdateExtentsFromContainer();
2769     this.TriggerEvent( MAP_EXTENT_CHANGED );
2770     return true;
2771 }
2772
2773
2774
2775 /************************************************************************/
2776 /*                                CWCUpdate                             */
2777 /*                                                                      */
2778 /*      Use the dynamic html to set the action and forms varaibales     */
2779 /*      and submit the page.                                            */
2780 /************************************************************************/
2781 function CWCUpdateNavTools()
2782 {
2783  
2784     if (this.NAV_CMD == "PAN_MAP")
2785     {
2786         CWCDHTML_HideLayer("MapLayerDiv");
2787     }
2788     CWCDHTML_ShowLayer("ActivityLayer");
2789
2790     aHiddenVars = new Array(4);
2791     aHiddenVars[0] = new Array(2);
2792     aHiddenVars[0][0] =  "NAV_CMD";
2793     aHiddenVars[0][1] = this.NAV_CMD;
2794
2795     aHiddenVars[1] = new Array(2);
2796     aHiddenVars[1][0] =  "NAV_INPUT_COORDINATES";
2797     aHiddenVars[1][1] = this.NAV_INPUT_COORDINATES;
2798
2799     aHiddenVars[2] = new Array(2);
2800     aHiddenVars[2][0] =  "NAV_INPUT_TYPE";
2801     aHiddenVars[2][1] = this.NAV_INPUT_TYPE;
2802
2803     aHiddenVars[3] = new Array(2);
2804     aHiddenVars[3][0] =  "ZOOMFACTOR";
2805     aHiddenVars[3][1] = this.oMap.zoomfactor;
2806
2807     szOnLoad = 'goCWCJSAPI.MapExtentsUpdated()';
2808
2809     this.CallServer(szOnLoad, aHiddenVars);
2810     return true;
2811 }
2812
2813 /************************************************************************/
2814 /*                              CWCCallServer                           */
2815 /************************************************************************/
2816 function CWCCallServer(szOnLoad, aHiddenVars)
2817 {
2818     //alert(szOnLoad);
2819     this.aCallStack[this.nCallStackLength] = new Array(szOnLoad, aHiddenVars);
2820     this.nCallStackLength++;
2821
2822     if (this.nCallStackLength == 1)
2823     {
2824         this.CallServerFromStack();
2825     }
2826     return true;
2827 }
2828
2829 /************************************************************************/
2830 /*                              CWCCallServerFromStack                  */
2831 /************************************************************************/
2832 function CWCCallServerFromStack()
2833 {
2834     //alert("CWCCallServerFromStack");
2835
2836     szOnLoad = this.aCallStack[this.nCallStackPos][0];
2837     aHiddenVars = this.aCallStack[this.nCallStackPos][1];
2838
2839     var d = new Date();
2840     var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
2841     var szURL = this.szURL + "UpdateMap.php?sid=" + this.sid;
2842
2843     if (this.bIE == 1 || this.bNetscape6 == 1)
2844     {
2845         var doc = this.GetDocumentObject();//(this.bIE ) ? this.oContainer.document : this.oContainer.contentDocument;
2846
2847     // init var for syncron call
2848         this.bLoaded = false;
2849
2850         doc.open();
2851         doc.write('<html><body>');
2852         doc.write('<form name="myform" method="post" target="" ');
2853         doc.write(' action="' + szURL + '&U=' + unique + '">');
2854
2855         //szHidden for debugging
2856         //szHidden = "";
2857         if (aHiddenVars != "")
2858         {
2859             nHidden = aHiddenVars.length;
2860             for (i=0; i<nHidden; i++)
2861             {
2862                 //szHidden for debugging
2863                 //szHidden += '<input type="hidden" name="'+aHiddenVars[i][0]+'" value="' + aHiddenVars[i][1] + '">';
2864                 doc.write('<input type="hidden" name="'+aHiddenVars[i][0]+'" value="' + aHiddenVars[i][1] + '">');
2865             }
2866         }
2867
2868         //onload function to call
2869         if (szOnLoad != "")
2870         {
2871             doc.write('<input type="hidden" name="ONLOAD_FUNCTION" value= "'+szOnLoad+'">');
2872         }
2873
2874         doc.write('</form></body></html>');
2875         doc.close();
2876         //szHidden for debugging
2877         //alert(szHidden);
2878
2879         doc.forms['myform'].submit();
2880     }
2881     else if (this.bNetscape4 == 1)
2882     {
2883         //alert("CWCCallServerFromStack : netscape4");
2884
2885         szURL += '&NETSCAPE4=1&U=' + unique;
2886         if (szOnLoad != "")
2887         {
2888             szURL += '&ONLOAD_FUNCTION=' + szOnLoad;
2889         }
2890         if (aHiddenVars != "")
2891         {
2892             nHidden = aHiddenVars.length;
2893             for (i=0; i<nHidden; i++)
2894             {
2895                 szURL += '&' + aHiddenVars[i][0] + "=" + aHiddenVars[i][1];
2896             }
2897         }
2898         //ttt = "url = " + szURL;
2899         //alert(ttt);
2900
2901         oLayer = this.GetDocumentObject();
2902         oLayer = this.oContainer;
2903         oLayer.src = szURL;
2904
2905     }
2906
2907     return true;
2908 }
2909
2910 function CWCCheckCallStack()
2911 {
2912     this.nCallStackPos++;
2913
2914     if (this.nCallStackPos < this.nCallStackLength)
2915     {
2916         this.CallServerFromStack();
2917     }
2918     else
2919     {
2920         this.nCallStackPos = 0;
2921         this.nCallStackLength = 0;
2922     }
2923     return true;
2924 }
2925
2926 /************************************************************************/
2927 /*                            UpdateNavQuickZoom                        */
2928 /*                                                                      */
2929 /*      Quick zoom update.                                              */
2930 /************************************************************************/
2931 function CWCUpdateNavQuickZoom()
2932 {
2933     CWCDHTML_ShowLayer("ActivityLayer");
2934
2935     aHiddenVars = new Array(1);
2936     aHiddenVars[0] = new Array(2);
2937     aHiddenVars[0][0] =  "NAV_QUICKZOOM";
2938     aHiddenVars[0][1] = this.NAV_QUICKZOOM;
2939
2940     this.CallServer("goCWCJSAPI.MapExtentsUpdated()", aHiddenVars);
2941     return true;
2942 }
2943
2944 /************************************************************************/
2945 /*                            CWCUpdateScaleZoom                        */
2946 /*                                                                      */
2947 /*      Calls UpdateMap when for zooming using a scale value.           */
2948 /************************************************************************/
2949 function CWCUpdateScaleZoom()
2950 {
2951     CWCDHTML_ShowLayer("ActivityLayer");
2952
2953     aHiddenVars = new Array(2);
2954
2955     aHiddenVars[0] = new Array(2);
2956     aHiddenVars[0][0] =  "NAV_CMD";
2957     aHiddenVars[0][1] = "SCALE_ZOOM";
2958
2959     aHiddenVars[1] = new Array(2);
2960     aHiddenVars[1][0] =  "SCALE_ZOOM";
2961     aHiddenVars[1][1] = this.SCALE_ZOOM;
2962
2963     szOnLoad = 'goCWCJSAPI.MapExtentsUpdated()';
2964
2965     this.CallServer(szOnLoad, aHiddenVars);
2966     return true;
2967 }
2968
2969 /************************************************************************/
2970 /*                    CWCUpdateExpressionBuilder                        */
2971 /*                                                                      */
2972 /*      Calls UpdateMap when applying an expression.                    */
2973 /************************************************************************/
2974 function CWCUpdateExpressionBuilder( szFilter, nLayerIndex, szExpressions,
2975          nApplyToMap, szSLDName, szWFSConnection, szLayerType, szSLDFile  )
2976 {
2977     CWCDHTML_ShowLayer("ActivityLayer");
2978
2979     aHiddenVars = new Array(1);
2980     aHiddenVars[0] = new Array(2);
2981     aHiddenVars[0][0] =  "WFS_FILTER";
2982     aHiddenVars[0][1] = szFilter;
2983     aHiddenVars[1] = new Array(2);
2984     aHiddenVars[1][0] =  "WFS_FILTER_LAYER_INDEX";
2985     aHiddenVars[1][1] = nLayerIndex;
2986     aHiddenVars[2] = new Array(2);
2987     aHiddenVars[2][0] =  "WFS_FILTER_EXPRESSIONLIST";
2988     aHiddenVars[2][1] = szExpressions;
2989     aHiddenVars[3] = new Array(2);
2990     aHiddenVars[3][0] =  "WFS_FILTER_APPLYTOMAP";
2991     aHiddenVars[3][1] = nApplyToMap;
2992     aHiddenVars[4] = new Array(2);
2993     aHiddenVars[4][0] =  "WFS_FILTER_SLD";
2994     aHiddenVars[4][1] = szSLDName;
2995     aHiddenVars[5] = new Array(2);
2996     aHiddenVars[5][0] =  "WFS_FILTER_CONNECTION";
2997     aHiddenVars[5][1] = szWFSConnection;
2998     aHiddenVars[6] = new Array(2);
2999     aHiddenVars[6][0] =  "WFS_FILTER_LAYERTYPE";
3000     aHiddenVars[6][1] = szLayerType;
3001     aHiddenVars[7] = new Array(2);
3002     aHiddenVars[7][0] =  "WFS_APPLY_EXPRESSIONLIST";
3003     aHiddenVars[7][1] = "1";
3004     aHiddenVars[8] = new Array(2);
3005     aHiddenVars[8][0] =  "WFS_FILTER_SLD_FILE";
3006     aHiddenVars[8][1] = szSLDFile;   
3007    
3008     szOnLoad = 'goCWCJSAPI.MapExtentsUpdated()';
3009     this.CallServer(szOnLoad, aHiddenVars);
3010
3011     return true;
3012 }
3013
3014 /************************************************************************/
3015 /*                            CWCUpdateCompassPan                       */
3016 /*                                                                      */
3017 /*      Calls UpdateMap when panning                        .           */
3018 /************************************************************************/
3019 function CWCUpdateCompassPan()
3020 {
3021     //alert("CWCUpdateCompassPan");
3022     CWCDHTML_ShowLayer("ActivityLayer");
3023
3024     aHiddenVars = new Array(1);
3025     aHiddenVars[0] = new Array(2);
3026     aHiddenVars[0][0] =  "NAV_PAN";
3027     aHiddenVars[0][1] = this.NAV_PAN;
3028
3029     szOnLoad = 'goCWCJSAPI.MapExtentsUpdated()';
3030
3031     this.CallServer(szOnLoad, aHiddenVars);
3032     return true;
3033
3034 }
3035
3036 /************************************************************************/
3037 /*                       CWCProcessLegendTemplate                       */
3038 /*                                                                      */
3039 /*      Calls UpdateMap to re-process the legend template.              */
3040 /************************************************************************/
3041 function CWCProcessLegendTemplate(nID)
3042 {
3043     //alert(nID);
3044     CWCDHTML_ShowLayer("ActivityLayer");
3045
3046     aHiddenVars = new Array(2);
3047     aHiddenVars[0] = new Array(2);
3048     aHiddenVars[0][0] =  "PROCESS_L_TEMPLATE";
3049     aHiddenVars[0][1] = "1";
3050     aHiddenVars[1] = new Array(2);
3051     aHiddenVars[1][0] =  "PROCESS_L_TEMPLATE_ID";
3052     aHiddenVars[1][1] = nID;
3053
3054     szOnLoad = 'goCWCJSAPI.LegendTemplateProcessed()';
3055
3056     this.CallServer(szOnLoad, aHiddenVars);
3057     return true;
3058 }
3059
3060 /************************************************************************/
3061 /*                     CWCLegendTemplateProcessed                       */
3062 /*                                                                      */
3063 /*      Updates the hidden form variable to the results of the process  */
3064 /*      legend template.                                                */
3065 /************************************************************************/
3066 function CWCLegendTemplateProcessed()
3067 {
3068     var doc = this.GetDocumentObject()//(this.bIE ) ? this.oContainer.document : this.oContainer.contentDocument;
3069     if(doc.forms[0].UPDATE_LEGEND_TEMPLATE_RESULTS)
3070     {
3071         checkString = doc.forms[0].UPDATE_LEGEND_TEMPLATE_RESULTS.value;
3072         var newString = "";
3073
3074         // loop through each letter
3075         for (var i = 0; i < checkString.length; i++)
3076         {
3077             // check for #!#, and #!!#
3078             if ( checkString.substr(i,3) == "#!#" )
3079             {
3080                 newString = newString + "'";
3081                 i = i + 2;
3082             }
3083             else
3084             {
3085                 if ( checkString.substr(i,4) == "#!!#" )
3086                 {
3087                     newString = newString + "\"";
3088                     i = i + 3;
3089                 }
3090                 else
3091                     newString = newString + checkString.substr(i,1);
3092             }
3093         }
3094         //alert( 'newstring:'+newString);
3095         // update the div tag
3096         this.GetDocumentDivObject("legendTemplateDiv").innerHTML =
3097                                             "<table>" + newString + "</table>";
3098     }
3099     return true;
3100 }
3101
3102 /************************************************************************/
3103 /*                        CWCGetDocumentDivObject                       */
3104 /*                                                                      */
3105 /*      This function returns the correct div object for the current    */
3106 /*      browser.                                                        */
3107 /************************************************************************/
3108 function CWCGetDocumentDivObject( szDIVName )
3109 {
3110     // return object based on browser and version
3111     if ( this.bNetscape4 == 1 )
3112         return document.layers[szDIVName];
3113     if ( this.bNetscape6 == 1 )
3114         return document.getElementById(szDIVName);
3115     if ( this.bIE == 1 )
3116         return document.all[szDIVName];
3117
3118     // throw error
3119     this.oErrorManager.Error(ERR_WARNING,
3120                           this.oMLT.Get("114", "Browser not supported"));
3121
3122     // return empty object
3123     return "";
3124 }
3125
3126 /**
3127  * internal function to update the projection from a container
3128  */
3129 function CWCUpdateProjectionFromContainer()
3130 {
3131     var doc = this.GetDocumentObject()//(this.bIE ) ? this.oContainer.document : this.oContainer.contentDocument;
3132     if(doc.forms[0].MAP_PROJECTION)
3133     {
3134         this.oMap.projection = doc.forms[0].MAP_PROJECTION.value;
3135     }
3136     return true;
3137 }
3138
3139 /**
3140  * the projection has been updated.  Get the values into the map object
3141  * and update all the event listeners
3142  */
3143 function CWCProjectionUpdated()
3144 {
3145     this.UpdateProjectionFromContainer();
3146     this.TriggerEvent( MAP_PROJECTION_CHANGED );
3147     this.MapExtentsUpdated();
3148     return true;
3149 }
3150
3151 /**
3152  * update the projection
3153  */
3154 function CWCUpdateProjection()
3155 {
3156     CWCDHTML_ShowLayer("ActivityLayer");
3157
3158
3159     aHiddenVars = new Array(1);
3160     aHiddenVars[0] = new Array(2);
3161     aHiddenVars[0][0] =  "MAP_PROJECTION";
3162     aHiddenVars[0][1] = this.oMap.projection;
3163
3164     szOnLoad = 'goCWCJSAPI.ProjectionUpdated()';
3165
3166     this.CallServer(szOnLoad, aHiddenVars);
3167     return true;
3168 }
3169
3170
3171 /************************************************************************/
3172 /*                          CWCLayerStatusUpdated                       */
3173 /*                                                                      */
3174 /*      Trigger event for layer status changed. Called after a          */
3175 /*      refrsh map is done.                                             */
3176 /************************************************************************/
3177 function CWCLayerStatusUpdated()
3178 {
3179     //test for deleted layers
3180     aNewLayers = new Array();
3181     idx = 0;
3182     for (i=0; i<this.oMap.numlayers; i++)
3183     {
3184         if (this.oMap.aLayers[i].status != 4)
3185         {
3186             aNewLayers[idx] = this.oMap.aLayers[i];
3187             aNewLayers[idx].index = idx;
3188             idx ++;
3189         }
3190     }
3191     this.oMap.layerdrawingorder="";
3192     this.oMap.aLayers = aNewLayers;
3193     this.oMap.numlayers = this.oMap.aLayers.length;
3194    
3195     this.TriggerEvent(LAYER_STATUS_CHANGED);
3196     //reset the layer status tracker
3197     this.LAYER_STATUS_MODIFIED = false;
3198     return true;
3199 }
3200
3201 /************************************************************************/
3202 /*                          CWCLayerStyleUpdated                        */
3203 /*                                                                      */
3204 /*      Trigger event for layer style changed. Called after a           */
3205 /*      refrsh map is done.                                             */
3206 /************************************************************************/
3207 function CWCLayerStyleUpdated()
3208 {
3209     this.TriggerEvent(LAYER_STYLE_CHANGED);
3210     //reset the layer status tracker
3211     this.LAYER_STYLE_MODIFIED = false;
3212     return true;
3213 }
3214
3215 /************************************************************************/
3216 /*                          CWCLayerOrderUpdated                        */
3217 /*                                                                      */
3218 /*      Trigger event for layer drawing order is changed. Called after a*/
3219 /*      refrsh map is done.                                             */
3220 /************************************************************************/
3221 function CWCLayerOrderUpdated()
3222 {
3223 /* ==================================================================== */
3224 /*      If the layer order is updated, we have to sync the layers in    */
3225 /*      the jsapi which the map on the server. (using the session,      */
3226 /*      the temporary map file saved on the server was saved with       */
3227 /*      the new layer order).                                           */
3228 /* ==================================================================== */
3229     aOrder = this.oMap.layerdrawingorder.split(",");
3230     if (aOrder.length == this.oMap.numlayers)
3231     {
3232         //alert ("CWCLayerOrderUpdated");
3233         //alert( this.oMap.layerdrawingorder);
3234         aNewLayerArray = new Array(this.oMap.numlayers);
3235         for (i=0; i<this.oMap.numlayers; i++)
3236         {
3237             aNewLayerArray[i] = this.oMap.aLayers[aOrder[i]];
3238             aNewLayerArray[i].index = i;
3239         }
3240        
3241         this.oMap.aLayers = aNewLayerArray;
3242     }
3243    
3244     this.TriggerEvent(LAYER_ORDER_CHANGED);
3245     //reset the layer oder tracker
3246     this.oMap.layerdrawingorder="";
3247     this.LAYER_ORDER_MODIFIED = false;
3248     return true;
3249 }
3250
3251
3252 /************************************************************************/
3253 /*                              CWCRefreshMap                           */
3254 /*                                                                      */
3255 /*      Used to update on the server layer status, layer                */
3256 /*      styles(TODO).                                                   */
3257 /************************************************************************/
3258 function CWCRefreshMap()
3259 {
3260     if (this.LAYER_STATUS_MODIFIED == true || this.LAYER_ORDER_MODIFIED == true ||
3261         this.LAYER_STYLE_MODIFIED == true )
3262     {
3263         CWCDHTML_ShowLayer("ActivityLayer");
3264
3265         var iParams = 0;
3266         if (this.LAYER_STATUS_MODIFIED == true)
3267         {
3268             iParams++; //for "LAYER_STATUS_CHANGED
3269             iParams += this.oMap.numlayers; //each layer is sent in the url
3270         }
3271         if (this.LAYER_ORDER_MODIFIED == true )
3272         {
3273             iParams++; //for LAYER_ORDER_CHANGED
3274         }
3275         if (this.LAYER_STYLE_MODIFIED == true)
3276         {
3277             iParams++; //for LAYER_STYLE_CHANGED
3278              for (i=0; i<this.oMap.numlayers; i++)
3279              {
3280                  var oLayer = this.oMap.aLayers[i];
3281                  if (oLayer.style != "")
3282                  {
3283                      iParams++; //each layer that has a style is sent in the url
3284                  }
3285              }
3286         }
3287         aHiddenVars = new Array(iParams);
3288
3289         iParams = 0;
3290
3291         if (this.LAYER_STATUS_MODIFIED == true)
3292         {
3293             aHiddenVars[iParams] = new Array(2);
3294             aHiddenVars[iParams][0] =  "LAYER_STATUS_CHANGED";
3295             aHiddenVars[iParams][1] = "1";
3296             iParams++;
3297             for (i=0; i<this.oMap.numlayers; i++)
3298             {
3299                 var oLayer = this.oMap.aLayers[i];
3300                 aHiddenVars[iParams] = new Array(2);
3301                 aHiddenVars[iParams][0] =  oLayer.name;
3302                 aHiddenVars[iParams][1] = oLayer.status;
3303                 iParams++;
3304             }
3305         }
3306         if (this.LAYER_ORDER_MODIFIED == true)
3307         {
3308             aHiddenVars[iParams] = new Array(2);
3309             aHiddenVars[iParams][0] =  "LAYER_ORDER_CHANGED";
3310             aHiddenVars[iParams][1] = this.oMap.layerdrawingorder;
3311             iParams++;
3312         }
3313
3314         if (this.LAYER_STYLE_MODIFIED == true)
3315         {
3316             aHiddenVars[iParams] = new Array(2);
3317             aHiddenVars[iParams][0] =  "LAYER_STYLE_CHANGED";
3318             aHiddenVars[iParams][1] = "1";
3319             iParams++;
3320             for (i=0; i<this.oMap.numlayers; i++)
3321             {
3322                 var oLayer = this.oMap.aLayers[i];
3323                 if (oLayer.style != "")
3324                 {
3325                     aHiddenVars[iParams] = new Array(2);
3326                     aHiddenVars[iParams][0] =  oLayer.name;
3327                     aHiddenVars[iParams][1] = escape(oLayer.style);
3328                     iParams++;
3329                 }
3330             }
3331         }
3332         szOnLoadFunc = "";
3333         if (this.LAYER_STATUS_MODIFIED == true)
3334         {
3335             szOnLoadFunc += "goCWCJSAPI.LayerStatusUpdated();";
3336         }
3337         if (this.LAYER_ORDER_MODIFIED == true)
3338         {
3339             szOnLoadFunc += "goCWCJSAPI.LayerOrderUpdated();";
3340         }
3341         if (this.LAYER_STYLE_MODIFIED == true)
3342         {
3343             szOnLoadFunc += "goCWCJSAPI.LayerStyleUpdated();";
3344         }
3345
3346         this.CallServer(szOnLoadFunc, aHiddenVars);
3347     }
3348     return true;
3349 }
3350
3351
3352 /************************************************************************/
3353 /*                              CWCLoadContext                          */
3354 /*                                                                      */
3355 /*      Load a context. Submits the page.                               */
3356 /************************************************************************/
3357 function CWCLoadContext(szContext)
3358 {
3359     if (szContext != "")
3360     {
3361         var szFormElement = ""+ this.form + ".CONTEXT.value = '" + szContext + "'";
3362         eval(szFormElement);
3363
3364         szFormElement = ""+ this.form + ".submit()";
3365         eval(szFormElement);
3366
3367         return true;
3368     }
3369     else
3370     {
3371         return false;
3372     }
3373 }
3374
3375
3376 /************************************************************************/
3377 /*                             CWCContextSaved                          */
3378 /*                                                                      */
3379 /*      Called when the context has finished saving.                    */
3380 /************************************************************************/
3381 function CWCContextSaved()
3382 {
3383     var doc = this.GetDocumentObject();
3384
3385     if (doc.forms[0].FUNCTION_CALLBACK != null &&
3386         doc.forms[0].FILENAME != null)
3387     {
3388         eval(doc.forms[0].FUNCTION_CALLBACK.value+'("'+doc.forms[0].FILENAME.value+'");');
3389     }
3390 }
3391        
3392
3393 /************************************************************************/
3394 /*                              CWCSaveContext                          */
3395 /*                                                                      */
3396 /*      Save context and call the callback function passed as           */
3397 /*      argument with the url to the file to download.                  */
3398 /************************************************************************/
3399 function CWCSaveContext(szCallBack)
3400 {
3401     aHiddenVars = new Array(2);
3402     aHiddenVars[0] = new Array(2);
3403     aHiddenVars[0][0] =  "SAVE_CONTEXT";
3404     aHiddenVars[0][1] = "1";
3405
3406     aHiddenVars[1] = new Array(2);
3407     aHiddenVars[1][0] =  "FUNCTION_CALLBACK";
3408     aHiddenVars[1][1] = szCallBack;
3409    
3410     szOnLoad = 'goCWCJSAPI.ContextSaved()';
3411    
3412     this.CallServer(szOnLoad, aHiddenVars);
3413
3414     return true;
3415 }
3416 /* -------------------------------------------------------------------- */
3417 /*      application class prototypes.                                   */
3418 /* -------------------------------------------------------------------- */
3419
3420 CWCApplication.prototype.GetProperty = CWCGetProperty;
3421
3422 CWCApplication.prototype.RegisterEvent = CWCRegisterEvent;
3423 CWCApplication.prototype.TriggerEvent = CWCTriggerEvent;
3424
3425 CWCApplication.prototype.MouseClicked = CWCMouseClicked;
3426
3427 CWCApplication.prototype.CallServer = CWCCallServer;
3428 CWCApplication.prototype.CallServerFromStack = CWCCallServerFromStack;
3429 CWCApplication.prototype.CheckCallStack = CWCCheckCallStack;
3430 CWCApplication.prototype.UpdateNavTools = CWCUpdateNavTools;
3431 CWCApplication.prototype.UpdateScaleZoom = CWCUpdateScaleZoom;
3432 CWCApplication.prototype.UpdateCompassPan = CWCUpdateCompassPan;
3433 CWCApplication.prototype.UpdateNavQuickZoom = CWCUpdateNavQuickZoom;
3434
3435 CWCApplication.prototype.RefreshMap = CWCRefreshMap;
3436
3437 CWCApplication.prototype.ZoomToScale = CWCZoomToScale;
3438
3439 CWCApplication.prototype.LayerStatusUpdated = CWCLayerStatusUpdated;
3440 CWCApplication.prototype.LayerOrderUpdated = CWCLayerOrderUpdated;
3441 CWCApplication.prototype.LayerStyleUpdated = CWCLayerStyleUpdated;
3442
3443 CWCApplication.prototype.AddWMSLayer = CWCAddWMSLayerApp;
3444 CWCApplication.prototype.NewLayerAdded = CWCNewLayerAdded;
3445
3446 CWCApplication.prototype.AddPointWidget = CWCAddPointWidgetApp;
3447 CWCApplication.prototype.AddRectangleWidget = CWCAddRectangleWidgetApp;
3448 CWCApplication.prototype.NewElementAdded = CWNewElementAdded;
3449
3450 CWCApplication.prototype.MapExtentsUpdated = CWCMapExtentsUpdated;
3451 CWCApplication.prototype.UpdateExtentsFromContainer = CWCUpdateExtentsFromContainer;
3452
3453 CWCApplication.prototype.ProcessLegendTemplate = CWCProcessLegendTemplate;
3454 CWCApplication.prototype.LegendTemplateProcessed = CWCLegendTemplateProcessed;
3455
3456 CWCApplication.prototype.UpdateProjection = CWCUpdateProjection;
3457 CWCApplication.prototype.ProjectionUpdated = CWCProjectionUpdated;
3458 CWCApplication.prototype.UpdateProjectionFromContainer = CWCUpdateProjectionFromContainer;
3459 CWCApplication.prototype.PointReprojected = CWCPointReprojected;
3460
3461 CWCApplication.prototype.ContainerSetVisibility = CWCJSAPIContainerSetVisibility;
3462 CWCApplication.prototype.GetDocumentObject = CWCGetDocumentObject;
3463 CWCApplication.prototype.GetDocumentDivObject = CWCGetDocumentDivObject;
3464 CWCApplication.prototype.CreateDHTMLLayer = CWCCreateDHTMLLayer;
3465
3466
3467 CWCApplication.prototype.ResourceLoaded = CWCResourceLoaded;
3468 CWCApplication.prototype.ServerErrorsLoaded = CWCServerErrorsLoaded;
3469
3470 CWCApplication.prototype.LoadContext = CWCLoadContext;
3471 CWCApplication.prototype.SaveContext = CWCSaveContext;
3472 CWCApplication.prototype.ContextSaved = CWCContextSaved;
3473
3474 CWCApplication.prototype.UpdateExpressionBuilder = CWCUpdateExpressionBuilder;
Note: See TracBrowser for help on using the browser.