<?xml version="1.0" encoding="UTF-8"?>
<rmml>
<!--
$RCSfile: rnmc_stdZone.xml $
$Revision: 903 $
$State: Exp $
$Locker:  $

last change: $Date: 2009-01-23 20:29:53 +0300 (Пт, 23 янв 2009) $
             $Author: Pavel $

  Lacerta Project
  version 1.0.0.1
  Copyright (C) 2008 RNMC
-->
<composition name="rnmc_stdZone" class="rnmc_stdMediaObject">
<script><![CDATA[
  this.type = "rnmc_stdZone";
  this.id = null;
  this.visibility = OBJECT_VISIBILITY_TRUE;
  this.visited = false;
  //  событие после которго зона считается найденной
  //  допускаются следующие значения:
  //  EVENT_ON_PRESS      //  нажатие кнопки мыши
  //  EVENT_ON_RELEASE    //  отпускание кнопки мыши
  //  EVENT_ON_ROLLOVER    //  наезд на объект
  //  EVENT_ON_ROLLOUT    //  съезд с объекта
  this.visitedEvent = EVENT_ON_PRESS;

  this.optional = false;

  this.zoneHitArea = null;

  this.zoneObjects = null;

  function GetCursorType(strType){
    switch(strType){
    case "NoCursor":
      return 0;
      break;
    case "Normal":
      return 1;
      break;
    case "Active":
      return 2;
      break;
    case "Wait":
      return 3;
      break;
    case "Beam":
      return 4;
      break;
    case "Drag":
      return 5;
      break;
    case "Size1":
      return 6;
      break;
    case "Size2":
      return 7;
      break;
    case "Size3":
      return 8;
      break;
    case "Size4":
      return 9;
      break;
    case "Zoom":
      return 10;
      break;
    case "ZoomD":
      return 11;
      break;
    default:
      return 1;
    }
  }

  function initFromNode(srcNode){
    var xmlNode = null;
    var xmlAttributeMap = null;
    var xmlAttribute = null;

    this.zoneObjects = new Array();

    xmlAttributeMap = srcNode.attributes;
    if (xmlAttributeMap){
      xmlAttribute = xmlAttributeMap.getNamedItem("id");
      if (xmlAttribute != null && xmlAttribute.specified){
        this.id = xmlAttribute.value;
      }
      xmlAttribute = xmlAttributeMap.getNamedItem("visible");
      if (xmlAttribute != null && xmlAttribute.specified){
        if(xmlAttribute.value.toLowerCase() == "true")
          this.visibility = OBJECT_VISIBILITY_TRUE;
        else if(xmlAttribute.value.toLowerCase() == "false")
          this.visibility = OBJECT_VISIBILITY_FALSE;
      }
      xmlAttribute = xmlAttributeMap.getNamedItem("enabled");
      if (xmlAttribute != null && xmlAttribute.specified
        && xmlAttribute.value.toLowerCase() == "false")
        this.disabled = true;
    }

    xmlNode = srcNode.firstChild;  
    var cursor_type = -1;
    while(xmlNode){
      if(xmlNode.nodeName == "param"){
        this.parseParamNode(xmlNode);
        xmlAttributeMap = xmlNode.attributes;
        if (xmlAttributeMap){
          xmlAttribute = xmlAttributeMap.getNamedItem("optional");
          if (xmlAttribute != null && xmlAttribute.specified){
            if(xmlAttribute.value == "true")
              this.optional = true;
            else if(xmlAttribute.value == "false")
              this.optional = false;
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("cursor");
          if (xmlAttribute != null && xmlAttribute.specified){
            cursor_type = GetCursorType(xmlAttribute.value);
            this.useHandCursor = cursor_type;
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("visitedEvent")
          if (xmlAttribute != null && xmlAttribute.specified){
            switch (xmlAttribute.value.toLowerCase())
            {
              case "onpress":
                this.visitedEvent = EVENT_ON_PRESS;
                break;

              case "onrelease":
                this.visitedEvent = EVENT_ON_RELEASE;
                break;

              case "onrollover":
                this.visitedEvent = EVENT_ON_ROLLOVER;
                break;

              case "onrollout":
                this.visitedEvent = EVENT_ON_ROLLOUT;
                break;
            }
          }
        }
      } else if(xmlNode.nodeName == "area"){
        if(xmlNode.textContent){
          var newObject = new Button();
          newObject.enabled = false;
          newObject.hitArea = xmlNode.textContent;
          xmlAttributeMap = xmlNode.attributes;
          if (xmlAttributeMap){
            xmlAttribute = xmlAttributeMap.getNamedItem("x");
            if (xmlAttribute != null && xmlAttribute.specified){
              newObject.x = parseInt(xmlAttribute.value);
            }
            xmlAttribute = xmlAttributeMap.getNamedItem("y");
            if (xmlAttribute != null && xmlAttribute.specified){
              newObject.y = parseInt(xmlAttribute.value);
            }
            xmlAttribute = xmlAttributeMap.getNamedItem("depth");
            if (xmlAttribute != null && xmlAttribute.specified){
              newObject.depth = parseInt(xmlAttribute.value);
            }
            xmlAttribute = xmlAttributeMap.getNamedItem("cursor");
            if (xmlAttribute != null && xmlAttribute.specified){
              newObject.useHandCursor = GetCursorType(xmlAttribute.value);
            } else if ( cursor_type != -1 ) {
              newObject.useHandCursor = cursor_type;
            }
          }
          newObject.parent = this;
          this.zoneObjects.push(newObject);
        }
      } else if(xmlNode.nodeName == "mask"){
        xmlAttributeMap = xmlNode.attributes;
        if (xmlAttributeMap){
          var newObject = new Image();
          newObject.visible = false;
          newObject.enabled = false;
          newObject.parent = this;
          xmlAttribute = xmlAttributeMap.getNamedItem("x");
          if (xmlAttribute != null && xmlAttribute.specified){
            newObject.x = parseInt(xmlAttribute.value);
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("y");
          if (xmlAttribute != null && xmlAttribute.specified){
            newObject.y = parseInt(xmlAttribute.value);
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("depth");
          if (xmlAttribute != null && xmlAttribute.specified){
            newObject.depth = parseInt(xmlAttribute.value);
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("src");
          if (xmlAttribute != null && xmlAttribute.specified){
            newObject.src = xmlAttribute.value;
          }
          xmlAttribute = xmlAttributeMap.getNamedItem("cursor");
          if (xmlAttribute != null && xmlAttribute.specified){
            newObject.useHandCursor = GetCursorType(xmlAttribute.value);
          } else if ( cursor_type != -1 ) {
            newObject.useHandCursor = cursor_type;
          }
          newObject.hitArea = "opaque";
          this.zoneObjects.push(newObject);
        }
      } else if(xmlNode.nodeName == "actions"){
        this.parseActionsNode(xmlNode);
      } else if(xmlNode.nodeName == "hint"){
        this.parseHintNode(xmlNode);
      } else if(xmlNode.nodeName == "title"){
        this.parseTitleNode(xmlNode);
      } else if(xmlNode.nodeName == "attach"){
        this.parseAttachNode(xmlNode);
      } else if(xmlNode.nodeName == "control"){
        this.parseControlNode(xmlNode);
      } else if(xmlNode.nodeName == "effects"){
        this.parseEffectsNode(xmlNode);
      } else if(xmlNode.nodeName == "objectives"){
        this.parseObjectivesNode(xmlNode);
      } else if(xmlNode.nodeName == "properties"){
        parsePropertiesNode(xmlNode);
      } else if(xmlNode.nodeName == "conditions"){
        var conditionNode = xmlNode.firstChild;
        while(conditionNode){
          if(conditionNode.nodeName == "condition"){
            this.parseConditionNode(conditionNode);
          }
          conditionNode = conditionNode.nextSibling;
        }
        this.parseConditionNode(xmlNode);
      }
      xmlNode = xmlNode.nextSibling;
    }

    return true;
  }
  
  function unloadObject(){
  }

  function showObject(){
  this.objectContent = this;
  var objectPosition = this.getPosition();
  this.setPosition(objectPosition[0], objectPosition[1],
                     objectPosition[2], objectPosition[3],
                     this.objectDepth);
  this.objectContent.opacity = this.objectOpacity;
    if(this.zoneObjects){
      for(var i = 0; i < this.zoneObjects.length; i++){
        this.zoneObjects[i].enabled = true;
      }
    }
    rnmc_stdMediaObject_showObject();
  }

  function hideObject(){
    if(this.zoneObjects){
      for(var i = 0; i < this.zoneObjects.length; i++){
        this.zoneObjects[i].enabled = false;
      }
    }
    rnmc_stdMediaObject_hideObject();
  }

  //  обработчики событий
  function onPressHandler(){
    rnmc_stdMediaObject_onPressHandler();

      if(this.visitedEvent == EVENT_ON_PRESS && "notifyZoneVisited" in parent){
        this.visited = true;
        parent.notifyZoneVisited(this.zoneId);
      }
  }

  function zone_onRelease(){
  rnmc_stdMediaObject_onReleaseHandler();

    if(this.visitedEvent == EVENT_ON_RELEASE && "notifyZoneVisited" in parent){
      this.visited = true;
      parent.notifyZoneVisited(this.zoneId);
    }
  }

  function onRollOverHandler(){
  rnmc_stdMediaObject_onRollOverHandler();
  
    if(this.visitedEvent == EVENT_ON_ROLLOVER && "notifyZoneVisited" in parent){
      this.visited = true;
      parent.notifyZoneVisited(this.zoneId);
    }
  }

  function zone_onRollout(){
    rnmc_stdMediaObject_onRollOutHandler();

    if(this.visitedEvent == EVENT_ON_ROLLOUT && "notifyZoneVisited" in parent){
      this.visited = true;
      parent.notifyZoneVisited(this.zoneId);
    }
  }
]]></script>
</composition>
</rmml>
