/*
 * Author: Renaud Guyon
 * Website: http://reno.guyon.ca
 * by Reno Guyon, 2010, for Flowstation.net
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/


var submenu = {

	timeout: 500,
	closetimer: 0,
	open: function( position, html ){
		
		this.close();
		
		$('<div></div>').appendTo('body').addClass('dynDiv menugenres').css({
			'top':position.top,
			'left': position.left,
			'position':'absolute',
			'display':'block'
		}).html( html ).fadeIn('slow');
		
		$(document).click( this.close );
		
	},
	close: function(){
		$('.dynDiv').remove();
		this.cancel_timer();
		$(document).unbind('click', this.close);
	},
	set_timer: function(){
		this.closetimer = window.setTimeout( this.close, this.timeout );
	},
	cancel_timer: function(){
		if(this.closetimer){
			window.clearTimeout(this.closetimer);
			this.closetimer = null;
		}
	}

};