PageRenderTime 81ms CodeModel.GetById 12ms app.highlight 62ms RepoModel.GetById 1ms app.codeStats 0ms

/js/freshdns.js

http://freshdns.googlecode.com/
JavaScript | 657 lines | 617 code | 38 blank | 2 comment | 16 complexity | 9ce5bd256f36e5510bc136ed2bfe8afe MD5 | raw file
  1var timeoutInMilisec = 100;
  2
  3function resultError (request)
  4{
  5	alert('Error ' + request.status + ' -- ' + request.statusText + ' -- ' + request.responseText);
  6}
  7
  8function resultDebug (request)
  9{
 10	document.getElementById("debug").style.display = 'inline';
 11	document.getElementById("debug").innerHTML = request.responseText;
 12}
 13
 14function dummy ()
 15{
 16	return true;
 17}
 18
 19function succesFailed (request)
 20{
 21	if (request.readyState==4)
 22	{
 23		// JAVASCRIPT DEBUG INFORMATION
 24		//document.getElementById("query").innerHTML = request.responseText;
 25		
 26		var jsonData = eval('('+request.responseText+')');
 27
 28		if(jsonData.status=="success")
 29		{
 30			alert(jsonData.text);
 31		}else
 32		{
 33			alert("Failed: "+jsonData.text);
 34		}
 35		
 36		if(jsonData.reload=="yes")
 37		{
 38			window.location.reload();
 39		}
 40	}
 41}
 42
 43function displayList (id, name, records, fullname, userId)
 44{
 45	output  = '<tr><td>[ <a href="javascript:deleteZone(\''+id+'\')">delete zone</a> ]</td>';
 46	output += '<td><a href="javascript:editDomain('+id+');">'+name+'</a></td>';
 47	output += '<td>'+records+'</td>';
 48	output += '<td><a href="javascript:ownersList(\''+userId+'\');">'+fullname+'</a></td></tr>';
 49	
 50	return output;
 51}
 52
 53function list (letter)
 54{
 55	new Ajax.Request(baseurl+"?p=letterlist&letter="+letter, 
 56	{
 57		method:"get",
 58		asynchronous:true,
 59		onSuccess:showList,
 60		onFailure:resultError
 61	});
 62}
 63
 64function showList (request)
 65{
 66	if (request.readyState==4) {
 67		document.getElementById("body").innerHTML = '';
 68		
 69		var jsonData = eval('('+request.responseText+')');
 70		var output = '<table width="800">';
 71		
 72		if(request.responseText.length==2)
 73		{
 74			output += '<tr><td>No results found</td></tr>';
 75		}
 76		
 77		for(i=0; i<jsonData.length; i++)
 78		{
 79			output += displayList (jsonData[i].id, jsonData[i].name, jsonData[i].records, jsonData[i].fullname, jsonData[i].userId);
 80		}
 81		
 82		output += '</table>';
 83		
 84		document.getElementById("body").innerHTML = output;
 85	}
 86}
 87
 88function liveSearchStart()
 89{
 90	new Ajax.Request(baseurl+"?p=livesearch&q="+document.getElementById('livesearch').value, 
 91	{
 92		method:"get",
 93		asynchronous:true,
 94		onSuccess:liveSearchResults,
 95		onFailure:resultError
 96	});
 97}
 98
 99function liveSearchResults (request) 
100{
101	if (request.readyState==4) {
102		document.getElementById("body").innerHTML = '';
103		
104		var jsonData = eval('('+request.responseText+')');
105		var output = '<table width="800">';
106		
107		if(request.responseText.length==2)
108		{
109			output += '<tr><td>No results found</td></tr>';
110		}
111		
112		for(i=0; i<jsonData.length; i++)
113		{
114			output += displayList (jsonData[i].id, jsonData[i].name, jsonData[i].records, jsonData[i].fullname, jsonData[i].userId);
115		}
116		
117		output += '</table>';
118		
119		document.getElementById("body").innerHTML = output;
120	}
121}
122
123function ownersList (userId)
124{
125	new Ajax.Request(baseurl+"?p=ownerslist&userId="+userId, 
126	{
127		method:"get",
128		asynchronous:true,
129		onSuccess:showOwnersList,
130		onFailure:resultError
131	});
132}
133
134function showOwnersList (request)
135{
136	if (request.readyState==4) {
137		document.getElementById("body").innerHTML = '';
138		
139		var jsonData = eval('('+request.responseText+')');
140		var output = '<table width="800">';
141		
142		if(request.responseText.length==2)
143		{
144			output += '<tr><td>No results found</td></tr>';
145		}
146		
147		for(i=0; i<jsonData.length; i++)
148		{
149			output += displayList (jsonData[i].id, jsonData[i].name, jsonData[i].records, jsonData[i].fullname, jsonData[i].userId);
150		}
151		
152		output += '</table>';
153		
154		document.getElementById("body").innerHTML = output;
155	}
156}
157
158function deleteZone (domainId)
159{
160	if(confirm("Are you sure you want to delete this domain?"))
161	{
162		new Ajax.Request(baseurl+"?p=deleteZone&domainId="+escape(domainId), 
163		{
164			method:"get",
165			asynchronous:true,
166			onSuccess:succesFailed,
167			onFailure:resultError
168		});
169	}
170}
171
172function editDomain (domainId)
173{
174	new Ajax.Request(baseurl+"?p=getDomainInfo&domainId="+escape(domainId), 
175	{
176		method:"get",
177		asynchronous:true,
178		onSuccess:editDomainWindow,
179		onFailure:resultError
180	});
181}
182
183function editDomainWindow (request)
184{	
185	if (request.readyState==4)
186	{
187		if(request.responseText=='failed')
188		{
189			alert("The action you performed failed.");
190		}else
191		{
192			var jsonData = eval('('+request.responseText+')');
193			
194			new Ajax.Request(baseurl+"?p=getOwners",
195        		{
196                		method:"get",
197                		asynchronous:true,
198                		onSuccess:changeOwnersSelect,
199                		onFailure:resultError
200        		});
201
202
203			var result  = '<p><table>';
204			result += '  <tr>';
205			result += '	<td><h1>Edit domain :: '+jsonData.domain.name+' ('+jsonData.records.length+')</h1></td>';
206			result += '  </tr>';
207			result += '  <tr>';
208			result += '	<td><form name="editDomain" action="javascript:saveAllRecords(document.editDomain);">';
209			result += '	<input type="hidden" id="domainId" value="'+jsonData.domain.id+'" /><table>';
210			result += '	<tr><td><b>name</b></td><td><b>type</b></td><td><b>content</b></td><td><b>prio</b></td><td><b>ttl</b></td><td>&nbsp;</td><td>&nbsp;</td></tr>';
211			
212			for(i=0; i<jsonData.records.length; i++)
213			{
214				var r = jsonData.records[i];
215				result += '<tr>';
216				result += '<td><input type="text" value="'+r.name+'" id="name['+i+']"><input type="hidden" value="'+r.id+'" id="id['+i+']"></td>';
217				result += '<td><input type="text" size="4" value="'+r.type+'" id="type['+i+']"></td>';
218				result += '<td><input type="text" size="50" value="'+r.content+'" id="content['+i+']"></td>';
219				result += '<td><input type="text" size="2" value="'+r.prio+'" id="prio['+i+']"></td>';
220				result += '<td><input type="text" size="4" value="'+r.ttl+'" id="ttl['+i+']"></td>';
221				result += '<td><input type="button" onclick="removeRecord('+r.id+', '+jsonData.domain.id+');setTimeout(\'editDomain('+jsonData.domain.id+');\', '+timeoutInMilisec+');" value="delete record" id="delete['+i+']"></td>';
222				result += '<td><input type="button" onclick="javascript:saveRecord('+jsonData.domain.id+', document.getElementById(\'id['+i+']\').value, ';
223				result += 'document.getElementById(\'name['+i+']\').value, document.getElementById(\'type['+i+']\').value, ';
224				result += 'document.getElementById(\'content['+i+']\').value, document.getElementById(\'prio['+i+']\').value, ';
225				result += 'document.getElementById(\'ttl['+i+']\').value); setTimeout(\'editDomain('+jsonData.domain.id+');\', '+timeoutInMilisec+');" id="save['+i+']" value="save"></td>';
226				result += '</tr>';
227			}
228			
229			result += '	<tr><td colspan="7"><input type="submit" value="save all changes"></td></tr></table></form></td>';
230			result += '  </tr>';
231			result += '  <tr>';
232			result += '	<td><h1>Add a record</h1></td>';
233			result += '  </tr>';
234			result += '  <tr>';
235			result += '	   <td><table>';
236			result += '	   <tr><td><b>name</b></td><td><b>type</b></td><td><b>content</b></td><td><b>prio</b></td><td><b>ttl</b></td><td>&nbsp;</td></tr>';
237			result += '    <tr><td><input type="text" value="'+r.name+'" id="new[name]" /></td>';
238			result += '    <td><select id="new[type]"><option selected="selected" value="A">A</option>';
239			result += '    <option value="AAAA">AAAA</option><option value="CNAME">CNAME</option>';
240			result += '    <option value="HINFO">HINFO</option><option value="MX">MX</option>';
241			result += '    <option value="NAPTR">NAPTR</option><option value="NS">NS</option>';
242			result += '    <option value="PTR">PTR</option><option value="SOA">SOA</option>';
243			result += '    <option value="TXT">TXT</option><option value="URL">URL</option>';
244			result += '    <option value="SRV">SRV</option><option value="MBOXFW">MBOXFW</option></select></td>';
245			result += '	   <td><input type="content" size="50" value="" id="new[content]" /></td>';
246			result += '	   <td><input type="prio" size="2" value="0" id="new[prio]" /"></td>';
247			result += '	   <td><input type="ttl" size="4" value="3600" id="new[ttl]" /></td>';
248			result += '	   <td><input type="button" onclick="newRecord('+jsonData.domain.id+', document.getElementById(\'new[name]\').value, ';
249			result += 'document.getElementById(\'new[type]\').value, document.getElementById(\'new[content]\').value, ';
250			result += 'document.getElementById(\'new[prio]\').value, document.getElementById(\'new[ttl]\').value); setTimeout(\'editDomain('+jsonData.domain.id+');\', '+timeoutInMilisec+');" id="new[save]" value="save" />';
251			result += '	</tr></table></td>';
252			result += '  </tr>';
253
254			if(userlevel >= 5)
255			{
256				result += '  <tr>';
257                result += '     <td><h1>Transfer domain</h1></td>';
258                result += '  </tr>';
259                result += '  <tr>';
260                result += '    <td>Transfer domain to <select id="owner"></select>';
261				result += ' <input type="button" onclick="transferDomain('+jsonData.domain.id+', document.getElementById(\'owner\').value);" value="transfer" /></td>';
262                result += '  </tr>';
263				result += '</table></p>';
264			}
265			
266			document.getElementById('body').innerHTML = result;
267		}
268	}
269}
270
271function saveAllRecords (input)
272{
273	var postBody = 'dummy=true';
274	
275	for(i=0; i<input.length; i++)
276	{
277		var ident = input[i].id;
278		var value = input[i].value;
279		
280		if(ident == "domainId")
281		{
282			var domainId = value;
283		}
284		
285		postBody += '&'+escape(ident)+'='+escape(value);
286	}
287	
288	new Ajax.Request(baseurl+"?p=saveAllRecords",
289    {
290    	method:"post",
291		postBody:postBody,
292		asynchronous:true,
293		onSuccess:succesFailed,
294		onFailure:resultError
295	});
296	
297	setTimeout('editDomain('+domainId+');', timeoutInMilisec);
298}
299
300function transferDomain (domainId, owner)
301{
302	new Ajax.Request(baseurl+"?p=transferDomain",
303        {
304                method:"post",
305                postBody:"domainId="+escape(domainId)+"&owner="+escape(owner),
306                asynchronous:true,
307                onSuccess:succesFailed,
308                onFailure:resultError
309        });
310}
311
312function removeRecord (recordId, domainId)
313{
314	if(confirm("Are you sure you want to delete the record?"))
315	{
316		new Ajax.Request(baseurl+"?p=removeRecord&recordId="+escape(recordId)+"&domainId="+escape(domainId), 
317		{
318			method:"get",
319			asynchronous:true,
320			onSuccess:succesFailed,
321			onFailure:resultError
322		});
323	}
324}
325
326function saveRecord(domainId, recordId, name, type, content, prio, ttl)
327{
328	new Ajax.Request(baseurl+"?p=saveRecord", 
329	{
330		method:"post",
331		postBody:"domainId="+escape(domainId)+"&recordId="+escape(recordId)+"&name="+escape(name)+"&type="+escape(type)+"&content="+escape(content)+"&prio="+escape(prio)+"&ttl="+escape(ttl),
332		asynchronous:true,
333		onSuccess:succesFailed,
334		onFailure:resultError
335	});
336}
337
338function newRecord (domainId, name, type, content, prio, ttl)
339{
340	new Ajax.Request(baseurl+"?p=newRecord", 
341	{
342		method:"post",
343		postBody:"domainId="+escape(domainId)+"&name="+escape(name)+"&type="+escape(type)+"&content="+escape(content)+"&prio="+escape(prio)+"&ttl="+escape(ttl),
344		asynchronous:true,
345		onSuccess:succesFailed,
346		onFailure:resultError
347	});
348}
349
350function newDomain ()
351{
352	new Ajax.Request(baseurl+"?p=getOwners", 
353	{
354		method:"get",
355		asynchronous:true,
356		onSuccess:changeOwnersSelect,
357		onFailure:resultError
358	});
359	
360	new Ajax.Request(baseurl+"?p=getTemplates", 
361	{
362		method:"get",
363		asynchronous:true,
364		onSuccess:changeTemplateSelect,
365		onFailure:resultError
366	});
367	
368	var result  = '<table>';
369	result += '<tr>';
370	result += '	 <td colspan="2"><h1>Add a domain</h1></td>';
371	result += '</tr>';
372	result += '<tr><td>Domain name:</td><td><input type="text" id="domain" /></td></tr>';
373	result += '<tr><td>WEB IP:</td><td><input type="text" id="webIP" /></td></tr>';
374	result += '<tr><td>Mail IP:</td><td><input type="text" id="mailIP" /></td></tr>';
375	result += '<tr><td>Owner:</td><td><select id="owner"></select></td></tr>';
376	result += '<tr><td>Template:</td><td><select id="template"></select></td></tr>';
377	result += '<tr><td>&nbsp;</td><td><input type="button" id="add" value="Add domain" onClick="saveNewRecord(document.getElementById(\'domain\').value, ';
378	result += 'document.getElementById(\'webIP\').value, document.getElementById(\'mailIP\').value, document.getElementById(\'owner\').value, ';
379	result += 'document.getElementById(\'template\').value);" /></td></tr>';
380	result += '</table>';
381	
382	document.getElementById('body').innerHTML = result;
383}
384
385function bulkNewDomain ()
386{
387	new Ajax.Request(baseurl+"?p=getOwners", 
388	{
389		method:"get",
390		asynchronous:true,
391		onSuccess:changeOwnersSelect,
392		onFailure:resultError
393	});
394	
395	new Ajax.Request(baseurl+"?p=getTemplates", 
396	{
397		method:"get",
398		asynchronous:true,
399		onSuccess:changeTemplateSelect,
400		onFailure:resultError
401	});
402	
403	var result  = '<table>';
404	result += '<tr>';
405	result += '	 <td colspan="2"><h1>Add multiple domains</h1></td>';
406	result += '</tr>';
407	result += '<tr><td>Domain names:<br />(one domain per line)</td><td><textarea id="domains" rows="10" cols="50"></textarea></td></tr>';
408	result += '<tr><td>WEB IP:</td><td><input type="text" id="webIP" /></td></tr>';
409	result += '<tr><td>Mail IP:</td><td><input type="text" id="mailIP" /></td></tr>';
410	result += '<tr><td>Owner:</td><td><select id="owner"></select></td></tr>';
411	result += '<tr><td>Template:</td><td><select id="template"></select></td></tr>';
412	result += '<tr><td>&nbsp;</td><td><input type="button" id="add" value="Add domains" onClick="saveNewDomains(document.getElementById(\'domains\').value, ';
413	result += 'document.getElementById(\'webIP\').value, document.getElementById(\'mailIP\').value, document.getElementById(\'owner\').value, ';
414	result += 'document.getElementById(\'template\').value);" /></td></tr>';
415	result += '</table>';
416	
417	document.getElementById('body').innerHTML = result;
418}
419
420function changeOwnersSelect (request)
421{
422	if (request.readyState==4)
423	{
424		var jsonData = eval('('+request.responseText+')');
425		
426		document.getElementById('owner').options.length=0;
427		
428		for(i=0; i<jsonData.length; i++)
429		{
430			if(userlevel<5)
431			{
432				if(myUserId==jsonData[i].id)
433				{
434					document.getElementById('owner').options[i]=new Option(jsonData[i].fullname, jsonData[i].id, false, true);
435				}
436			}else
437			{
438				document.getElementById('owner').options[i]=new Option(jsonData[i].fullname, jsonData[i].id, false, false);
439			}
440		}
441	}
442}
443
444function changeTemplateSelect (request)
445{
446	if (request.readyState==4)
447	{
448		var jsonData = eval('('+request.responseText+')');
449		
450		document.getElementById('template').options.length=0;
451		
452		for(i=0; i<jsonData.length; i++)
453		{
454			document.getElementById('template').options[i]=new Option(jsonData[i], jsonData[i], false, false);
455		}
456	}
457}
458
459function saveNewRecord (domain, webIP, mailIP, owner, template)
460{	
461
462	new Ajax.Request(baseurl+"?p=newDomain", 
463	{
464		method:"post",
465		postBody:"domain="+escape(domain)+"&webIP="+escape(webIP)+"&mailIP="+escape(mailIP)+"&owner="+escape(owner)+"&template="+escape(template),
466		asynchronous:true,
467		onSuccess:succesFailed,
468		onFailure:resultError
469	});
470}
471
472function saveNewDomains (domains, webIP, mailIP, owner, template)
473{
474	new Ajax.Request(baseurl+"?p=newDomains", 
475	{
476		method:"post",
477		postBody:"domains="+escape(domains)+"&webIP="+escape(webIP)+"&mailIP="+escape(mailIP)+"&owner="+escape(owner)+"&template="+escape(template),
478		asynchronous:true,
479		onSuccess:succesFailed,
480		onFailure:resultError
481	});
482}
483
484function userAdmin ()
485{
486	new Ajax.Request(baseurl+"?p=getOwners", 
487	{
488		method:"get",
489		asynchronous:true,
490		onSuccess:showUserAdmin,
491		onFailure:resultError
492	});
493}
494
495function showUserAdmin (request)
496{
497	if (request.readyState==4)
498	{
499		var jsonData = eval('('+request.responseText+')');
500		
501		var result = '<form name="addUserrrr"><table width="800">';
502		
503		for(i=0; i<jsonData.length; i++)
504		{
505			if(!(userlevel<5 && jsonData[i].id != myUserId))
506			{
507				result += '<tr>';
508				result += '  <td>[ <a onclick="deleteUser('+jsonData[i].id+');setTimeout(\'userAdmin();\', '+timeoutInMilisec+');">delete user</a> ]</td>';
509				result += '  <td><a href="javascript:editUser('+jsonData[i].id+');">'+jsonData[i].fullname+'</a></td>';
510				result += '  <td>'+jsonData[i].level+'</td>';
511				result += '</tr>';
512			}
513		}
514		
515		result += '<tr><td colspan="3">&nbsp;</td></tr>';
516		result += '<tr><td colspan="3"><h1>Add a user</h1></td></tr>';
517		result += '<tr><td>Username</td><td colspan="2"><input type="text" id="username"></td></tr>';
518		result += '<tr><td>Password</td><td colspan="2"><input type="text" id="password"></td></tr>';
519		result += '<tr><td>Password check</td><td colspan="2"><input type="text" id="passwordcheck"></td></tr>';
520		result += '<tr><td>Full name</td><td colspan="2"><input type="text" id="fullname"></td></tr>';
521		result += '<tr><td>E-mail</td><td colspan="2"><input type="text" id="email"></td></tr>';
522		result += '<tr><td>Description</td><td colspan="2"><input type="text" id="description"></td></tr>';
523		result += '<tr><td>Max domains</td><td colspan="2"><input type="text" id="maxdomains" value="0"></td></tr>';
524		result += '<tr><td>Level</td><td colspan="2"><select id="level"><option value="1" selected="selected">normal user</option>';
525		result += '<option value="5">moderator</option><option value="10">administrator</option></td></tr>';
526		result += '<tr><td>Active</td><td colspan="2">Yes <input type="radio" name="activeBool" id="activeBool1" value="1" checked="checked" /> No <input type="radio" name="activeBool" id="activeBool0" value="0" /></td></tr>';
527		result += '<tr><td colspan="3"><input type="button" id="save" value="Add user" onclick="addUser(';
528		result += ' document.getElementById(\'username\').value, document.getElementById(\'password\').value, document.getElementById(\'passwordcheck\').value,';
529		result += ' document.getElementById(\'fullname\').value, document.getElementById(\'email\').value, document.getElementById(\'description\').value,';
530		result += ' document.getElementById(\'level\').value, checkActiveBool(document.getElementById(\'activeBool1\'),document.getElementById(\'activeBool0\')),document.getElementById(\'maxdomains\').value);setTimeout(\'userAdmin();\', '+timeoutInMilisec+');"></td></tr>';
531		result += '</table></form>';
532		
533		document.getElementById("body").innerHTML = result;
534	}
535}
536
537function checkActiveBool (bool0, bool1)
538{
539	if (bool0.checked)
540	{
541		return bool0.value;
542	}else
543	{
544		return bool1.value;
545	}
546}
547
548function deleteUser (userId)
549{
550	if(confirm("Are you sure you want to delete this user, and all it's data?"))
551	{
552		new Ajax.Request(baseurl+"?p=deleteUser",
553		{
554			method:"post",
555			postBody:"userId="+userId,
556			asynchronous:true,
557			onSuccess:succesFailed,
558			onFailure:resultError
559		});
560	}
561}
562
563function editUser (userId)
564{
565	new Ajax.Request(baseurl+"?p=getUser", 
566	{
567		method:"post",
568		postBody:"userId="+userId,
569		asynchronous:true,
570		onSuccess:showEditUser,
571		onFailure:resultError
572	});
573}
574
575function showEditUser (request)
576{
577	if (request.readyState==4)
578	{
579		var jsonData = eval('('+request.responseText+')');
580		
581		var result = '<table width="800"><input type="hidden" id="userId" value="'+jsonData.id+'">';
582		result += '<tr><td>Username</td><td><input type="text" id="username" value="'+jsonData.username+'"></td></tr>';
583		result += '<tr><td>Password</td><td><input type="password" id="password" value=""></td></tr>';
584		result += '<tr><td>Full name</td><td><input type="text" id="fullname" value="'+jsonData.fullname+'"></td></tr>';
585		result += '<tr><td>E-mail</td><td><input type="text" id="email" value="'+jsonData.email+'"></td></tr>';
586		result += '<tr><td>Description</td><td><textarea id="description">'+jsonData.description+'</textarea></td></tr>';
587		result += '<tr><td>Max domains</td><td colspan="2"><input type="text" id="maxdomains" value="'+jsonData.maxdomains+'"></td></tr>';
588		result += '<tr><td>Level</td><td><input type="text" id="level" value="'+jsonData.level+'"></td></tr>';
589		result += '<tr><td>Active</td><td><input type="text" id="active" value="'+jsonData.active+'"></td></tr>';
590		result += '<tr><td><input type="button" name="save" value="Opslaan" onclick="javascript:saveUser(';
591		result += 'document.getElementById(\'userId\').value, document.getElementById(\'username\').value, document.getElementById(\'password\').value,';
592		result += ' document.getElementById(\'fullname\').value, document.getElementById(\'email\').value, document.getElementById(\'description\').value,';
593		result += ' document.getElementById(\'level\').value, document.getElementById(\'active\').value, document.getElementById(\'maxdomains\').value);"></td><td></td></tr>';
594		result += '</table>';
595		
596		document.getElementById("body").innerHTML = result;
597	}
598}
599
600function addUser (username, password, passwordcheck, fullname, email, description, level, active, maxdomains)
601{
602	new Ajax.Request(baseurl+"?p=addUser", 
603	{
604		method:"post",
605		postBody:"username="+username+"&password="+password+"&passwordcheck="+passwordcheck+"&fullname="+fullname+"&email="+email+"&description="+description+"&level="+level+"&active="+active+"&maxdomains="+maxdomains,
606		asynchronous:true,
607		onSuccess:succesFailed,
608		onFailure:resultError
609	});
610}
611
612function saveUser (userId, username, password, fullname, email, description, level, active, maxdomains)
613{
614	new Ajax.Request(baseurl+"?p=editUser", 
615	{
616		method:"post",
617		postBody:"userId="+userId+"&username="+username+"&password="+password+"&fullname="+fullname+"&email="+email+"&description="+description+"&level="+level+"&active="+active+"&maxdomains="+maxdomains,
618		asynchronous:true,
619		onSuccess:succesFailed,
620		onFailure:resultError
621	});
622}
623
624function loginForm ()
625{
626	var result  = '<p><form method="post" action=\'javascript:login(document.getElementById("usernamefield").value, document.getElementById("passwordfield").value);\'><table>';
627	result += '  <tr>';
628	result += '	<td rowspan="4" width="70"><img src="images/agent.png" alt="Please login" /></td>';
629	result += '	<td colspan="3"><b>Login<span id="infoHead"></span></b></td>';
630	result += '  </tr>';
631	result += '  <tr>';
632	result += '	<td>Username:</td>';
633	result += '	<td><input type="text" id="usernamefield" tabindex="1" /></td>';
634	result += '	<td rowspan="2"><img src="images/forward.png" id="loginstatus" alt="login status" /></td>';
635	result += '  </tr>';
636	result += '  <tr>';
637	result += '	<td>Password:</td>';
638	result += '	<td><input type="password" id="passwordfield" tabindex="2" /></td>';
639	result += '  </tr>';
640	result += '  <tr>';
641	result += '	<td colspan="2"><input type="submit" value="login" tabindex="3" id="loginBtn" /></td>';
642	result += '  </tr>';
643	result += '</table></form></p>';
644	document.getElementById('login').innerHTML = result;
645}
646
647function login (username, password)
648{
649	new Ajax.Request(baseurl+"?p=doLogin", 
650	{
651		method:"post",
652		postBody:"username="+escape(username)+"&password="+escape(password),
653		asynchronous:true,
654		onSuccess:succesFailed,
655		onFailure:resultError
656	});
657}