/*			----=====[ horizon ajax library ]====-----
				++++| Zorion Media |++++			*/


function $(element){
  var elements = typeof(element) == "object"? elements = element : document.getElementById(element);
  if(elements != null && elements != "[object Event]" ){
  	$$.callit(elements);
		return elements;
}
}




 var $$ = {
	o: ["getA","hasAttribut","setA","toggle","fizes","sizes","html","opac","remove","append"],
	callit: function(obj){
		var t = this.o;
		for(i=0; i < t.length; i++){
			obj[t[i]] = $$[t[i]];
			}
	},
	
	append: function(apobj){
	this.appendChild(apobj);
	},
	


	getA: function(t){
	var gt = this.getAttribute(t);
	if(browser.opera)gt = subDivs[no].t;
	return gt;
	},
	
	hasAttribut: function(attr){
	if(browser.ie) return this.outerHTML.match(/^<[^>]*>/)[0].indexOf(" " + attr + "=") > -1;
	else return this.hasAttribute(attr);
	},
	
	
	setA:  function(a,b){
	this.setAttribute(a,b);
	},









	
	toggle: function(t){
	var obj = this;
	if(obj.style.display == 'none' || (t != "" && obj.style.display == "")){
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
	}
	else{
		obj.style.display = 'none';
		obj.style.visibility = 'hidden';
	}
}, 
 remove: function(){
	this.parentNode.removeChild(this);
},



html: function(html){
	this.style.innerHTML = html;
},


fizes: function(){
return [this.offsetWidth,this.offsetHeight];
},

sizes: function(w,h){
if(w) this.style.width = w + "px";
if(h) this.style.height = h + "px";
},


opac: function(o){
this.style.opacity = (o / 10); 
this.style.MozOpacity = (o / 10); 
this.style.KhtmlOpacity = (o / 10); 
this.style.filter = "alpha(opacity=" + (o * 10) + ")";
}




}








/*
Object.prototype.getE = function(el){
if(!el) el = "DIV";
return this.getElementsByTagName(el);
}

styles




Object.prototype.printMe = function(){
var phead = ParentBox.getE('STYLE');
var p = window.open('','','width=600,height=300,resizable=1');
p.document.open("text/html");
p.document.write('<html><head><style type="text/css">' + phead[0].innerHTML + '</style></head><body class="print"><div class="print">' +  this.innerHTML + '</div></body></html>');
p.print();
p.close();
}

*/



function crtDiv(id,clss,elem,html,node){
if(!elem) elem = "DIV";
if(browser.ie) elem = "<" + elem + " name='" + id + "'>'";//better detection ie
var laDiv = document.createElement(elem);
laDiv.id = id;
if(!defined(id)|| id == "")laDiv.id = crtSess(5);
if(html) laDiv.innerHTML = html;
if(clss) laDiv.className = clss;
if(node) node.appendChild(laDiv);
return $(laDiv);
}


function crtSess(length){
  chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  pass = "";
  for(x=0;x<length;x++) pass += chars.charAt((Math.floor(Math.random() * 62)));
  return pass;
}


function getInnerText(elt) {
	var _innerText = elt.innerText;
	if (!defined(_innerText)) {_innerText = elt.innerHTML.replace(/<[^>]+>/g,"");}
	return _innerText;
}





Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) return true;
	}
	return false;
};


Array.prototype.remove = function(value){
var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) this.splice(i,1);
	}
}



Array.prototype.push = function(elem){
 this[this.length] = elem;
 }


Array.prototype.next = function(){
 var n = this.pop();
 this.unshift(n);
 return n;
 }
 
 Array.prototype.prev = function(){
 var n = this.shift();
 this.push(n);
 return n;
 }

Array.prototype.allf = function(){
for(var x=0;x<this.length;x++)this[x]();
}

Array.prototype.appendNodes = function(obj){
for(var x=0;x<this.length;x++) $(obj).append(this[x]);
}








String.prototype.isNumeric = function(){
return typeof this != "boolean" && this !== null && !isNaN(+ this);
}


String.prototype.pos = function(c){
return this.indexOf(c);
}







getSizeImg = function(sRc){
var newImg = new Image();
newImg.src = sRc;
// hier moet nog komen te staan wanneer het volledig geladen is... anders valt het niet te meten.
return [newImg.width,newImg.height];
}





var oEvent =	{
    _registry: null,
    Initialise: function(){
        if (this._registry == null){
            this._registry = [];
            // Register the cleanup handler on page unload.
            oEvent.Add(window, "unload", this.CleanUp);
        }
    },

    Add: function(obj, type, fn, useCapture){
        this.Initialise();
        if (typeof obj == "string") obj = $(obj);
        if (obj == null || fn == null) return false;

        // Mozilla/W3C listeners?
        if (obj.addEventListener){
            obj.addEventListener(type, fn, useCapture);
     
						obj.myflag = "test";
						obj.mydata = "123";
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: useCapture});
            return true;
        }

        // IE-style listeners?
        if (obj.attachEvent && obj.attachEvent("on" + type, function(){obj.f = fn;obj.f();} )){
        	obj.myflag = obj;

            this._registry.push({obj: obj, type: type, fn: fn, useCapture: false});
            return true;
        }
        return false;
    },
    
    Remove: function(obj, type, fn, useCapture){
        this.Initialise();
        if (typeof obj == "string") obj = $(obj);
        if (obj == null || fn == null) return false;

        // Mozilla/W3C listeners?
        if (obj.addEventListener){
            obj.removeEventListener(type, fn, useCapture);
            this._registry.remove({obj: obj, type: type, fn: fn, useCapture: useCapture});
            return true;
        }

        // IE-style listeners?
        if (obj.detachEvent && obj.detachEvent("on" + type, fn)){
            this._registry.remove({obj: obj, type: type, fn: fn, useCapture: false});
            return true;
        }
        return false;
    },


    //Cleans up all the registered event handlers.
    CleanUp: function(){
        for (var i = 0; i < oEvent._registry.length; i++){
            with (oEvent._registry[i]){
                // Mozilla/W3C listeners?
                if (obj.removeEventListener)	obj.removeEventListener(type, fn, useCapture);
                // IE-style listeners?
                else if (obj.detachEvent)		obj.detachEvent("on" + type, fn);
            }
        }
        // Kill off the registry itself to get rid of the last remaining references.
        oEvent._registry = null;
    }
};



function defined(a){
	if(a != undefined ) return true;
	return false;
}



function disTxt(obj){
if(browser.ie) obj.onselectstart = new Function('return false');
else {
	obj.onmousedown= function(){return false;};
	obj.onclick = function(){return true;};}
}


//onerror,onload, onbeforeunload,onresize
Function.prototype.startup = function(handler){if(!handler) handler = "load";oEvent.Add(window, handler, this);}
Function.prototype.endit = function(handler){if(!handler) handler = "load";oEvent.Remove(window, handler, this);}