var pz = {
	event: [],
	specialStyles: [],
	initialized: false,
	functions: [],
	pzEs: [],
	uniqueIdCounter: 0,
	isIE: false,
	w3c: false,
	emptypzE: 0,
	mouse: {x: 0, y: 0},
	
	cache: function(url)
	{
		var image = new Image();
		image.src = url;
	},
	
	start: function()
	{		
		if(document.addEventListener)
			document.addEventListener('DOMContentLoaded', pz.initialize, false);
			
		pz.isIE = navigator.appVersion.match(/MSIE/);
		
		pz.w3c = 	typeof document.getElementsByTagName != 'undefined' &&
					typeof document.addEventListener != 'undefined';
					
		window.onload = function()
		{
			pz.initialize();
		}
		
		if(/KHTML|WebKit/i.test(navigator.userAgent)) 
		{
			if(/loaded|complete/.test(document.readyState)) 
			{
				pz.initialize();
			} 
			else 
			{
				setTimeout(pz.start, 100);
			}
		} 
		else if(pz.isIE)
		{			
			try 
			{
				document.documentElement.doScroll('left');
			} 
			catch(error) 
			{
				setTimeout(pz.start, 100);
				return;
			}
			
			pz.initialize();
		}
	},
	
	initialize : function()
	{
		if(pz.initialized)
			return false;
		
		pz.$(document).mousemove(function(event)
		{
			var position = pz.getEventPosition(event);
			pz.mouse.x = position.x;
			pz.mouse.y = position.y;
		});
			
		pz.specialStyles['opacity'] = pz.setOpacity;
		
		pz.initialized = true;
		
		var i = 0;
		for(; i < pz.event.length; i++)
		{
			pz.event[i]();
		}
		
		pz.event = 0;
	},
	
	each: function(selector, f)
	{
		pz.getElementsBySelector(selector, undefined, 0, f);
	},
	
	createXMLHttpRequest : function()
	{
		if(typeof XMLHttpRequest != 'undefined')
		{
			return new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
			var array = ['Microsoft.XMLHTTP', 'Microsoft.XmlHttp', 'MSXML2.XmlHttp', 'MSXML2.XmlHttp.3.0',  'MSXML2.XmlHttp.4.0', 'MSXML2.XmlHttp.5.0'];
		    for (var i = array.length - 1; i >= 0; i--) 
			{
				try {
					httpObj = new ActiveXObject(array[i]);
					return httpObj;
				} 
				catch(e) 
				{
					//do nothing and we'll continue
				}
			}
		}
		
		return null;
	},
	
	request : function(request, callback)
	{		
		var xmlHttpRequest = pz.createXMLHttpRequest();
		if(xmlHttpRequest != null)
		{
			xmlHttpRequest.open('GET', request, true);
			xmlHttpRequest.setRequestHeader('If-Modified-Since', new Date(0));
			
			xmlHttpRequest.onreadystatechange = function() 
			{			
				if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) 
				{
					eval(callback(xmlHttpRequest.responseText));
					xmlHttpRequest = null;
				}
				else if(xmlHttpRequest.readyState == 4)
				{
					eval(callback());
					xmlHttpRequest = null;
				}
				else
				{
					//alert('received ' + xmlHttpRequest.status + ' ' + xmlHttpRequest.readyState + '(' + request + ' -> ' + xmlHttpRequest.responeText + ')');
				}
			}
			
			xmlHttpRequest.send(null);
		}
		else
		{
			eval(callback()); //call the callback with no text defined
		}
	},
	
	getEventPosition: function(e)
	{
		var position = { x : 0, y : 0 };
		
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) {
			position.x = e.pageX;
			position.y = e.pageY;
		}
		else if (e.clientX || e.clientY) {
			position.x = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			position.y = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		
		return position;
	},
	
	getCursor: function()
	{
		return pz.mouse;
	},
	
	getElementPosition: function(element)
	{
		if(typeof element == 'undefined')
			return false;
			
		var position = { x: element.offsetLeft, y: element.offsetTop };
		if(element.offsetParent)
		{
			while(element = element.offsetParent)
			{
				position.x += element.offsetLeft;
				position.y += element.offsetTop;
			}
		}
		
		return position;
	},
	
	getDocumentSize: function()
	{
		if(typeof window.innerWidth != 'undefined')
			return {w: window.innerWidth, h: window.innerHeight};
		else if(typeof document.body.clientWidth != 'undefined')
			return {w: document.body.clientWidth, h: document.body.clientHeight};
		else
			return {w: document.documentElement.clientWidth, h: document.documentElement.clientHeight};
	},
	
	post : function(request, postdata, callback)
	{
		var xmlHttpRequest = pz.createXMLHttpRequest();
		if(xmlHttpRequest != null)
		{
			xmlHttpRequest.open('POST', request, true);
			xmlHttpRequest.setRequestHeader('If-Modified-Since', new Date(0));
			xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			
			xmlHttpRequest.onreadystatechange = function() 
			{			
				if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) 
				{
					eval(callback(xmlHttpRequest.responseText));
					xmlHttpRequest = null;
				}
				else if(xmlHttpRequest.readyState == 4)
				{
					eval(callback());
					xmlHttpRequest = null;
				}
			}
			
			if(typeof postdata != 'string')
			{
				var array = postdata;
				postdata = '';
				
				var value;
				for(value in array)
				{
					if(postdata.length != 0)
						postdata += '&';
						
					postdata += escape(value) + '=' + escape(array[value]);
				}
			}
			
			xmlHttpRequest.send(postdata);
		}
		else
		{
			eval(callback());
		}
	},
	
	addLoadEvent : function(e)
	{
		if(pz.initialized)
			e();
		else
			pz.event[pz.event.length] = e;
	},
	
	addEvent: function(e, m, f)
	{
		if(typeof e == 'undefined')
			return false;
			
		if(e.addEventListener)
			e.addEventListener(m, f, false);
		else if(e.attachEvent)
		{
			var key = '{KEY::' + e.uniqueID + '::' + m + '::' + f + '}';
			var fun = pz.functions[key];
			if(typeof fun != 'undefined')
				return false;
				
			fun = function()
			{
				f.call(e);
			};
			
			pz.functions[key] = fun; 
			e.attachEvent('on' + m, fun);
			
			key = null;
		}
	},
	
	removeEvent: function(e, m, f)
	{
		if(typeof e == 'undefined')
			return;
	
		if(e.removeEventListener)
			e.removeEventListener(m, f, false);
		else if(e.detachEvent)
		{
			var key = '{KEY::' + e.uniqueID + '::' + m + '::' + f + '}';
			var fun = pz.functions[key];
			if(typeof fun != 'undefined')
			{
				e.detachEvent('on' + m, fun);
				delete pz.functions[key];
			}
			
			key = null;
		}
	},
	
	getChildNodes: function(e)
	{
		return typeof e.all != 'undefined' ? e.all : e.getElementsByTagName('*');
	},
	
	getElementsBySelector: function(selector, parentNode, limit, callback)
	{
		if(typeof parentNode == 'undefined')
			parentNode = document;
			
		if(typeof limit == 'undefined')
			limit = 0;
			
		if(!parentNode.getElementsByTagName)
			return new Array();
	  
		// Split selector in to tokens
		var tokens = selector.split(' ');
		var currentContext = new Array(parentNode);
		for(var i = 0; i < tokens.length; i++) {
			token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
		    if(token.indexOf('#') > -1) 
			{
				// Token is an ID selector
				var bits = token.split('#');
				var tagName = bits[0];
				var id = bits[1];
				var element = document.getElementById(id);
				if(tagName && element.nodeName.toLowerCase() != tagName) 
				{
					return new Array();
				}
				
				currentContext = new Array(element);
				continue;
		    }
			
		    if(token.indexOf('.') > -1) 
			{
				var bits = token.split('.');
				var tagName = bits[0];
				var className = bits[1];
				if(!tagName)
					tagName = '*';
					
				var found = new Array;
				var foundCount = 0;
				for(var h = 0; h < currentContext.length; h++)
				{
			        var elements;
			        if (tagName == '*') {
			            elements = pz.getChildNodes(currentContext[h]);
			        } else {
			            elements = currentContext[h].getElementsByTagName(tagName);
			        }
			        for (var j = 0; j < elements.length; j++) {
						found[foundCount++] = elements[j];
			        }
				}
				
			    currentContext = new Array;
			    var currentContextIndex = 0;
			    for (var k = 0; k < found.length; k++) {
					if(found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b')))
					{
						currentContext[currentContextIndex++] = found[k];
						
						if(i + 1 == tokens.length)
						{
							if(callback)
								callback.call(found[k]);
							
							if(limit > 0 && currentContextIndex == limit)
								return currentContext;
						}
					}
			        
			    }
				
			    continue;
		    }
			
		    if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) 
			{
				var tagName = RegExp.$1;
				var attrName = RegExp.$2;
				var attrOperator = RegExp.$3;
				var attrValue = RegExp.$4;
				if(!tagName) 
					tagName = '*';
		      
			    // Grab all of the tagName elements within current context
			    var found = new Array;
			    var foundCount = 0;
			    for(var h = 0; h < currentContext.length; h++) 
				{
			        var elements;
			        if (tagName == '*') 
			            elements = pz.getChildNodes(currentContext[h]);
			        else 
			            elements = currentContext[h].getElementsByTagName(tagName);
			        
			        for(var j = 0; j < elements.length; j++)
						found[foundCount++] = elements[j];
			        
			    }
				
				if(pz.isIE)
				{
					if(attrName == 'class')
						attrName = 'className';
				}
				
				currentContext = new Array;
				var currentContextIndex = 0;
				var checkFunction; // This function will be used to filter the elements
				switch(attrOperator) 
				{
					case '=': // Equality
						checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
						break;
						
					case '~': // Match one of space seperated words 
						checkFunction = function(e) 
						{
							var value = e.getAttribute(attrName);
							return (value && value.match(new RegExp('\\b'+attrValue+'\\b'))); 
						};
						break;
						
					case '|': // Match start with value followed by optional hyphen
						checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
						break;
						
					case '^': // Match starts with value
						checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
						break;
						
			        case '$': // Match ends with value - fails with "Warning" in Opera 7
						checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
						break;
						
					case '*': // Match ends with value
						checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
						break;
						
					default :
						checkFunction = function(e) { return e.getAttribute(attrName); };
				}
			  
				currentContext = new Array;
				var currentContextIndex = 0;
				for(var k = 0; k < found.length; k++) 
				{
					if(checkFunction(found[k])) 
					{
						currentContext[currentContextIndex++] = found[k]; 
						
						if(i + 1 == tokens.length)
						{
							if(callback)
								callback.call(found[k]);
							
							if(limit > 0 && currentContextIndex == limit)
								return currentContext;
						}
					}
				}
				
				continue;
		    }
		    
		    if (!currentContext[0])
		    	return;
		    
		    // If we get here, token is JUST an element (not a class or ID selector)
		    tagName = token;
		    var found = new Array;
		    var foundCount = 0;
		    for(var h = 0; h < currentContext.length; h++) 
			{
				var elements = currentContext[h].getElementsByTagName(tagName);
				for(var j = 0; j < elements.length; j++) 
				{
					found[foundCount++] = elements[j];
					
					if(i + 1 == tokens.length)
					{
						if(callback)
							callback.call(elements[j]);
							
						if(limit > 0 && currentContextIndex == limit)
							return currentContext;
					}
				}
		      
		    }
			
		    currentContext = found;
		}
		
		return currentContext;
	},
	
	$: function(e, parentNode)
	{
		if(e.constructor == pzE)
			return e;
			
		var selector = e;
			
		if(typeof e == 'string')
		{
			e = pz.getElementsBySelector(e, parentNode, 1)[0];
		}
		
		if(typeof e == 'undefined' || e == null)
		{
			if(pz.emptypzE == 0)
				pz.emptypzE = new pzE();
			
			return pz.emptypzE;
		}
					
		var uniqueId = typeof e.uniqueID != 'undefined' ? e.uniqueID : ++pz.uniqueIdCounter;
		
		uniqueId;
		pz;
		pz.pzEs;
		
		if(typeof pz.pzEs[uniqueId] == 'undefined')
		{
			pz.pzEs[uniqueId] = new pzE(e);
		}
		
		return pz.pzEs[uniqueId];
	},
	
	setInterval: function(caller, f, time, array)
	{
		var interval = new Interval(caller, f, time, array);
		Interval.execute(interval);
		return interval;
	},
	
	setTimeout: function(caller, f, time, array)
	{
		var timeout = new Timeout(caller, f, time, array);
		Timeout.execute(timeout);
		return timeout;
	},
	
	createCookie: function(name, value, days)
	{
		var expires = '';
		if(typeof days != 'undefined')
		{
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			expires = 'expires=' + date.toGMTString() + ';';
		}
		
		document.cookie = escape(name) + '=' + escape(value) + ';' + expires + 'path=/';
	},
	
	readCookie: function(name)
	{
		var pos = -1;
		var cookies = document.cookie.split(';');
		
		for(var j = 0; j < cookies.length; j++)
		{
			var c = cookies[j];
			if((pos = c.indexOf(name)) != -1)
				return c.substring(pos + name.length + 1);
		}
		
		return '';
	},
	
	removeCookie: function(name)
	{
		pz.createCookie(name, '', -1);
	},
	
	setOpacity: function(a, b)
	{
		pz.$(a).setOpacity(b);
	},
	
	getElementByEvent: function(event)
	{
		if(typeof event == 'undefined')
			event = window.event;
			
		var e = typeof event.srcElement != 'undefined' ? event.srcElement : event.target;
		if(e.nodeType == 3)
			e = e.parentNode;
			
		return e;
	},
	
	getElementSize: function(element)
	{
		var pzE = pz.$(element);
		
		var width = pzE.css('width');
		var height = pzE.css('height');
		
		width = parseInt(width.substr(0, width.length - 2))
		height = parseInt(height.substr(0, height.length - 2));
		
		return {w: width, h: height};
	},
	
	displayResult: function(errorSelector, successSelector, text)
	{
		if(typeof text == 'undefined')
			return false;
			
		var success = pz.$(successSelector);
		var error = pz.$(errorSelector);
		
		pz.each('.error-pzE', function() { pz.$(this).css({'display': 'none'}); });
		pz.each('.success-pzE', function() { pz.$(this).css({'display': 'none'}); });
		
		var types = text.split('__TYPE_OUTPUT__');
		for(var j = 0; j < types.length; j++)
		{
			var className = types[j].substr(0, 4);
								
			if(className.length == 0)
				continue;
				
			if(className == 'ERRO')
			{
				if(error.exists())
				{
					var errors = types[j].substr(4).split('||');
										
					error.css({'display': 'pzE'}).execute(function() { pz.$('.error-content', this).html(errors[0], true); });
										
					for(var k = 1; k < errors.length; k++)
					{
						pz.$(errors[k]).css({'border': '2px solid #E22', 'margin': '0px'});
					}
				}
			}
			else if(className == 'SUCC')
			{
				if(success.exists())
				{
					var content = types[j].substr(4);
										
					success.css({'display': 'pzE'}).html(content, true);
				}
			}
			else if(className == 'REDI')
			{
				window.location = types[j].substr(4);
			}
			else if(className == 'EVAL')
			{
				eval(types[j].substr(4));
			}
			else if(className == 'SET1')
			{
				//
			}
			else if(className == 'AUTH')
			{
				var size = pz.getDocumentSize();
				pz.$('body').html('<div id="overlay" style="left:0px;top:0px;position: absolute; z-index: 1; width: ' + size.w + 'px; height: ' + size.h + 'px; background-color: #666;">Asd</div>');
				pz.$('#overlay').css({'opacity': 70});
				//alert('U bent niet meer ingelogd. We werken nog aan een systeem zodat u via een pop-up uw gebruikersnaam en wachtwoord kunt invullen en u gewoon kunt verder werken.');
			}
			else
			{
				alert(types[j]);
			}
		}
		
		return true;
	}
}

pz.start();

Timeout.counter = 0;
Timeout.calls = {};

function Timeout(caller, f, time, array)
{
	this.id = ++Timeout.counter;
	this.timerId = 0;
	this.caller = caller;
	this.f = f;
	this.time = time;
	this.arguments = array;
	Timeout.calls[this.id] = this;
}

Timeout.prototype.cancel = function()
{
	clearTimeout(this.timerId);
	delete Interval.calls[this.id];
}

Timeout.prototype.execute = function()
{
	this.caller[this.f](this.arguments[0], this.arguments[1], this.arguments[2], this.arguments[3], 
		this.arguments[4], this.arguments[5], this.arguments[6], this.arguments[7], 
		this.arguments[8], this.arguments[9], this.arguments[10], this.arguments[11]);
	this.cancel();
}

Timeout.execute = function(call)
{
	Timeout.calls[call.id].timerId = setTimeout('if(Timeout.calls[' + call.id + ']) Timeout.calls[' + call.id + '].execute();', call.time);
}

Interval.counter = 0;
Interval.calls = {};

function Interval(caller, f, time, array)
{
	this.id = ++Interval.counter;
	this.timerId = 0;
	this.caller = caller;
	this.f = f;
	this.time = time;
	this.arguments = array;
	Interval.calls[this.id] = this;
}

Interval.prototype.cancel = function()
{
	clearInterval(this.timerId);
	delete Interval.calls[this.id];
}

Interval.prototype.execute = function()
{	
	this.caller[this.f](this.arguments[0], this.arguments[1], this.arguments[2], this.arguments[3], 
			   this.arguments[4], this.arguments[5], this.arguments[6], this.arguments[7], 
			   this.arguments[8], this.arguments[9], this.arguments[10], this.arguments[11]);		   
}

Interval.execute = function(call)
{
	Interval.calls[call.id].timerId = setInterval('if(Interval.calls[' + call.id + ']) Interval.calls[' + call.id + '].execute();', call.time);
}

pzE = function(e)
{
	this.element = e;
	
	this.fadeInterval = -1;
	this.fadeValue = { current: -1, increment: 0, end: 0, callback: -1 };
	
	this.sizeInterval = -1;
	this.sizeValue = { current: -1, increment: 0, end: 0, callback: -1 };
}

pzE.prototype.exists = function()
{
	return (this.element != null);
}

pzE.prototype.fade = function(start, end, time)
{
	if(this.fadeInterval != -1)
	{
		this.fadeInterval.cancel();
		this.fadeInterval = -1;
	}
	
	if(start == 0 && this.css('display') != 'none')
		start = (this.css('opacity') || 0) * 100;
	else if(start == 100 && this.css('display') != 'none')
		start = (this.css('opacity') || 1) * 100;
	
	var total = Math.abs(start - end);
	var timePerInterval = (time / total);
	
	if(pz.isIE)
		timePerInterval = Math.max(1, Math.round(timePerInterval / 10));
	
	this.fadeValue.current = start;
	this.fadeValue.end = end;
	
	if(this.fadeValue.current > this.fadeValue.end)
	{
		this.fadeValue.increment = -2;
	}
	else
	{
		this.fadeValue.increment = 2;
	}
	
	this.fadeInterval = pz.setInterval(this, 'preFade', timePerInterval, []);
	return this;
}

pzE.prototype.child = function(exp)
{
	return pz.$(exp, this.element);
}

pzE.prototype.childs = function(exp, _callback)
{
	pz.getElementsBySelector(exp, this.element, 0, _callback);
	return this;
}

pzE.prototype.size = function(sizeTo, time, __callback)
{
	if(this.sizeInterval != -1)
	{
		if(this.sizeValue.callback != -1)
			this.sizeValue.callback(false);
			
		this.sizeInterval.cancel();
		this.sizeInterval = -1;
	}
	
	this.sizeValue.current = { width: -1, height: -1 };
	
	if(typeof __callback == 'undefined')
		__callback = -1;
		
	this.sizeValue.callback = __callback;
	
	if(typeof sizeTo.width != 'undefined')
	{
		var currentWidth = this.css('width');
		if(currentWidth == 'auto')
			currentWidth = 0;
		else
			currentWidth = parseInt(currentWidth.substr(0, currentWidth.length - 2));
		
		var total = Math.abs(sizeTo.width - currentWidth);
		var timePerInterval = (time / total) / 10;

		this.sizeValue.end = sizeTo.width;
		this.sizeValue.current.width = currentWidth;
		this.sizeValue.current.height = -1;
		
		if(this.sizeValue.current.width > this.sizeValue.end)
		{
			this.sizeValue.increment = -4;
		}
		else
		{
			this.sizeValue.increment = 4;
		}
		
		if(pz.isIE)
			timePerInterval = Math.max(1, Math.round(timePerInterval));
		
		this.sizeInterval = pz.setInterval(this, 'preSize', timePerInterval, []);
	}
	else if(typeof sizeTo.height != 'undefined')
	{
		var currentHeight = this.css('height');
		if(currentHeight == 'auto')
			currentHeight = 0;
		else
			currentHeight = parseInt(currentHeight.substr(0, currentHeight.length - 2));
			
		var total = Math.abs(sizeTo.height - currentHeight);
		var timePerInterval = (time / total) / 10;
			
		this.sizeValue.end = sizeTo.height;
		
		this.sizeValue.current.width = -1;
		this.sizeValue.current.height = currentHeight;
		
		if(this.sizeValue.current.height > this.sizeValue.end)
		{
			this.sizeValue.increment = -4;
		}
		else
		{
			this.sizeValue.increment = 4;
		}
		
		if(pz.isIE)
			timePerInterval = Math.max(1, Math.round(timePerInterval));
		
		this.sizeInterval = pz.setInterval(this, 'preSize', timePerInterval, []);
	}
	
	return this;
}

pzE.prototype.preSize = function()
{
	if(this.sizeValue.current.width != -1)
		this.sizeValue.current.width = Math.max(0, this.sizeValue.current.width + this.sizeValue.increment);
		
	if(this.sizeValue.current.height != -1)
		this.sizeValue.current.height = Math.max(0, this.sizeValue.current.height + this.sizeValue.increment);
	
	var call = false;
	
	if(this.sizeValue.current.width != -1 && Math.abs(this.sizeValue.current.width - this.sizeValue.end) <= Math.abs(this.sizeValue.increment) || 
	   this.sizeValue.current.height != - 1 && Math.abs(this.sizeValue.current.height - this.sizeValue.end) <= Math.abs(this.sizeValue.increment))
	{
		if(this.sizeValue.current.width != -1)
			this.sizeValue.current.width = this.sizeValue.end;
			
		if(this.sizeValue.current.height != -1)
			this.sizeValue.current.height = this.sizeValue.end;
			
		this.sizeInterval.cancel();
		this.sizeInterval = -1;
		
		call = true;
	}
	
	this.setSize(this.sizeValue.current);
	
	if(call && this.sizeValue.callback != -1)
	{
		this.sizeValue.callback(true);
		this.sizeValue.callback = -1;
	}
	
	return this;
}

pzE.prototype.preFade = function()
{
	this.fadeValue.current = Math.min(100, Math.max(0, this.fadeValue.current + this.fadeValue.increment));
	
	if(Math.abs(this.fadeValue.current - this.fadeValue.end) < Math.abs(this.fadeValue.increment))
	{
		this.fadeValue.current = this.fadeValue.end;
		
		this.fadeInterval.cancel();
		this.fadeInterval = -1;
	}
	
	this.setOpacity(this.fadeValue.current);
	return this;
}

pzE.prototype.setOpacity = function(opacity)
{	
	if(typeof this.element == 'undefined')
		return this;
		
	var style = this.element.style;
	if(typeof style == 'undefined')
		return this;
		
	if(this.element.currentStyle && !this.element.currentStyle.hasLayout)
		style.zoom = 1;
				
	style.opacity = (opacity / 100); 
	style.MozOpacity = (opacity / 100); 
	style.KhtmlOpacity = (opacity / 100); 
	style.filter = 'alpha(opacity=' + opacity + ')';
			
	if(opacity > 0)
		style.display = 'block';
	else if(opacity == 0)
		style.display = 'none';
	
	return this;
}

pzE.prototype.setSize = function(size)
{
	if(typeof this.element == 'undefined')
		return this;
		
	if(typeof size == 'undefined' || typeof size.width == 'undefined' || typeof size.height == 'undefined')
		return this;
	
	var style = this.element.style;
	if(typeof style == 'undefined')
		return this;
		
	if(size.width != -1)
		style.width = size.width + 'px';
		
	if(size.height != -1)
		style.height = size.height + 'px';
	
	if(style.overflow != 'hidden')
		style.overflow = 'hidden';
	
	if((size.height > 0 || size.height == -1) && (size.width > 0 || size.width == -1))
		style.display = 'block';
	else
		style.display = 'none';
		
	return this;
}

pzE.prototype.css = function(array)
{
	if(typeof this.element == 'undefined')
		return this;
	
	if(typeof array == 'string')
	{
		var s = array;
		if(/-([a-z])/.test(s))
			s = s.replace(/-([a-z])/, RegExp.$1.toUpperCase());
			
		var value = this.element.style[s];
		
		if(!value)
		{
			if(document.defaultView)
				value = document.defaultView.getComputedStyle(this.element, '').getPropertyValue(array);
			else if(this.element.currentStyle)
				value = this.element.currentStyle[s];
		}
		
		return value;
	}
	else
	{
		for(i in array)
		{
			var s = i;
			if(/-([a-z])/.test(s))
				s = s.replace(/-([a-z])/, RegExp.$1.toUpperCase());
			
			if(pz.specialStyles[s])
			{
				pz.specialStyles[s](this.element, array[i]);
			}
			else
				this.element.style[s] = array[i];
		}
	}
	
	return this;
}

pzE.prototype.html = function(html, replace)
{
	if(typeof this.element == 'undefined')
		return this;
		
	if(typeof replace == 'undefined')
		replace = false;
	
	if(typeof html != 'undefined')
	{
		if(replace == false)
			this.element.innerHTML += html;
		else
			this.element.innerHTML = html;
	}
	
	return this;
}

pzE.prototype.addEvent = function(m, f)
{
	if(typeof this.element == 'undefined')
	{
		return this;
	}
	
	pz.addEvent(this.element, m, f);
	return this;
}

pzE.prototype.removeEvent = function(m, f)
{
	if(typeof this.element == 'undefined')
		return false;
	
	pz.removeEvent(this.element, m, f);
	return this;
}

pzE.prototype.setAttribute = function(name, value)
{	
	if(this.element && typeof this.element != 'undefined')
	{
		//this.element[name] = value;
		
		//pz seems unavailable in IE - let's use this simple query instead of pz.isIE
		if(navigator.appVersion.match(/MSIE/))
		{
			//IE seems to not like touching password fields value nor it's type - let's avoid that then
			if(this.element.type == 'password' && (name == 'value' || name == 'type'))
			{
				//
			}
			else
			{
				this.element[name] = value;
			}
		}
		else
		{
			this.element.setAttribute(name, value);
		}
	}
		
	return this;
}

pzE.prototype.getAttribute = function(name)
{
	if(this.element)
		return this.element[name];
		
	return 0;
}

pzE.prototype.execute = function(f)
{
	f.call(this.element);
	return this;
}

pzE.prototype.setFocus = function()
{
	if(this.element)
	{
		this.element.focus();
	}
	
	return this;
}

pzE.prototype.mousemove = function(f) { return this.addEvent('mousemove', f); }
pzE.prototype.mouseup = function(f) { return this.addEvent('mouseup', f); }
pzE.prototype.mousedown = function(f) { return this.addEvent('mousedown', f); }
pzE.prototype.mouseover = function(f) { return this.addEvent('mouseover', f); }
pzE.prototype.mouseout = function(f) { return this.addEvent('mouseout', f); }
pzE.prototype.keyup = function(f) { return this.addEvent('keyup', f); }
pzE.prototype.keydown = function(f) { return this.addEvent('keydown', f); }
pzE.prototype.click = function(f) { return this.addEvent('click', f); }
pzE.prototype.doubleclick = function(f) { return this.addEvent('dblclick', f); }
pzE.prototype.blur = function(f) { return this.addEvent('blur', f); }
pzE.prototype.focus = function(f) { return this.addEvent('focus', f); }
pzE.prototype.keypress = function(f) { return this.addEvent('keypress', f); }
pzE.prototype.change = function(f) { return this.addEvent('change', f); }

