/* (C) 2009 Musikhaus Thomann. Do not even think about copying, stealing or changing the code. MER dunnit. */

function CAppearer() {
	var __const = function() {}
	
	this.act = function(Pparam,Pkind,Pwhat,Pparams,PfinishedCallback) {
		var box = (typeof Pparam == 'string' ? document.getElementById(Pparam) : (typeof Pparam == 'object' ? Pparam : '') )
		if (!box) return;
		
		Pkind = Pkind.toUpperCase();
		Pwhat = Pwhat.toUpperCase();

		if (Pkind == 'BLUR') blur(box, Pwhat, Pparams, PfinishedCallback);
	}
	var blur = function(box,what,params,finCB) {
		var blurTime = (params['bt'] >= 0 ? params['bt'] : 2);
		var step = (params['st'] >= 0 ? params['st'] : 1);
	
		var blurTime = 2;
		var op = '';
		var handle = '';
		if (what == 'SHOW') {
			changeTrans(box,0);
			box.style.display = 'block';
			op = 0;
			handle = window.setInterval(
									function () {
										op = op + step;
										changeTrans(box,op);
										if (op >= 100) {
											window.clearInterval(handle);
											if (finCB) finCB(true);
										}
									},
									blurTime);
		}
		if (what == 'HIDE') {
			op = 100;
			handle = window.setInterval(
									function () {
										op = op - step;
										changeTrans(box,op);
										if (op <= 0) {
											window.clearInterval(handle);
											box.style.display = 'none';
											if (finCB) finCB(true);
										}
									},
									blurTime);
		}
	}
	var changeTrans = function (box, opacity) {
		box.style.opacity = (opacity / 100);
		box.style.MozOpacity = (opacity / 100);
		box.style.KhtmlOpacity = (opacity / 100);
		box.style.filter = "alpha(opacity=" + opacity + ")";
	}

	__const();
}



function CDimension() {
	var __const = function() {}
	
	this.act = function(Pbox,Pparams,PfinishedCallback) {
		var box = (typeof Pbox == 'string' ? document.getElementById(Pbox) : (typeof Pbox == 'object' ? Pbox : '') )
		if (!box) return;
		
		var endWidth = (Pparams['we'] >= 0 ? Pparams['we'] : -1);
		var endHeight = (Pparams['he'] >= 0 ? Pparams['he'] : -1);
		var akt = (Pparams['ak'] > 0 ? Pparams['ak'] : 5);
		var steps = (Pparams['st'] > 0 ? Pparams['st'] : 1);
		
		var startWidth = box.offsetWidth;
		var startHeight = box.offsetHeight;
		var currWidth = box.offsetWidth;
		var currHeight = box.offsetHeight;
		
		var handle1;
		var handle2;
		
		if (endHeight >= 0 && startHeight != endHeight) {
			handle1 = window.setInterval(
								function () { 
									if (endHeight > startHeight) {
										if ((currHeight + steps) > endHeight) {
											currHeight = endHeight;
										} else {
											currHeight = currHeight + steps;
										}
									} else {
										if ((currHeight - steps) < endHeight) {
											currHeight = endHeight;
										} else {
											currHeight = currHeight - steps;
										}
									}
									box.style.height=currHeight;
									if (currHeight == endHeight) {
										window.clearInterval(handle1);
										if (PfinishedCallback) PfinishedCallback(true);
									}
								},
								akt);
		}
		if (endWidth >= 0 && endWidth != endHeight) {
			alert('change width support is buggy!');
			handle2 = window.setInterval(
								function () { 
									box.style.width=currWidth;
									if (endWidth > startWidth) currWidth=currWidth+steps; else currWidth=currWidth-steps;
									if ((startWidth < endWidth && currWidth >= endWidth) || (startWidth > endWidth && currWidth <= endWidth)) {
										window.clearInterval(handle2);
										if (PfinishedCallback) PfinishedCallback(true);
									}
								},
								akt);
		}
	}
	__const();
}
