
function MQBaseMap(strDivName) {

   this.locations = null;
   this.onRollover = null;
   this.onRollout = null;
   this.origin = null;
   this.UId = getguid();
   this.mapImageId = "map"+this.UId;
   this.setMapImageId =function(ID){this.mapImageId=ID;this.UId=ID.split('map')[1];}

   //private
   this.minWidth               = 463;//this.width;
   this.maxWidth               = 1400;
   this.paddingWidth           = 6;
   this.optionsWidth           = 41;
   this.sideWidth              = 28; //width of east + west rails
   this.gapWidth               = 5; //width of gap between zoom and pan
   this.widgetMinWidth         = this.minWidth + this.optionsWidth + this.paddingWidth+ this.sideWidth + this.gapWidth;
   this.widgetMaxWidth         = this.maxWidth + this.optionsWidth + this.paddingWidth+ this.sideWidth + this.gapWidth;
   this.nsSpacerOffset         = 49 + 15 + 76 + 11 + 52 - this.sideWidth; //nw, nxnw, n, nxne, ne
   this.ewSpacerOffset         = 37 + 13 + 76 + 10 + 37; //ene, exne, e, exse, ese
   this.centerlatapi           = "";
   this.centerlngapi           = "";
   this.getMapCallback = null;
   this.initialMS = new function() {
      this.centerLL=null;
      this.centerSet=false;
   }


   this.color = 'blue';
   this.getSkin = function() {
      return this.color;
   }

   this.setSkin = function(strColor) {
      this.color = strColor;
      var strColorSkin = this.getSkin();
      var cssLinkObj = document.getElementById("cssSkin");
      cssLinkObj.href = "http://" + _mqServerPort + "/oapi/css/" + strColorSkin + "_frame.css";
   }

   this.setMapSize = function ( iSize ) {
      iSize.setWidth( iSize.getWidth() + this.optionsWidth + this.paddingWidth + this.sideWidth + this.gapWidth + 4 );
      iSize.setHeight( iSize.getHeight() + 32 + 22 + 4 );
      setPDivSize( this, iSize );
      resizeMapWidget( this );
      this.getMap();
   }

   this.setWidgetSize = function ( iSize ) {
      setPDivSize( this, iSize );
      resizeMapWidget( this );
      this.getMap();
   }

   this.getMapSize = function () {
      size = getPDivSize( this );
      size.setWidth( size.getWidth() - this.optionsWidth - this.paddingWidth - this.sideWidth - this.gapWidth );
      size.setHeight( size.getHeight() - 32 - 22 );
      return size;
   }

   this.getWidgetSize = function () {
      size = getPDivSize( this );
      size.setWidth( size.getWidth() + 4 );
      size.setHeight( size.getHeight() + 4 );
      return size;
   }


   this.panNorth = function () {
      panMap("n", this.mapImageId );
   }

   this.panSouth = function () {
      panMap("s", this.mapImageId );
   }

   this.panEast = function () {
      panMap("e", this.mapImageId );
   }

   this.panWest = function () {
      panMap("w", this.mapImageId );
   }

   this.panNorthWest = function () {
      panMap("nw", this.mapImageId );
   }

   this.panNorthEast = function () {
      panMap("ne", this.mapImageId );
   }

   this.panSouthWest = function () {
      panMap("sw", this.mapImageId );
   }

   this.panSouthEast = function () {
      panMap("se", this.mapImageId );
   }

   this.zoomIn = function () {
      this.zoomMapIn(this.mapImageId );
   }

   this.zoomOut = function () {
      this.zoomMapOut(this.mapImageId );
   }

   this.zoomLevel1 = function () {
      this.zoomMap(1, this.mapImageId );
   }

   this.zoomLevel2 = function () {
      this.zoomMap(2, this.mapImageId );
   }

   this.zoomLevel3 = function () {
      this.zoomMap(3, this.mapImageId );
   }

   this.zoomLevel4 = function () {
      this.zoomMap(4, this.mapImageId );
   }

   this.zoomLevel5 = function () {
      this.zoomMap(5, this.mapImageId );
   }

   this.zoomLevel6 = function () {
      this.zoomMap(6, this.mapImageId );
   }

   this.zoomLevel7 = function () {
      this.zoomMap(7, this.mapImageId );
   }

   this.zoomLevel8 = function () {
      this.zoomMap(8, this.mapImageId );
   }

   this.zoomLevel9 = function () {
      this.zoomMap(9, this.mapImageId );
   }

   this.zoomLevel9 = function () {
      this.zoomMap(9, this.mapImageId );
   }

   this.zoomLevel10 = function () {
      this.zoomMap(10, this.mapImageId );
   }






   this.setMapId = function(strMapId){
      this.mapId = strMapId;
   }


   this.getMapId = function(){
      return this.mapId;
   }

   this.setRollOver = function(rollover){
      this.rollover = rollover;
   }
   this.getRollOver = function(){
      return this.rollover;
   }
   this.setRadius = function(radius){
      this.radius = radius;
   }
   this.getRadius = function(){
      return this.radius;
   }
   this.setProxIconId = function(proxIconIds){
      this.proxIconIds = proxIconIds;
   }
   this.getProxIconId = function(){
      return this.proxIconIds;
   }


   this.setMapCenterLL = function (MQPointLL_LatLng ) {
      this.centerlatapi = MQPointLL_LatLng .getLat().toString();
      this.centerlngapi = MQPointLL_LatLng .getLng().toString();
      if (eval("__mqcontainer.map." + this.mapImageId) != null) {
         zoom = parseInt(this.mapState.zoomLevel);
         newMapData = new function()
         {
            this.action = "zoom";
            this.change = zoom;
         }
         this.getNewMap(newMapData);
         this.centerlatapi = "";
         this.centerlngapi = "";
      } else {
         this.initialMS.centerLL = new MQPointLL(MQPointLL_LatLng.getLat(),MQPointLL_LatLng.getLng());
         this.initialMS.centerSet = true;
      }
   }

   this.setMapCenterXY = function (MQPointXY_XY ) {
      //get recenter data
      newMapData      = new function()
      {
         this.action = "center";
         this.x      = MQPointXY_XY .getX();
         this.y      = MQPointXY_XY .getY();
      }
      var Element = document.getElementById(this.mapImageId);
      eval("__dragObj.info"+this.mapImageId+" = new Object()");
      eval("__dragObj.info"+this.mapImageId).xx = MQPointXY_XY.getX() - (Element.width/2);
      eval("__dragObj.info"+this.mapImageId).yy = MQPointXY_XY.getY() - (Element.height/2);
      this.getNewMap(newMapData);
   }

   this.getMapCenterLL = function () {
      var latlng = new MQPointLL();
      if (eval("__mqcontainer.map." + this.mapImageId) != null) {
         latlng.setLat(this.mapState.getLatitude());
         latlng.setLng(this.mapState.getLongitude());
      }
      return latlng;
   }

   this.getMapCenterXY = function () {
      var xy = new MQPointXY();
      size = this.getMapSize();
      xy.setX(size.getWidth() / 2);
      xy.setY(size.getHeight() / 2);
      return xy;
   }

   this.placeLayers = function(MQPopup_popup ,bVisibilityFlag) {
      var map1 = this.mapImageId ;
      var locColl = this.locations;
      mapObj = document.getElementById("mapcontainer" + this.UId);
      var size = this.locations.getSize();
      var popup = this.popup;
      var visibilityProp = (bVisibilityFlag) ? "visible" : "hidden";

      (this.onRollout) ?  eval(this.onRollout)(1) : this.popup.hide(1);

      for (var i=0; i < size ;i++)
      {
         //this is to erase poi layers if present
         var currentLocation = this.locations.getAt(i);
         if (currentLocation.poiLayer)
         {
            oldLayer = document.getElementById(currentLocation.poiLayer.id);
            mapObj.removeChild(oldLayer);
            currentLocation.poiLayer = null;
         }
      }
      for (var i=0; i < size ;i++)
      {
         var currentLocation = this.locations.getAt(i);
         //to not place div's which don't have x,y defined
         if(currentLocation.getX() && currentLocation.getY())
         {
            poiLayer = document.createElement ('img');
            poiLayer.id = this.mapImageId +poiImageId+"-"+String(i+1);
            poiLayer.src = currentLocation.getIconSource().length == 0 ? defaultIcon.src + '?dummy=' + getguid() : currentLocation.getIconSource() + '?dummy=' + getguid();
            poiLayer.style.left = parseInt(currentLocation.getX())    + 'px';
            poiLayer.style.top = parseInt(currentLocation.getY())  + 'px';
            if(currentLocation.getIconSource().length == 0) {
               poiLayer.width = 8;
               poiLayer.height = 8;
            }
            removeEvent(poiLayer,"load",poiOnLoad);
            addEvent(poiLayer,"load",poiOnLoad);
            poiLayer.style.visibility = visibilityProp;
            poiLayer.style.position = "absolute";
            poiLayer.style.zIndex = -1;
            mapObj.appendChild(poiLayer);
            currentLocation.poiLayer = poiLayer;

            // defining function for showing the popups on mouseover
            poiLayer.onerror = function ()
            {
               this.src = defaultIcon.src;
            }
            poiLayer.onmouseover = function(evt)
            {
               var targ;
               if (!evt) var evt = window.event;
               if (evt.target) targ = evt.target;
               else if (evt.srcElement) targ = evt.srcElement;
               if (targ.id != popup.getState() || popup.popupDiv.style.visibility != "visible")
               {
                  var topoffset = 0;
                  var leftoffset = 0;
                  var temp = targ;
                  while(temp.offsetParent)
                  {
                     leftoffset   += temp.offsetLeft;
                     topoffset    += temp.offsetTop;
                     temp = temp.offsetParent;
                  }
                  popup.showPopUpOverLocColl(leftoffset + parseInt(targ.width)/2,
                  topoffset + parseInt(targ.height)/2,targ.id,locColl,this.width,map1);
               }
            }
         }
      }
   }

   this.rolloverPopups = true;
   this.setRolloverPopups = function( bFlag ) {
      this.rolloverPopups = bFlag;
   }

   this.popupContentDisplay = true;
   this.setPopupContentDisplay = function( flag ) {
      this.popupContentDisplay = flag;
   }


   this.addListener = function(sEventName, sFunctionName) {
      if(sEventName == "rollover")
      {
         this.onRollover = sFunctionName;
      }
      if(sEventName == "rollout")
      {
         this.onRollout = sFunctionName;
      }
   }

   this.init = function (strDivName) {
      this.parentDivName = strDivName;
      this.popup = new MQPopup(this.parentDivName);
      this.mapState = new MQMapState();
      this.orgMapState = new MQMapState();

      if (document.getElementById(this.parentDivName) == null)
      {
         this.parentDivName = "map_parent_" + (Math.round((Math.random()*197)+1));
         var bodyObj = document.getElementsByTagName('body').item(0);
         this.parent = createDiv(bodyObj,"",this.parentDivName);
      }
      else
      {
         this.parent = document.getElementById(this.parentDivName);
      }
      this.m_dvMqContainer = createDiv (this.parent, 'mqMap', 'mqContainer'+ this.UId);
   }


   this.callSlideImage = function(fDir)
   {
      var UID =  this.UId;
      var strUrl = this.mapState.getMapUrl();
      //netscape 7.1 got issues with the layout created for mapslide functionality. Hence, work BAU.

      if((__mqcontainer.browser.name=="netscape")&&(__mqcontainer.browser.version == 7.1))
      {
         getElementById(this.mapImageId).src = strUrl;
         return;
      }
      this.slider.setCurrentMap(this.mapImageId);
      this.slider.setNewMap("map0" + UID);
      this.slider.setMapContainer("mapcontainer" + UID);
      this.slider.setImageSlider(document.getElementById(this.slider.map0));
      this.slider.setImagePortView (document.getElementById(this.mapImageId));
      var pDir = (fDir)?fDir:"";
      this.slider.setpDir(pDir);
      var mapHeight = this.slider.getImagePortView().height;
      var mapWidth = this.slider.getImagePortView().width;

      // assuming prefix of fCurrMapId will be 'map0' always
      // clip the area according to the size of the map

      getElementById("mapcontainer"+ UID).style.clip = "rect(0px," + String(mapWidth + 2) + "px," + String(mapHeight + 2) + "px,0px)";
      getElementById("mapcontainer"+ UID).style.height = String(mapHeight)+"px";
      getElementById("mapcontainer"+ UID).style.width = String(mapWidth)+"px";
      //for dragging
      if (! fDir)
      {
         this.slider.imgSlider.style.zIndex = 1;
         this.slider.getImagePortView().style.zIndex = 0;
      }
      removeEvent(this.slider.imgSlider, "mousedown", dragStart);
      addEvent(this.slider.imgSlider, "mousedown", dragStart);
      this.slider.imgSlider.src = strUrl;
      //opera 7.5 got issues with subsequent image loading
      if((__mqcontainer.browser.name=="opera")&&(__mqcontainer.browser.version < 8.0))
      {
         pause(2500);
         slideImage(this.mapImageId);
      }
      else
      {
         removeEvent(this.slider.imgSlider,"load",slideImage);
         addEvent(this.slider.imgSlider,"load",slideImage);
      }
   }


   this.moveMap = function (newLeftPos, newTopPos)
   {
      var newTopPos = parseFloat(newTopPos);
      var newLeftPos = parseFloat(newLeftPos);
      var leftSign = this.slider.getSliderLeft() >=0?-1:1;
      var topSign  = this.slider.getSliderTop()  >=0?-1:1;
      var leftMove = Math.round( Math.abs(this.slider.getSliderLeft())>Math.abs(this.slider.getSliderTop())?this.slider.getIncrement() : Math.abs( (this.slider.getSliderLeft()/this.slider.getSliderTop())*this.slider.getIncrement()));
      var topMove = Math.round( Math.abs(this.slider.getSliderTop())>Math.abs(this.slider.getSliderLeft())?this.slider.getIncrement() :Math.abs( (this.slider.getSliderTop()/this.slider.getSliderLeft())*this.slider.getIncrement()));
      if(this.slider.getType() != "left")
      {
         this.slider.imgSlider.style.top = String(this.slider.getSliderTop() + topSign* newTopPos) + "px";
         this.slider.imgPortView.style.top = String(topSign * newTopPos) + "px";
      }
      if(this.slider.getType() != "top")
      {
         this.slider.imgSlider.style.left = String(this.slider.getSliderLeft() + leftSign*newLeftPos) + "px";
         this.slider.imgPortView.style.left = String(leftSign * newLeftPos) + "px";
      }
      if(newLeftPos == Math.abs(this.slider.getSliderLeft()) &&
         newTopPos == Math.abs(this.slider.getSliderTop()))
      {
         this.swapImageIds(this.mapImageId);
         this.slider.imgSlider.style.visibility = "hidden";
         return;
      }
      if((Math.abs(newLeftPos) + Math.abs(leftMove)) < Math.abs(this.slider.getSliderLeft()) || (Math.abs(newTopPos) + Math.abs(topMove)) < Math.abs(this.slider.getSliderTop()))
      {
         newTopPos += Math.abs(topMove);
         newLeftPos += Math.abs(leftMove);
      }
      if((this.slider.getType() != "top" && (Math.abs(newLeftPos) + Math.abs(leftMove)) >= Math.abs(this.slider.getSliderLeft())) ||
         (this.slider.getType() != "left" && (Math.abs(newTopPos) + Math.abs(topMove)) >= Math.abs(this.slider.getSliderTop())))
      {
         newTopPos = Math.abs(this.slider.getSliderTop());
         newLeftPos =Math.abs(this.slider.getSliderLeft());
      }
      var slide = "__mqcontainer.map." + this.mapImageId + ".MQMap.moveMap('" + newLeftPos + "','" + newTopPos + "')";
      setTimeout(eval("\"" + slide + "\""),this.slider.getDelayTime());
   }


   /**
    * SWAP PAN
    * @directional pan rollover
    */
   this.swapPan = function (d, s)
   {
       var fDir    = eval("__mqcontainer.art.data." + this.getPanDirection(d));
       var fState  = (s == 1) ? "On" : "";
       for (var i = 0, n = fDir.length; i < n; i++)
       {
           var fImg                                    = fDir[i];
           // XxXX pieces need adjustment
           var fImgId                                  = (fImg.indexOf("c") > 0) ? fImg.substring(0, fImg.length - 1) : fImg;
           getElementById(this.mapImageId + "-" + fImgId).src   = eval("__mqcontainer.art.img." + fImg + fState + ".src");
       }
   }//swapPan()

/**
 * GET PAN DIRECTION
 * @returns correct map direction to pan to based on image id
 */


this.getPanDirection = function (d)
{
    if((d.indexOf("a") > 0) || (d.indexOf("b") > 0))
    {   //spacer piece for side dir
        return d.substring(0,1); // sa -> s
    }
    else if(d.indexOf("x") > 0)
    {   //spacer piece for corner dir
        return d.substring(2,4); // wxsw -> sw
    }
    else if(d.length == 3)
    {   // upright leg for corner
        return d.substring(1,3); // wnw -> nw
    }
    return d;
} //getPanDirection()

/**
 * HEIGHLIGHT PAN
 * @directional pan rollover
 */
this.highLightPan = function highLightPan(d, s)
{
   var fDir    = eval("__mqcontainer.art.data." + this.getPanDirection(d));
   var fState  = (s == 1) ? "_hover" : "";
   for (var i = 0, n = fDir.length; i < n; i++)
   {
      var fImg                                    = fDir[i];
      // XxXX pieces need adjustment
      var fImgId                                  = (fImg.indexOf("c") > 0) ? fImg.substring(0, fImg.length - 1) : fImg;
      var firstLetter = fImg.substring(0,1);
      var newfImg;
      if(firstLetter == 'n')
      {
         newfImg = 'mqN'+ fImg.substring(1, fImg.length);
      }
      else if(firstLetter == 's')
      {
         newfImg = 'mqS'+ fImg.substring(1, fImg.length);
      }
      else if(firstLetter == 'e')
      {
         newfImg = 'mqE'+ fImg.substring(1, fImg.length);
      }
      else
      {
         newfImg = 'mqW'+ fImg.substring(1, fImg.length);
      }
      getElementById(this.mapImageId + "-" + fImgId).className   = newfImg + fState;
   }
}//swapPan()



   this.swapImageIds = function ()
   {
      var currMap0Id = this.slider.getNewMap();
      removeEvent(getElementById(this.mapImageId),"load",showPOILayers);
      addEvent(getElementById(currMap0Id),"load",showPOILayers);
      getElementById(this.mapImageId).id = "temp";
      getElementById(currMap0Id).id = this.mapImageId;
      getElementById("temp").id = currMap0Id;
      this.slider.setImageSlider(getElementById(currMap0Id));
      this.slider.setImagePortView(getElementById(this.mapImageId));
      this.slider.imgSlider.style.zIndex = 1;
      this.slider.getImagePortView().style.zIndex = 0;
      var size = this.locations.getSize();
      for(var i=0;i<size;i++)
      {
         var currLoc = this.locations.getAt(i);
         if(currLoc.poiLayer)
            currLoc.poiLayer.style.visibility = "visible";
      }
   }

   this.swapZoom = function (l, s, fZoomId)
   {

      var fElementId  = getElementById(fZoomId);
      var curZoomId   = fZoomId.split('-')[0] + "-z" + this.mapState.getZoomLevel();
      

      switch(s)
      {
         case 1: // mouse over
         case 2: // set new current notch
            fElementId.className  = "mqZ_hover";
            break;
         default:
            if(fZoomId != curZoomId)
            {
               fElementId.className  = "mqZ" + l ;
            }
      }
      var zoomId = getElementById(fZoomId);
      zoomId.title ="zoom "+fZoomId.split('z')[1];
     
      
     
   }


   this.swapZoomInOut = function (s,fZoomId)
   {
       var fElementId  = getElementById(fZoomId);
       var curZoomId   = fZoomId.split('-')[0] + "-z" + this.mapState.getZoomLevel();
       switch(s)
       {
           case 1: // mouse over
               fElementId.className = (fZoomId.split('-')[1] == "zin") ? "mqZin_hover" : "mqZout_hover";
                             
               break;
           default:
               if(fZoomId != curZoomId)
               {
                   fElementId.className  = (fZoomId.split('-')[1] == "zin")  ? "mqZin" : "mqZout";
               }
       }
       var zoomId = getElementById(fZoomId);
       zoomId.title ="zoom "+fZoomId.split('z')[1];
   }


   this.zoomMapOut = function ()
   {
       var thisZoom = this.mapState.getZoomLevel();
       if(thisZoom > 1)
       {
           thisZoom = thisZoom - 1;
           this.zoomMap(thisZoom);
       }
   }
   this.zoomMapIn = function ()
   {
       var thisZoom = this.mapState.getZoomLevel();
       if(thisZoom < 10)
       {
           thisZoom++;
           this.zoomMap(thisZoom);
       }
   }
   this.zoomMap = function (l)
   {
       newMapData  = new function()
       {
           this.action = "zoom";
           this.change =  l;
       }
       this.getNewMap(newMapData);
   }


   this.swapImage = function ()
   {
       var element = getElementById(this.mapImageId);

       var strUrl = this.mapState.getMapUrl();
       if(element)
       {
           element.src = strUrl;
       }
   }


   this.panMap = function (d)
   {
      d  = this.getPanDirection(d);
      newMapData  = new function()
      {
         this.action = "pan";
         this.change =  d;
      }
      this.getNewMap(newMapData);
   }


   this.dragMap = function (xx,yy)
   {
      mapObj = document.getElementById(this.mapImageId);
      var quarterWidth = mapObj.width/2;
      var quarterHeight = mapObj.height/2;
      newMapData  = new function()
      {
         this.action = "drag";
         this.x = quarterWidth + xx;
         this.y = quarterHeight + yy;
      }
      this.getNewMap(newMapData);
   }
   this.toggleRevert = function (fAction)
      {

         if((this.getRevertState() == 1) && (fAction == 1))
         {   // revert is already enabled
            return;
         }
         fRevertObj  = getElementById(this.mapImageId + "-revert");
         switch(fAction)
         {
            case 0: //disable
               var fImage  = __mqcontainer.art.img.mapRevertOff.src;
               var fAlt    = "";
               removeEvent(fRevertObj, "click", revertMap);// remove eventhandlers
               removeEvent(fRevertObj, "mouseout", swapRevert);
               removeEvent(fRevertObj, "mouseover", swapRevert);
               fRevertObj.className = "mqRevert";
               if(getElementById("revertState"))
                  getElementById("revertState").value="0";

               if(document.next&&document.next.url) {
                  var url = document.next.url.value;
                  url = url.replace(/revertState=[01]?/,"revertState=0");
                  document.next.url.value = url;
               }
               if(document.prev&&document.prev.url) {
                  var url = document.prev.url.value;
                  url = url.replace(/revertState=[01]?/,"revertState=0");
                  document.prev.url.value = url;
               }
               break;
            default: //enable
               var fImage  = __mqcontainer.art.img.mapRevert.src;
               var fAlt    = "Revert map to initial result.";
               removeEvent(fRevertObj, "click", revertMap); 
               addEvent(fRevertObj, "click", revertMap); // add eventhandlers
               removeEvent(fRevertObj, "mouseout", swapRevert);
               addEvent(fRevertObj, "mouseout", swapRevert);
               removeEvent(fRevertObj, "mouseover", swapRevert);
               addEvent(fRevertObj, "mouseover", swapRevert);
               fRevertObj.className = "mqReverton";
               if(getElementById("revertState")) {
                  getElementById("revertState").value="1";
                }
               if(document.next&&document.next.url) {
                  var url = document.next.url.value;
                  url = url.replace(/revertState=[01]?/,"revertState=1");
                  document.next.url.value = url;

               }
               if(document.prev&&document.prev.url) {
                  var url = document.prev.url.value;
                  url = url.replace(/revertState=[01]?/,"revertState=1");
                  document.prev.url.value = url;
               }
         }
         this.setRevertState(fAction);
         fRevertObj.setAttribute("alt", fAlt);
         fRevertObj.setAttribute("title", fAlt);
   }

}

function MQObjectCollection() {

   var m_items = new Array();

   this.add = function(obj){
      m_items.push(obj);
      return m_items.length;
   }

   this.getSize = function () {
      return m_items.length;
   }

   this.getAt = function(i){
      return m_items[i];
   }

   this.remove = function (iIndex) {
      return m_items.splice(iIndex, 1);
   }

   this.removeAll = function () {
      m_items = null;
      m_items = new Array();
   }

   this.contains = function (item) {
      for (var count = 0; count < this.getSize(); count++) {
         if (m_items[count] == item) {
            return true;
         }
      }
      return false;
   }
   this.getById = function (strId) {
       for (var count = 0; count < this.getSize(); count++) {
          if (m_items[count].getId() == strId) {
             return m_items[count];
          }
       }
       return null;
   }

}

function MQBaseLocation() {

   this.m_xmlDoc = null;
   this.m_xslDoc = null;

   this.setProperty = function (strPropName, strPropValue) {
      var strXPathExpression = "/location/" + strPropName;
      var ndNewProp = mqSetNodeText(this.m_xmlDoc,strXPathExpression,strPropValue);

      if ( ndNewProp == null) {
         var ndNewPropParent = this.m_xmlDoc.createElement(strPropName);
         var ndRoot = this.m_xmlDoc.documentElement.appendChild(ndNewPropParent);
         ndNewProp = mqSetNodeText(this.m_xmlDoc,strXPathExpression,strPropValue);
      }

      return ndNewProp;
   }

   this.getProperty = function (strPropName) {
      var strXPathExpression = "/location/" + strPropName;
      return mqGetXPathNodeText(this.m_xmlDoc,strXPathExpression);
   }

   this.loadXsl = function (strXsl) {
      this.m_xslDoc = mqCreateXMLDoc(strXsl);
   }

   this.xmlStr = function () {
      return mqXmlToStr(this.m_xmlDoc);
   }

   this.xslStr = function () {
      return mqXmlToStr(this.m_xslDoc);
   }

   this.setName = function (strName) {
      this.setProperty("name",strName);
   }

   this.getName = function () {
      return this.getProperty("name");
   }

   this.setIconId = function (strIconId) {
      this.setProperty("iconId",strIconId);
   }

   this.getIconId = function () {
      return this.getProperty("iconId");
   }

   this.setLatitude = function (strLatitude) {
      this.setProperty("latitude",strLatitude);
   }

   this.getLatitude = function () {
      return this.getProperty("latitude");
   }

   this.setLongitude = function (strLongitude) {
      this.setProperty("longitude",strLongitude);
   }

   this.getLongitude = function () {
      return this.getProperty("longitude");
   }

   this.setAddress = function (strAddress) {
      this.setProperty("address",strAddress );
   }

   this.getAddress = function () {
      return this.getProperty("address");
   }

   this.setCity = function (strCity) {
      this.setProperty("city",strCity);
   }

   this.getCity = function () {
      return this.getProperty("city");
   }

   this.setCounty = function (strCounty) {
      this.setProperty("county",strCounty);
   }

   this.getCounty = function () {
      return this.getProperty("county");
   }

   this.setStateProvince = function (strStateProvince) {
      this.setProperty("stateProvince",strStateProvince);
   }

   this.getStateProvince = function () {
      return this.getProperty("stateProvince");
   }

   this.setCountry = function (strCountry) {
      this.setProperty("country",strCountry);
   }

   this.getPostalCode = function () {
      return this.getProperty("postalCode");
   }

   this.setPostalCode = function (strPostalCode) {
      this.setProperty("postalCode",strPostalCode);
   }

   this.getCountry = function () {
      return this.getProperty("country");
   }

   this.setX = function (strX) {
      return this.setProperty("x",strX);
   }

   this.getX = function () {
      return this.getProperty("x");
   }

   this.setY = function (strY) {
      return this.setProperty("y",strY);
   }

   this.getY = function () {
      return this.getProperty("y");
   }

   this.setGeocodeQuality = function (strGeocodeQuality) {
      return this.setProperty("geocodeQuality",strGeocodeQuality);
   }

   this.getGeocodeQuality = function () {
      return this.getProperty("geocodeQuality");
   }

   this.setRecordId = function (strRecordId) {
      return this.setProperty("recordId",strRecordId);
   }

   this.getRecordId = function () {
      return this.getProperty("recordId");
   }

   this.getThumbNail = function () {
      return this.getProperty("thumbnail");
   }

   this.getIconSource = function() {
      return this.getProperty("iconsource");
   }

   this.setIconSource = function(strIconSource) {
      this.setProperty("iconsource",strIconSource);
   }

}

function MQSize (w, h) {

   var m_nHeight = new Number();
   var m_nWidth = new Number();
   if (w != null) { m_nWidth = w; }
   if (h != null) { m_nHeight = h; }

   this.setHeight = function(nHeight) {
      m_nHeight = nHeight;
   }

   this.setWidth = function(nWidth) {
      m_nWidth = nWidth;
   }

   this.getHeight = function() {
      return m_nHeight;
   }

   this.getWidth = function() {
      return m_nWidth;
   }
}

function MQPointXY (x, y) {

   var m_nX = new Number();
   var m_nY = new Number();
   if (x != null) { m_nX = x; }
   if (y != null) { m_nY = y; }

   this.setX = function(nX) {
      m_nX = nX;
   }

   this.setY = function(nY) {
      m_nY = nY;
   }

   this.getX = function() {
      return m_nX;
   }

   this.getY = function() {
      return m_nY;
   }
}

function MQPointLL (lat, lng) {

   var m_nLat = new Number();
   var m_nLng = new Number();
   if (lat != null) { m_nLat = lat; }
   if (lng != null) { m_nLng = lng; }

   this.setLat = function(nLat) {
      m_nLat = nLat;
   }

   this.setLng = function(nLng) {
      m_nLng = nLng;
   }

   this.getLat = function() {
      return m_nLat;
   }

   this.getLng = function() {
      return m_nLng;
   }
}

function MQLatLngConverter () {

   var m_nDecimal = new Number();
   var m_nDegrees = new Number();
   var m_nMinutes = new Number();
   var m_nSeconds = new Number();

   this.setLatLngDecimalDegrees = function(nLatLng) {
      m_nDecimal = nLatLng;
      m_nDegrees = nLatLng >= 0 ? Math.floor(m_nDecimal) : Math.ceil(m_nDecimal);
      m_nMinutes = Math.floor( Math.abs(m_nDecimal - m_nDegrees) * 60);
      m_nSeconds = Math.round( Math.abs( ( (Math.abs(m_nDecimal - m_nDegrees) * 60) - m_nMinutes) * 60));
   }

   this.setLatLngDegreesMinutesSeconds = function(nDegrees,nMinutes,nSeconds) {
      m_nDegrees = nDegrees;
      m_nMinutes = nMinutes;
      m_nSeconds = nSeconds;
      m_nDecimal = nDegrees + (nMinutes / 60 * (nDegrees >= 0 ? 1 : -1) ) + (nSeconds / 3600 * (nDegrees >= 0 ? 1 : -1) );
   }

   this.getDecimal = function() {
      return m_nDecimal;
   }

   this.getDegrees = function() {
      return m_nDegrees;
   }

   this.getMinutes = function() {
      return m_nMinutes;
   }

   this.getSeconds = function() {
      return m_nSeconds;
   }
}
function MQMapState()
{
   this.sessionid ="";
   this.zoomLvl ="";
   this.width ="";
   this.height ="";
   this.type ="";
   this.latitude ="";
   this.longitude ="";
   this.mapStyle ="";
   this.mapUrl ="";
   this.mapStyle = "style5";
   // setter and getter methods for above variables
   this.setMapStyle = function (strStyle) {
      this.mapStyle = strStyle;
   }
   this.getMapStyle = function () {
      return this.mapStyle;
   }
   this.setWidth = function(strWidth){
      this.width = strWidth;
   }
   this.getWidth = function(){
      return this.width;
   }
   this.setHeight = function(strHeight){
      this.height = strHeight;
   }
   this.getHeight = function(){
      return this.height;
   }
   this.setMapUrl = function(strMapUrl) {
      this.mapUrl = strMapUrl;
   }

   this.getMapUrl = function() {
      return this.mapUrl;
   }
   this.setSessionId = function(strSessionId) {
      this.sessionid = strSessionId;
   }

   this.getSessionId = function() {
      return this.sessionid;
   }
   this.setZoomLevel = function(strZoomLevel){
      this.zoomLvl = strZoomLevel;
   }

   this.getZoomLevel = function(){
      return this.zoomLvl;
   }

   this.setLatitude = function(strLatitude) {
      this.latitude = strLatitude;
   }
   this.getLatitude = function() {
      return this.latitude;
   }

   this.setLongitude = function(strLongitude) {
      this.longitude = strLongitude;
   }
   this.getLongitude = function() {
      return this.longitude;
   }

   this.load = function (xmlDoc, path) {
      this.sessionid     = mqGetXPathNodeText(xmlDoc,path+"/mapSessionId");
      this.zoomLvl       = mqGetXPathNodeText(xmlDoc,path+"/zoomLevel");
      this.width         = mqGetXPathNodeText(xmlDoc,path+"/width");
      this.height        = mqGetXPathNodeText(xmlDoc,path+"/height");
      this.type          = mqGetXPathNodeText(xmlDoc,path+"/type");
      this.latitude      = mqGetXPathNodeText(xmlDoc,path+"/latitude");
      this.longitude     = mqGetXPathNodeText(xmlDoc,path+"/longitude");
      this.m_strMapStyle = mqGetXPathNodeText(xmlDoc,path+"/mapStyle");
      this.mapUrl        = mqGetXPathNodeText(xmlDoc,path+"/request");
   }
}



function MQSlider() {

   this.map1="";
   this.map0="";
   this.mapcontainer="";
   this.imgSlider="";
   this.imgPortView = "";
   this.sliderLeftPos = null;
   this.sliderTopPos = null;
   this.newLeftPos = 0;
   this.newTopPos =0;
   this.pixdiv =15.0;
   this.type = "";
   this.pDir="";

   var delay = 10;
   var moveFactor = 2.222; //45% -> 2.222=100/45


   this.setpDir = function(pdir) {
         this.pDir = pdir;
      }

   this.setCurrentMap = function(strMap) {
      this.map1 = strMap;
   }
   this.setNewMap = function(strMap) {
      this.map0 = strMap;
   }
   this.setMapContainer = function(strMapContainer) {
      this.mapcontainer = strMapContainer;
   }

   this.setImageSlider = function(strImgSlider) {
      this.imgSlider = strImgSlider;
   }

   this.setImagePortView = function(strImgPortView) {
      this.imgPortView = strImgPortView;
   }

   this.setSliderLeft = function(strLeft) {
      this.sliderLeftPos = strLeft;
   }

   this.setSliderTop = function(strTop) {
      this.sliderTopPos = strTop;
   }

   this.setNewLeft = function( strLeft) {
      this.newLeftPos = strLeft;
   }

   this.setNewTop = function(strTop) {
      this.newTopPos = strTop;
   }

   this.setIncrement = function(strIncr) {
      this.pixdiv = strIncr;
   }
   this.setType = function(strType) {
      this.type = strType;
   }


   this.getpDir = function() {
       return this.pDir;
   }


   this.getCurrentMap = function() {
      return this.map1;
   }
   this.getNewMap = function() {
      return this.map0;
   }
   this.getMapContainer = function() {
      return this.mapcontainer;
   }

   this.getImageSlider = function() {
      return this.imgSlider;
   }

   this.getImagePortView = function() {
      return this.imgPortView;
   }

   this.getSliderLeft = function() {
      return this.sliderLeftPos;
   }

   this.getSliderTop = function() {
      return this.sliderTopPos;
   }

   this.getNewLeft = function( ) {
      return this.newLeftPos;
   }

   this.getNewTop = function() {
      return this.newTopPos;
   }

   this.getIncrement = function() {
      return this.pixdiv;
   }
   this.getType = function() {
      return this.type;
   }
   this.getDelayTime = function() {
      return delay;
   }
   this.setDelayTime = function(strTime) {
      delay = strTime;
   }
   this.getMoveFactor = function() {
      return moveFactor;
   }

   this.setMoveFactor = function(strFactor) {
      moveFactor = strFactor;
   }
}

