/*
	Filename         :	indico.js
	Created by       :	Mark Thomas
	Last modified by :	Mark Thomas
	Created          :	20 June 2005 16:27:23
	Last Updated     :	6 October 2005 11:30:28
	Comments         :	v 1/1
*/

indicoAddLoad(function(){
	window.oIndico = new IndicoPage();
});


/****************************************************************************************
IndicoPage main Class
****************************************************************************************/ 

function IndicoPage(){
	if(!document.getElementsByTagName){
		return;
	};
	this.nPageID = document.getElementsByTagName("meta")[1].getAttribute("content");
	this.nParentID = document.getElementsByTagName("meta")[2].getAttribute("content");
	var aLinkSplit = String(document.getElementsByTagName("a")[0].href).split(".");
	this.sLanguage = aLinkSplit[aLinkSplit.length-1].split("?")[0];
};
IndicoPage.prototype.xmlHTTP = function(){
	if(window.ActiveXObject){
		if(this.__MSXML()){
			return new ActiveXObject(this.sMSXMLtype + ".XMLHTTP");
		};
	};
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	};
	return false;
};
IndicoPage.prototype.xmlDocument = function(){
	try{
		if(document.implementation && document.implementation.createDocument){
			var oDoc = document.implementation.createDocument("", "", null);
			return oDoc;
		};
		if(window.ActiveXObject){
			if(this.__MSXML()){
				return new ActiveXObject(this.sMSXMLtype + ".DOMDocument");
			}
		};
	}catch(e){};
	return false;	
};
IndicoPage.prototype.__MSXML = function(){
	if(!this.sMSXMLHTTPtype){
		this.aMSXML = new Array("MSXML2", "Microsoft", "MSXML", "MSXML3");
		var oTest;
		for(var i=0;i<this.aMSXML.length; i++){
			try{
				oTest = new ActiveXObject(this.aMSXML[i] + ".DOMDocument");
				oTest = new ActiveXObject(this.aMSXML[i] + ".XMLHTTP");
				this.sMSXMLtype = this.aMSXML[i];
				return this.sMSXMLtype;
			}catch(e){};
		};
	}else{
		return this.sMSXMLtype;
	};
};
/****************************************************************************************
addLoadEvent
****************************************************************************************/

function indicoAddLoad(oFunc) {
	var oOriginalOnLoad = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = oFunc;
	}else{
		window.onload = function(){
			oOriginalOnLoad();
			oFunc();
		};
	};
};
/****************************************************************************************
DOM additions
****************************************************************************************/

if(window.DOMParser && window.XMLSerializer && window.Node && Node.prototype && Node.prototype.__defineGetter__){
	Document.prototype.loadXML = function(s){
		var oDoc = (new DOMParser()).parseFromString(s, "text/xml");
		while(this.hasChildNodes())
	    	this.removeChild(this.lastChild);
		for(var i = 0; i < oDoc.childNodes.length; i++) {
			this.appendChild(this.importNode(oDoc.childNodes[i], true));
		};
	};
	Document.prototype.__defineGetter__("xml", function(){
		return (new XMLSerializer()).serializeToString(this);
	});
};