// event observe
Event.observe(window, 'load', function() {
	// start the SelectPt script 
	new SelectPt('select_pt_options', 'select_pt');	

	Event.observe($('logo'), 'click', function() {
		document.location.href = this_website;
	}, false);

	try{
		Event.observe($('last_menu_item'), 'mouseover', function(){
			$('menu_left').style.backgroundPosition = '0 -36px';
		}, false);

		Event.observe($('last_menu_item'), 'mouseout', function(){
			$('menu_left').style.backgroundPosition = '0 0';
		}, false);
	}catch(e){
	}
});

// SelectPt prototype class
SelectPt = Class.create();
SelectPt.prototype = {
	// costructor function 
	initialize: function(nodeId,observeId){
		nodeIdEl = document.getElementById(nodeId);
		observeId = document.getElementById(observeId);

		observeId.timeout = false;
		Event.observe(observeId, 'click', this.onclick.bind(observeId, nodeIdEl), false);
		Event.observe(observeId, 'mouseover', this.mouseover.bind(observeId), false);
		Event.observe(nodeIdEl, 'mouseover', this.mouseover.bind(observeId), false);
		Event.observe(nodeIdEl, 'mouseout', this.mouseout.bind(observeId, nodeIdEl), false);
	},

	onclick: function(node){
		// block the timeout
		if(this.timeout){
			clearTimeout(this.timeout);
		 	this.timeout = false;
		}
		
		// show it
		Effect.toggle(node,'blind');
	},
	
	mouseover: function(){
		// block the timeout
		 if(this.timeout){
			 clearTimeout(this.timeout);
			 this.timeout = false;
		 }
	},

	mouseout: function(node){
		// set the timeout before hide the node
		this.timeout = setTimeout(SelectPt.prototype.hide.bind(node),200);
  	},
	
	hide: function() {
		// hide it
		Effect.toggle(this,'blind');
	}
}
