var sExt="com";var sItemUrl="http://www.dofus."+sExt+"/-LANG-/apidofus/item";var sMonsterUrl="http://www.dofus."+sExt+"/-LANG-/apidofus/monster";var bDefaultTemplate=true;if(typeof(sTemplateName)=="undefined"){var sTemplateUrl="http://www.dofus."+sExt+"/apidofus/items/dofus2_item_template.js?l="+sLinkerLanguage}else{var sTemplateUrl="http://www.dofus."+sExt+"/apidofus/items/"+sTemplateName+".js?l="+sLinkerLanguage;bDefaultTemplate=false}if(typeof(sMonsterTemplateName)=="undefined"){var sMonsterTemplateUrl="http://www.dofus."+sExt+"/apidofus/items/dofus_monster_template.js?l="+sLinkerLanguage}else{var sMonsterTemplateUrl="http://www.dofus."+sExt+"/apidofus/items/"+sMonsterTemplateName+".js?l="+sLinkerLanguage;bDefaultTemplate=false}var aItems=new Array();var yuiPath="";var DofusLinker=function(){self=this};var callbackjson={success:SuccessHandlerJSON,failure:FailureHandlerJSON,timeout:5000};function SuccessHandlerJSON(d){bLoading=false;try{var c=d;var b=YAHOO.lang.JSON.parse(c.responseText);sCurrentTemplate=ProcessData(b,sCallbackType)}catch(a){sCurrentTemplate="JSON Parse failed! "+a}TestRegion(sCurrentTemplate)}function FailureHandlerJSON(a){div[iLinkerCount].innerHTML=a.status+" "+a.statusText}var callbackxml={success:SuccessHandlerXML,failure:FailureHandlerXML,timeout:5000};function SuccessHandlerXML(b){bLoading=false;var a=b.responseXML;sCurrentTemplate=ProcessData(a,sCallbackType);TestRegion(sCurrentTemplate)}function FailureHandlerXML(a){div[iLinkerCount].innerHTML=a.status+" "+a.statusText}function TestRegion(c){if(typeof(div[iLinkerCount])!="undefined"){oElem=YAHOO.util.Dom.get(div[iLinkerCount].getAttribute("launcher_elem"));var b=fCoordX-20;var d=fCoordY-15;oLauncherRegion=YAHOO.util.Region.getRegion(oElem);oMouseRegion=new YAHOO.util.Region(d-100,b+100,d+100,b-100);div[iLinkerCount].innerHTML=c;if(oLauncherRegion.intersect(oMouseRegion)){div[iLinkerCount].style.display=""}else{try{document.body.removeChild(div[iLinkerCount])}catch(a){}}}}function SuccessHandlerJSONP(b){bLoading=false;try{sCurrentTemplate=ProcessData(jsonDofusElement,sCallbackType)}catch(a){sCurrentTemplate="JSONP Parse failed! "+a}TestRegion(sCurrentTemplate)}function FailureHandlerJSONP(a){div[iLinkerCount].innerHTML=a.status+" "+a.statusText}var iState=new Array();var iBlock=new Array();var aLinkerPosition=new Array();var fCoordX=0;var fCoordY=0;var iLinkerCount=0;var iMaxCount=3;var bLoading=false;for(i=iLinkerCount;i<=iMaxCount;i++){iState[i]=0;iBlock[i]=0;aLinkerPosition[i]="start"}var div=new Array();function mouseposition(a){if(!a){var a=window.event}if(a.pageX||a.pageY){fCoordX=a.pageX;fCoordY=a.pageY}else{if(a.clientX||a.clientY){fCoordX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;fCoordY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}}fCurrentX=fCoordX;if(aLinkerPosition[iLinkerCount]=="start"){if((ScreenWidth()/2)>fCurrentX){fCoordX=fCoordX+15}else{fCoordX=fCoordX-515}}else{switch(aLinkerPosition[iLinkerCount]){case"left":fCoordX=fCoordX-510;break;case"right":fCoordX=fCoordX+15;break}}fCoordY=fCoordY+10;if(iState[iLinkerCount]==1&&iBlock[iLinkerCount]==0&&div[iLinkerCount]!=null||bLoading){if(aLinkerPosition[iLinkerCount]=="start"){if((ScreenWidth()/2)>fCurrentX){aLinkerPosition[iLinkerCount]="right"}else{aLinkerPosition[iLinkerCount]="left"}}div[iLinkerCount].style.left=fCoordX+"px";div[iLinkerCount].style.top=fCoordY+"px"}}function ScreenWidth(){var a=0,b=0;if(typeof(window.innerWidth)=="number"){a=window.innerWidth;b=window.innerHeight}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){a=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){a=document.body.clientWidth;b=document.body.clientHeight}else{a=-1;b=-1}}}return a}var eventLoader=new YAHOO.util.YUILoader({require:["event"],loadOptional:false,onSuccess:function(a){YAHOO.util.Event.addListener(document,"mousemove",mouseposition)}});eventLoader.insert();function CloseItem(){if(iState[iLinkerCount]==1&&iBlock[iLinkerCount]==0){aLinkerPosition[iLinkerCount]="start";try{document.body.removeChild(div[iLinkerCount])}catch(a){}iState[iLinkerCount]=0}}function CloseItemByNumber(a){if(iState[a]==1&&iBlock[a]==0){aLinkerPosition[a]="start";document.body.removeChild(div[a]);div[a]=null;iState[a]=0}}function BlockItem(){if(bLoading==false){if(iLinkerCount<iMaxCount){iBlock[iLinkerCount]=1;SetCurrentItem()}}return 0}function UnBlockItem(a){iBlock[a]=0;CloseItemByNumber(a);SetCurrentItem()}function SetCurrentItem(){i=0;while(i<iMaxCount&&div[i]!=null){i++}iLinkerCount=i}function ProcessData(a,b){if(a.item!=undefined){sCurrentTemplate=ProcessItemData(a,b)}else{if(a.monster!=undefined){sCurrentTemplate=ProcessMonsterData(a,b)}}return sCurrentTemplate}function ProcessItemData(u,k){var h=sItemTemplate;switch(k){case"json":case"jsonp":h=h.replace(/\[ITEM_NAME\]/g,u.item["name"]);h=h.replace(/\[ITEM_LVL\]/g,u.item["lvl"]);if(u.item["typeid"]!=null){h=h.replace(/\[TYPE_ID\]/g,u.item["typeid"])}else{if(u.item["supertypeid"]!=null){h=h.replace(/\[TYPE_ID\]/g,u.item["supertypeid"])}else{h=h.replace(/\[TYPE_ID\]/g,"")}}if(u.item["typename"]!=null){h=h.replace(/\[TYPE_NAME\]/g,u.item["typename"])}else{h=h.replace(/\[TYPE_NAME\]/g,"")}h=h.replace(/\[GFXID\]/g,u.item["gfxid"]);h=h.replace(/\[SUPERTYPE_ID\]/g,u.item["supertypeid"]);h=h.replace(/\[ITEM_NAME_URL\]/g,encodeURI(u.item["name"]));h=h.replace(/\[SHOWMORE\]/g,u.item["showmore"]);if(u.item["typeid"]==-1){h=h.replace(/\[PRINTKNOWMORE\]/g,'style="display:none;"')}else{h=h.replace(/\[PRINTKNOWMORE\]/g,"")}var e=true;var o="display:none;";if(u.item["effectslist"]!=undefined){if(u.item["effectslist"].length>0&&u.item["typeid"]!=18){o="";e=false}}h=h.replace(/\[EFFECTSLISTSTYLE\]/g,o);var d="display:none;";if(u.item["carac"]!=undefined&&u.item["typeid"]!=18){d="";e=false}h=h.replace(/\[CARACSLISTSTYLE\]/g,d);if(bDefaultTemplate){if(e){h=h.replace(/\[SUMMARY\]/g,u.item["summary"])}else{h=h.replace(/\[SUMMARY\]/g,"")}}else{h=h.replace(/\[SUMMARY\]/g,u.item["summary"])}var v="display:none;";var a="display:none;";if(u.item["craftslist"]!=undefined){if(u.item["craftslist"].length>0){var c=0;if(u.item["craftslist"].length%5==0){c=u.item["craftslist"].length/5}else{c=Math.floor(u.item["craftslist"].length/5)+1}if(c==0){c=1}if(bDefaultTemplate){v="height:"+c*90+"px;"}else{v=""}a=""}}h=h.replace(/\[CRAFTLISTSTYLE\]/g,v);h=h.replace(/\[CRAFTLISTTITLESTYLE\]/g,a);sEffects="";if(u.item["effectslist"]!=undefined){sEffects+='<ul id="dofusitem_effects">';for(i=0;i<u.item["effectslist"].length;i++){sEffects+='<li class="dofusitem_row'+(i%2)+'">'+u.item["effectslist"][i]["value"]+"</li>"}sEffects+="</ul>"}h=h.replace(/\[EFFECTSLIST\]/g,sEffects);sConditions="";if(u.item["conditionslist"]!=undefined){sConditions+='<ul id="dofusitem_effects">';for(i=0;i<u.item["conditionslist"].length;i++){sConditions+='<li class="dofusitem_row'+(i%2)+'">'+u.item["conditionslist"][i]+"</li>"}sConditions+="</ul>"}h=h.replace(/\[CONDITIONSLIST\]/g,sConditions);sSetProperty="display:none;";sSetId="";sSetName="";sSetNameURL="";sSetURL="";if(u.item["set"]!=undefined){sSetId=u.item["set"]["id"];sSetName=u.item["set"]["name"];sSetURL=u.item["set"]["url"];sSetNameURL=u.item["set"]["urlname"];sSetProperty=""}h=h.replace(/\[SETID\]/g,sSetId);h=h.replace(/\[SETNAME\]/g,sSetName);h=h.replace(/\[SETURL\]/g,sSetURL);h=h.replace(/\[SETNAMEURL\]/g,sSetNameURL);h=h.replace(/\[SETPROPERTY\]/g,sSetProperty);sCaracs="";if(u.item["carac"]!=undefined){sCaracs=sCaracRow;sCaracs=sCaracs.replace(/\[PA\]/g,u.item["carac"]["pa"]);sCaracs=sCaracs.replace(/\[PO\]/g,u.item["carac"]["po"]);sCaracs=sCaracs.replace(/\[CC\]/g,u.item["carac"]["cc"]);sCaracs=sCaracs.replace(/\[EC\]/g,u.item["carac"]["ec"])}h=h.replace(/\[CARACSLIST\]/g,sCaracs);sCrafts="";if(u.item["craftslist"]!=undefined){sCrafts+='<ul id="dofusitem_craftlist">';for(i=0;i<u.item["craftslist"].length;i++){sCurrentRow=sCraftRow;sCurrentRow=sCurrentRow.replace(/\[TYPE_ID\]/g,u.item["craftslist"][i]["typeid"]);sCurrentRow=sCurrentRow.replace(/\[GFXID\]/g,u.item["craftslist"][i]["gfxid"]);if(u.item["craftslist"][i]["quantity"]!=undefined){sCurrentRow=sCurrentRow.replace(/\[QUANTITY\]/g,u.item["craftslist"][i]["quantity"])}else{sCurrentRow=sCurrentRow.replace(/\[QUANTITY\]/g,"1")}sCurrentRow=sCurrentRow.replace(/\[NAME\]/g,u.item["craftslist"][i]["name"]);sCrafts+="<li>"+sCurrentRow+"</li>"}sCrafts+="</ul>"}h=h.replace(/\[CRAFTLIST\]/g,sCrafts);aItems[u.item["id"]]=h;h=h.replace(/\[ITEMHEADER\]/g,"itemHeader_"+iLinkerCount);h=h.replace(/\[NUMBER\]/g,iLinkerCount);break;case"xml":var s=u.getElementsByTagName("page");for(i=0;i<s.length;i++){var t=s[0].getElementsByTagName("item")[i];var n=t.attributes.getNamedItem("id").value;var r=t.attributes.getNamedItem("name").value;var p="";if(t.attributes.getNamedItem("supertypeid")!=undefined){p=t.attributes.getNamedItem("supertypeid").value}var f="";if(t.attributes.getNamedItem("typeid")!=undefined){f=t.attributes.getNamedItem("typeid").value}var l=t.attributes.getNamedItem("gfxid").value;var m=t.attributes.getNamedItem("lvl").value;var b=t.attributes.getNamedItem("url").value;h=h.replace(/\[ITEM_NAME]/g,r);h=h.replace(/\[ITEM_LVL]/g,m);h=h.replace(/\[TYPE_ID]/g,f);h=h.replace(/\[GFXID]/g,l);for(j=0;j<t.length;j++){var w=t[0].getElementsByTagName("effectslist")[j].firstChild.nodeValue;var g=t[0].getElementsByTagName("effectslist")[j].firstChild.nodeValue;var q=t[0].getElementsByTagName("effectslist")[j].firstChild.nodeValue;var x=t[0].getElementsByTagName("effectslist")[j].firstChild.nodeValue}}aItems[t.attributes.getNamedItem("id").value]=h;h=h.replace(/\[ITEMHEADER]/g,"itemHeader_"+iLinkerCount);h=h.replace(/\[NUMBER]/g,iLinkerCount);break;default:h="";break}return h}function ProcessMonsterData(d,f){var b=sMonsterTemplate;switch(f){case"json":case"jsonp":b=b.replace(/\[MONSTER_ID\]/g,d.monster["id"]);b=b.replace(/\[MONSTER_NAME\]/g,d.monster["name"]);b=b.replace(/\[GFXID\]/g,d.monster["gfxid"]);b=b.replace(/\[COLOR1\]/g,d.monster["color1"]);b=b.replace(/\[COLOR2\]/g,d.monster["color2"]);b=b.replace(/\[COLOR3\]/g,d.monster["color3"]);b=b.replace(/\[MONSTER_LVL_MIN\]/g,d.monster["lvlmin"]);b=b.replace(/\[MONSTER_LVL_MAX\]/g,d.monster["lvlmax"]);b=b.replace(/\[MONSTER_LVL\]/g,d.monster["lvl"]);b=b.replace(/\[MONSTER_SUPERRACE_ID\]/g,d.monster["superraceid"]);b=b.replace(/\[MONSTER_SUPERRACE_NAME\]/g,d.monster["superracename"]);b=b.replace(/\[MONSTER_SUPERRACE_NAMEURL\]/g,d.monster["superracenameurl"]);b=b.replace(/\[MONSTER_RACE_ID\]/g,d.monster["raceid"]);b=b.replace(/\[MONSTER_RACE_NAME\]/g,d.monster["racename"]);b=b.replace(/\[MONSTER_RACE_NAMEURL\]/g,d.monster["racenameurl"]);b=b.replace(/\[MONSTER_PV_MIN\]/g,d.monster["lifepointsmin"]);b=b.replace(/\[MONSTER_PV_MAX\]/g,d.monster["lifepointsmax"]);b=b.replace(/\[MONSTER_PV\]/g,d.monster["lifepoints"]);b=b.replace(/\[MONSTER_AP_MIN\]/g,d.monster["actionpointmin"]);b=b.replace(/\[MONSTER_AP_MAX\]/g,d.monster["actionpointmax"]);b=b.replace(/\[MONSTER_AP\]/g,d.monster["actionpoint"]);b=b.replace(/\[MONSTER_PM_MIN\]/g,d.monster["movmentpointmin"]);b=b.replace(/\[MONSTER_PM_MAX\]/g,d.monster["movmentpointmax"]);b=b.replace(/\[MONSTER_PM\]/g,d.monster["movmentpoint"]);b=b.replace(/\[MONSTER_GOLD_MIN\]/g,d.monster["goldmin"]);b=b.replace(/\[MONSTER_GOLD_MAX\]/g,d.monster["goldmax"]);b=b.replace(/\[MONSTER_GOLD\]/g,d.monster["gold"]);b=b.replace(/\[MONSTER_REDUCTION_EARTH_MIN\]/g,d.monster["reductionearthmin"]);b=b.replace(/\[MONSTER_REDUCTION_EARTH_MAX\]/g,d.monster["reductionearthmax"]);b=b.replace(/\[MONSTER_REDUCTION_EARTH\]/g,d.monster["reductionearth"]);b=b.replace(/\[MONSTER_REDUCTION_AIR_MIN\]/g,d.monster["reductionairmin"]);b=b.replace(/\[MONSTER_REDUCTION_AIR_MAX\]/g,d.monster["reductionairmax"]);b=b.replace(/\[MONSTER_REDUCTION_AIR\]/g,d.monster["reductionair"]);b=b.replace(/\[MONSTER_REDUCTION_FIRE_MIN\]/g,d.monster["reductionfiremin"]);b=b.replace(/\[MONSTER_REDUCTION_FIRE_MAX\]/g,d.monster["reductionfiremax"]);b=b.replace(/\[MONSTER_REDUCTION_FIRE\]/g,d.monster["reductionfire"]);b=b.replace(/\[MONSTER_REDUCTION_WATER_MIN\]/g,d.monster["reductionwatermin"]);b=b.replace(/\[MONSTER_REDUCTION_WATER_MAX\]/g,d.monster["reductionwatermax"]);b=b.replace(/\[MONSTER_REDUCTION_WATER\]/g,d.monster["reductionwater"]);b=b.replace(/\[MONSTER_REDUCTION_NEUTRAL_MIN\]/g,d.monster["reductionneutralmin"]);b=b.replace(/\[MONSTER_REDUCTION_NEUTRAL_MAX\]/g,d.monster["reductionneutralmax"]);b=b.replace(/\[MONSTER_REDUCTION_NEUTRAL\]/g,d.monster["reductionneutral"]);b=b.replace(/\[MONSTER_SPELLS\]/g,d.monster["spells"]);if(d.monster["spell"]){b=b.replace(/\[MONSTER_SPELL_DISPLAY\]/g,"");b=b.replace(/\[MONSTER_SPELLS_LIST\]/g,d.monster["spellslist"])}else{b=b.replace(/\[MONSTER_SPELL_DISPLAY\]/g,"display:none");b=b.replace(/\[MONSTER_SPELLS_LIST\]/g,"")}if(d.monster["dropslist"]!=""){b=b.replace(/\[MONSTER_DROPS_SHOW\]/g,"");b=b.replace(/\[MONSTER_DROPS_LIST\]/g,d.monster["dropslist"])}else{b=b.replace(/\[MONSTER_DROPS_SHOW\]/g,"display:none");b=b.replace(/\[MONSTER_DROPS_LIST\]/g,"")}var c="display:none;";var e="display:none;";if(d.monster["craftslist"]!=undefined){if(d.monster["craftslist"].length>0){var a=0;if(d.monster["craftslist"].length%5==0){a=d.monster["craftslist"].length/5}else{a=Math.floor(d.monster["craftslist"].length/5)+1}if(a==0){a=1}if(bDefaultTemplate){c="height:"+a*90+"px;"}else{c=""}e=""}}b=b.replace(/\[CRAFTLISTSTYLE\]/g,c);b=b.replace(/\[CRAFTLISTTITLESTYLE\]/g,e);aItems[d.monster["id"]]=b;b=b.replace(/\[ITEMHEADER\]/g,"itemHeader_"+iLinkerCount);b=b.replace(/\[NUMBER\]/g,iLinkerCount);break;case"xml":break;default:b="";break}return b}function ProcessExistingData(a){bLoading=false;sCurrentTemplate=aItems[a];sCurrentTemplate=sCurrentTemplate.replace(/\[ITEMHEADER\]/g,"itemHeader_"+iLinkerCount);sCurrentTemplate=sCurrentTemplate.replace(/\[NUMBER\]/g,iLinkerCount);if(typeof(div[iLinkerCount])!="undefined"){div[iLinkerCount].style.display="";div[iLinkerCount].innerHTML=sCurrentTemplate}}function OpenCloseIlContent(d,c){var a=document.getElementById(d);var b=document.getElementById(c);if(a!=undefined){if(a.style.display==""){b.className="il_spec_btn_title_left il_spec_title_rec_close";a.style.display="none"}else{b.className="il_spec_btn_title_left il_spec_title_rec_open";a.style.display=""}}}DofusLinker.ShowItem=function(c,f,e,d){if(e==null){e="fr"}sRequestUrl=sRequestUrl.replace("-LANG-",e);if(d==null){d="jsonp"}if(iState[iLinkerCount]==0&&iBlock[iLinkerCount]==0){if(bLoading&&typeof(div[iLinkerCount])!="undefined"){try{document.body.removeChild(div[iLinkerCount]);iState[iLinkerCount]=0}catch(b){}}bLoading=true;div[iLinkerCount]=document.createElement("div");launcherId=c.id;if(!launcherId){launcherId="dofusitemlauncher"+iLinkerCount;c.setAttribute("id",launcherId)}div[iLinkerCount].setAttribute("launcher_elem",launcherId);div[iLinkerCount].setAttribute("id","dofusitem_"+iLinkerCount);div[iLinkerCount].style.position="absolute";div[iLinkerCount].style.display="";document.body.appendChild(div[iLinkerCount]);div[iLinkerCount].innerHTML="<div id='dofus_linker_loading'>&nbsp;</div>";var a=new YAHOO.util.YUILoader({require:["connection","dragdrop","animation","json","get"],loadOptional:false,onSuccess:function(l){div[iLinkerCount].style.left=fCoordX+"px";div[iLinkerCount].style.top=fCoordY+"px";div[iLinkerCount].style.zIndex="5001";if(aItems[f]==null){var h=true;switch(d){case"json":var g="id="+f+"&type="+d;var k=YAHOO.util.Connect.asyncRequest("POST",sRequestUrl,callbackjson,g);break;case"jsonp":sCurrentUrl=sRequestUrl+"?id="+f+"&type="+d;YAHOO.util.Get.script(sCurrentUrl,{onSuccess:SuccessHandlerJSONP,onFailure:FailureHandlerJSONP});break;case"xml":var g="id="+f+"&type="+d;var k=YAHOO.util.Connect.asyncRequest("POST",sRequestUrl,callbackxml,g);break;default:h=false;break}}else{ProcessExistingData(f);h=true}if(h){iState[iLinkerCount]=1;(function(){var m;m=new YAHOO.util.DD("dofusitem_"+iLinkerCount);m.setHandleElId("itemHeader_"+iLinkerCount)})()}else{document.body.removeChild(div[iLinkerCount])}},onFailure:function(g){document.body.removeChild(div[iLinkerCount])}});if(!is_defined("sItemTemplate")){a.addModule({name:"template",type:"js",fullpath:sTemplateUrl});a.require("template")}if(!is_defined("sMonsterTemplate")){a.addModule({name:"monstertemplate",type:"js",fullpath:sMonsterTemplateUrl});a.require("monstertemplate")}a.insert()}};DofusLinker.Item=function(a,c,b){if(b==null){b="fr"}sRequestUrl=sItemUrl;a.style.cursor="pointer";a.onclick=function(){BlockItem()};a.onmouseout=function(){CloseItem()};a.removeAttribute("href");DofusLinker.ShowItem(a,c,b)};DofusLinker.Monster=function(a,c,b){if(b==null){b="fr"}sRequestUrl=sMonsterUrl;a.style.cursor="pointer";a.onclick=function(){BlockItem()};a.onmouseout=function(){CloseItem()};a.removeAttribute("href");DofusLinker.ShowItem(a,c,b)};function is_defined(a){return(typeof(window[a])=="undefined")?false:true};