﻿window.attackDelay=function(){var a=new Date,b=a.getTime()+375;while(a.getTime()<b)a=new Date};window.removeSpan=function(b){var c=b.indexOf("<span");if(c>-1){var a=b.substr(c),d=b.substr(0,c);a=a.substr(a.indexOf(">")+1);var e=a.indexOf("</span>");d+=a.substr(0,e)+a.substr(e+7);return d}else return b};unsafeWindow.attackAll=function(f){var a,b,d=document.evaluate("//img[contains(@src, 'icon_action_arrow_green.gif')]",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),e=document.getElementById("attackallframe");for(var c=0;c<d.snapshotLength;c++){b=d.snapshotItem(c).parentNode.parentNode.innerHTML;a=b.indexOf("cmd=combat")-10;attacklink=b.substr(a);a=attacklink.indexOf("creature_id=");a=attacklink.indexOf('"',a);attacklink=attacklink.substr(0,a);attacklink=attacklink.replace(new RegExp("&amp;","g"),"&");e.src="http://www.fallensword.com/"+attacklink;attackDelay()}if(f)window.location.href="index.php?cmd=blacksmith&subcmd=repairall&fromworld=1";else window.location.href="index.php?cmd=world"};unsafeWindow.attackType=function(g){var a,b,c,e=document.evaluate("//img[contains(@src, 'icon_action_arrow_green.gif')]",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),f=document.getElementById("attackallframe");for(var d=0;d<e.snapshotLength;d++){c=e.snapshotItem(d).parentNode.parentNode;if(removeSpan(c.childNodes[2].innerHTML)==g){b=c.innerHTML;a=b.indexOf("cmd=combat")-10;attacklink=b.substr(a);a=attacklink.indexOf("creature_id=");a=attacklink.indexOf('"',a);attacklink=attacklink.substr(0,a);attacklink=attacklink.replace(new RegExp("&amp;","g"),"&");f.src="http://www.fallensword.com/"+attacklink;attackDelay()}}window.location.href="index.php?cmd=world"};var xpath="//img[contains(@src, 'icon_action_arrow_green.gif')]",hastargets=document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),xpath="//img[contains(@src, '/skin/')]",imgurls=document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);if(hastargets.snapshotLength){var actiontable=hastargets.snapshotItem(0).parentNode.parentNode;while(actiontable.tagName!="TBODY")actiontable=actiontable.parentNode;var idindex=imgurls.snapshotItem(0).src.indexOf("/skin/"),imgserver=imgurls.snapshotItem(0).src.substr(0,idindex),attackLink=null,typeName=null,actionRow=null;for(var incr=0;incr<hastargets.snapshotLength;incr++){actionRow=hastargets.snapshotItem(incr).parentNode.parentNode;typeName=removeSpan(actionRow.childNodes[2].innerHTML);attackLink=actionRow.childNodes[3].childNodes[0].childNodes[6];attackLink.href='javascript:attackType("'+typeName+'")';attackLink.firstChild.src=imgserver+"/skin/icon_action_group.gif";attackLink.firstChild.setAttribute("title","Attack all "+typeName)}var tablerow=document.createElement("tr"),tabledata=document.createElement("td");tabledata.setAttribute("align","center");tabledata.setAttribute("colspan","3");var newhtml="<a href='javascript:attackAll(0)'>";newhtml+="<img alt='Attack all creatures' title='Attack all creatures' src=";newhtml+=imgserver+"/skin/icon_action_attack1.gif></a>&nbsp;&nbsp;&nbsp;";newhtml+="<a href='javascript:attackAll(1)'>";newhtml+="<img alt='Attack all with repair' title='Attack all with repair' src=";newhtml+=imgserver+"/skin/icon_action_attack1.gif>";newhtml+="<img alt='Attack all with repair' title='Attack all with repair' src=";newhtml+=imgserver+"/skin/realm/icon_action_repair.gif></a>";newhtml+='<iframe id="attackallframe" style="width:0px; height:0px; border: 0px"></iframe>';tabledata.innerHTML=newhtml;tablerow.appendChild(tabledata);actiontable.appendChild(tablerow)}
