﻿/**
*
*  uno.xml.presentmore.js 
*  by Hideki Yamamoto eu-gsm[+393453332248]
*  Version Alpha 0.0.3.0
*  This file is part of the uno project.
*  The user must agree with the terms specified in
*
*  ©Hideki Yamamoto, all rights reserved.
*
*  Licence       : Http://www.unodot.net/framework/current/uno.licence.txt
*  Documentation : Http://www.unodot.net/framework/current/uno.js.usage.txt
*  History       : Http://www.unodot.net/framework/current/uno.js.history.txt
*
**/
//if(!uno.xml.present){alert('uno.xml.presentmore.js requires uno.xml.present.js');}
uno.xml.appendselect = function(node) {
    var select_elm = document.createElement('select');
    var selected = uno.xml.attributevalue(node.getAttributeNode('selected'));
    var opts = node.getElementsByTagName('option');
    for (var e = 0 ; e<opts.length ; e++){
        uno.xml._appendoption(select_elm,selected,opts[e]);}
    var parent_id = uno.xml.attributevalue(node.getAttributeNode('parent'));
    $(parent_id).appendChild(select_elm);
};
uno.xml._appendoption = function(select_elm,selected,node) {
  var onodevalue = uno.xml.attributevalue(node.getAttributeNode('value'));
  var onodehtml = uno.xml.nodeinnerxml(node);
  var opt = document.createElement('option');
  if (selected == onodevalue){opt.setAttribute('selected', 'selected');} 
  opt.setAttribute('value', onodevalue);
  opt.innerHTML = onodehtml;   
  $(select_elm).appendChild(opt);
};
uno.xml.getchild = function(node,tag){
    for (var i=0;i<node.childNodes.length;i++){
        if (node.childNodes[i].nodeName == tag){return node.childNodes[i];}
    }return null;};
uno.xml.getchilds = function(node,tag){
    var xx = new Array();
    for (var i=0;i<node.childNodes.length;i++){
        if (node.childNodes[i].nodeName == tag){xx[xx.length] = node.childNodes[i];}
    }return xx;};
uno.xml.firstchildinnerxml = function(node,tag){
    var n = uno.xml.getchild(node,tag);
    if (n){return uno.xml.nodeinnerxml(n);
    }return null;};