/**
 * Javascript Dropdownmenu
 * @copyright Marcel Siewert 2010 (Bitkomponist.de)
 * @author Marcel Siewert 
 */

(function($){
	
	//Toolfunctions
	//----------------------------------------------------------------------------------
	function debug(mixed){
		if(window.console&&window.console.debug)window.console.debug(mixed)
	}
	
	function log(mixed){
		if(window.console&&window.console.log)window.console.log(mixed)
	}
		
	//Extending jQuery
	//----------------------------------------------------------------------------------
	$.extend($.fn,{
		BkDropMenu:function(config){
			return this.each(function() { 
				new BkDropMenu(this,$.extend({},defaultConfig, config));
			});
		}
	});
	
	//Constructor
	//----------------------------------------------------------------------------------
	function BkDropMenu (element,config){
		this.element = $(element);
		this.config = config;
		this.init();
	}
		
	//Config
	//----------------------------------------------------------------------------------
	var defaultConfig = {
		
	};
	
	
	//Logic/Prototype
	//----------------------------------------------------------------------------------
	BkDropMenu.prototype = BkDropMenu.fn = {
		id: null,
		name: 'BkDropMenu',
		element: null,
		config: null,
		//Helper to construct child element ids for quick access via '#' selectors
		cid:function(eltype){return this.id+eltype;},
		
		//
		init:function(){
			this.id = this.config.id||(this.name+(new Date().getTime())+''+(Math.round(Math.random()*1000)));
			if(!this.element.length)return false;
			this.element.addClass(this.name);
			var t=this;
			//this.element.children('li').mouseover();
		    this.element.children('li').hover(function(e){ return t.eOver(e);},function(e){ return t.eOut(e);});
		},
		eOver:function(e){
            var target = $(e.currentTarget);
            target.children('ul:first').slideDown(300);
            return false;
        },
        eOut:function(e){
            var target = $(e.currentTarget);
            target.children('ul:first').hide();
            return false;
        }
        
	};
	
	$(function(){
        $('#sitemenu').BkDropMenu();
    });
})(jQuery);

