function DoNothing(){}function ValidateControl(controlId){document.getElementById(controlId).className='ValidControlInput'}function InvalidateControl(controlId){document.getElementById(controlId).className='InvalidControlInput'}function ValidateInput(valueId){var control=document.getElementById(valueId);if(control.value.indexOf(".")>-1)control.value=control.value.replace(/\./g,'');if(control.value.indexOf(" ")>-1)control.value=control.value.replace(/\s/g,'');if((isPositiveInteger(control.value)!=1)&&(control.value!=''))InvalidateControl(valueId);else ValidateControl(valueId)}function in_array(item,arr){for(var p=0;p<arr.length;++p)if(item==arr[p])return true;return false}function CheckInputName(inputName,useExtendedChars){if(inputName.length<2)return false;regularCharacters=new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');additionalCharacters=new Array('-','_','=',' ');extendedCharacters=new Array('{','}','(',')','[',']','.',':','*','#');if(!useExtendedChars){allowedCharacters=regularCharacters.concat(additionalCharacters)}else{allowedCharacters=regularCharacters.concat(additionalCharacters);allowedCharacters=allowedCharacters.concat(extendedCharacters)}var validInputName=true;var regularCharCount=0;for(var i=0,len=inputName.length;i<len;++i){if(!in_array(inputName.charAt(i),allowedCharacters))validInputName=false;if(in_array(inputName.charAt(i),regularCharacters))regularCharCount++}if(regularCharCount<1)validInputName=false;return validInputName}function FormatNumber(number){if(isNaN(number)){return''}else{var sign=(number<0?'-':'');var length=0;number=Math.floor(number);var tmp_number=""+Math.abs(number);length=tmp_number.length;if(length>3){var mod=length%3;var output=(mod>0?(tmp_number.substring(0,mod)):'');for(i=0;i<Math.floor(length/3);i++){if((mod==0)&&(i==0))output+=tmp_number.substring(mod+3*i,mod+3*i+3);else output+='.'+tmp_number.substring(mod+3*i,mod+3*i+3)}output=sign+output;return output}else{return number}}}function FormatTime(seconds){if(seconds<=0){return'00:00:00'}else{var days=0;var hours=0;var minutes=0;if(seconds>59){minutes=Math.floor(seconds/60);seconds=seconds-minutes*60}if(minutes>59){hours=Math.floor(minutes/60);minutes=minutes-hours*60}if(hours>0){days=Math.floor(hours/24);hours=hours-days*24}seconds=seconds<10?'0'+seconds:seconds;minutes=minutes<10?'0'+minutes:minutes;hours=hours<10?'0'+hours:hours;return days==0?hours+':'+minutes+':'+seconds:days+' d '+hours+':'+minutes+':'+seconds}}function FormatDate(unixtime,lineBreak){lineBreak=typeof lineBreak=="undefinded"?false:lineBreak;var finishtime=new Date();finishtime.setTime(unixtime*1000);var day=finishtime.getDate();day=day<10?'0'+day:day;var month=finishtime.getMonth()+1;month=month<10?'0'+month:month;var year=finishtime.getFullYear()-2000;year=year<10?'0'+year:year;var hours=finishtime.getHours();hours=hours<10?'0'+hours:hours;var minutes=finishtime.getMinutes();minutes=minutes<10?'0'+minutes:minutes;var seconds=finishtime.getSeconds();seconds=seconds<10?'0'+seconds:seconds;return day+'.'+month+'.'+year+(lineBreak?'<br />':' ')+hours+':'+minutes+':'+seconds}var startCountdown=new Date();function Countdown(element,finishTime,secondsLeft,finishText,textColor){if((secondsLeft==0)||(secondsLeft%15==0)){var currentTime=new Date();var servertime=realServerTime+(currentTime.getTime()-startCountdown.getTime());secondsLeft=Math.floor(((finishTime*1000)-servertime)/1000)}else{secondsLeft-=1}var control=$(element);if(control){control.setStyle({color:textColor});if(secondsLeft<=0){window.clearTimeout(countdownTimer[element]);control.update(finishText);return}else{control.update(FormatTime(secondsLeft))}}countdownTimer[element]=window.setTimeout('Countdown("'+element+'",'+finishTime+','+secondsLeft+',"'+finishText+'","'+textColor+'")',1000)}function OrderCountdown(element,finishTime,secondsLeft,nextLevel,regularText,finishText,textColor){if((secondsLeft==0)||(secondsLeft%15==0)){var currentTime=new Date();var servertime=realServerTime+(currentTime.getTime()-startCountdown.getTime());secondsLeft=Math.floor(((finishTime*1000)-servertime)/1000)}else{secondsLeft-=1}var control=$(element);if(control){control.setStyle({color:textColor});var displayText='<span class="cursorhelp" onmouseover="MouseOverTextInfo(\'<span style=color:'+textColor+'>'+FormatDate(finishTime,true)+'</span>\')" onmouseout="return nd()">'+regularText+' '+nextLevel+'<br />';if(secondsLeft<=0){window.clearTimeout(countdownTimer[element]);control.update(displayText+finishText+'</span>');return nd()}else{control.update(displayText+FormatTime(secondsLeft)+'</span>')}countdownTimer[element]=window.setTimeout('OrderCountdown("'+element+'",'+finishTime+','+secondsLeft+','+nextLevel+',"'+regularText+'","'+finishText+'","'+textColor+'")',1000)}}function ShowDateTimer(starttimeunix,arrivaltimeunix,servertimeunix,element,color,id){var starttime=starttimeunix*1000;var arrivaltime=arrivaltimeunix*1000;var doc=document.getElementById(element);var currenttime=new Date();var now=currenttime.getTime();var returntime=now+(now-starttime);returntime=returntime<starttime?starttime:returntime;if((doc)&&(currenttime>=arrivaltime)){clearTimeout(timer[id]);doc.innerHTML='<font color="'+color+'">-</font>';return}if(!doc){clearTimeout(timer[id]);return}formatedTime=FormatDate(Math.floor(returntime/1000));if(doc)doc.innerHTML='<font color="'+color+'">'+formatedTime+'</font>';timer[id]=window.setTimeout('ShowDateTimer('+starttimeunix+','+arrivaltimeunix+','+servertimeunix+',"'+element+'","'+color+'",'+id+')',1000)}function ShowCarrierJumpCountDown(endtime,finishtime,element,color,text,normaltext,xposition,yposition){var doc=document.getElementById(element);if(text=="")text="<font color='"+color+"'>Jump</font>";if(text==undefined)text="";if(normaltext==undefined)normaltext="";if(endtime<=0){doc.innerHTML=text;return nd()}endtime-=1;if(finishtime>0)formatedDate=' style="cursor:help" onmouseover="return overlib(\'<table width=100% cellpadding=3><tr><td align=center><font color='+color+'>'+FormatDate(finishtime,true)+'</font></td></tr></table>\', WIDTH, 80, FGCLASS, \'overlibFG\', BGCLASS, \'overlibBG\', LEFT, ABOVE);" onmouseout="return nd();"';else formatedDate=' ';formatedTime=FormatTime(endtime+1);if((xposition!='')&&(yposition!=''))doc.innerHTML="<font"+formatedDate+" color=\""+color+"\">"+normaltext+" <a style=\"color:"+color+"\" href=\"./index.php?ACTION=Galaxy&XPOSITION="+xposition+"&YPOSITION="+yposition+"\">"+xposition+":"+yposition+"</a><br>"+formatedTime+"</font>";else doc.innerHTML="<font"+formatedDate+" color=\""+color+"\">"+normaltext+"<br>"+formatedTime+"</font>";window.setTimeout('ShowCarrierJumpCountDown('+endtime+','+finishtime+',"'+element+'","'+color+'","'+text+'","'+normaltext+'","'+xposition+'","'+yposition+'")',1000)}var startTime=new Date();function ShowServerClock(begintime){var currentTime=new Date();var doc=document.getElementById('serverzeit');var servertime=new Date();servertime.setTime(begintime*1000+(currentTime.getTime()-startTime.getTime()));var hours=servertime.getHours();hours=hours<10?'0'+hours:hours;var minutes=servertime.getMinutes();minutes=minutes<10?'0'+minutes:minutes;var seconds=servertime.getSeconds();seconds=seconds<10?'0'+seconds:seconds;if(doc)doc.innerHTML=hours+':'+minutes+':'+seconds}function isPositive(number){if(!isNumber(number))return-1;number=Math.floor(number);if(number<0)return 0;return 1}function isNegative(number){if(!isNumber(number))return-1;number=Math.floor(number);if(number>0)return 0;return 1}function isPositiveInteger(number){if(!isNumber(number))return-1;number=Math.floor(number);if(number<0)return 0;if(parseInt(number)!=number)return-1;return 1}function isNegativeInteger(number){if(!isNumber(number))return-1;number=Math.floor(number);if(number>0)return 0;if(parseInt(number)!=number)return-1;return 1}function isNumber(number){return(!isNaN(number))}function ShowNewDialog(url,width,height){window.open(url,"","scrollbars=yes,dependent=yes,location=no,status=no,toolbar=no,resizable=yes,width="+width+",height="+height)}function ShowUserPage(id){ShowNewDialog('./index.php?ACTION=User&SUBACTION=ShowProfile&ID='+id,820,600)}function ShowAlliancePage(id){ShowNewDialog('./index.php?ACTION=Alliance&SUBACTION=ShowAlliancePage&ID='+id,820,800)}function ShowBuildingInfoDialog(id){ShowNewDialog('./index.php?ACTION=Building&SUBACTION=ShowInfo&ID='+id,700,400)}function ShowRocketInfoDialog(id){ShowNewDialog('./index.php?ACTION=Rocket&SUBACTION=ShowInfo&ID='+id,700,325)}function ShowResearchInfoDialog(id){ShowNewDialog('./index.php?ACTION=Research&SUBACTION=ShowInfo&ID='+id,700,300)}function ShowSpaceshipInfoDialog(id){ShowNewDialog('./index.php?ACTION=Spaceship&SUBACTION=ShowInfo&ID='+id,700,350)}function ShowDefenseInfoDialog(id){ShowNewDialog('./index.php?ACTION=Defense&SUBACTION=ShowInfo&ID='+id,700,300)}function MouseOverInfo(title,text){var showInfo='<table style="width:100%" cellpadding="0" cellspacing="0">'+'<tr class="cellLightHeader"><td style="text-align:center">'+title+'</td></tr>'+'<tr class="cellContent"><td style="text-align:left;padding:5px">'+text+'</td></tr>'+'</table>';return overlib(showInfo,WIDTH,350,FGCLASS,'overlibFGInfo',BGCLASS,'overlibBG',HAUTO,VAUTO)}function MouseOverTextInfo(text,width,wrapText){width=typeof width=="undefined"?0:width;wrapText=typeof wrapText=="undefined"?'':';white-space:nowrap';var direction=width>0?'left':'center';var showInfo='<table style="width:100%" cellpadding="0" cellspacing="0">'+'<tr><td style="text-align:'+direction+';padding:5px'+wrapText+'">'+text+'</td></tr>'+'</table>';if(width>0)return overlib(showInfo,WIDTH,width,FGCLASS,'overlibFG',BGCLASS,'overlibBG',HAUTO,VAUTO);else return overlib(showInfo,FGCLASS,'overlibFG',BGCLASS,'overlibBG',HAUTO,VAUTO,WRAP)}function MouseOverTimeInfo(productiontime){var currentTime=new Date();var finishTime=Math.floor(currentTime.getTime()/1000)+productiontime;var showInfo='<table style="width:100%" cellpadding="0" cellspacing="0">'+'<tr><td style="text-align:center;padding:5px">'+FormatDate(finishTime,true)+'</td></tr>'+'</table>';return overlib(showInfo,WIDTH,80,FGCLASS,'overlibFG',BGCLASS,'overlibBG',HAUTO,VAUTO,WRAP)}function JumpTo(menu,planetId){var requestData="ID="+planetId;new Ajax.Request('./index.php?ACTION=Menu&SUBACTION=ChangeActivePlanet',{method:'post',parameters:requestData,onSuccess:function(r){if(r.responseText!=''){parent.frames['G_Wars_Inhalt'].$('PlanetSelection').value=r.responseText}parent.frames["G_Wars_Hauptframe"].location.href='./index.php?ACTION='+menu}})}function GotoSolarSystem(xPosition,yPosition,position){window.location.href="./index.php?ACTION=Galaxy&XPOSITION="+xPosition+"&YPOSITION="+yPosition+"&POSITION="+position}function ReloadPage(action,subaction){parent.frames['G_Wars_Header'].document.location.reload();parent.frames['G_Wars_Inhalt'].document.location.reload();location.target="G_Wars_Hauptframe";var page='./index.php?';if(action)page+='ACTION='+action;if(subaction)page+='&SUBACTION='+subaction;location.href=page}function GetDisplayHeight(){var height;if(self.innerHeight){height=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){height=document.documentElement.clientHeight}else if(document.body){height=document.body.clientHeight}return height-75}var confirmTimeoutId=null;function GetConfirmation(element,func,textQuestion,textConfirm,textCancel,verticalPos){window.clearTimeout(confirmTimeoutId);if($('ConfirmationBox')!=null){$('ConfirmationBox').remove()}if(element!=undefined){verticalPos=(typeof verticalPos=="undefined")||(verticalPos=="")?"left":verticalPos;var offset=$(element).cumulativeOffset();var scrollOffset=$(element).cumulativeScrollOffset();var offsetTop=offset.top-scrollOffset.top;if(verticalPos=="left"){var offsetLeft=offset.left-25}else{var offsetLeft=$(element).getWidth();offsetLeft+=offset.left+10}if(textQuestion==undefined)textQuestion="Sicher?";if(textConfirm==undefined)textConfirm="OK";if(textCancel==undefined)textCancel="Cancel";$(document.body).insert({bottom:'<div id="ConfirmationBox" '+'style="position:absolute;top:'+offsetTop+'px;left:'+offsetLeft+'px;display:none">'+'<p class="textyellow">'+textQuestion+'</p>'+'<input class="form" type="button" onclick="window.clearTimeout(confirmTimeoutId);$(\'ConfirmationBox\').remove();'+func+'" value="'+textConfirm+'">&#160;&#160;'+'<input class="form bold" type="button" onclick="window.clearTimeout(confirmTimeoutId);$(\'ConfirmationBox\').remove();" value="'+textCancel+'">'+'</div>'});var divWidth=$('ConfirmationBox').getWidth()+10;var divHeight=$('ConfirmationBox').getHeight()+10;if(verticalPos=="left")var leftPos=offsetLeft-divWidth;else var leftPos=offsetLeft;$('ConfirmationBox').setStyle({left:leftPos+'px',width:divWidth+'px',height:divHeight+'px'});Effect.BlindDown('ConfirmationBox',{duration:0.25});confirmTimeoutId=window.setTimeout("GetConfirmation()",5000)}}function DecodeAmpy(){if(document.getElementById&&document.getElementsByName){var d=document.getElementById('cometestme');if((d)&&('textContent'in d)){var ampy=d.textContent;if(ampy=="\x26amp;"){var to_decode=document.getElementsByName('decodeable');if(to_decode){var s;for(var i=to_decode.length-1;i>=0;i--){s=to_decode[i].textContent;if(!(s==undefined||(s.indexOf('&')==-1&&s.indexOf('<')==-1))){to_decode[i].innerHTML=s}}}}}}return}var statusTimeoutId=null;function ShowStatusMessage(errMsg,succMsg){window.clearTimeout(statusTimeoutId);if($('StatusMessageBox')!=null){$('StatusMessageBox').remove()}if(((errMsg!=undefined)&&(errMsg!=''))||((succMsg!=undefined)&&(succMsg!=''))){var messageText='';var messageClass='';if(errMsg!=''){messageText=errMsg;messageClass='statusError'}else if(succMsg!=''){messageText=succMsg;messageClass='statusSuccess'}if(messageText!=''){var dimensions=document.viewport.getDimensions();var topPosition=0;var leftPosition=0;$(document.body).insert({bottom:'<div id="StatusMessageBox" class="'+messageClass+'" '+'style="position:absolute;top:'+topPosition+'px;left:'+leftPosition+'px;display:none">'+'<p>'+messageText+'</p>'+'<input type="button" onclick="window.clearTimeout(statusTimeoutId);$(\'StatusMessageBox\').remove();" value="OK">'+'</div>'});var boxHeight=$('StatusMessageBox').getHeight()+10;var boxWidth=$('StatusMessageBox').getWidth()+10;topPosition=Math.floor((dimensions.height/2)-(boxHeight/2));leftPosition=Math.floor((dimensions.width/2)-(boxWidth/2));$('StatusMessageBox').setStyle({top:topPosition+'px',left:leftPosition+'px',width:boxWidth+'px',height:boxHeight+'px'});Effect.BlindDown('StatusMessageBox',{duration:0.25});statusTimeoutId=window.setTimeout("ShowStatusMessage()",5000)}}}function CopyToClipboard(id){var requestData='ID='+id;new Ajax.Request('./index.php?ACTION=Messages&SUBACTION=CopyToClipboard',{method:'post',parameters:requestData,onSuccess:function(){}})}function PasteFromClipboard(){new Ajax.Request('./index.php?ACTION=Messages&SUBACTION=PasteFromClipboard',{method:'get',onSuccess:function(r){if(r.responseText.indexOf('ReportTemplate')>0){var xml=XMLObjectifier.textToXML(r.responseText);var data=XMLObjectifier.xmlToJSON(xml);update=typeof update=='undefined'?'':update;var content=new EJS({url:'/_templates/ejs/'+language+'/'+data.Report[0].Type.toLowerCase()+data.ReportTemplate+'.ejs'+update}).render(data)}else{var content=r.responseText}var textareaContent=$('MESSAGE').value.strip();$('MESSAGE').value=textareaContent+content.unescapeHTML()}})}
