function Dropdown() {
	var debug = false;
  var this1 = this;
 	this1.id = "Dropdown"; // name of this object

  
	this1.timeout         = 500;
	this1.closetimer		  = 0;
	this1.ddmenuitem      = 0;
	
	var clicked = false;

	this1.active = function() {
	}
	this1.inactive = function() {
	}
	// open hidden layer
	//function mopen(id)
	var mopen = function() {

		clicked = false;
			
		divid = "menu"+this.id.substr(8);
		logit("mopen="+this.id+'/'+divid);
		// cancel close timer
		mcancelclosetime();
	
		// close old layer
		if(this1.ddmenuitem) this1.ddmenuitem.style.visibility = 'hidden';
	
		// get new layer and show it
		this1.ddmenuitem = document.getElementById(divid);

		if (this1.ddmenuitem) {
			this1.ddmenuitem.style.visibility = 'visible';
	  }	
    this1.active();
	}
	// close showed layer
	
	var mclose = function() {
		logit("mclose timer");
		if(this1.closetimer)
		{
			window.clearTimeout(this1.closetimer);
			this1.closetimer = null;
		}
		if(this1.ddmenuitem) this1.ddmenuitem.style.visibility = 'hidden';
		this1.inactive();
	}
	var mcloseclick = function() {
		clicked = true;
		logit("mcloseclick");
		window.clearTimeout(this1.closetimer);
		if(this1.ddmenuitem) this1.ddmenuitem.style.visibility = 'hidden';
	}
	// go close timer
	var mclosetime = function() {
		logit("mclosetime:"+this.id+"Clicked:"+clicked);
		if (clicked == false) {
			if (this1.ddmenuitem) {
				this1.closetimer = window.setTimeout(mclose, this1.timeout);
			} else {
				mclose();
			}
		}
	}
	
	// cancel close timer
	var mcancelclosetime = function() {
		//logit("mcancelclosetime:"+this.id);
		if(this1.closetimer)
		{
			window.clearTimeout(this1.closetimer);
			this1.closetimer = null;
		}
	}
	var menuclick = function() {
		mcloseclick();
		logit('clickItem:'+this.id);
		logit('Parent:'+$(this).parent()[0].id);
		this1.clickItem(this,$(this).parent()[0].id);  // callback
		return false;
	}
	var navclick = function() {
		//this1.mcloseclick();
		logit('navclickItem:'+this.id);
		this1.clickItem(this,"");  // callback (top row clicked: no parent
	}
	this1.clickItem = function(thisobject,parent) {
	}
	$("ul#sddm > li > a").hover(mopen,mclosetime);
	$("ul#sddm > li > div").hover(mcancelclosetime,mclosetime);
	$("ul#sddm > li > div > a").click(menuclick);
	$("ul#sddm > li > a").click(navclick);
	
	function logit(text) {
		logitAll("Dropdown-"+text);
	}

}	

