function combit_dd_menu(id)
{
    if (!document.getElementById || !document.getElementsByTagName)
    {
        return false;
    }
    this.menu          = document.getElementById(id).getElementsByTagName("ul")[0];
    this.debug         = false;
    this.id            = id;
    this.slideInSpeed  = 3;
    this.slideOutSpeed = 5;
    this.slideIn       = true;
    this.slideOut      = true;
    this.timer         = Array();
}
combit_dd_menu.prototype.init = function()
{
	var mainInstance = this;
  	for (var i = 0; i < this.menu.getElementsByTagName("li").length; i++)
  	{
  		var currentNode = this.menu.getElementsByTagName("li")[i];
  		if (currentNode.parentNode.parentNode.id == mainInstance.id)
  		{
      		currentNode.parentNode.style.height = "0px"; // Opera-Fix
        	currentNode.onmouseover = function(e)
	        {
	            if (mainInstance.slideIn) {
	                mainInstance.expandMenu(e, this.getElementsByTagName("ul")[0]);
	            }
	        };
	    	currentNode.onmouseout = function(e)
	        {
	          if (mainInstance.slideOut) {
	              mainInstance.collapseMenu(e, this.getElementsByTagName("ul")[0]);
	            }
	        };
        }
  	}
  	window.onunload = function(e)
  	{
  		mainInstance.update_debug(e, "OnUnload");
		mainInstance.closeMenues();
   	}
  	window.onblur = function(e)
  	{
  		mainInstance.update_debug(e, "OnBlur");
		mainInstance.closeMenues();
   	}
    if (this.debug)
    {
    	document.write("<div id=\"combit_dd_menu_debug\"><h2>Combit-DD-Menue<br />Debug <span id=\"combit_dd_menu_debug_1\"></span></h2><ul><li><strong>e.fromElement.tagName:</strong> <span id=\"combit_dd_menu_debug_2\"></span></li><li><strong>e.toElement.tagName:</strong> <span id=\"combit_dd_menu_debug_3\"></span></li><li><strong>e.target.tagName:</strong> <span id=\"combit_dd_menu_debug_4\"></span></li></ul></div><div id=\"combit_dd_menu_debug_5\"><ul><li>Menü geladen</li></ul></div>");
    }
}
combit_dd_menu.prototype.expandMenu = function(e, submenu)
{
	if (!e)
	{
		var e = window.event; // Internet-Explorer-Fix
	};
	this.update_debug(e, "OnMouseOver");
 	var target 		= e.target 		  || e.srcElement  || false;
	var fromElement = e.relatedTarget || e.fromElement || false;
  	if (submenu.parentNode.getElementsByTagName("A")[0].className.indexOf("hover") == -1 &&    !this.isInside(target, submenu))
	{
	    if (this.slideOut)
    	{
        	submenu.style.display = "block";
     	}
        submenu.style.height = "0px"
     	var fullHeight = 0;
     	var links      = submenu.getElementsByTagName("li");
      	for (var i = 0; i < links.length; i++)
      	{
          	fullHeight += links[i].offsetHeight + 5;
      	}
     	var moveBy = Math.round(this.slideInSpeed * links.length);
      	var mainInstance = this;
		clearTimeout(mainInstance.timer[submenu.className.substr(0, 6)]);
		submenu.parentNode.getElementsByTagName("A")[0].className += " hover";
    	mainInstance.timer[submenu.className.substr(0, 6)] = setInterval(function()
     	{
        	var curHeight = submenu.offsetHeight;
        	var newHeight = curHeight + moveBy;
        	if (newHeight < fullHeight)
        	{
            	submenu.style.height = newHeight + "px";
          	}
          	else
          	{
              	clearInterval(mainInstance.timer[submenu.className.substr(0, 6)]);
              	submenu.style.height = fullHeight + "px";
          	}
      	}, 30);
  	}
};


combit_dd_menu.prototype.isInside = function(toElement, submenu)
{
    for (i = 1; i <= 5; i++)
    {
        if (toElement == submenu)
        {
            return true;
        }
        if (toElement)
        toElement = toElement.parentNode;
    }
    return false;
}

combit_dd_menu.prototype.collapseMenu = function(e, submenu)
{
	if (!e)
	{
		var e = window.event; // Internet-Explorer-Fix
	};
    this.update_debug(e, "OnMouseOut");
    var target 	  = e.target   		|| e.srcElement  || false;
    var toElement = e.relatedTarget || e.toElement	 || false;
    if (submenu.parentNode.getElementsByTagName("A")[0] != toElement && !this.isInside(toElement, submenu))
	{
	    submenu.style.display = "block";
    	var moveBy = Math.round(this.slideOutSpeed * submenu.getElementsByTagName("li").length);
    	if (moveBy < 10) {
    	  moveBy = 10;
    	}
    	var mainInstance = this;
      	clearTimeout(mainInstance.timer[submenu.className.substr(0, 6)]);
     	mainInstance.timer[submenu.className.substr(0, 6)] = setInterval(function()
      	{
        	var curHeight = submenu.offsetHeight;
        	var newHeight = curHeight - moveBy;
        	if (newHeight > 0)
        	{
            	submenu.style.height = newHeight + "px";
        	}
          	else
          	{
              	clearInterval(mainInstance.timer[submenu.className.substr(0, 6)]);
              	submenu.style.height = "0px";
              	submenu.style.display = "none";
              	submenu.parentNode.getElementsByTagName("A")[0].className = submenu.parentNode.getElementsByTagName("A")[0].className.replace("hover", "");
          	}
    	}, 30);
  	}
};
combit_dd_menu.prototype.closeMenues = function()
{
    for (var i = 0; i < this.menu.getElementsByTagName("li").length; i++)
  	{
        if (this.menu.getElementsByTagName("ul")[i])
        {
            this.menu.getElementsByTagName("ul")[i].display = "none";
        }
        if (this.menu.getElementsByTagName("a")[i])
        {
            this.menu.getElementsByTagName("a")[i].className = this.menu.getElementsByTagName("a")[i].className.replace("hover", "");
        }
    }
}
combit_dd_menu.prototype.update_debug = function(e, type)
{
	if (this.debug)
	{
		if (!e)
		{
			var e = window.event; // Internet-Explorer-Fix
		}
    	var target 	    = e.target   	  || e.srcElement  || false;
  		var toElement   = e.relatedTarget || e.toElement   || false;
  		var fromElement = e.relatedTarget || e.fromElement || false;
  		document.getElementById('combit_dd_menu_debug_1').innerHTML = "(" + type + ")";
  		document.getElementById('combit_dd_menu_debug_4').innerHTML = target.tagName;
  		document.getElementById('combit_dd_menu_debug_3').innerHTML = toElement.tagName;
  		document.getElementById('combit_dd_menu_debug_2').innerHTML = fromElement.tagName;
  		document.getElementById('combit_dd_menu_debug_5').getElementsByTagName("UL")[0].innerHTML = "<li>" + type + ": " + target.tagName + "</li>" + document.getElementById('combit_dd_menu_debug_5').getElementsByTagName("UL")[0].innerHTML;
  	}
};



/*     --------------------    jshelper.js   --------------------   */

function newwin(strFile,strName,nW,nH)  {	
	//strName = strName.replace(/\s/g,'_');
	//strName = strName.replace(/\./g,'_');
	
	if(parseInt(nW) > 1024 || parseInt(nH) > 900) {
		newWinI = window.open("about:blank",strName +"S",'width=' + nW + ',height=' + nH +',screenx=100,screeny=100,scrollbars=yes');
	} else {
		newWinI = window.open("about:blank",strName,'width=' + nW + ',height=' + nH +',screenx=100,screeny=100');
	}
	newWinI.document.close();
	newWinI.document.open();
	newWinI.document.write("<html><head><title>"+strName+"</title></head>");
	newWinI.document.write("<body marginwidth='0' marginheight='0' topmargin='0' rightmargin='0' leftmargin='0'>");
    newWinI.document.write("<img src='" + strFile + "' width='" + nW + "' height='" + nH +"'>");
    newWinI.document.write("</body></html>"); 
    newWinI.document.close();
}	


function Mail(sName) 
{
	var Mailto = "mailto:" + sName + "@combit.net";
	window.location.href = Mailto;
}


if(top.frames.length > 0)
{
  try
  {
    if(location.search != '?refsp=combit_com' && location.href.indexOf('195.149.74.124') == -1 && location.href.indexOf('cms.combit.dev') == -1 && location.href.indexOf('cms.combit.') == -1 && location.href.indexOf('87.106.14.68') == -1 && location.href.indexOf('intra') == -1  && location.href.indexOf('backend') == -1)
    {
        //top.location.href = 'http://www.combit.net' + parent.frames[0].location.pathname;
	top.location.href = "/welcome.aspx";
    }
  }
  catch (e)
  {
  }
}







