	
	document.writeln("<script language='JavaScript' type='text/javascript' src='ajax.js'></script>");

	var bgc;
//	var idArray = new Array();
/*	var isIE = false;
	var isOpera = false;
	var isFF = false;
	
	if (navigator.appName.indexOf("Opera") != -1) isOpera = true;
	else if (navigator.appName.indexOf("Explorer") != -1) isIE = true;
	else isFF = true;
*/	
	function requirements() {
		document.getElementById('js_pic').src = 'images/yes.gif';
		if( navigator.cookieEnabled ) document.getElementById('cookies_pic').src = 'images/yes.gif';
		else document.getElementById('cookies_pic').src = 'images/no.gif';
		
		if(document.ids)x='nc4';
		else if( document.all && !document.getElementById )x='ie4';
		else if( window.opera && !document.createElement )x='op5';
		else if( window.opera && window.getComputedStyle )  {
				  if(document.createRange)x='op8';
					else if(window.navigate)x='op7.5';
									 else x='op7.2';                   }
		else if( window.opera && document.compatMode )x='op7';
		else if( window.opera && document.releaseEvents )x='op6';
		else if( document.contains && !window.opera )x='kq3';
		else if(window.pkcs11&&window.XML)x='f15';
		else if( window.getSelection && window.atob )x='nn7';
		else if( window.getSelection && !document.compatMode )x='nn6';
		else if( window.clipboardData && document.compatMode )
		  x=window.XMLHttpRequest? 'IE7' : 'IE6';
		else if( window.clipboardData ){x='ie5';
			 if( !document.createDocumentFragment ) x+='.5';
			 if( document.doctype && !window.print ) x+='m';}
		else if( document.getElementById && !document.all ) x='op4';
		else if( document.images && !document.all ) x='nn3';
		else if(document.clientWidth&&!window.RegExp)x='kq2';
		else x='???';
		
		if( x.toLowerCase().indexOf('ie') != -1 ) {
			if( x.indexOf('6') != -1 || x.indexOf('7') != -1 ) {
				document.getElementById('browser_pic').src = 'images/yes.gif';
			}
		} else if( x.indexOf('f') != -1 ) {
			document.getElementById('browser_pic').src = 'images/yes.gif';
		} else {
			document.getElementById('browser_pic').src = 'images/no.gif';
		}
	}
	
	function sure_del(id, qrystr) {
		var check = confirm('Are you sure?');
		if( check ) window.location.href = 'db.php?' + qrystr + '=' + id;
	}
	
	function checkBoardForm() {
		if( document.getElementById('aBtitle').value == '' ) {
			alert('Title missing...');
			document.getElementById('aBtitle').focus();
			return false;
		} else if( document.getElementById('aBmessage').value == '' ) {
			alert('Message missing...');
			document.getElementById('aBmessage').focus();
			return false;
		} else {
			return true;
		}
	}

	function checkHelpForm() {
		if( document.helpForm.bugTopic.value == '' ) {
			alert('All fields are required!');
			document.helpForm.bugTopic.focus();
			return false;
		} else if( document.helpForm.bugTime.value == '' ) {
			alert('All fields are required!');
			document.helpForm.bugTime.focus();
			return false;
		} else if( document.helpForm.bugMsg.value == '' ) {
			alert('All fields are required!');
			document.helpForm.bugMsg.focus();
			return false;
		} else {
			return true;
		}
	}

	function selectAll() {
		var elements = document.getElementsByTagName( '*' );
		for( i=0; i < elements.length; i++ ) {
			if( elements[i].tagName.toLowerCase() == 'input' ) {
				if( elements[i].type == 'checkbox' ) {
					elements[i].checked = true;
				}
			}
		}
	}

	function selectNone() {
		var elements = document.getElementsByTagName( '*' );
		for( i=0; i < elements.length; i++ ) {
			if( elements[i].tagName.toLowerCase() == 'input' ) {
				if( elements[i].type == 'checkbox' ) {
					elements[i].checked = false;
				}
			}
		}
	}

	function sel(name) {
		var cols = document.getElementById('js_helper').getAttribute('colspan');
		for(i=0; i<cols; i++) {
			var element = document.getElementById(name + '_' + i);
			bgc = element.style.backgroundColor;
			element.style.backgroundColor = '#FFF1D5';
			element.style.cursor = 'pointer';
		}	
	}
	
	function unsel(name) {
		var cols = document.getElementById('js_helper').getAttribute('colspan');
		for(i=0; i<cols; i++) {
			var element = document.getElementById(name + '_' + i);
			element.style.backgroundColor = bgc;
			element.style.cursor = 'default';
		}	
	}

	// mouse over - hover effect
	function over(id) {
		document.getElementById(id).style.background = '#FFF1D5';
	}
	// mouse out
	function out(id) {
		document.getElementById(id).style.background = '#FFFDF6';
	}

	// hide menu
	function ddMenuHide() {
		ddDelayHide = setTimeout("document.getElementById('ddMenu').style.display = 'none'", 300);
	}

	// clear delay
	function ddClearHide() {
		if (typeof ddDelayHide!="undefined") clearTimeout(ddDelayHide);
	}

	// move popup menu to mouse position and show it
	function ddMenu(e, id) {
		
		if(document.documentElement.scrollTop) var scrollY = document.documentElement.scrollTop;
		else var scrollY = window.pageYOffset;
		if(scrollY == 'undefined' || scrollY == null) scrollY = 0;
		
		document.getElementById('objID').value = id;
		
		if(!e) e = window.event;
		
		var posX = e.clientX - 5;
		var posY = e.clientY - 5 + scrollY;
		
		var x,y;
		if (self.innerHeight) {
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) {
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		if (document.getElementById) {
			
			if( id.indexOf('h') != -1 ) {
				if(document.getElementById('optimal')) {
					document.getElementById('optimal').style.display = 'none';
				}
				document.getElementById('timer').style.display = 'none';
			} else {
				if(document.getElementById('optimal')) {
					document.getElementById('optimal').style.display = 'block';
				}
				document.getElementById('timer').style.display = 'block';
			}
			
			document.getElementById("ddMenu").style.left  = posX + "px";
			document.getElementById("ddMenu").style.top = posY + "px";
			
			document.getElementById('ddMenu').style.display = 'block';
			
			document.getElementById("ddMenuShadow").style.width = document.getElementById("ddMenuTable").offsetWidth + "px";
			document.getElementById("ddMenuShadow").style.height = document.getElementById("ddMenuTable").offsetHeight + "px";
			
		} else if (document.all) {
			
			if( id.indexOf('h') != -1 ) {
				if(document.all.optimal) {
					document.all.optimal.style.display = 'none';
				}
				document.all.timer.style.display = 'none';
			} else {
				if(document.all.optimal) {
					document.all.optimal.style.display = 'block';
				}
				document.all.timer.style.display = 'block';
			}

			document.all.ddMenu.style.left = posX + "px";
			document.all.ddMenu.style.top = posY + "px";
			
			document.all.ddMenu.style.display = 'block';
			
			document.all.ddMenuShadow.style.width = document.all.ddMenuTable.offsetWidth + "px";
			document.all.ddMenuShadow.style.height = document.all.ddMenuTable.offsetHeight + "px";

		}
	}

	// menu item: fitting
	function fitting(id) {
		if( document.URL.indexOf('rc.php') != -1 ) {
			var qry = document.getElementById('qry').value;
			window.location.href = 'fitting.php?id=' + id + '&qry=' + qry;
		} else {
			window.location.href = 'fitting.php?id=' + id;
		}
	}
	
	// menu item: fuel
	function fuel(id) {
		if( document.URL.indexOf('rc.php') != -1 ) {
			var qry = document.getElementById('qry').value;
			window.location.href = 'fuel.php?id=' + id + '&qry=' + qry;
		} else {
			window.location.href = 'fuel.php?id=' + id;
		}
	}

	// menu item: timer
	function timer(id) {
		if( document.URL.indexOf('rc.php') != -1 ) {
			var qry = document.getElementById('qry').value;
			window.location.href = 'timer.php?id=' + id + '&qry=' + qry;
		} else {
			window.location.href = 'timer.php?id=' + id;
		}
	}
	
	// menu item: optimal
	function optimal(id) {
		var t = document.getElementById('optimal_' + id.substr(1)).value.split(',');
		document.getElementById('days').value = t[0];
		document.getElementById('hours').value = t[1];
		document.refuelingForm.submit();
	}

	// cc / rc
	function calculator(calc) {
		var elementIDsP = new Array();
		var elementIDsH = new Array();
		var elements = document.getElementsByTagName('*');
		for( i=0; i < elements.length; i++ ) {
			if( elements[i].type == 'checkbox' ) {
				if( elements[i].checked == true ) {
					if( elements[i].name.indexOf('p') != -1 ) {
						elementIDsP.push(elements[i].name.substr(1));
					} else {
						elementIDsH.push(elements[i].name.substr(1));
					}
				}
			}
		}
		if( elementIDsP.length > 0 ) {
			window.location.href = calc + '.php?days=1&p=' + elementIDsP.join(',') + '&h=' + elementIDsH.join(',');
		} else {
			alert('You need to select some POS\'s first.');
		}
	}
/*	
	function sureDelSuspended(type) {
		var elements = document.getElementsByName('selection');
		for( i=0; i < elements.length; i++ ) {
			if( elements[i].checked == true ) {
				if( elements[i].value.indexOf(type) != -1 ) {
					idArray.push(elements[i].value.substr(1));
				}
			}
		}
		if( idArray.length > 0 ) {
			var check = confirm('POS will be deleted now. Are you sure?');
			if( check ) {
				check = confirm('Did you ask your mom?');
				if( check ) {
					var idStr = idArray.join(',');
					window.location.href = 'db.php?delSuspended=' + type + '&objIDs=' + idStr;
				}
			}
		} else {
			alert( 'You need to select some POS\'s/hangars first' );
		}
	}
*/
	function checkForNaN(value, id) {
		if( isNaN( value )) {
			alert('This entry must be a number...');
			document.getElementById(id).value = '';
			document.getElementById(id).focus();
		}
	}
	
	function applyLabel(n) {
		var id = document.getElementById('objID').value;
		var label = document.getElementById('timer' + n + 'label').value;
		window.location.href = 'db.php?labelTimer=' + n + '&label=' + label + '&id=' + id;
	}
		
	function startTimer(n) {
		var id = document.getElementById('objID').value;
		var nD = document.getElementById('timer' + n + 'days').value;
		var nH = document.getElementById('timer' + n + 'hours').value;
		var nM = document.getElementById('timer' + n + 'minutes').value;
		if( document.getElementById('timer' + n + 'days').value == '' ) nD = 0;
		if( document.getElementById('timer' + n + 'hours').value == '' ) nH = 0;
		if( document.getElementById('timer' + n + 'minutes').value == '' ) nM = 0;
		window.location.href = 'db.php?setTimer=' + n + '&d=' + nD + '&h=' + nH + '&m=' + nM + '&id=' + id;
	}
	
	function stopTimer(n) {
		window.location.href = 'db.php?stopTimer=' + n + '&id=' + document.getElementById('objID').value;
	}
	
	function resetTimer(n) {
		var timerArray = document.getElementById('t' + n + 'val').value.split(',,,');
		document.getElementById('timer' + n + 'days').value = timerArray[0];
		document.getElementById('timer' + n + 'hours').value = timerArray[1];
		document.getElementById('timer' + n + 'minutes').value = timerArray[2];
	}
	
	function enableWarning() {
		var period = document.getElementById('warning').value;
		if( period != '' ) {
			window.location.href = 'db.php?enableWarning=' + period + '&id=' + document.getElementById('objID').value;
		}
	}
	
	function disableWarning() {
		window.location.href = 'db.php?disableWarning&id=' + document.getElementById('objID').value;
	}
	
	function editP() {
		var tower = document.getElementById('ePtower');
		document.getElementById('ePpg').value = document.getElementById('ePpg_v').value;
		document.getElementById('ePcpu').value = document.getElementById('ePcpu_v').value;
		if( document.getElementById('ePlabel').value == '' ) {
			alert('Label missing...');
			document.getElementById('ePlabel').focus();	
		} else {
			if( parseInt(document.getElementById('ePcpu').value) > 
				parseInt(document.getElementById('maxCPU_' + tower.options[tower.selectedIndex].value).value) ) {
				var check = confirm('CPU exceeds the maximum output!\n\nProceed?');
				if( !check ) {
					document.getElementById('ePcpu').focus();
					return false;
				}
			}
			if( parseInt(document.getElementById('ePpg').value) >
				parseInt(document.getElementById('maxPG_' + tower.options[tower.selectedIndex].value).value) ) {
				var check = confirm('Powergrid exceeds the maximum output!\n\nProceed?');
				if( !check ) {
					document.getElementById('ePpg').focus();
					return false;
				}
			}
			if( document.getElementById('ePpg').value == '' )
				document.getElementById('ePpg').value = 0;
			if( document.getElementById('ePcpu').value == '' )
				document.getElementById('ePcpu').value = 0;
			var check = confirm('Structure details will be changed now. Are you sure?');
			if( check ) document.editPform.submit();
		}
	}
	
	function editH() {
		if( document.getElementById('eHlabel').value == '' ) {
			alert('Label missing...');
			document.getElementById('eHlabel').focus();
			return false;
		} else {
			var check = confirm('Structure details will be changed now. Are you sure?');
			if( check ) document.editHform.submit();
		}
	}
/*	
	function checkSecurity() {
		if( document.getElementById('ePsovereignty').options[0].selected == false ) {
			document.getElementById('ePsecurity').options[0].selected = true;
		}
	}

	function checkSovereignty() {
		if( document.getElementById('ePsecurity').options[1].selected == true ) {
			document.getElementById('ePsovereignty').options[0].selected = true;
		}
	}
*/
	function toggleModule(fitting_id) {
		var posID = document.getElementById('objID').value;
		window.location.href = 'db.php?toggleModule&id=' + posID + '&fitting_id=' + fitting_id;
	}
	
	function delModule(fitting_id) {
		var posID = document.getElementById('objID').value;
		var check = confirm('Are you sure?');
		if( check )
			window.location.href = 'db.php?delModule&id=' + posID + '&fitting_id=' + fitting_id;
	}
	
	function removeModule() {
		if( document.getElementById('rMselect').options[document.getElementById('rMselect').selectedIndex].value == '' ) {
			alert( 'You need to select a module first.' );
			return false;
		} else {
			var check = confirm( 'Are you sure?' );
			if( check ) 
				document.removeModuleForm.submit();
		}
	}
	
	function delStructure(structure) {
		var id = document.getElementById('objID').value;
		var check = confirm('Structure will be deleted now. Are you sure?');
		if( check ) {
			check = confirm('God damnit! You really know what you\'re doing?');
			if( check ) 
				window.location.href = 'db.php?delStructure=' + structure + '&id=' + id;
		}
	}
	
	function refuelStructure() {
		var check = confirm('Structure will be refueled now. Are you sure?');
		if( check ) document.refuelForm.submit();
	}

	function accAction(action) {
		if( document.getElementById('acc_name').value == '' ) {
			alert('Name is missing...');
			document.getElementById('acc_name').focus();
		} else if( document.getElementById('acc_email').value == '' ) {
			alert('eMail is missing...');
			document.getElementById('acc_email').focus();
		} else if( document.getElementById('acc_repeat').value == '' ) {
			alert('Repeat eMail is missing...');
			document.getElementById('acc_repeat').focus();
		} else {
			if( document.getElementById('acc_email').value != document.getElementById('acc_repeat').value ) {
				alert('eMail and repeat eMail does not match...');
				document.getElementById('acc_email').focus();
			} else {
				if( action == 'Edit' ) {
					var check = confirm('Are you sure?');
					if( check ) document.getElementById(action + 'ACCform').submit();
				} else {
					document.getElementById(action + 'ACCform').submit();
				}
			}
		}
	}
	
	function editAcc() {
		if( document.getElementById('edit_account').options[document.getElementById('edit_account').selectedIndex].value == '' ) {
			alert( 'You need to select an account owner first!' );
		} else {
			document.getElementById('selectACCform').submit();
		}
	}
	
	function delAcc() {
		if( document.getElementById('del_account').options[document.getElementById('del_account').selectedIndex].value != '' ) {
			var check = confirm('Did we got an ingame mail, with the order to delete this account?');
			if( check ) {
				var check = confirm('Are you sure?');
				if( check ) document.getElementById('delACCform').submit();
			}
		} else {
			alert('You need to select an account owner first.');
		}
	}
	
	function newsAction(action) {
		if( document.getElementById('news_topic').value == '' ) {
			alert('Topic missing...');
			document.getElementById('news_topic').focus();
		} else if( document.getElementById('news_text').value == '' ) {
			alert('Text missing...');
			document.getElementById('news_text').focus();
		} else {
			document.getElementById(action + 'NEWSform').submit();
		}
	}

	function editNews() {
		if( document.getElementById('edit_news').options[document.getElementById('edit_news').selectedIndex].value == '' ) {
			alert( 'You need to select a news first!' );
		} else {
			document.getElementById('selectNEWSform').submit();
		}
	}

	function delNews() {
		if( document.getElementById('del_news').options[document.getElementById('del_news').selectedIndex].value != '' ) {
			var check = confirm('Are you sure?');
			if( check )	document.getElementById('delNEWSform').submit();
		} else {
			alert('You need to select a news first.');
		}
	}

	function messageToAll() {
		if( document.getElementById('mta_topic').value != '' && document.getElementById('mta_text').value != '' ) {
			document.getElementById('messageToAll').submit();
		}
	}

	function addStructure() {
		if( document.getElementById('label').value == '' ) {
			alert('Label is missing...');
			document.getElementById('label').focus();
		} else {
			document.getElementById('addStructureForm').submit();
		}
	}
	
	function checkSecurity() {
		if( document.getElementById('ePsovereignty') ) {
			if( document.getElementById('ePsovereignty').options[0].selected == false ) {
				document.getElementById('ePsecurity').options[0].selected = true;
			}
		} else {
			if( document.getElementById('sovereignty').options[0].selected == false ) {
				document.getElementById('security').options[0].selected = true;
			}
		}
	}

	function checkSovereignty() {
		if( document.getElementById('ePsovereignty') ) {
			if( document.getElementById('ePsecurity').options[1].selected == true ) {
				document.getElementById('ePsovereignty').options[0].selected = true;
			}
		} else {
			if( document.getElementById('security').options[1].selected == true ) {
				document.getElementById('sovereignty').options[0].selected = true;
			}
		}
	}

	
	function userAction(action) {
		if( document.getElementById('name').value == '' ) {
			alert('Name is missing...');
			document.getElementById('name').focus();
		} else if( document.getElementById('email').value == '' ) {
			alert('eMail is missing...');
			document.getElementById('email').focus();
		} else if( document.getElementById('password').value == '' ) {
			alert('Password is missing...');
			document.getElementById('password').focus();
		} else {
			if( action == 'Edit' ) {
				var check = confirm('Are you sure?');
				if( check ) document.getElementById(action + 'UserForm').submit();
			} else {
				document.getElementById(action + 'UserForm').submit();
			}
		}
	}

	function editUser() {
		if(document.getElementById('edit_user').options[document.getElementById('edit_user').selectedIndex].value == '') {
			alert('You need to select an user first!');
		} else {
			document.getElementById('editUserForm').submit();
		}
	}
	
	function delUser() {
		if( document.getElementById('del_user').options[document.getElementById('del_user').selectedIndex].value != '' ) {
			var check = confirm('Are you sure?');
			if( check ) document.getElementById('delUserForm').submit();
		} else {
			alert('You need to select an user first.');
		}
	}

	function towerAction(action) {
		if( document.getElementById('ect_label').value == '' ||
			document.getElementById('ect_capacity').value == '' ||
			document.getElementById('ect_pg').value == '' ||
			document.getElementById('ect_cpu').value == '' ||
			document.getElementById('ect_uranium').value == '' ||
			document.getElementById('ect_oxygen').value == '' ||
			document.getElementById('ect_mech_parts').value == '' ||
			document.getElementById('ect_coolant').value == '' ||
			document.getElementById('ect_robotics').value == '' ||
			document.getElementById('ect_isotopes').value == '' ||
			document.getElementById('ect_ozone').value == '' ||
			document.getElementById('ect_water').value == '' ||
			document.getElementById('ect_charter').value == '' ||
			document.getElementById('ect_strontium').value == '' ) {
				alert('All fields are required!');
		} else {
			if(action == 'Edit') {
				var check = confirm('Are you sure?');
				if( check ) document.getElementById(action + 'TowerForm').submit();
			} else {
				document.getElementById(action + 'TowerForm').submit();
			}
		}
	}
	
	function delTower() {
		if( document.getElementById('del_tower').options[document.getElementById('del_tower').selectedIndex].value != '' ) {
			var check = confirm('This will delete the selected tower.\nAre you sure?');
			if( check ) document.getElementById('delTowerForm').submit();
		} else {
			alert('You need to select a tower first.');
		}
	}
	
	function editTower() {
		if(document.getElementById('edit_tower').options[document.getElementById('edit_tower').selectedIndex].value == '') {
			alert('You need to select a tower first!');
		} else {
			document.getElementById('selectTowerForm').submit();
		}
	}
	
	function setHangarID(id) {
		var elements = document.getElementsByTagName('*');
		for( var i = 0; i < elements.length; i++ )
			if( elements[i].tagName.toLowerCase() == 'input' )
				if( elements[i].name.toLowerCase() == 'hangar_id' )
					elements[i].value = id;
	}
	
	function headquarters() {
		window.location.href = 'hq.php';
	}

	function groupSelected(id) {
		http_request('GET', 'db.php?group_selected&id=' + id + '&', true, 'successGroupSelected', 'failedGroupSelected', 10000);
	}
	
	function successGroupSelected(data) {
		var list = document.getElementById('system_list');
		list.length = 0;
		list.options[0] = new Option('System', '', true, false);
		for (var i = 0; i < data.length; i++) {
			option = new Option(data[i].label, data[i].id, false, false);
			list.options[list.length] = option;
		}
	}

	function failedGroupSelected() {
		document.getElementById('group_list').options[0].selected = 'selected';
		list.length = 0;
		list.options[0] = new Option('System', '', true, false);
	}
	
	function enterSystem() {
		if(document.getElementById('system_list').options[0].selected == true) {
			alert('Choose a system please!');
		} else {
			document.getElementById('poswarForm').action = 'poswar.php?enter';
			document.getElementById('poswarForm').submit();
		}
	}
	
	function updateSystem() {
		if(document.getElementById('system_list').options[0].selected == true) {
			alert('Choose a system please!');
		} else {
			document.getElementById('poswarForm').action = 'poswar.php?update';
			document.getElementById('poswarForm').submit();
		}
	}

	function systemLog() {
		if(document.getElementById('system_list').options[0].selected == true) {
			alert('Choose a system please!');
		} else {
			document.getElementById('poswarForm').action = 'poswar.php?log';
			document.getElementById('poswarForm').submit();
		}
	}
	
	function createGroup() {
		var value = document.getElementById('label').value;
		if( value != '' ) {
			for( i=0; i < document.getElementById('group_list_1').length; i++ ) {
				if( document.getElementById('group_list_1').options[i].text == value ) {
					var exists = true;
				}
			}
			if( exists ) alert( 'The group name already exists.' );
			else document.getElementById('createGroup').submit();
		}
	}
	
	function deleteGroup() {
		var check = confirm('This will delete the selected group. Are you sure?');
		if( check ) document.getElementById('deleteGroup').submit();
	}
	
	function rankHelp() {
		alert('General has full access.\nColonel has the same rights as the General except delete group.\nMajor has the same rights as the Colonel except add/remove user and remove systems.\nCaptain is not permitted to do anything inside the command post.\n\nEach user can add as much groups as he want.\nRanks can differ according to your group membership.');
	}
	
	function addUserToGroup() {
		var user = document.getElementById('email').value;
		var group = document.getElementById('group_list_1').options[document.getElementById('group_list_1').selectedIndex].text;
		if( user != '' ) {
			var check = confirm( 'Do you want to add the user: ' + user + ' to the group: ' + group + '?' );
			if( check ) document.getElementById('addUserToGroup').submit();
		}
	}
	
	function removeUserFromGroup() {
		var check = confirm( 'Do you want to remove this user from this group?' );
		if( check ) document.getElementById('removeUserFromGroup').submit();
	}
	
	function planetDetails(p) {
		for( i=1; i<21; i++ ) {
			document.getElementById('p' + i).style.display = 'none';
		}
		for( i=1; i<=p; i++ ) {
			document.getElementById('p' + i).style.display = 'block';
		}
	}
	
	function addSystem() {
		if( document.getElementById('s_label').value != '' ) {
			if( document.getElementById('planets').value != '' ) {
				var check = confirm('Add the system?');
				if( check ) document.getElementById('addSystem').submit();
			}
		}
	}
	
	function delSystem() {
		if(document.getElementById('system_list').value != '') {
			var check = confirm('Are you sure?');
			if( check ) document.getElementById('delSystem').submit();
		}
	}
	
	function getMoonData(id) {
		http_request('GET', 'db.php?get_moon_data&id=' + id + '&', true, 'successGetMoonData', 'failedGetMoonData', 10000);
	}
	
	function successGetMoonData(data) {
		var size = document.getElementById('size');
		var status = document.getElementById('status');
		for (var i = 0; i < data.length; i++) {
			if( data[i].size == 'Large' ) size.options[0].selected = true;
			if( data[i].size == 'Medium' ) size.options[1].selected = true;
			if( data[i].size == 'Small' ) size.options[2].selected = true;
			if( data[i].status == 0 ) status.options[0].selected = true;
			if( data[i].status == 1 ) status.options[1].selected = true;
			document.getElementById('ally').value = data[i].ally;
			document.getElementById('corp').value = data[i].corp;
		}
	}

	function failedGetMoonData() {
		var location = document.getElementById('location');
		location.options[0].selected = 'selected';
	}
	
	function updateMoon() {
		if( document.getElementById('location').value != '' ) {
			document.getElementById('update_moon').submit();
		}
	}
	
	function enterDEDreport() {
		if(document.getElementById('report').value != '') {
			var check = confirm("Attention!\n\nThe system with all planets and moons must already be in existence,\notherwise the report will be stored incorrect!\nFurthermore the report will overwrite all existent entries for this system.\n\nAre you sure?");
			if( check )	document.getElementById('ded').submit();
		}
	}

	function standings() {
		var element = document.getElementById('standings');
		(element.style.display == 'block') ? element.style.display = 'none' : element.style.display = 'block';
	}

	function sovereignty() {
		var element = document.getElementById('sovereignty2');
		(element.style.display == 'block') ? element.style.display = 'none' : element.style.display = 'block';
	}
	
	function moons() {
		var element = document.getElementById('empty_moons_2');
		(element.style.display == 'block') ? element.style.display = 'none' : element.style.display = 'block';
	}

	function reinforced() {
		var element = document.getElementById('reinforced');
		(element.style.display == 'block') ? element.style.display = 'none' : element.style.display = 'block';
	}
	
	function neutrals() {
		var element = document.getElementById('neutrals');
		(element.style.display == 'block') ? element.style.display = 'none' : element.style.display = 'block';
	}
	
	function setSovereignty() {
		if( document.getElementById('alliance').value != '' ) {
			var check = confirm('Do you want to change sovereignty for this system?');
			if( check ) document.getElementById('setSovereignty').submit();
		}
	}
	

	// messages
	if( document.URL.indexOf('module_still_in_use') != - 1 ) alert( 'Can\'t delete module, it\'s still used by one or more POS\'s.');
	if( document.URL.indexOf('delete_structure_done') != - 1 ) alert( 'Structure deleted successfully.');
	if( document.URL.indexOf('delete_structure_failed') != - 1 ) alert( 'Failed to delete the structure.');
	if( document.URL.indexOf('email_in_use') != - 1 ) alert('eMail address already exists. Unable to create/edit an account with this address.');
	if( document.URL.indexOf('add_account_done') != - 1 ) alert('Account created successfully. The customer was informed by eMail.');
	if( document.URL.indexOf('add_account_done_mail_failed') != - 1 ) alert('ERROR - Failed sending eMail.\nAccount created successfully.');
	if( document.URL.indexOf('edit_account_done_ok') != - 1 ) alert('Account details changed successfully. The customer was informed by eMail.');
	if( document.URL.indexOf('edit_account_done_no_mail') != - 1 ) alert('Account details changed successfully.');
	if( document.URL.indexOf('edit_account_done_mail_failed') != - 1 ) alert('ERROR - Failed sending eMail.\nAccount details changed successfully.');
	if( document.URL.indexOf('delete_account_done_ok') != - 1 ) alert('Account deleted successfully. The customer was informed by eMail.');
	if( document.URL.indexOf('delete_account_done_mail_failed') != - 1 ) alert('ERROR - Failed sending eMail.\nAccount deleted successfully.');
	if( document.URL.indexOf('add_news_done') != - 1 ) alert('News added.');
	if( document.URL.indexOf('edit_news_done') != - 1 ) alert('News changed.');
	if( document.URL.indexOf('delete_news_done') != - 1 ) alert('News deleted.');
	if( document.URL.indexOf('add_user_done') != - 1 ) alert('User added. Both, you and the new user have got a mail.');
	if( document.URL.indexOf('edit_user_done') != - 1 ) alert('User details changed. Both, you and the user have got a mail.');
	if( document.URL.indexOf('email_exists') != - 1 ) alert('The eMail address is already in use. Please choose an other one.');
	if( document.URL.indexOf('delete_user_done') != - 1 ) alert('User removed successfully.');
	if( document.URL.indexOf('delete_user_failed') != - 1 ) alert('You cant delete this user!');
	if( document.URL.indexOf('delete_owner_failed') != - 1 ) alert('You cant delete the account owner! Changes to this account can only be made by the POSwatch Team.');
	if( document.URL.indexOf('owner_not_changeable') != - 1 ) alert('You cant edit the account owner! Changes to this account can only be made by the POSwatch Team.');
	if( document.URL.indexOf('add_pos_done') != - 1 ) alert('POS added successfully.');
	if( document.URL.indexOf('add_hangar_done') != - 1 ) alert('Hangar added successfully.');
	if( document.URL.indexOf('add_tower_done') != - 1 ) alert('Customized tower added successfully.');
	if( document.URL.indexOf('edit_tower_done') != - 1 ) alert('Customized tower details changed successfully.');
	if( document.URL.indexOf('delete_tower_done') != - 1 ) alert('Customized tower deleted successfully.');
	if( document.URL.indexOf('delete_tower_failed') != - 1 ) alert('Failed to delete customized tower.');
	if( document.URL.indexOf('tower_in_use') != - 1 ) alert('Tower still in use, unable to delete it. Please delete or modify the respective POS(s) first!');
	if( document.URL.indexOf('create_group_done') != - 1 ) alert('Group created successfully.');
	if( document.URL.indexOf('delete_group_done') != - 1 ) alert('Group removed successfully.');
	if( document.URL.indexOf('email_not_found') != - 1 ) alert('Email address not found. The user needs an POSwatch login.');
	if( document.URL.indexOf('user_added_to_group') != - 1 ) alert('User successfully added to the group.');
	if( document.URL.indexOf('user_already_in_group') != - 1 ) alert('This user is already member of this group.');
	if( document.URL.indexOf('not_permitted') != - 1 ) alert('You do not have the required rank to do this.');
	if( document.URL.indexOf('add_system_done') != - 1 ) alert('System added.');
	if( document.URL.indexOf('system_already_exists') != - 1 ) alert('Could not create system - label already exists in database.');
	if( document.URL.indexOf('del_system_done') != - 1 ) alert('System deleted.');
	if( document.URL.indexOf('system_not_exists') != - 1 ) alert('System does not exists - failed to process report.');
	if( document.URL.indexOf('system_not_correct') != - 1 ) alert('The system wasn\'t created correctly. Couldn\'t found at least one of the required moons. Unable to process the report and update the system.');
	if( document.URL.indexOf('report_done') != - 1 ) alert('DED report processed - system updated.');


