/* common.js
	Public Domain (Programmed by RobaQ[private@robaq.info] in 2003-2005.)
*/

// CONST or ENUM (っぽい)
// ろばQ屋本舗の基底URL
var ROBAQS_WORKSHOP_URL = "http://robaq.info/";

// DOM LEVEL 2 の nodeType[targetNode.nodeType - 1]
var nodeType = new Array(
	"Element",
	"Attribute",
	"Text",
	"CDATASection",
	"EntityReference",
	"Entity",
	"ProcessingInstruction",
	"Comment",
	"Document",
	"DocumentType",
	"DocumentFragment",
	"Notation"
);

// XML の各種名前空間
var namespace = {
	xml		: "http://www.w3.org/XML/1998/namespace",		// XML
	xhtml	: "http://www.w3.org/1999/xhtml",				// XHTML 1.0, XHTML Basic 1.0 and XHTML 1.1
	xhtml2	: "http://www.w3.org/2002/06/xhtml2",			// XHTML 2.0 (is not yet public. See: "http://www.w3.org/TR/xhtml2/")
	xlink	: "http://www.w3.org/1999/xlink",				// XLink
	xforms	: "http://www.w3.org/2002/xforms",				// XForms became W3C Recommendation on October 14, 2003. "http://www.w3.org/TR/xforms/".
	xframes	: "http://www.w3.org/2002/06/xframes",			// XFrames (is not yet public. See: "http://www.w3.org/TR/xframes/")
	rdf		: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",// RDF
	rss		: "http://purl.org/rss/1.0/",					// RDF Site Summary 1.0
	dc		: "http://purl.org/dc/elements/1.1/",			//
	dcterms	: "http://purl.org/dc/terms/"					//
};

// XML の各種公開識別子
var publicId = {
	xhtmlbacis10		: "-//W3C//DTD XHTML Basic 1.0//EN",
	xhtml10Strict		: "-//W3C//DTD XHTML 1.0 Strict//EN",
	xhtml10Transitional	: "-//W3C//DTD XHTML 1.0 Transitional//EN",
	xhtml10Frameset		: "-//W3C//DTD XHTML 1.0 Frameset//EN",
	xhtml11				: "-//W3C//DTD XHTML 1.1//EN",
	xhtml20				: "-//W3C//DTD XHTML 2.0//EN" // XHTML 2.0 (is not yet public. See: "http://www.w3.org/TR/xhtml2/")
};

// METHOD

// 嘘 addEventListener (useCapture 未対応)
if(document.implementation.hasFeature("Events", "2.0") === false){
	window.addEventListener = function(type, listener, useCapture){
		var event;
		oldListener = function(oldListener, appendListener){
			return function(){
				if(oldListener){
					oldListener();
				}
				appendListener();
			};
		}(window["on" + type], listener);
	}
}


function addEvent(targetObject, eventName, eventListener, useCapture){
	if(document.implementation.hasFeature("HTMLEvents", "2.0") === true){
		targetObject.addEventListener(eventName, eventListener, useCapture);
		return true;
	}else if(targetObject.attachEvent){// IE 6 for Win
		targetObject.attachEvent("on" + eventName, eventListener);
		return true;
	}
	return false;
}

// FUNCTION

// xhtml の noscript に CSS の "display:none;" を指定します。
if(document.implementation.hasFeature("CSS", "2.0") === true){
	window.addEventListener('load', function(){

		var noscriptElements = null;
		if(document.documentElement.namespaceURI !== null){
			if(document.implementation.hasFeature("core", "2.0") === true){
				noscriptElements = document.getElementsByTagNameNS(namespace.xhtml, "noscript");
			}
		}else if(document.documentElement.namespaceURI === null){
			if(document.implementation.hasFeature("XML", "1.0") === true){
				noscriptElements = document.getElementsByTagName("noscript");
			}
		}

		if(noscriptElements === null){
			return void(0);
		}

		for(var i = 0, len = noscriptElements.length; i < len; i++){
			noscriptElements[i].style.display = "none";
		}
	}, false);
}
