function trend_menu (){
	if (!document.getElementById) return false;
	if (!document.getElementById("trend_item")) return false;
	obj = document.getElementById("trend_item"); 
	var dt = obj.getElementsByTagName("dt");
	var dd = obj.getElementsByTagName("dd");
	maxmenu = dt.length;
	for (i = 0 ; i < maxmenu ; i++){
		dt[i].img = dt[i].getElementsByTagName("img");
		dt[i].num = i;
		dt[i].onclick = function(){
			reset_dd();
			set_dt(this);
		}
		dd[i].style.display = "none";
	}

	var reset_dd = function(){
		for (j = 0; j < maxmenu ; j++){
			dd[j].style.display = "none";
			dt[j].img[0].src = dt[j].img[0].src.replace("_on.",".");
			dt[j].img[1].src = dt[j].img[1].src.replace("_on.",".");
		}
		return;
	}

	var set_dt = function(elm){
		dt[elm.num].img[0].src = dt[elm.num].img[0].src.replace(".gif","_on.gif")
		dt[elm.num].img[1].src = dt[elm.num].img[1].src.replace(".gif","_on.gif")
		dd[elm.num].style.display = "";
	}

	dd[0].style.display = "";
	dt[0].img = dt[0].getElementsByTagName("img");
	dt[0].num = 0;
	set_dt(dt[0]);
}

function item_menu (){
	if (!document.getElementById) return false;
	if (!document.getElementById("item_menu")) return false;
	obj = document.getElementById("item_menu"); 
	var dt = obj.getElementsByTagName("dt");
	maxmenu = dt.length;
	for (i = 0 ; i < maxmenu ; i++){
		dt[i].style.cursor = "pointer";
		dt[i].style.display = "block";
		dt[i].img = dt[i].getElementsByTagName("img");
		dt[i].num = i;
		dt[i].onmouseover = function(){
			togle(this,"over");
		}
		dt[i].onmouseout = function(){
			togle(this,"out");
		}
	}

	var togle = function(elm,ts){
		if (ts == "over" && dt[elm.num].img[1].src.indexOf("_on.gif") == -1){
			dt[elm.num].img[1].src = dt[elm.num].img[1].src.replace(".gif","_on.gif");
		}else if (ts == "out" && dt[elm.num].img[1].src.indexOf(".gif") != -1){
			dt[elm.num].img[1].src = dt[elm.num].img[1].src.replace("_on.gif",".gif");
		}
		
	}
}


function rolling (elm){
	if (!document.getElementById) return false;
	if (!document.getElementById(elm)) return false;
	this.obj = document.getElementById(elm);
	this.lbtn = this.obj.getElementsByTagName("button")[0];
	this.rbtn = this.obj.getElementsByTagName("button")[1];
	this.roll = this.obj.getElementsByTagName("ul");
	this.maxcont = this.roll.length;
	this.nownum = 0;
	for (i = 0 ; i < this.maxcont ; i++){
		this.roll[i].style.display = "none";
	}
	this.roll[this.nownum].style.display = "";
	
	this.lbtn.call = this;
	this.lbtn.onclick = function(){
		move("-",this.call);
	}
	this.rbtn.call = this;
	this.rbtn.onclick = function(){
		move("+",this.call);
	}

	var move = function(adder,obj){
		if (adder == '+'){
			obj.nownum ++;
		}else if(adder == '-') {
			obj.nownum ++;
		}
		if (obj.nownum < 0){
			obj.nownum = obj.maxcont;
		}else if(obj.nownum == obj.maxcont){
			obj.nownum = 0;
		}

		for (i = 0 ; i < obj.maxcont ; i++){
			obj.roll[i].style.display = "none";
		}
		obj.roll[obj.nownum].style.display = "";
	}
}

function swap_tab(elm,telm,cs,tag){
	if (!document.getElementById) return false;
	if (!document.getElementById(elm)) return false;
	if (!document.getElementById(telm)) return false;
	this.obj = document.getElementById(elm);
	this.tobj = document.getElementById(telm);
	this.btn = this.tobj.getElementsByTagName("li");
	this.cs = cs;
	this.area = this.obj.getElementsByTagName("ul");
	
	for (i = 0 ; i < this.area.length ; i++ ){
		this.area[i].style.display = "none"; 
		 	
		if( this.btn[i]!=null && this.btn[i]!='undefined')
		{
		    this.btn[i].num = i;
		    this.btn[i].call = this;
		    try{
			    this.btn[i].className = "";
		    }catch(e){

		    }
		    this.btn[i].onclick = function(){
			    swap_item(this.num,this.call);
		    }
		}
	}
	if (!this.cs){
			this.btn[0].getElementsByTagName("img")[0].src = this.btn[0].getElementsByTagName("img")[0].src.replace(".gif","_on.gif");
	}
	this.area[0].style.display = "";
	try{
		this.btn[0].className = "on";
	}catch(e){
	
	}

	var swap_item = function(num,elm){
		for (i = 0 ; i < elm.btn.length ; i++){
			elm.area[i].style.display = "none";
			if (!elm.cs){
				elm.btn[i].getElementsByTagName("img")[0].src = elm.btn[i].getElementsByTagName("img")[0].src.replace("_on.gif",".gif");
			}
			try{
				elm.btn[i].className = "";
			}catch(e){
			
			}
		}
		if (!elm.cs){
			elm.btn[num].getElementsByTagName("img")[0].src = elm.btn[num].getElementsByTagName("img")[0].src.replace(".gif","_on.gif");
		}
		elm.area[num].style.display = "";
		try{
			elm.btn[num].className = "on";
		}catch(e){
		
		}
	}				
}



function rolling1 (elm,telm){
	if (!document.getElementById) return false;
	if (!document.getElementById(elm)) return false;
	this.obj = document.getElementById(elm);
	this.telm = document.getElementById(telm);
	this.tabbtn = this.telm.getElementsByTagName("li");
	this.lbtn = this.obj.getElementsByTagName("button")[0];
	this.rbtn = this.obj.getElementsByTagName("button")[1];
	this.roll = this.obj.getElementsByTagName("ul");
	this.maxcont = this.roll.length;
	this.nownum = 0;

	for (i = 0 ; i < this.maxcont ; i++){
		this.roll[i].style.display = "none";
		this.tabbtn[i].getElementsByTagName("img")[0].src = this.tabbtn[i].getElementsByTagName("img")[0].src.replace("_on.gif",".gif");

		this.tabbtn[i].getElementsByTagName("img")[0].call = this;
		this.tabbtn[i].getElementsByTagName("img")[0].num = i;
		
		this.tabbtn[i].getElementsByTagName("img")[0].onclick = function(){
			btnclick(this,this.call);
		}
	}

	this.roll[this.nownum].style.display = "";
	
	this.lbtn.call = this;
	this.lbtn.onclick = function(){
		move("-",this.call);
	}
	this.rbtn.call = this;
	this.rbtn.onclick = function(){
		move("+",this.call);
	}

	this.tabbtn[this.nownum].getElementsByTagName("img")[0].src = this.tabbtn[this.nownum].getElementsByTagName("img")[0].src.replace(".gif","_on.gif");


	var move = function(adder,obj){
		if (adder == '+'){
			obj.nownum ++;
		}else if(adder == '-') {
			obj.nownum ++;
		}
		if (obj.nownum < 0){
			obj.nownum = obj.maxcont;
		}else if(obj.nownum == obj.maxcont){
			obj.nownum = 0;
		}

		for (i = 0 ; i < obj.maxcont ; i++){
			obj.roll[i].style.display = "none";
			obj.tabbtn[i].getElementsByTagName("img")[0].src = obj.tabbtn[i].getElementsByTagName("img")[0].src.replace("_on.gif",".gif");
		}
		obj.roll[obj.nownum].style.display = "";
		obj.tabbtn[obj.nownum].getElementsByTagName("img")[0].src = obj.tabbtn[obj.nownum].getElementsByTagName("img")[0].src.replace(".gif","_on.gif");
	}

	var btnclick = function(elm,obj){
		obj.nownum = elm.num;
		for (i = 0 ; i < obj.maxcont ; i++){
			obj.roll[i].style.display = "none";
			obj.tabbtn[i].getElementsByTagName("img")[0].src = obj.tabbtn[i].getElementsByTagName("img")[0].src.replace("_on.gif",".gif");
		}
		obj.roll[obj.nownum].style.display = "";
		obj.tabbtn[elm.num].getElementsByTagName("img")[0].src = obj.tabbtn[elm.num].getElementsByTagName("img")[0].src.replace(".gif","_on.gif");
	}

}
