function DROW_preloadImages() { 
  var d=document; if(d.images){ if(!d.DROW_p) d.DROW_p=new Array();
    var i,j=d.DROW_p.length,a=DROW_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.DROW_p[j]=new Image; d.DROW_p[j++].src=a[i];}}
}

function DROW_PREload() { 
  var bild1=new Image();
  var bild2=new Image();
  bild2.src="/drowcrm/images/header_rechts.gif";
  var bild3=new Image();
  bild3.src="/drowcrm/images/header_links.gif";
  var bild4=new Image();
  bild4.src="/drowcrm/images/rechts_headline.gif";
  var bild5=new Image();
  bild5.src="/drowcrm/images/links_headline.gif";
  var bild6=new Image();
  bild6.src="drowcrm/images/backgr_headline.gif";
}

function DROW_repop(){
	if(!window.opener){
		if(window.open(this.location,'drowwcms','toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no')) {
			newWin=window.open(this.location,'drowwcms','toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no')
			newWin.resizeTo(1024,768);
			newWin.moveTo(0,0);
			window.opener='a';
			window.close();
		}
	}
}

/**function DROWLoader(){
	DROW_repop()
	DROW_PREload()
}*/




function cellGrauOn(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#EFEFEF";
		td.style.color="#EFEFEF";
	}
}

function cellGrauOff(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#ffffff";
		td.style.color="#EFEFEF";
	}
}

function cellOn(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#7E8BBB";
		td.style.color="#EFEFEF";
	}
}

function cellOff(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#ffffff";
		td.style.color="#4D4F87";
	}
}

//  neue CellOn-Funktionen   ->  ID der td übergeben
function cellGrauOn_id(td) {

	if (document.getElementById || (document.all && !(document.getElementById))) {
		document.getElementById(td).style.backgroundColor="#EFEFEF";
		document.getElementById(td).style.color="#EFEFEF";
	}

}

function cellGrauOff_id(td) {

	if (document.getElementById || (document.all && !(document.getElementById))) {
		document.getElementById(td).style.backgroundColor="#EFEFEF";
		document.getElementById(td).style.color="#EFEFEF";
	}

}
function cellOn_id(td) {
alert("On "+td);
	if (document.getElementById || (document.all && !(document.getElementById))) {
		document.getElementById(td).style.backgroundColor="#7E8BBB";
		document.getElementById(td).style.color="#EFEFEF";
	}

}

function cellOff_id(td) {
alert("Off "+td);
	if (document.getElementById || (document.all && !(document.getElementById))) {
		document.getElementById(td).style.backgroundColor="#ffffff";
		document.getElementById(td).style.color="#4D4F87";
	}

}


var delayTime = 700;
var showTime = 6000;
var tooltipDefaultStyle = "background: #FFFFFF; color: #000000; font: statusbar; padding: 0; border: 1 solid #7E8BBB; position: absolute; z-index: 99; visibility: hidden;";
var tooltipStart = "<div position: absolute;><table id=\"internaltooltipSpan\" cellspacing=2 cellpadding=2 style=\"" + tooltipDefaultStyle + "\"><tr><td>";
var tooltipEnd   = "</td></tr></table></div>";
var showTimeout;
var hideTimeout;
var shown = false;
var x;
var y;

function getReal(el) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (temp.getAttribute("tooltip")) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}

//document.onmouseover = doDocumentOnMouseOver;
//document.onmouseout = doDocumentOnMouseOut;
//document.onmousemove = doDocumentOnMouseMove;
function doDocumentOnMouseMove() {
	//x = window.event.x;
	//y = window.event.y;
}

function doDocumentOnMouseOver() {
	fromEl = getReal(window.event.fromElement);
	toEl = getReal(event.toElement);
	if ((toEl.getAttribute("tooltip")) && (toEl != fromEl)) {
		showTimeout = window.setTimeout("displaytooltip(toEl)", delayTime);
	}
}

function doDocumentOnMouseOut() {
	fromEl = getReal(event.fromElement);
	toEl = getReal(event.toElement);
	if ((fromEl.getAttribute("tooltip")) && (toEl != fromEl)) {
		window.clearTimeout(showTimeout);
		hidetooltip();
	}
}

function displaytooltip(el) {
	if (!document.all.internaltooltipSpan) {
		document.body.insertAdjacentHTML("BeforeEnd", tooltipStart + el.getAttribute("tooltip") + tooltipEnd);
	}
	else {
		internaltooltipSpan.outerHTML = tooltipStart + el.getAttribute("tooltip") + tooltipEnd;
	}
	var toolStyle = el.getAttribute("tooltipstyle");
	if (toolStyle != null) {
		internaltooltipSpan.style.cssText = tooltipDefaultStyle + toolStyle;
	}
	internaltooltipSpan.style.left = x - 3;  
	internaltooltipSpan.style.top = y + 20;

	dir = getDirection();
	if (typeof(swipe) == "function")
		window.setTimeout("swipe(internaltooltipSpan, dir);",1);	
	else if (typeof(fade) == "function")
		window.setTimeout("fade(internaltooltipSpan, true, 5)",1);
	else
		internaltooltipSpan.style.visibility = "visible";

	shown = true;
	hideTimeout = window.setTimeout("hidetooltip()", showTime);
}

function hidetooltip() {
	if (shown) {
		window.clearTimeout(hideTimeout);
		internaltooltipSpan.style.visibility = "hidden";
		shown = false;
	}
}

function getDirection() {
	var pageWidth, pageHeight, scrollTop;
//	if (ie) {
		pageHeight    = document.body.clientHeight;
		pageWidth     = document.body.clientWidth;
		tooltipTop    = internaltooltipSpan.style.pixelTop;
		tooltipLeft   = internaltooltipSpan.style.pixelLeft;
		tooltipHeight = internaltooltipSpan.offsetHeight;
		tooltipWidth  = internaltooltipSpan.offsetWidth;
		scrollTop     = document.body.scrollTop;
		scrollLeft    = document.body.scrollLeft;
		if (tooltipWidth > pageWidth)
			internaltooltipSpan.style.left = scrollLeft;
		else if (tooltipLeft + tooltipWidth - scrollLeft > pageWidth)
			internaltooltipSpan.style.left = pageWidth - tooltipWidth + scrollLeft;
		if (tooltipTop + tooltipHeight - scrollTop > pageHeight) {
			internaltooltipSpan.style.top = tooltipTop - tooltipHeight - 22;
			return 8;
		}
		return 2;
//	}
}



function DROW_findeObjekt(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=DROW_findeObjekt(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function DROW_LayerSichtbarkeit() { //v6.0
//Kommentar
  var i,p,v,obj,args=DROW_LayerSichtbarkeit.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=DROW_findeObjekt(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function DROW_findeObjekt(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=DROW_findeObjekt(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function DROW_submenu() { //v6.0
//Kommentar
  var i,p,v,obj,args=DROW_submenu.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=DROW_findeObjekt(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function DROW_wechsleBild() {
  var i,j=0,x,a=DROW_wechsleBild.arguments; document.DROW_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=DROW_findeObjekt(a[i]))!=null){document.DROW_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function DROW_Layer_Inline_show(divid) {
document.getElementById(divid).style.display="inline";
}
function DROW_Layer_Inline_hide(divid) {
document.getElementById(divid).style.display="none";
}


function DROW_menue_highlight(id) {
	document.getElementById('links_headline_'+id).style.backgroundImage='url(/drowcrm/images/links_headline_hell.gif)';
	document.getElementById('rechts_headline_'+id).style.backgroundImage='url(/drowcrm/images/rechts_headline_hell.gif)';
	document.getElementById('backgr_headline_'+id).style.backgroundImage='url(/drowcrm/images/backgr_headline_hell.gif)';
	document.getElementById('backgr_headline_'+id).style.color='#000000';
}
function DROW_menue_lowlight(id) {
	document.getElementById('links_headline_'+id).style.backgroundImage='url(/drowcrm/images/links_headline.gif)';
	document.getElementById('rechts_headline_'+id).style.backgroundImage='url(/drowcrm/images/rechts_headline.gif)';
	document.getElementById('backgr_headline_'+id).style.backgroundImage='url(/drowcrm/images/backgr_headline.gif)';
	document.getElementById('backgr_headline_'+id).style.color='#ffffff';
}

function DROW_leftmenue_switch(menue) {
	for(i in document.getElementsByTagName("a")) {
		if(document.getElementsByTagName("a")[i].className=="leftmenue_active") {
			document.getElementsByTagName("a")[i].className="leftmenue";
		}
	}
	menue.className="leftmenue_active";
}

function DROW_preselect_leftmenue(id) {

	for(var i in document.getElementsByTagName("a")) {
		var a = document.getElementsByTagName("a")[i];
		if( a.className == "leftmenue_active") {
			a.className =  "leftmenue";
		}		
		
		var error=false;
		try {
			var aid = a.id.split("_");
		} catch(e) {
			error=true;
		}
		
		if(!error && a.className == "leftmenue") {
			var regExp='<div class=\"?.*?\"?><img .*?>&nbsp;'+id+'<\\\/div>';

			eval('var b = a.innerHTML.match(/'+regExp+'/i);');
			if( aid[0] == "leftmenue" && b) {
				a.className="leftmenue_active";
			}		
			//eval("var b = a.innerHTML.match(/"+id+"/)");		
			//var regExp='<div class="leftmenue_div"><img src="[\w\/._]+?" border="0" align="absmiddle" width="16" height="14">&nbsp;'+id+'<\/div>';
			//var regExp='[0-9][0-9]">&nbsp;'+id+'<\/div>';
		}
	}
	
}

function DROW_preselect_tab(tabset, id) {
	for(i in document.getElementsByTagName("td")) {
		td=document.getElementsByTagName("td")[i];
		error=false;
		try {
			tab=td.id.split("__");
		} catch(e) {
			error=true;
		}
		if(!error) {
			if(tab[0]==tabset && td.innerHTML==id) {
				td.className="reiter_titelbalken";
			}
		}
	}
}

function DROW_preselect_top(id) {
	document.getElementById(topmenue+"_"+id).className="topmenuelink_active";
}

function GE(id) {
	return document.getElementById(id);
}

function getFormElements(NodeElement, getstr) {
//	alert(getstr);
	var i;
	for (i=0; i < NodeElement.childNodes.length; i++) {
		if (NodeElement.childNodes[i].tagName == "INPUT") {
			if (NodeElement.childNodes[i].type == "text") {
	   			getstr += NodeElement.childNodes[i].name + "=" + NodeElement.childNodes[i].value + "&";
			}
			if (NodeElement.childNodes[i].type == "hidden") {
	   			getstr += NodeElement.childNodes[i].name + "=" + NodeElement.childNodes[i].value + "&";
			}			
			if (NodeElement.childNodes[i].type == "checkbox") {
		   		if (NodeElement.childNodes[i].checked) {
		      		getstr += NodeElement.childNodes[i].name + "=" + NodeElement.childNodes[i].value + "&";
		   		} else {
		      		getstr += NodeElement.childNodes[i].name + "=&";
		   		}
			}
			if (NodeElement.childNodes[i].type == "radio") {
		   		if (NodeElement.childNodes[i].checked) {
		      		getstr += NodeElement.childNodes[i].name + "=" + NodeElement.childNodes[i].value + "&";
		       	}
	    	}
	 	} else if (NodeElement.childNodes[i].tagName == "SELECT") {
			var sel = NodeElement.childNodes[i];
			var sellaenge = NodeElement.childNodes[i].length;
			var komma1 = false;
			//alert(sel.options[1].value);
			//alert(typeof(sel.selectedIndex) + ' ' + sel.selectedIndex);	
			//if (sel.selectedIndex > 0) {
				getstr += sel.name + "=";
				for(var i=0; i<sellaenge; i++) with (sel.options[i]) { 
					if(selected) {
						if(komma1 == false) {
					 		getstr += value;
							komma1 = true;
						} else {
							getstr += "," + value;
						}
				 	}
				}
				getstr += "&";
			//}
			//alert(getstr);
	 	} else if (NodeElement.childNodes[i].tagName == "TEXTAREA") {
			getstr += NodeElement.childNodes[i].name + "="+NodeElement.childNodes[i].innerHTML+"&";
	 	} else {
			if (NodeElement.childNodes[i].hasChildNodes()) {	 		 
	 		 	getstr = getFormElements(NodeElement.childNodes[i], getstr);	 		 	
	 		}
	 	}
	}

//	alert(NodeElement.name);	
	return getstr;
}

