{% extends 'schema_viewer/oxygen/oxygen_base.html' %}
{% load static %}

{% block extra_styles %}
    <link rel="stylesheet" href="{% static "schema_viewer/css/docHtml.css" %}" type="text/css" />
{% endblock %}

{% block extra_scripts %}
    <script type="text/javascript">
        var propertiesBoxes= ['properties_NistStreams_1.3.xsd',
				'properties_Motion',
				'properties_ToolGroup',
				'properties_ToolSuffix',
				'properties_Unit',
				'properties_SequenceNumber',
				'properties_PalletNumber'];
        var facetsBoxes= new Array('facets_IntegerValueType');
        var usedByBoxes= ['usedBy_MotionType',
                        'usedBy_ToolGroupType',
                        'usedBy_ToolSuffixType',
                        'usedBy_UnitType',
                        'usedBy_SequenceNumberType',
                        'usedBy_PalletNumberType'];
        var sourceBoxes= ['source_Motion',
                        'source_ToolGroup',
                        'source_ToolSuffix',
                        'source_Unit',
                        'source_SequenceNumber',
                        'source_PalletNumber',
                        'source_IntegerValueType',
                        'source_MotionType',
                        'source_ToolGroupType',
                        'source_ToolSuffixType',
                        'source_UnitType',
                        'source_SequenceNumberType',
                        'source_PalletNumberType'];
        var diagramBoxes= ['diagram_Motion',
                        'diagram_ToolGroup',
                        'diagram_ToolSuffix',
                        'diagram_Unit',
                        'diagram_SequenceNumber',
                        'diagram_PalletNumber',
                        'diagram_IntegerValueType',
                        'diagram_MotionType',
                        'diagram_ToolGroupType',
                        'diagram_ToolSuffixType',
                        'diagram_UnitType',
                        'diagram_SequenceNumberType',
                        'diagram_PalletNumberType'];
        var annotationBoxes= ['annotations_Motion',
                        'annotations_ToolGroup',
                        'annotations_ToolSuffix',
                        'annotations_Unit',
                        'annotations_SequenceNumber',
                        'annotations_PalletNumber',
                        'annotations_IntegerValueType',
                        'annotations_MotionType',
                        'annotations_ToolGroupType',
                        'annotations_ToolSuffixType',
                        'annotations_UnitType',
                        'annotations_SequenceNumberType',
                        'annotations_PalletNumberType'];
        var button_prefix = 'button_';

        /**
        * Returns an element in the current HTML document.
        *
        * @param elementID Identifier of HTML element
        * @return               HTML element object
        */
        function getElementObject(elementID) {
            var elemObj = null;
            if (document.getElementById) {
                elemObj = document.getElementById(elementID);
            }
            return elemObj;
        }

        /**
        * Switches the state of a collapseable box, e.g.
        * if it's opened, it'll be closed, and vice versa.
        *
        * @param boxID Identifier of box
        */
        function switchState(boxID) {
            var boxObj = getElementObject(boxID);
            var buttonObj = getElementObject(button_prefix + boxID);
            if (boxObj == null || buttonObj == null) {
                // Box or button not found
            } else if (boxObj.style.display == "none") {
                // Box is closed, so open it
                openBox(boxObj, buttonObj);
            } else if (boxObj.style.display == "block") {
                // Box is opened, so close it
                closeBox(boxObj, buttonObj);
            }
        }

        /**
        * Opens a collapseable box.
        *
        * @param boxObj       Collapseable box
        * @param buttonObj Button controlling box
        */
        function openBox(boxObj, buttonObj) {
            if (boxObj == null || buttonObj == null) {
                // Box or button not found
            } else {
                // Change 'display' CSS property of box
                boxObj.style.display = "block";

                // Change text of button
                if (boxObj.style.display == "block") {
                    buttonObj.src = "img/btM.gif";
                }
            }
        }

        /**
        * Closes a collapseable box.
        *
        * @param boxObj       Collapseable box
        * @param buttonObj Button controlling box
        */
        function closeBox(boxObj, buttonObj) {
            if (boxObj == null || buttonObj == null) {
                // Box or button not found
            } else {
                // Change 'display' CSS property of box
                boxObj.style.display = "none";

                // Change text of button
                if (boxObj.style.display == "none") {
                    buttonObj.src = "img/btP.gif";
                }
            }
        }

       function switchStateForAll(buttonObj, boxList) {
            if (buttonObj == null) {
                // button not found
            } else if (buttonObj.value == "+") {
                // Expand all
                expandAll(boxList);
                buttonObj.value = "-";
            } else if (buttonObj.value == "-") {
                // Collapse all
                collapseAll(boxList);
                buttonObj.value = "+";
            }
        }

        /**
        * Closes all boxes in a given list.
        *
        * @param boxList Array of box IDs
        */
        function collapseAll(boxList) {
            var idx;
            for (idx = 0; idx < boxList.length; idx++) {
                var boxObj = getElementObject(boxList[idx]);
                var buttonObj = getElementObject(button_prefix + boxList[idx]);
                closeBox(boxObj, buttonObj);
            }
        }

        /**
        * Open all boxes in a given list.
        *
        * @param boxList Array of box IDs
        */
        function expandAll(boxList) {
            var idx;
            for (idx = 0; idx < boxList.length; idx++) {
                var boxObj = getElementObject(boxList[idx]);
                var buttonObj = getElementObject(button_prefix + boxList[idx]);
                openBox(boxObj, buttonObj);
            }
        }

        /**
         * Update the message presented in the title of the html page.
         * - If the documentation was splited by namespace we present something like: "Documentation for namespace 'ns'"
         * - If the documentation was splited by location we present somehing like: "Documentation for 'Schema.xsd'"
         * - If no split we always present: "Documentation for 'MainSchema.xsd'"
         */
        function updatePageTitle(message) {
{#            top.document.title = message;#}
        }



         /**
          * Finds an HTML element by its ID and makes it floatable over the normal content.
          *
          * @param x_displacement The difference in pixels to the right side of the window from
          *           the left side of the element.
          * @param y_displacement The difference in pixels to the right side of the window from
          *           the top of the element.
          */
         function findAndFloat(id, x_displacement, y_displacement){

            var element = getElementObject(id);

            window[id + "_obj"] = element;

            if(document.layers) {
               element.style = element;
            }

            element.current_y = y_displacement;
            element.first_time = true;

            element.floatElement = function(){
               // It may be closed by an user action.

               // Target X and Y coordinates.
               var x, y;

               var myWidth = 0, myHeight = 0;
               if( typeof( window.innerWidth ) == 'number' ) {
                  //Non-IE
                  myWidth = window.innerWidth;
                  myHeight = window.innerHeight;
               } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myWidth = document.documentElement.clientWidth;
                  myHeight = document.documentElement.clientHeight;
               } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myWidth = document.body.clientWidth;
                  myHeight = document.body.clientHeight;
               }


               x = myWidth - x_displacement;

               var ns = (navigator.appName.indexOf("Netscape") != -1);
               y = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ?
                  document.documentElement.scrollTop : document.body.scrollTop;
               y = y + y_displacement;

               // The current y is the current coordinate of the floating element.
               // This should be at the limit the y target coordinate.
               this.current_y += (y - this.current_y)/1.25;

               // Add the pixels constant after the values
               // and move the element.
               var px = document.layers ? "" : "px";
               this.style.left =  x + px;
               this.style.top =  this.current_y + px;

               setTimeout(this.id + "_obj.floatElement()", 100);
            };;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

            element.floatElement();
            return element;
          }

         /**
          * Finds an HTML element by its ID and makes it floatable over the normal content.
          *
          * @param x_displacement The difference in pixels to the right side of the window from
          *           the left side of the element.
          * @param y_displacement The difference in pixels to the right side of the window from
          *           the top of the element.
          */
         function selectTOCGroupBy(id, isChunked, indexFileLocation, indexFileNamespace, indexFileComponent){

            if (!isChunked) {
             var selectIds = ['toc_group_by_namespace', 'toc_group_by_location', 'toc_group_by_component_type'];
             // Make all the tabs invisible.
               for (var i = 0; i < 3; i++){
                  var tab = getElementObject(selectIds[i]);
                  tab.style.display = 'none';
               }
               var selTab = getElementObject(id);
               selTab.style.display = 'block';
            } else {
             if (id == 'toc_group_by_namespace') {
               parent.indexFrame.location = indexFileNamespace;
             } else  if (id == 'toc_group_by_location') {
               parent.indexFrame.location = indexFileLocation;
             } else  if (id == 'toc_group_by_component_type') {
              parent.indexFrame.location = indexFileComponent;
             }
            }
         }
          // The namespace is the selected option in the TOC combo.

         // Floats the toolbar.
         var globalControls = getElementObject("global_controls");

         if(globalControls != null){
             var browser=navigator.appName;
             var version = parseFloat(navigator.appVersion.split('MSIE')[1]);

             var IE6 = false;
             if ((browser=="Microsoft Internet Explorer") && (version < 7)){
                IE6 = true;
             }

             //alert (IE6 + " |V| " + version);

             if(IE6){
                // On IE 6 the 'fixed' property is not supported. We must use javascript.
                 globalControls.style.position='absolute';
                 // The global controls will do not exist in the TOC frame, when chunking.
                 findAndFloat("global_controls", 225, 30);
             } else {
                  globalControls.style.position='fixed';
             }

             globalControls.style.right='0';
         }
    </script>
{% endblock %}