	var flag = "close";
var last_bg;
var activ_bg;
function change_bg (new_bg){
	var obj = document.getElementById('btn').style;
	if (new_bg){
		obj.background = new_bg;
	}else {
		if (flag == "open") {
			flag = "close";
			obj.background ="url(images/img/btn_open.jpg)";
			last_bg = "url(images/img/btn_open.jpg)";
			activ_bg = "url(images/img/btn_open_active.jpg)";
			YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip("tt1",{ 
				context:"btn", 
				text:"Click here to see more pages" });
		} else {
			flag = "open";
			obj.background ="url(images/img/btn_close.jpg)";
			last_bg = "url(images/img/btn_close.jpg)";
			activ_bg = "url(images/img/btn_close_active.jpg)";
			YAHOO.example.container.tt1 = new YAHOO.widget.Tooltip("tt1",{ 
				context:"btn", 
				text:"Click here to close" });
		}
	}
}

var menu = function () {
	var menu_div;
	var by = 155;
	var locked = 0;
	return {
		init : function () {
			menu_div = YAHOO.util.Dom.get('menu_div');
	 //			console.log(this.parentNode);
	 		if (menu_div.parentNode.nextSibling.scrollHeight > parseInt(menu_div.scrollHeight)) {
				menu_div.style.height = menu_div.parentNode.nextSibling.scrollHeight + 82 + 'px';
			} else {
	//		alert(menu_div.style.height);
		//	alert(menu_div.scrollHeight);
				menu_div.parentNode.style.height = menu_div.scrollHeight + 'px';
			}
			this.animate();
			setTimeout(this.animate, 3000);
		},
		animate : function () {
			if (!locked) {
				locked = 1;
				var anim = new YAHOO.util.Anim (menu_div, { left : {by : by}}, 1, YAHOO.util.Easing.easeOut);
				by *= -1;
				anim.onComplete.subscribe(function () {locked = 0; change_bg();});
				anim.animate();
			}
		}
	};
} ();

YAHOO.util.Event.on(window, 'load', menu.init, menu, true);

var div_mouseover = function(e) {
	change_bg (activ_bg);
}

var div_mouseout = function(e) {
	change_bg (last_bg);
}

YAHOO.util.Event.addListener("btn", "mouseover", div_mouseover);
YAHOO.util.Event.addListener("btn", "mouseout", div_mouseout);