function ActionUndo() {
	this._func=null;
	this._params;
}

function ActionMenu(a) {
	var u = new ActionUndo;
	this._action;
	this._pos;
	var aPositions;
	this.setPositions = function() {
		aPositions=this._pos;
	}
	this.setEvents = function () {
		var i;
		for (i=0; i<this._action.length;i++) {
			v2 = this._action[i];			
			objClickEvent.call(v2['object'],v2["paramSelf"],v2['params']);
		}
	}
	function objClickEvent(self,params) {				
		this.onclick=function () {			
			var i;
			if (params && params != null)
			for (var c in params) {				
				
				switch (c) {
				case "backgroundImage":
					for (var d in (params[c])) {												
						//document.getElementById("id_layer1").display="";
						//document.getElementById("id_layer1").style.backgroundImage=aPositions[d].style.backgroundImage;
						//alert(aPositions[d].clientHeight);
						aPositions[d].style.backgroundImage=params[c][d];						
					}
					break;
				case "innerHTML":
					for (var d in (params[c])) {
						aPositions[d].innerHTML=params[c][d]
					}
					break;
				case "display":
					for (var d in (params[c])) {
						aPositions[d].style.display=params[c][d]
					}
					break;
				case "func":
					for (i=0; i < params[c].length; i++)
						params[c][i]();
					break;
				}
			}
			if (self && self != null) {
				if (self.undo && self.undo == false)
					;
				else {
					if (u._func) {
						
						u._func.apply(null,u._params);
					}
	//					u._func.apply(null,u._params);
					u._func = function(obj,bgcolor,bgimage) {
						obj.style.backgroundColor=bgcolor;
						obj.style.backgroundImage=bgimage};		
					u._params = [this,this.style.backgroundColor,this.style.backgroundImage];		
				}
				for (var c in self) {				
					switch (c) {
					case "backgroundColor":				
	
						this.style.backgroundColor=self[c];
	//					flipImg.call(this.firstChild,self[c])
						break;
					case "backgroundImage":
	
						this.style.backgroundImage=self[c];
	//					flipImg.call(this.firstChild,self[c])
						break;
					}
				}
			}
//			for (i=0; i < f_main1.length; i++)
//				flipImg2.call(aPositions[i],f_main1[i])
//			flipImg2.call(aPositions[i],f_main1[i])
			
			
			return false;
		};
	}
	
	function flipImg(url_bg) {		
		if (u._func) u._func.apply(null,u._params);
		u._func = function(obj,url) {obj.style.backgroundImage=url};		
		u._params = [this,this.style.backgroundImage];		
		this.style.backgroundImage=url_bg		
	}	
}


function newElement(tagName, props) {		
	var oinput;
	var sprops="";
	var c;
	try {
		for(c in props) {
			sprops+=" "+c+"=\""+props[c]+"\"";
		}
		oinput = document.createElement("<"+tagName+sprops+">"+"</"+tagName+">");	
	}
	catch (err) {
		oinput = document.createElement(tagName);
		for(c in props) {
			oinput[c]=props[c];
		}
	}
	finally {
		return oinput;
	}
	return null;
}
function ActiveContent() {
	this._oInner;
	this._oOuter;
	this._oControl;
	
	var oInner,oOuter;
	var oCtrlDown,oCtrlUp;
	var activespeed=100;
	var activetime=10;
	var actInterval = null;
	this.IntervalSetting=function (speed,time) {
		activetime=time;
		activespeed=speed;
	}
	this.showHide = function(p) {

		this._oControl.style.display=p;			
	}
	this.drawControl=function () {
		
		var tempElement;
		this._oControl.innerHTML="";
		oInner = this._oInner;
		oOuter = this._oOuter;
		
		oCtrlDown=newElement("a",{href:"#",style:""});
		oCtrlUp=newElement("a",{href:"#",style:""});
		tempElement=newElement("img",{src:"images/arrow-down.gif",border:"0"});
		oCtrlDown.appendChild(tempElement);
		tempElement=newElement("img",{src:"images/arrow-up.gif",border:"0"});
		oCtrlUp.appendChild(tempElement);
		oCtrlDown.onclick=oCtrlUp.onclick=function () {return false;};
		oCtrlDown.onmouseover=function () {
			cancelevent();
			actInterval=window.setInterval(function () {move(-activespeed)},activetime);
		};
		oCtrlUp.onmouseover=function () {
			cancelevent();
			actInterval=window.setInterval(function () {move(activespeed)},activetime);
		};
		oCtrlDown.onmouseout=oCtrlUp.onmouseout=cancelevent;
		
		
		tempElement=newElement("div",{style:"height:1px;font-size:1px"});
		this._oControl.appendChild(oCtrlUp);
		this._oControl.appendChild(tempElement);
		this._oControl.appendChild(oCtrlDown);
		
	}
	function cancelevent() {
		window.clearInterval(actInterval);
	}	
	function move(speed) {	
		var intMarginTop=parseInt(oInner.style.marginTop.replace("px",""))
		if (speed==0) {
			cancelevent();
			return;
		}
		else if (speed<0 && intMarginTop<(oOuter.clientHeight-oInner.clientHeight)) {			
			cancelevent();
			return;
		}
		else if (speed>0 && (oInner.style.marginTop==""||intMarginTop>=0)) {

			cancelevent();
			return;
		}
		/*
		//info
		id_msgbox_action2.innerHTML="";
		id_msgbox_action2.innerHTML+="marginTop:"+intMarginTop+"\n";
		id_msgbox_action2.innerHTML+="innerHeight:"+oInner.clientHeight+"\n";
		id_msgbox_action2.innerHTML+="outerHeight:"+oOuter.clientHeight+"\n";
		*/
		if (oInner.style.marginTop)
			oInner.style.marginTop=intMarginTop+speed;
		else
			oInner.style.marginTop+=speed;
	}

}