$=function(id){
	return document.getElementById(id);
}

Namespace = new Object();
Namespace.register = function(namespace){
	var nsArray = namespace.split('.');
	var sEval = "";
    var sNS = "";
	for (var i = 0; i < nsArray.length; i++){
        if (i != 0) sNS += ".";
        sNS += nsArray[i];
        sEval += "if (typeof(" + sNS + ") == 'undefined') " + sNS + " = new Object();"
    }
    if (sEval != "") eval(sEval);
}

Namespace.register("CN56NET.util.setDiv");
Namespace.register("CN56NET.util.showDiv");

(function(){
	var initheight,totalheight;
	CN56NET.util.setDiv = {
		init:function(el,con,nums,overclassname,outclassname,speed,maxheight){
			var arg = new Array();
			for(i=0;i<arguments.length;i++){
				arg[i] = arguments[i];
			}
			for(j=1;j<=parseInt(arg[2]);j++){
				tagBox = $(arg[0] + j);
				hidBox = $(arg[1] + j);
				tagBox.m = j;
				hidBox.m = j;
				tagBox.onmouseover=function(){CN56NET.util.showDiv.slideshow(arg,this.m);};
				tagBox.onmouseout=function(){CN56NET.util.showDiv.slideshow(arg,this.m);};
				hidBox.onmouseover=function(){CN56NET.util.showDiv.slideshow(arg,this.m);};
			}
			CN56NET.util.showDiv.slideshow(arg,1);
		},
		
		build:function(el,className,targetName,cookiename,mspace){
			totalheight = 0;
			var ctrHeight;
			var mb_arr = new Array();
			var childtag = el.getElementsByTagName(targetName);
			for(i=0;i<childtag.length;i++){
				if(childtag[i].className==className){
					with(childtag[i].style){
						position = "absolute";
						top = totalheight + "px";
					}
					if(childtag[i].scrollHeight==0) ctrHeight = parseInt(childtag[i].style.height);
					else ctrHeight = childtag[i].scrollHeight;
					if(mspace!=null && mspace!="") totalheight = totalheight + ctrHeight + mspace;
					else totalheight = totalheight + ctrHeight;
					mb_arr[mb_arr.length] = childtag[i].id;
				}
			}
			el.style.height = totalheight + "px";
			CN56NET.util.move.init(el,mb_arr,cookiename);
		},
		
		rebuild:function(movebox,cookieValue,cookiename,mspace){
			var ctrHeight;
			var totalheight = 0;
			var mb_arr = cookieValue.split("&");
			for(var i=0;i<mb_arr.length;i++){
				$(mb_arr[i]).style.position = "absolute";
				$(mb_arr[i]).style.top = totalheight + "px";
				if(parseInt($(mb_arr[i]).scrollHeight)==0) {ctrHeight = parseInt($(mb_arr[i]).style.height);}
				else ctrHeight = $(mb_arr[i]).scrollHeight;
				if(mspace!=null && mspace!="") totalheight = totalheight + ctrHeight + mspace;
				else totalheight = totalheight + ctrHeight;
			}
			movebox.style.height = totalheight + "px";
			CN56NET.util.move.init(movebox,mb_arr,cookiename);
		},
		
		tabDivinit:function(nums,tab,con,curClassName,speed,oEvent,outcname){
			var t = oEvent;
			var arg = new Array;
			for(i=0;i<arguments.length;i++){
				arg[i] = arguments[i];
			}
			for(var j=0;j<arg[0];j++){
				var curtab = $(arg[1] + j);
				curtab.n = j;
				switch(t){
					case 'click':
						curtab.onclick = function(){CN56NET.util.showDiv.show(arg,this.n);};
						break;
					default:
						curtab.onmouseover = function(){CN56NET.util.showDiv.show(arg,this.n);};
						break;
				}
			}
			return arg;
		}
	};
})();

(function(){
	var pos;
	var showpos;
	CN56NET.util.showDiv = {
		show:function(arg,id){
			var curtab,curobj;
			curobj = this;
			var useArg = new Array;
			for(j=0;j<arg.length;j++){
				useArg[j] = arg[j];
			}
			for(var i=0;i<useArg[0];i++){
				curtab = $(useArg[1] +i);
				if(i==id){ 
					curtab.className = useArg[3];
					$(useArg[2]+i).style.display = "block";
				}else{
					curtab.className = useArg[6];
					$(useArg[2]+i).style.display = "none";
				}
			}	
		},

		autoshow:function(arg){
			var time1,curobj,curtab,curnum,bpos;
			curnum = 1;
			curobj = this;
			bpos = 0;
			var useArg = new Array;
			for(j=0;j<arg.length;j++){
				useArg[j] = arg[j];
			}
			this.show(useArg,0);
			function ctrl(){
				time1 = setInterval(function(){
					if(curnum>=useArg[0]) curnum=0;
					bpos = curnum;
					curobj.show(useArg,curnum);
					curnum++;
				},useArg[4])
			}
			ctrl();
			for(var i=0;i<useArg[0];i++){
				curtab = $(useArg[1] +i);
				switch(useArg[5]){
					case 'click':
						curtab.onclick = function(){curobj.show(useArg,this.n);};
						curtab.onmouseover = function(){clearInterval(time1);bpos=this.n;}
						break;
					default:
						curtab.onmouseover = function(){clearInterval(time1);curobj.show(useArg,this.n);bpos=this.n;};
						break;
				}
				$(useArg[2] +i).onmouseover = function(){clearInterval(time1);bpos++;}
				$(useArg[2] +i).onmouseout = function(){
					curnum = bpos;
					ctrl();
				}
				curtab.onmouseout = function(){
					curnum = bpos;
					ctrl();
				}
			}
		},

		slideshow:function(arg,id){
			var curobj = new Array();
			for(j=0;j<arg.length;j++){
				curobj[j] = arg[j];
			}
			var tagBox,hidBox;
			var ctrl = 0;
			if((id!=pos)||(pos==null)){
				for(i=1;i<=parseInt(curobj[2]);i++){
					tagBox = $(curobj[0] + i);
					hidBox = $(curobj[1] + i);
					if(i==id){
						pos=id;
						tagBox.className = curobj[3];
						hidBox.style.display = "block";
						hidBox.style.height = curobj[6] + "px";
					}else{
							hidBox.style.height = "0px";
							tagBox.className = curobj[4];
							hidBox.style.display = "none";
					}
				}
			}
		}
		
	}
})();
