window.addEvent("domready",function(){var a={duration:120000,url:"/indepth/elections2009/js/summary/local.js",year:2009,type:"local",title:"Local Election Results 2009",width:300};if($(a.type+a.year)){new ITLoadGraph(a).start()}a.year=2004;a.title="Local Election Results "+a.year;if($(a.type+a.year)){new ITLoadGraph(a).start()}a.year=2009;a.type="european";a.title="European Election Results "+a.year;a.url="/indepth/elections2009/js/summary/european.js";if($(a.type+a.year)){new ITLoadGraph(a).start()}a.year=2004;a.title="European Election Results "+a.year;if($(a.type+a.year)){new ITLoadGraph(a).start()}a={duration:120000,url:"/indepth/elections2009/js/byelections.js",imageurl:"/indepth/elections2009/images/candidates"};if($("dublincentral")){new ITLoadByelections(a).start()}a={duration:120000,url:"/indepth/elections2009/js/european.js",imageurl:"/indepth/elections2009/images/candidates"};if($("euromapimage")){new ITLoadEuropean(a).start()}});function switchTab(c,a){var b=$$("div."+a);b.each(function(f,e){if(f.id!="content"+c){var d=f.id.replace(/content/,"");$("tab"+d).removeClass("tab_active");$("tab"+d).addClass("tab_inactive");$("content"+d).setOpacity(0)}});b.each(function(e,d){if(e.id=="content"+c){$("tab"+c).addClass("tab_active");e.setOpacity(0);new Fx.Style(e,"opacity",{wait:true}).start(1)}});return false}function getCSSRule(d){d=d.toLowerCase();if(document.styleSheets){for(var b=0;b<document.styleSheets.length;b++){var e=document.styleSheets[b];var c=0;var a=false;do{if(e.cssRules){a=e.cssRules[c]}else{a=e.rules[c]}if(a){if(a.selectorText.toLowerCase()==d){return a}}c++}while(a)}}return false}var ITLoadBase=new Class({options:{duration:120000},initialize:function(a){this.setOptions(a)},start:function(){this.timer=this.load.periodical(this.options.duration,this);this.load()},stop:function(){$clear(this.timer)},load:function(){var b=this.options.url+"?ts="+(new Date()).getTime();var a=this;var c=new Json.Remote(b,{method:"get",onComplete:function(d){if(a.lastjsonObj==this.response.text){return}a.lastjsonObj=this.response.text;a.draw(d,a)}}).send()}});ITLoadBase.implement(new Options);var ITEuropeanAutoplay=new Class({options:{duration:10000},initialize:function(a){this.setOptions(a);this.arealist=$("euromap").getElements("area");this.areaindex=0;this.arealastid=""},start:function(){this.timer=this.load.periodical(this.options.duration,this);this.load()},stop:function(){$clear(this.timer)},load:function(){var a=this.arealist[this.areaindex];$(a).fireEvent("mouseover");if(this.arealastid){$(this.arealastid).fireEvent("mouseout")}this.arealastid=a;this.areaindex=(this.areaindex+1)%this.arealist.length}});ITEuropeanAutoplay.implement(new Options);var ITLoadGraph=ITLoadBase.extend({options:{duration:120000,url:"/indepth/elections2009/js/summary/local.js",year:2009,type:"local",title:"Local Results 2009",width:300,height:300},initialize:function(a){var b=$(a.type+"results"+a.year);if(b&&b.getStyle("width")){a.width=b.getStyle("width").toInt()}this.parent(a)},_round:function(a){if(a-Math.abs(a)<0.6){return Math.abs(a)}else{return Math.round(a)}},draw:function(m,d){var h=d.options.type;var i=d.options.year;var f=new Bluff.Bar(d.options.type+i,d.options.width,d.options.height);f.set_theme({font_color:"black",background_colors:"white"});f.minimum_value=0;f.no_data_message="Results Pending";f.hide_legend=true;f.left_margin=70;var e=[];for(var c in m.party){var n=parseInt(m.party[c]["seats"+i]);if(n<=0){continue}var b=parseInt(m.party[c]["pvote"+i]);e.push({party:c,seats:n,pvote:b})}e=e.sort(function(o,g){return(parseInt(g.seats,10)-parseInt(o.seats,10))});if(e.length>2&&e[0].seats>10){var j=parseInt(e[0].seats,10);var l=(j<=50?10:50);f.maximum_value=j+(l-(j%l))}var k=$(h+"table"+i);if(e.length>0){k.setStyle("display","block")}var a=["party","seats","pvote"];a.each(function(p){cellcount=$(h+p+i).getElements("th").length;cellcount+=$(h+p+i).getElements("td").length;var q=e.length-cellcount+1;if(q>=0){for(var o=0;o<q;o++){var g=new Element((p=="party"?"th":"td"),{id:h+p+i+o}).injectInside($(h+p+i))}}});e.each(function(o,g){var q=getCSSRule(".party-"+o.party);var p=null;if(q&&q.style.backgroundColor){p=q.style.backgroundColor}f.data(o.party,[o.seats],p)});f.draw();f.barpadding=this._round(f.barpadding);f.barw=Math.round(f.barw);if(k){k.removeAttribute("width");k.setAttribute("cellSpacing",f.barpadding);k.setStyle("border-collapse","separate");k.setStyle("border-spacing",f.barpadding)}a.each(function(p){var o=$(h+p+i).getFirst();if(o){var g=f.startlx-(f.barpadding*2);if(!isNaN(g)){o.setStyle("width",g)}}});e.each(function(o,g){$(h+"party"+i+g).setHTML(o.party).addClass("party-"+o.party);$(h+"party"+i+g).setStyle("width",f.barw);$(h+"party"+i+g).setStyle("padding",0);$(h+"seats"+i+g).setHTML(o.seats);$(h+"pvote"+i+g).setHTML(o.pvote)})}});var ITLoadEuropean=ITLoadBase.extend({options:{duration:120000,url:"/indepth/elections2009/js/european.js"},initialize:function(b){this.parent(b);var a=this;var c=["dublin","east","northernireland","northwest","south"];c.each(function(e){var d=$(e+"area");d.href="/indepth/elections2009/results/european/"+e+".html";d.addEvent("mouseover",function(){$("european-results").addClass(e);$("infobox").setOpacity(0);a.setinfobox(e);var f=new Fx.Styles("infobox",{duration:200});f.start({opacity:[0,0.8],width:[100,220]})});d.addEvent("mouseout",function(){$("european-results").removeClass(e);$("infobox").setOpacity(0)})});if(this.options.autoplay){this.autoplay=new ITEuropeanAutoplay({duration:this.options.autoplay})}},setinfobox:function(a){$("infobox").setHTML(this.options.constituency[a])},draw:function(h,b){b.options.constituency={};for(var e in h.constituency){var d="";for(var a in h.constituency[e].candidate){var g=h.constituency[e].candidate[a];if(g.status&&g.status.indexOf("Elected")>-1){d+=a+" - <strong>Elected</strong><br/>"}}var f=e.toLowerCase().replace(/\s+/,"");b.options.constituency[f]=d?d:"Results Pending"}if(this.options.autoplay){this.autoplay.start()}}});var ITLoadByelections=ITLoadBase.extend({options:{duration:120000,url:"/indepth/elections2009/js/byelections.js",imageurl:"/indepth/elections2009/images/candidates"},draw:function(i,b){var e=b.options.imageurl;for(var f in i.constituency){for(var a in i.constituency[f].candidate){var h=i.constituency[f].candidate[a];var g=f.toLowerCase().replace(/\s+/,"");var d=false;if(h.status&&h.status.indexOf("Elected")>-1){$(g).setOpacity(0);$(g+"name").setHTML(a);$(g+"image").src=e+"/"+h.url;$(g+"party").setHTML(h.party);$(g+"status").setHTML(h.status);new Fx.Style($(g),"opacity",{wait:true}).start(1);d=true;break}if(!d){$(g+"name").setHTML("Result pending")}}}}});Bluff.Renderer=new JS.Class(Bluff.Renderer,{annotate_scaled:function(c,b,a,f,e,d){this.font_weight="normal";this.callSuper(c,b,a,f,e,d)}});