function belItemSelected(querystring) {
//	alert("belItemSelected: " + querystring);
	  if (belenusHome.DetailFrame!= null) belenusHome.DetailFrame.belItemSelected(querystring);
}

function belHotspotClicked(id, exclusive) {
//	alert("belHotspotClicked: " + id + " ex? " + exclusive);
	belenusHome.DetailFrame.belItemClicked(id, exclusive);
}

function belTreeLabel(label) {
	if(belenusHome.HistoryBar != null) {
		belenusHome.HistoryBar.belTreeLabel(label);
	}
}

function belFolderSelected(treepath) {
//	alert("belFolderSelected: " + treepath);
	belenusHome.currentTreePath = treepath;
  if(!belenusHome.printServer) {  
  	if(belenusHome.HistoryBar != null) {
  		belenusHome.HistoryBar.IPH.add(treepath);
  	}
  }
  belenusHome.setXCookie("treepath",treepath);
}

function belItemDoubleClicked(querystring) {
  belenusHome.mrhidden.location.href="structure_jump.html?treepath="+belenusHome.currentTreePath+"&"+querystring;
}

function belDeviceSelected (treepath, id, treepathJunk) {
	//alert("belDeviceSelected: " + treepath + " / " + id + " / " + treepathJunk + " detlef: " + belenusHome.DetailFrame);
	belenusHome.currentTreePath = treepath;
  if(!belenusHome.printServer) {
  	if(belenusHome.HistoryBar != null) {
  	 	belenusHome.HistoryBar.IPH.add(treepath);
  	}
  	
  	belenusHome.setXCookie("treepath",treepath);
   
  	if (treepathJunk == "") treepathJunk = null;
  
  	if (belenusHome.DetailFrame == null) {
  		id = id.replace(/\./g,"%2e");
  		id = id.replace(/\?/g,"%3f");
  		id = id.replace(/\&/g,"%26");
  		id = id.replace(/\=/g,"%3d");
  		id = id.replace(/\:/g,"%3a");
  		id = id.replace(/\//g,"%2f");
   		url = 'detail.html?itemlist='+id+'&treepath='+treepath;
  		if (treepathJunk != null) {
  			url += '&selectitem='+treepathJunk;
  		}
  		belenusHome.inhalt.location = url;
  	} else if (belenusHome.DetailFrame != null) {
  		belenusHome.DetailFrame.setItemList(id, treepath, treepathJunk); // this function is defined at beldetail.js 
  	}
  }
}

// attachments in the tree applet are opened via this function
// to give the possibility for interaction and customisation
// display images centered
// it use the showDocument(..) fn

function belDocumentSelected(treepath, url, target) {
//	alert("belDocumentSelected: " + treepath + " / " + url + " / " + target);
	belenusHome.currentTreePath = treepath;
  if(!belenusHome.printServer) {  
  	if (treepath != null && treepath != '') {
  		if(belenusHome.HistoryBar != null) {
  			belenusHome.HistoryBar.IPH.add(treepath);  
  		}
  		belenusHome.setXCookie("treepath",treepath);
    } belenusHome.setXCookie("treepath","");
    if (url != null && url != '')	showDocument(url);
    else belenusHome.inhalt.location = "about:blank";
  }
}

// change drawing
function belChangeDrawing(label, id, url, mimetype) {
	if (belenusHome.DetailFrame != null) {
	  belenusHome.DetailFrame.changeDrawing(label, id, url, mimetype);
  }
}

function belSetImagelist(list, selected) {
//	alert("belSetImagelist: " + list + " / " + selected);
	if (belenusHome.DetailFrame != null) {
	  belenusHome.DetailFrame.belSetImageList(list, selected);
  }
}

function belSetToolbarButtonsStates(qsvalues) {
//	alert("belSetToolbarButtonsStates: " + qsvalues);
	if (belenusHome.DetailFrame != null) {
	  belenusHome.DetailFrame.belSetToolbarButtonsStates(qsvalues);
  }
}

// this function needs to be here, because
// it could be that the DetailFrame wasn't loaded, and u
// still like to show a document......
// this function was used only by the the function above "belDocumentSelected(.....)"
// if u call the showDocument(url) function directly an error occurrs...
// so we insert here an xtra function which calls the real executive function...

var gatta; // a place 4 the timer, so if this mehtode is call within a certain time, the executive method is not called twice a time, because the old (running) timer will be overwritten in this case.
function showDocument(url) {
//	alert("showDocument: " + url);
	clearTimeout(gatta);
	gatta = setTimeout("showDocumentX('"+url+"')",500); //wait...
}

function showDocumentX(url) {
	//alert("showDocumentX: " + url);
		var str = url.substring(url.lastIndexOf(".")+1, url.length);
		if(str == "gif" || str == "jpg" || str == "jpeg" || str == "png") { 
		    belenusHome.inhalt.document.open();
		    belenusHome.inhalt.document.writeln('<html><head><link type="text/css" rel="stylesheet" href="./css/content.css"></head><body bgcolor="#ffffff" scroll="auto"><table border="0" height="100%" width="100%"><tr><td valign="middle" align="center">');
		    belenusHome.inhalt.document.writeln('<table border="0"><tr><td align="center" valign="middle"><img src="'+url+'" border="0"></td></tr></table></td></tr></table></body></html>');
		    belenusHome.inhalt.document.close();
		}
		else if(str == "htm" || str == "html") {
		    belenusHome.inhalt.document.open();
		    belenusHome.inhalt.document.writeln('<html><body bgcolor="#ffffff" scroll="no"><iframe src="'+url+'" width="100%" height="100%">NO IFRAMES</iframe></body></html>');
		    belenusHome.inhalt.document.close();
		}
		else if(str == "avi" || str == "mov" || str == "mpg" || str == "mpeg") {
		    belenusHome.inhalt.document.open();
		    belenusHome.inhalt.document.writeln('<html><body scroll="no"><embed src="'+url+'" width="100%" height="100%"></embed></body></html>');
		    belenusHome.inhalt.document.close();
		}    
		else {
			belenusHome.inhalt.location = url;
		}		

}

// attachments in the table are opened via this fn

function belOpenURL(url, target, type) {
//	alert("belOpenURL: " + url + " / " + target + " / " + type);
	// handle absolute urls when j2js-bridging
	url = url.replace(/%3f/g,"?");
	url = url.replace(/%26/g,"&");
	url = url.replace(/%3d/g,"=");
	url = url.replace(/%2e/g,".");
	url = url.replace(/%3a/g,":");
	url = url.replace(/%2f/g,"/");
  url = unescape(url);
	//  type: 'default'(not used), 'pic', 'info'
	if (type == "pic") {
		window.open(url, "Info", "width=650,height=500,resizable=yes,scrollbars=yes").focus();
	} else {
		
		if (type == "info") {
			window.open(url, "Info", "width=650,height=600,resizable=yes,scrollbars=yes").focus();
		} else {
			window.open(url, "Info", "width=650,height=600,resizable=yes,scrollbars=yes").focus();
		}
		
	}
}

function belPrintSVG(url, w, h, transX, transY, scale) {
  var headline = belenusHome.currentLabel;
  var winWidth = 720;//720
  var winHeight = 880;//1080
  var commentFieldHeight = 170;
  var imgMaxWidth = winWidth;
  var imgMaxHeight = winHeight - commentFieldHeight; 
  if (w != imgMaxWidth || h != imgMaxHeight) {
    var factViewport = w/h;
    var factPrint = imgMaxWidth/imgMaxHeight;
    if (factViewport > factPrint) {
    	transX = Math.round(transX * imgMaxWidth / w);
    	transY = Math.round(transY * imgMaxWidth / w);
    	h = Math.round(imgMaxWidth * h / w);
    	w = imgMaxWidth;
    } else {
    	transX = Math.round(transX * imgMaxHeight / h);
    	transY = Math.round(transY * imgMaxHeight / h);
	    w = Math.round(imgMaxHeight * w / h);
    	h = imgMaxHeight;
    }
  }
  var winOpenProps = "scrollbars=yes,width="+(winWidth)+",height="+eval(parseInt(h)+commentFieldHeight);
      winOpenProps += "&type=svg&x="+transX+"&y="+transY+"&width="+w+"&height="+h+"&url="+escape(url)+"&fact="+scale+"&headline="+escape(headline);
  belenusHome.WM.openWindow("drawingPrint",winOpenProps,true);
}

function belPrintImage(url, x, y, w, h, factor, contr, cThres, smoo, origW, origH) {
  var headline = belenusHome.currentLabel;
  var winWidth = 800;//720
  var winHeight = 880;//1080
  var commentFieldHeight = 170;
  var imgMaxWidth = winWidth;
  var imgMaxHeight = winHeight - commentFieldHeight; 
  //adjust image sizes
  var tmpFact; 
  if (w < imgMaxWidth || h < imgMaxHeight) {
    var factY = h/imgMaxHeight;
    var factX = w/imgMaxWidth;
    if (factY < factX) {
	tmpFact = factY;
    	w = Math.round(w / tmpFact); 
    	h = imgMaxHeight;
    } else {
	tmpFact = factX;
    	h = Math.round(h / tmpFact);
    	w = imgMaxWidth;
    }
    factor = Math.round(factor / tmpFact);
    y = Math.round(y / tmpFact);
    x = Math.round(x / tmpFact);
  }
  if (h > imgMaxHeight) {
    tmpFact = h/imgMaxHeight;
    w = Math.round(w / tmpFact); 
    h = imgMaxHeight;
    factor = Math.round(factor / tmpFact);
    y = Math.round(y / tmpFact);
    x = Math.round(x / tmpFact);
  }
  if (w > imgMaxWidth) {
    tmpFact = w/imgMaxWidth;
    h = Math.round(h / tmpFact);
    w = imgMaxWidth;
    factor = Math.round(factor / tmpFact);
    y = Math.round(y / tmpFact);
    x = Math.round(x / tmpFact);
  }
  var winOpenProps = "";//"scrollbars=yes,width="+(winWidth)+",height="+eval(parseInt(h)+commentFieldHeight);
      winOpenProps += "&type=img&x="+x+"&y="+y+"&width="+w+"&height="+h+"&url="+escape(url)+"&fact="+factor+"&headline="+escape(headline)+"&smooth="+smoo+"&contrast="+contr+"&cThreshold="+cThres+"&origW="+origW+"&origH="+origH;
  belenusHome.WM.openWindow("drawingPrint",winOpenProps,true);
}

function belPrintSPL() {
	belenusHome.WM.openWindow("splPrintPopup");
//  var printWin = open('html/empty.html','printWin','width=760,height=560,scrollbars=yes');
	belenusHome.WM.getWindowReference("splPrintPopup").document.open();
	belenusHome.WM.getWindowReference("splPrintPopup").document.write('<html><head><link type="text/css" rel="stylesheet" href="./css/print_spl.css">');
	belenusHome.WM.getWindowReference("splPrintPopup").document.write('<title>'+belenusHome.getPrintLabel()+'</title></head>');
	belenusHome.WM.getWindowReference("splPrintPopup").document.write('<body leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" onload="self.print();">');
	if(belenusHome.currentLabel != "") {
		belenusHome.WM.getWindowReference("splPrintPopup").document.write('<b><font size="3" face="verdana">&nbsp;'+belenusHome.getPrintLabel()+'</font></b><br>');
	}
	var str = null;
//  alert(belenusHome.DetailFrame.jsPrintListNext());
	while ((str = belenusHome.DetailFrame.jsPrintListNext()) != "" && str != undef) { 
		belenusHome.WM.getWindowReference("splPrintPopup").document.write(str);
	}
	belenusHome.WM.getWindowReference("splPrintPopup").document.write('</body></html>');
	belenusHome.WM.getWindowReference("splPrintPopup").document.close();
}	

function belSearchForSingleID() {
	if(belenusHome.oci_interface == true) {
		belenusHome.document.getElementById('InvisibleFrame').src='oci/search_for_single_id.html';
	}
}

function belShowOrder() {
//	alert("belShowOrder");
	if(belenusHome.openCartWindowEnabled == true) {
		belenusHome.WM.openWindow("basket");
	}
}

