//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright  2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;
using Dom;


namespace Dom{
	
	/// <summary>
	/// Handles various standard attribute DOM functions.
	/// This is an extended set which is likely to be unused, but is here for compliance.
	/// </summary>

	public partial class Node{
		
		/// <summary>Gets an attribute as a boolean value.</summary>
		internal bool GetBoolAttribute(string name){
			string v=getAttribute(name);
			
			if(!string.IsNullOrEmpty(v)){
				if(v=="0" || v.ToLower()=="false"){
					return false;
				}
				
				return true;
				
			}
			
			return false;
		}
		
		/// <summary>Sets an attribute as a boolean value.</summary>
		internal void SetBoolAttribute(string name,bool value){
			setAttribute("name", value?"":null);
		}
		
		/// <summary>Get the value of an attribute by name. Generally element[name] is better.</summary>
		public AttributeNode getAttributeNodeNS(string ns,string name){
			return new AttributeNode(this,name,getAttribute(ns+":"+name),ns);
		}
		
		/// <summary>Set the named attribute. element[name] is generally better.</summary>
		public void setAttributeNodeNS(AttributeNode node){
			setAttribute(node.name, node.value);
		}
		
		/// <summary>Get the value of an attribute by name. Generally element[name] is better.</summary>
		public AttributeNode getAttributeNode(string name){
			return new AttributeNode(this,name,getAttribute(name));
		}
		
		/// <summary>Does this element have the named attribute? element[name] is generally better.</summary>
		public bool hasAttributeNode(AttributeNode node){
			return hasAttribute(node.name);
		}
		
		/// <summary>Set the named attribute. element[name] is generally better.</summary>
		public void setAttributeNode(AttributeNode node){
			setAttribute(node.name, node.value);
		}
		
		/// <summary>Remove the named attribute. element[name] is generally better.</summary>
		public void removeAttributeNode(AttributeNode node){
			removeAttribute(node.name);
		}
		
	}
	
}