			function showHide(divId)
			{
				var now=document.getElementById(divId).style.display;
				if(now=="block")
				{
					document.getElementById(divId).style.display='none';
				}
				else
				{
					document.getElementById(divId).style.display='block';
				}
				
			}
 
  			function replaceString(original, replace, value)
  			{
  				while(original.indexOf(replace)>=0)
  				{
  					var before=original.substring(0,original.indexOf(replace));
  					var after=original.substring(original.indexOf(replace)+replace.length);
  					original=before+value+after;
  				}
  				
  				return original;
  			}
  		
  			function submitEdit(id)
  			{
				var theForm=document.getElementById('form_'+id);
					
				
				dojo.xhrPost({
				      url: "kalender_online_include.jsp",
				      form: 'form_'+id,
				      load: function(data, ioargs){
				      	var status=(data.replace(/^\s+|\s+$/g,""));
				      	if("NOT LOGGED IN"==status)
				      	{
				      		document.location.reload();	
				      	}
				      	else {
				      		document.getElementById('calendar_'+id.substring(0,id.lastIndexOf("_"))).innerHTML=data;	
				      		
				      	}
			      },
				      error: function(error,ioargs){
				         alert(error);
			      }
		      });
				

  				
  			}

  			function submitEditEn(id)
  			{
				var theForm=document.getElementById('form_'+id);
					
				
				dojo.xhrPost({
				      url: "calendar_online_include.jsp",
				      form: 'form_'+id,
				      load: function(data, ioargs){
				      	var status=(data.replace(/^\s+|\s+$/g,""));
				      	if("NOT LOGGED IN"==status)
				      	{
				      		document.location.reload();	
				      	}
				      	else {
				      		document.getElementById('calendar_'+id.substring(0,id.lastIndexOf("_"))).innerHTML=data;	
				      		
				      	}
			      },
				      error: function(error,ioargs){
				         alert(error);
			      }
		      });
				

  				
  			}
  			
  			function showEdit(id,holidays)
  			{
  				document.getElementById("d_"+id).style.display='none';
  				document.getElementById("e_"+id).style.display='block';
  				
  				var form='<div onclick=\"submitEdit(\'###id###\');\" style=\"position:fixed;top:0;left:0;width:100%;height:100%;background:#000000;z-index:2;opacity:0.01;filter:alpha(opacity=1);\"></div><div style=\"position:absolute;z-index:3\"><form id=\"form_###id###\"><input type=\"hidden\" name=\"holidays\" value=\"'+holidays+'\" /><input type=\"hidden\" name=\"date\" value=\"###id###\" /><textarea id=\"t_###id###\" wrap=\"on\" name=\"text\" style=\"font-family:verdana;border:0px;margin:0px;width:92px;height:70px;overflow:auto;font-size:9px;\"></textarea><input type=\"checkbox\" name=\"repeat\"  />\&nbsp;<small>Alle \u00e5r</small></form></div>';

  				var value=document.getElementById("o_"+id).value;
  				
  				form=replaceString(form,"###id###",id);
  				value=replaceString(value,"<br/>","\n");
  				
  				document.getElementById("e_"+id).innerHTML=form;
  				document.getElementById("t_"+id).value=value;
  				document.getElementById("c_"+id).onclick="";
  				document.getElementById("t_"+id).focus();
	  				
	  			}

   			function showEditEn(id,holidays)
  			{
  				document.getElementById("d_"+id).style.display='none';
  				document.getElementById("e_"+id).style.display='block';
  				
  				var form='<div onclick=\"submitEditEn(\'###id###\');\" style=\"position:fixed;top:0;left:0;width:100%;height:100%;background:#000000;z-index:2;opacity:0.01;filter:alpha(opacity=1);\"></div><div style=\"position:absolute;z-index:3\"><form id=\"form_###id###\"><input type=\"hidden\" name=\"holidays\" value=\"'+holidays+'\" /><input type=\"hidden\" name=\"date\" value=\"###id###\" /><textarea id=\"t_###id###\" wrap=\"on\" name=\"text\" style=\"font-family:verdana;border:0px;margin:0px;width:92px;height:70px;overflow:auto;font-size:9px;\"></textarea><input type=\"checkbox\" name=\"repeat\"  />\&nbsp;<small>Every year</small></form></div>';

  				var value=document.getElementById("o_"+id).value;
  				
  				form=replaceString(form,"###id###",id);
  				value=replaceString(value,"<br/>","\n");
  				
  				document.getElementById("e_"+id).innerHTML=form;
  				document.getElementById("t_"+id).value=value;
  				document.getElementById("c_"+id).onclick="";
  				document.getElementById("t_"+id).focus();
	  				
	  			}

  			
  				var counters=new Array();		
	
				function show(id)
				{
					if(counters[id]== undefined) counters[id]=0;
					
					counters[id]=counters[id]+1;
					var count=counters[id];
					
					
					setTimeout('showIt("'+id+'","'+count+'")',100);
				}
				
				function hide(id)
				{
					if(counters[id]== undefined) counters[id]=0;
	
					counters[id]=counters[id]+1;
					var count=counters[id];
	
					setTimeout('hideIt("'+id+'","'+count+'")',250);
				}
	
				function showIt(id,count)
				{
					if(counters[id]!=count) return;
					document.getElementById(id).style.display='block';
				}
				
				function hideIt(id,count)
				{
					if(counters[id]!=count) return;
					document.getElementById(id).style.display='none';
				}

  				function testUser()
				{
					var theForm=document.getElementById('login_form');
					
				
					dojo.xhrPost({
					      url: "make_test_user.jsp",
					      form: "login_form",
					      load: function(data, ioargs){
					      	var status=(data.replace(/^\s+|\s+$/g,""));
					      	if("true"==status)
					      	{
					      		document.location.reload();	
					      	}
					      	else if("false"==status)
					      	{
								document.getElementById('login_error').style.display="block";      		
					      		
					      	}
				      },
					      error: function(error,ioargs){
					         alert(error);
				      }
			      });
				

				}  	
				
  				function login()
				{
					var theForm=document.getElementById('login_form');
					
				
					dojo.xhrPost({
					      url: "make_login.jsp",
					      form: "login_form",
					      load: function(data, ioargs){
					      	var status=(data.replace(/^\s+|\s+$/g,""));
					      	if("true"==status)
					      	{
					      		document.location.reload();	
					      	}
					      	else if("false"==status)
					      	{
								document.getElementById('login_error').style.display="block";      		
					      		
					      	}
				      },
					      error: function(error,ioargs){
					         alert(error);
				      }
			      });
				

				}  			

 				function logout()
				{
					var theForm=document.getElementById('login_form');
					
				
					dojo.xhrPost({
					      url: "make_logout.jsp",
					      form: "login_form",
					      load: function(data, ioargs){
					      	var status=(data.replace(/^\s+|\s+$/g,""));
				      		document.location.reload();	
				      },
					      error: function(error,ioargs){
					         alert(error);
				      }
			      });
				

				}  		
 				
 				
			function loadContent(div_id,theurl)
			{
			
				dojo.xhrGet({
			    url: theurl,
			    load: function(response, ioArgs){
			      dojo.byId(div_id).innerHTML = response;
		      return response;
	    	},
	    		error: function(response, ioArgs){
	    	  	dojo.byId(div_id).innerHTML = 
	    	  	  " " + response;
	      
	    	  	return response;
	    	},
	    		handleAs: "text"
		  	});
		}		

  			function submitAndReload(form_id, target)
			{
				var theForm=document.getElementById(form_id);
				
				
				dojo.xhrPost({
				      url: target,
				      form: form_id,
				      load: function(data, ioargs){
				      	document.location.reload();
				      },
				      error: function(error,ioargs){
				         alert(error);
				      }
			      });
				

			}
			
  			function submitAndLoad(form_id, target, result_div)
			{
				var theForm=document.getElementById(form_id);
				
				
				dojo.xhrPost({
				      url: target,
				      form: form_id,
				      load: function(data, ioargs){
				      	document.getElementById(result_div).innerHTML=data;
				      },
				      error: function(error,ioargs){
				         alert(error);
				      }
			      });
				

			}
