function showPicture(image, title, sizex, sizey) {
	par ="";
	
	if (sizex != null) par += "&width="+sizex;
	if (sizey != null) par += "&height="+sizey;
	
	screenX_size = screen.width  - 200;
	screenY_size = screen.height - 200;
	
	if (screenX_size > 900) screenX_size = 900;
	if (screenY_size > 800) screenY_size = 800;
	 
	if (screenX_size < 1) screenX_size = 640;
	if (screenY_size < 1) screenY_size = 480;
	
	
	par += "&screenx=" + screenX_size;
	par += "&screeny=" + screenY_size;
	windowprops = getWinPosition(screenX_size, screenY_size) + ",resizable=yes";
	return window.open("doc/preview.jsp?image="+image+"&title="+title+par, "preview", windowprops );	
}

function showPicWithID(id, title) {
	      obj = document.getElementById(id);
	      
	      if (obj != null)
	      	showPic(obj.src, title, obj.width, obj.height);
	     
	}

function showPicture1(URL, title, base) {
	windowprops = getWinPosition(650,500);
 	text = "<html><head><base href=\""+base+"\"/><title>Preview</title>\n<link rel=\"stylesheet\" href=\"css/style.css\" type=\"text/css\">";
	text += "\n<script type=\"text/javascript\" src=\"doc/scripts/script.js\"></script>";
	text += "\n<script>var hh = 400; \n function doResize() { document.images[0].height=getHeight(window)-100; } \n</script>";
	text += "</head><body onresize=\"doResize()\" topmargin=\"0\" leftmargin=\"0\" bgcolor=\"white\">";
	text += "\n<center><br>";
	text += "\n<script>document.write('<img src=\"" + URL + "\" height=\"'+ hh +'\">');</script>\n";
	text = text + "\n<p/><br><a align=\"center\" class=\"preview\">" + title + "</a>";
	text = text + "\n<p/><br>&lt;<a class=\"preview\" HREF=\"Javascript:this.close()\">Fenster schliessen</a>&gt;";
	text = text + "\n</center></body></html>";
	windowprops +=",resizable=yes";
 	
 	preview = window.open("", "preview", windowprops);
	preview.document.open();
	preview.document.write(text);
	preview.document.close();

return preview;
}

function showGastInfo(url){
	window.open(url,"GastInfo", getWinPosition(650,500));
}

function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}



function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}



function Trim(String)
{
	if (String == null)
		return (false);

	return RTrim(LTrim(String));
}

function getWidth(whichFrame) {
	if (whichFrame != null) {
 		width  = whichFrame.innerWidth;
   	if (isNaN(width) == true)	width = whichFrame.document.body.clientWidth;
	  	return width;
   } else return -1;
}   

function getRestWidth(whichFrame) {
	if (whichFrame != null) {
 		width  = whichFrame.innerWidth;
   	if (isNaN(width) == true)	width = whichFrame.parent.document.body.clientWidth - whichFrame.document.body.clientWidth;
   	else width = wichFrame.parent.innerWidth - width;
	  	return width;
   } else return -1;
} 

function getHeight(whichFrame) {
	if (whichFrame != null) {
 		height  =  whichFrame.innerHeight;
   	if (isNaN(height) == true)	height = whichFrame.document.body.clientHeight;
   	return height;
   } else return -1;
}  

function getRestHeight(whichFrame) {
	if (whichFrame != null) {
 		height  = whichFrame.innerHeight;
   	if (isNaN(height) == true)	height = whichFrame.parent.document.body.clientHeight - whichFrame.document.body.clientHeight;
   	else height = wichFrame.parent.innerHeight - height;
	  	return height;
   } else return -1;
} 

function goBack(){
	 history.back();
}

function isIE(){
 if (navigator.appName=='Microsoft Internet Explorer') return true;
 return false;
	
}

function getBrowser() {
	return navigator.appName;
}

function getWinPosition(xsize,ysize) {
	dimString  = "dependent=true, left="+Math.floor((screen.width - xsize)/2);
	dimString += ",top="+(Math.floor((screen.height - ysize)/2)-35);
	dimString += ",width="+xsize;
	dimString += ",height="+ysize;
	 
	return dimString;
}

function getGPS(float_value){
	if (float_value.length == 0) return "";
	grad = Math.floor(float_value / 60);
	min = float_value - (grad * 60) +" ";
	pos = min.indexOf(".");
	if (pos ==1) min = "0"+min;
	return grad+"°"+min.substring(0,5)+"'";
}

function initWindow(win) {
			if (win!=null && !win.closed) win.close();
}

function highLightField(id, class_name) {
	 
		 document.getElementById(id).className=class_name;
		
	
}

var animationRun = true;
var point =" ";

function startAnimation(text) {
	 
		point=" ";
		animationRun = true;
		obj = document.getElementById("animation");
	
	  
	   
		 if (obj == null) return;
		
		obj.innerHTML = "&nbsp;" +text+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		obj.style.display="inline";
	 
		obj.style.left = (getWidth(window) - obj.clientWidth) / 2 ; 
		obj.style.top  = (getHeight(window)- obj.clientHeight) / 2; 
	
		startAnimation1(3,text);
}

function startAnimation1(nr, text){
	 obj1 = document.getElementById("animation");
	 
	 if (obj1 == null || animationRun == false) return;
	 
	 obj1.style.display="inline";
	 
	 if (nr == 0) {
	 	 text_mes = "&nbsp;"+text+" &nbsp;&nbsp;&nbsp;&nbsp;";
	 	 cmd = "startAnimation1(1,'"+text+"')";
	 	 
	 }else if (nr == 1) {
	 	text_mes = "&nbsp;"+text+" .&nbsp;&nbsp;&nbsp;";
	 	cmd = "startAnimation1(2,'"+text+"')";
	 	 
	 } else if (nr == 2) {
	 	 text_mes = "&nbsp;"+text+" ..&nbsp;&nbsp;";
	 	 cmd = "startAnimation1(3,'"+text+"')";
	 	 
	 } else if (nr == 3) {
	 	 text_mes = "&nbsp;"+text+" ...&nbsp;";
	 	 cmd = "startAnimation1(0,'"+text+"')";
	 	 
	 	}
	 
	 obj1.innerHTML = text_mes;
	 point += ".";
	 if (top != null) top.status = text + point;
	 setTimeout(cmd, 500);
}

function stopAnimation(){
	 animationRun = false;
	 
	 obj2 = document.getElementById("animation");
	 
	 if (obj2 == null) return;
	 
	 obj2.style.display="none";
}

function setStatus(text) {

	if (top != null) top.status = text;	
	
}

function replaceChars(entry, out, add) {
	temp = "" + entry; // temporary holder
	
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));

	}
		return temp;
}