User:Acapnia/monaco.js

// == meitar @ 2009-12-04 02:57:36 == // New global Wikia namespace. Please see // global Wikia namespace. Please see //    https://staff.wikia-inc.com/wiki/Coding_conventions#JavaScript // for details. // TODO: Is there a better, more fundamental place for this? var WIKIA = {};

// prevent JS errors when AJAX request for magic words is not sent var magicWords = {};

//Attach DOM-Ready handlers $(function {	$("#headerButtonHub").bind("click.headerMenu", openHubMenu);	$("#headerButtonUser").bind("click.headerMenu", openUserMenu);	$(document).ajaxStart(startAjax).ajaxStop(stopAjax);	setupVoting; });

//Ajax Wait Indicator function startAjax { $("body").addClass("ajax"); } function stopAjax { $("body").removeClass("ajax"); }

//Search Field function monacoSearchField(event) { if (event.type == 'focus') { if ($("#search_field").val == $("#search_field").attr("title")) { $("#search_field").val('').addClass("field_active"); }	} else if (event.type == 'blur') { if ($("#search_field").val == '') { $("#search_field").val($("#search_field").attr("title")).removeClass("field_active"); }	} }

//Hub Menu function openHubMenu(event) { event.stopPropagation;

if ( $('#headerMenuHub').exists ) { $("#headerMenuHub").makeHeaderMenu('headerButtonHub', openHubMenu, {attach_to: "#headerButtonHub", attach_at: "bottom"}); }	else { $.get(wgScript + '?action=ajax&rs=GetHubMenu&cb=' + wgMWrevId + '-' + wgStyleVersion, function(html) {			$("#positioned_elements").append(html);			$("#headerMenuHub").makeHeaderMenu('headerButtonHub', openHubMenu, {attach_to: "#headerButtonHub", attach_at: "bottom"});		}); } }

//User Menu function openUserMenu(event) { event.stopPropagation;

if ( $('#headerMenuUser').exists ) { $("#headerMenuUser").makeHeaderMenu("headerButtonUser", openUserMenu, {attach_to: "#userData", attach_at: "bottom"}); }	else { $.get(wgScript + '?action=ajax&rs=GetUserMenu&rsargs[]='+ wgUserName +'&uselang='+ wgUserLanguage + '&cb=' + wgMWrevId + '-' + wgStyleVersion,			function(html) {				$("#positioned_elements").append(html);				$("#headerMenuUser").makeHeaderMenu("headerButtonUser", openUserMenu, {attach_to: "#userData", attach_at: "bottom"});				$('#cockpit1').click(WidgetFramework.show_cockpit);				$("#headerMenuUser").click( function(e){ if (e.target.nodeName == "A" ){ $.tracker.byStr('userMenu/' + $(e.target).attr('id')); };					});			});	} }

//Header Menu $.fn.extend({	makeHeaderMenu: function(trigger, headerMenuFunction, options) {		if (!trigger) {			//adding error logging here			$(this).remove;		} else {			trigger = $("#"+trigger);		}

var menu = $(this); var headerMenuTimer; var settings = { delay: 500, edge: 10, attach_to: "#wikia_header", attach_at: "bottom" };		if (options) { $.extend(settings, options); }

//make the trigger unclickable for now - will bound again when menu is closed trigger.unbind(".headerMenu");

//calculate left position var center = trigger.offset.left + ( trigger.outerWidth / 2 ); var menuWidth = menu.outerWidth; var targetLeft = center - ( menuWidth / 2 ); if (targetLeft < settings.edge) { targetLeft = settings.edge; }

//calculate top position var targetTop = $(settings.attach_to).offset.top; if (settings.attach_at == "bottom") { targetTop += $(settings.attach_to).outerHeight; }

//show menu, set mouseenter/mouseleave handlers menu.css("left", targetLeft).css("top", targetTop).slideDown("fast").mouseleave(function {			headerMenuTimer = setTimeout(function { menu.closeHeaderMenu(trigger, headerMenuFunction); }, settings.delay);		}).mouseenter(function {			clearTimeout(headerMenuTimer);		});

trigger.mouseleave(function {			headerMenuTimer = setTimeout(function { menu.closeHeaderMenu(trigger, headerMenuFunction); }, settings.delay);		}).mouseenter(function {			clearTimeout(headerMenuTimer);		});

//close menu by clicking anywhere $(document).bind("click.headerMenu", function {			menu.closeHeaderMenu(trigger, headerMenuFunction);		});

menu.click(function(event) {			event.stopPropagation;		}); },	closeHeaderMenu: function(trigger, headerMenuFunction) { $(document).unbind("click.headerMenu"); trigger.bind("click.headerMenu", headerMenuFunction); $(this).slideUp("fast"); } });

//Navigation var monacoNavigationInitCalled = false; function menuInit { if (monacoNavigationInitCalled) { return; }	monacoNavigationInitCalled = true;

function monacoNavigationRender(i, item, append) { //if appending a new chain of menus to the top-level nav, reset html var if (append) { html = ''; }		//create a sub-menu html += ' '; if (typeof item != 'object') { if (typeof magicWords[item] != 'undefined') { $.each(magicWords[item], function {					classname = '';					text = this.text;					if (this.className) {						classname = ' class="' + this.className + '"';						if (this.className == 'Monaco-sidebar_more') {							text = wgMenuMore;						} else if (this.className == 'Monaco-sidebar_edit') {							if (typeof wgMenuEdit != 'undefined') {								text = wgMenuEdit;							} else {								return true;							}						}					}					html += ' ' + text +' ';				}); }		} else { $.each(item, function(i, item) {				//does this item have children?				var children = '';				if (menuArray[item].children || menuArray[item].magic) {					children = ' &rsaquo; ';				}				//render div for this item				html += ' ' + menuArray[item].text + children + '';					if (menuArray[item].children) {						monacoNavigationRender(menuArray[item], menuArray[item].children);					} else if (menuArray[item].magic) {						monacoNavigationRender(menuArray[item], menuArray[item].magic);					}				html += ' ';			}); }		html += ' '; if (append) { $("#menu-item_" + i).append(html); }	}	$.each(menuArray.mainMenu, function (i, item) {		monacoNavigationRender(i, item, true);	}); $(".sub-menu").each(function {		//no more per menu 'edit' links, rt#22739

//no border on last item in sub-menus $(this).children("div:last").css("border", 0); });

// just 1 per menu 'edit' at top level, rt#22739 if (typeof wgMenuEdit != 'undefined') { href = ($("#navigation").hasClass("userMenu")) ? '?title=User:' + wgUserName + '/Monaco-sidebar&action=edit' : '?title=MediaWiki:Monaco-sidebar&action=edit'; $("#navigation").append(' ' + wgMenuEdit + ' '); }	monacoNavigationHoverActions; }

var menutimer; function monacoNavigationHoverActions { $("#navigation .menu-item").hover(function {		$(this).addClass("navigation-hover").children(".sub-menu").show;		$(this).siblings.removeClass("navigation-hover").find(".sub-menu").hide.end.find(".menu-item").removeClass("navigation-hover");	}); $("#navigation").mouseleave(function {		$(this).find(".menu-item").removeClass("navigation-hover");		menutimer = setTimeout(function { $("#navigation").find(".sub-menu").hide; }, 500);	}).mouseover(function {		clearTimeout(menutimer);	});

// RT #19924 $('#wpTextbox1').mouseover(function {		$('#navigation').find(".menu-item").removeClass("navigation-hover");		menutimer = setTimeout(function { $("#navigation").find(".sub-menu").hide; }, 500);	}); }

// footer star voting function setupVoting {

// callback for vote and unrate var callback = function(data) { $('#star-rating').removeClass('star-rating-progress');

// show current rating $('#current-rating').css('width', Math.round(data.item.wkvoteart[0].avgvote * $('#star-rating').attr('rel')) + 'px'); $('#star-rating a').css('display', data.item.wkvoteart[0].remove ? '' : 'none'); $('#unrateLink').css('display', data.item.wkvoteart[0].remove ? 'none' : '');

// purge current page $.post(window.location.href, {action: 'purge'}); };

$('#star-rating').find('a').click(function(ev) {		ev.preventDefault;

var rating = this.id.substr(4,1); $('#star-rating').addClass('star-rating-progress');

$.getJSON(wgScriptPath+'/api.php?action=insert&list=wkvoteart&format=json&wkvote='+rating+'&wkpage='+wgArticleId, callback);

WET.byStr('ArticleFooter/vote/' + rating); });

$('#unrateLink').click(function(ev) {		ev.preventDefault;

$('#star-rating').addClass('star-rating-progress'); $('#unrateLink').css('display', 'none');

$.getJSON(wgScriptPath+'/api.php?action=wdelete&list=wkvoteart&format=json&wkpage='+wgArticleId, callback);

WET.byStr('ArticleFooter/vote/unrate'); }); }

//watch unwatch combomodal $(function {	 $("#ca-watch").click(function(e){ $.tracker.byStr( 'articleAction/watch' ); var callback_link = $(e.target).attr("href"); showComboAjaxForPlaceHolder(false, false, function{				AjaxLogin.doSuccess = function {					window.location = callback_link;				}			}, false, true); // show the 'login required for this action' message. return false; }); }); /** * Copyright © 2011 - Daniel Friesen * @author Daniel friesen * @license Dual-licensed MIT / GPL2+ */

jQuery('.hovermenu *') .live("blur", function(e) {		$(this).closest('.hovermenu').removeClass('open');	}) .live("focus", function(e) {		$(this).closest('.hovermenu').addClass('open');	});

jQuery(".hover-navigation *") .live("blur", function(e) {		$(this).closest(".hover-navigation").find('.menu-item.with-sub-menu.open').removeClass('open');	}) .live("focus", function(e) {		$(this).parents(".menu-item.with-sub-menu").addClass('open');	});

// onfocus handler for #search_field function sf_focus(e) {

// Let's make sure that we are going only one time thru the initialization procedure if(!window.sf_initiated) { window.sf_initiated = true;

// onblur handler for #search_field - if the search field value is empty then recover it to default and remove field_active class $('#search_field').blur(function {			if($("#search_field").val == '') {				$("#search_field").val($("#search_field").attr('alt')).removeClass("field_active");			}		});

// download necessary dependencies (AutoComplete pluign) and initialize search suggest feature for #search_field $.getScript(stylepath+'/common/jquery/jquery.autocomplete.js', function {			a=$('#search_field').autocomplete({ serviceUrl: wgServer+wgScript+'?action=ajax&rs=getLinkSuggest&format=json', fnFormatResult: function(v) { return v;				}, onSelect: function(v, d) { window.location.href = wgArticlePath.replace(/\$1/, encodeURIComponent(v.replace(/ /g, '_'))); },				selectedClass: 'navigation-hover', deferRequestBy: 1000, appendTo: '#search_box' });		   $('body').children('div').slice(-1).css('zIndex', 20000);		}); }

// if the search field value is same as a default then clean it and add field_active class if($('#search_field').val == $("#search_field").attr('alt')) { $('#search_field').val('').addClass('field_active'); } } /** * IMPORTANT: If you want to make any changes in this code or in any part of widget * framework (also PHP) then you need to discuss it with author * @author Inez Korczynski  * * YUI to jQuery rewrite * @author Maciej Brencz  */ var WidgetFramework = { isIE6: ($.browser.msie && $.browser.version.substr(0,1)<7),

edit: function(e) { var id = $(this).attr('id').split('_')[1];

$('#widget_' + id + '_content').hide; $('#widget_' + id + '_editform').show.addClass('widget_loading').html;

$.getJSON(wgScript, {			action: 'ajax',			rs: 'WidgetFrameworkAjax',			actionType: 'editform',			skin: skin,			id: id		}, function(res) {			if (res.success) {				$('#widget_' + res.id + '_editform').removeClass('widget_loading').html(res.content);

$('#widget_' + res.id + '_save').click(WidgetFramework.edit_save); $('#widget_' + res.id + '_cancel').click(WidgetFramework.edit_cancel); }		});

},

edit_save: function(e) { var id = $(this).attr('id').split('_')[1];

var req = { action: 'ajax', rs: 'WidgetFrameworkAjax', actionType: 'configure', skin: skin, id: id		};

// get editor fields and add them to AJAX request params var fields = $('#widget_' + id + '_editor').serializeArray; for (f=0; f<fields.length; f++) { req[ fields[f].name ] = fields[f].value; }

$('#widget_'+id+'_editform').html('').addClass('widget_loading');

$.getJSON(wgScript, req, function(res) {			if(res.success) {				$('#widget_' + res.id + '_editform').removeClass('widget_loading').hide;				$('#widget_' + res.id + '_content').html(res.body).show;

if(res.title) { // save content of widget toolbox when title is updated (trac #2330) toolBox = $('#widget_' + res.id + '_header')[0].childNodes[0];

if (toolBox.className == 'widgetToolbox') { $('#widget_' + res.id + '_header')[0].childNodes[1].nodeValue = res.title; }					else { $('#widget_' + res.id + '_header').html(res.title); }				}

var fname = res.type + '_after_edit'; if (typeof window[fname] == 'function') { window[fname]( res.id, $('#widget_' + res.id) ); }			}		});

},

edit_cancel: function(e) { var id = $(this).attr('id').split('_')[1];

$('#widget_' + id + '_content').show; $('#widget_' + id + '_editform').hide.html(''); },

addingBlocked: false,

add: function(e) { // fix RT #14269 if (WidgetFramework.addingBlocked) { return; }

var target = $(this); var type = '';

if (target.hasClass('add')) { type = target.attr('rel'); }		else { return; }

WidgetFramework.addingBlocked = true; $('body').addClass('widgetsAddingBlocked');

$.log('new ' + type, 'Widgets');

// temporary element tempId = 'widget_temp_' + (new Date).getTime; loadEl = document.createElement((skin == 'quartz') ? 'li' : 'dl');

$(loadEl).attr('id', tempId).addClass('widget').addClass('widget_loading').prependTo('#sidebar_1');

// send request $.getJSON(wgScript, {			action: 'ajax',			rs: 'WidgetFrameworkAjax',			actionType: 'add',			index: 1,			sidebar: 1,			skin: skin,			type: type		}, function(res) {			if (res.reload) {				window.location.reload(true);			}			else if (res.success) {				$(loadEl).remove;

// get ID of new widget newId = parseInt( res.widget.match(/widget_(\d+)/).pop, 10 );

$('#sidebar_1').prepend(res.widget).log(res.type + ' added as #' + newId, 'Widgets');

// setup widget toolbar (edit / close) var widget = $('#widget_' + newId); widget.find('.edit').click(WidgetFramework.edit); widget.find('.close').click(WidgetFramework.close);

var fname = res.type + '_init'; if(typeof window[fname] == 'function') { $.log('calling ' + fname, 'Widgets'); window[fname](newId, widget); }

WidgetFramework.addingBlocked = false; $('body').removeClass('widgetsAddingBlocked'); }		});	},

// update widget - used by widgets JS	update: function(widgetId, params, callback) { $('#widget_' + widgetId + '_content').html('').addClass('widget_loading');

// form AJAX request var req = { action: 'ajax', rs: 'WidgetFrameworkAjax', actionType: 'configure', id: widgetId, skin: skin };

req = $.extend(req, params);

$.getJSON(wgScript, req, function(res) {			if(res.success) {				$('#widget_' + res.id +'_content').removeClass('widget_loading').html(res.body);

if(res.title) { // save content of widget toolbox when title is updated (trac #2330) toolBox = $('#widget_' + res.id + '_header')[0].childNodes[0];

if (toolBox.className == 'widgetToolbox') { $('#widget_' + res.id + '_header')[0].childNodes[1].nodeValue = res.title; }					else { $('#widget_' + res.id + '_header').html(res.title); }				}

// fire callback if provided if (typeof callback == 'function') { callback(res.id, $('#widget_' + res.id)); }			}		});	},

close: function(e) { var id = $(this).attr('id').split('_')[1];

$.get(wgScript, {			action: 'ajax',			rs: 'WidgetFrameworkAjax',			actionType: 'delete',			id: id		});

$('#widget_' + id).remove; },

//	// widget cockpit //	carouselLoaded: false, carouselVisible: false, carouselLength: 0,

show_cockpit: function(e) { e.preventDefault;

$('#headerMenuUser').hide.log('showing cockpit', 'Widgets');

if(WidgetFramework.carouselLoaded == false) { // RT #16828 $('#wikia_header').before('   ');

var carousel = $('#widget_cockpit_list').hide;

widgetsConfig = WidgetFramework._sort(widgetsConfig);

for(var i in widgetsConfig) { widgetConfig = widgetsConfig[i]; var allow = false; if(widgetConfig.groups.length > 0) { for(var j in widgetConfig.groups) { if(wgUserGroups.indexOf(widgetConfig.groups[j]) >= 0) { allow = true; }						}					} else if (widgetConfig.languages.length > 0) { for(var k in widgetConfig.languages) { if(wgContentLanguage.indexOf(widgetConfig.languages[k]) >= 0) { allow = true; }						}					} else { allow = true; }

if(allow) { WidgetFramework.carouselLength++;

var thumb_el = document.createElement('li');

if(skin == 'quartz') { thumb_el.id = 'mycarousel-item-' + WidgetFramework.carouselLength; } else { thumb_el.id = 'widget_cockpit-item-' + WidgetFramework.carouselLength; }						thumb_el.name = i + '_thumb';

if( typeof widgetConfig.title[wgUserLanguage] == 'string' ) { title = widgetConfig.title[wgUserLanguage]; }						else { title = widgetConfig.title.en; }

if( typeof widgetConfig.desc[wgUserLanguage] == 'string' ) { desc = widgetConfig.desc[wgUserLanguage]; }						else { desc = widgetConfig.desc.en; }

thumb_el.className = 'widget_thumb draggable clearfix ' + i +'Thumb'; if(skin == 'monaco' || skin == 'awesome') { thumb_el.innerHTML = ' ' + title + ' ' + desc; } else if(skin == 'quartz') { thumb_el.innerHTML = title; thumb_el.title = desc; }						carousel.append(thumb_el); }				}

// handle adding widgets from cockpit carousel.find('.add').click(WidgetFramework.add);

// set correct width of carousel carousel.css("width", (WidgetFramework.carouselLength * ($.browser.msie ? 211 : 210)) + 'px').show;

// close cockpit $('#cockpit_close').click(WidgetFramework.hide_cockpit);

// cockpit is fully loaded WidgetFramework.carouselLoaded = true; }

// show cockpit $('#cockpit').show;

$('#positioned_elements').css('visibility', 'visible');

WidgetFramework.carouselVisible = true; },

_sort: function (widgets) { var widgets_sorted = new Array;

var widgets_flat = new Array; for (var i in widgets) { var widget = widgets[i]; widget._i = i;				widgets_flat.push(widget); }

widgets_flat.sort(function (a, b) {				return (WidgetFramework._getTitle(a) > WidgetFramework._getTitle(b)) ? 1 : -1;			});

for (var j in widgets_flat) { var widget = widgets_flat[j]; var i = widget._i; widgets_sorted[i] = widget; }

return widgets_sorted; },		_getTitle: function (widget) { return (typeof widget.title[wgUserLanguage] == 'string') ? widget.title[wgUserLanguage] : widget.title.en; },

hide_cockpit: function(e) { WidgetFramework.carouselVisible = false;

$('#cockpit').hide; } };

// init widgets $(function {	$.log('init', 'Widgets');

var start = (new Date).getTime;

if (skin == 'quartz') { widgets = $('li.widget'); }	else { widgets = $('dl.widget'); }

if (wgUserName != null) { // setup sortable UI jQuery plugin // for all widget sidebars var sidebars = $('.sidebar');

sidebars.each(function {			// check sidebar ID			if (!this.id) {				return;			}

$(this).sortable({				connectWith: sidebars,				containment: 'document',				delay: 100,				forcePlaceholderSize: true,				handle: (skin == 'quartz' ? 'h1' : 'dt'),				items: '> .widget',				opacity: 0.5,				placeholder: 'widget_sort_placeholder',				revert: 200, // smooth animation				// events				start: function(event, ui) 				{					/*					 * @author Tomek0.					 * it remove script tag with google ads, because 					 * during insert of html script tag will be start one more 					 * time and will cause empty page effect 					 */					if ($(ui.item).hasClass( 'WidgetAdvertiser' )) {						$(ui.item).find( 'script' ).remove;					}				},				stop: function(ev, ui) {					var newSidebar = ui.item.closest('.sidebar');

// index - first widget in the sidebar has index = 1 var index = 0; newSidebar.children('.widget').each( function(i) {						if ($(this).attr('id') == ui.item.attr('id')) {							index = i+1;						}					});

// get sidebar ID					var id = parseInt(newSidebar.attr('id').substring(8), 10);

/* 					 * @author Tomek0. * block drag WidgetCommunity to WidgetDashboard (id != 1 ) * 					 * */ 					if( (id != 1 ) && ($(ui.item).hasClass( 'WidgetCommunity' )) ) { $(ev.target).sortable("cancel"); return true; }					// send reindex request to WidgetFramework $.get(wgScript, {						action: 'ajax',						rs: 'WidgetFrameworkAjax',						actionType: 'reorder',						sidebar: id,

id: ui.item.attr('id').split('_').pop, index: index });				}			});		});		$.log(sidebars.length + ' sidebar(s) done after ' + ((new Date).getTime - start) + ' ms', 'Widgets');	}

// run widgets init functions widgets.each(function {		// get widget id		var id = parseInt(this.id.substring(7), 10);

// try to run widget init function var fname = this.className.split(' ').pop + '_init'; if (typeof window[fname] == 'function') { $.log('calling ' + fname, 'Widgets'); window[fname](id, $(this)); }

// setup widget toolbar (edit / close) if (wgUserName != null) { $('#widget_' + id + '_edit').click(WidgetFramework.edit); $('#widget_' + id + '_close').click(WidgetFramework.close); }	});

// widgets cockpit $('#cockpit1, #cockpit2').click(WidgetFramework.show_cockpit);

$.log(widgets.length + ' widgets initialised in ' + ((new Date).getTime - start) + ' ms', 'Widgets'); }); // @see http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/ var WikiaScriptLoader = function {	// detect Firefox / Opera and use script DOM node injection for them	var userAgent = navigator.userAgent.toLowerCase;	this.useDOMInjection = (userAgent.indexOf('opera') != -1) ||		(userAgent.indexOf('firefox') != -1);

// detect IE	this.isIE = (userAgent.indexOf('opera') == -1) && (userAgent.indexOf('msie') != -1);

// get reference to tag this.headNode = document.getElementsByTagName('HEAD')[0]; };

WikiaScriptLoader.prototype = { // load script from provided URL and don't block another downloads // see pages 57 and 58 of "Even Faster Web Sites" loadScript: function(url, onloadCallback) { if (this.useDOMInjection) { this.loadScriptDOMInjection(url, onloadCallback); }		else { this.loadScriptDocumentWrite(url, onloadCallback); }	},

// use script DOM node injection method loadScriptDOMInjection: function(url, onloadCallback) { // add tag to node var scriptNode = document.createElement('script'); scriptNode.type = "text/javascript"; scriptNode.src = url;

// handle script onload event var scriptOnLoad = function { scriptNode.onloadDone = true;

if (typeof onloadCallback == 'function') { onloadCallback; }		};

scriptNode.onloadDone = false; scriptNode.onload = scriptOnLoad; scriptNode.onreadystatechange = function { // for Opera if (scriptNode.readyState == 'loaded' && !scriptNode.onloadDone) { scriptOnLoad; }		}

this.headNode.appendChild(scriptNode); },

// use document.write method to add script tag loadScriptDocumentWrite: function(url, onloadCallback) { document.write('');

// handle script onload event var scriptOnLoad = function { if (typeof onloadCallback == 'function') { onloadCallback; }		};

if (typeof onloadCallback == 'function') { this.addHandler(window, 'load', scriptOnLoad); }	},

// load script content using AJAX request loadScriptAjax: function(url, onloadCallback) { var self = this; var xhr = this.getXHRObject;

xhr.onreadystatechange = function { if (xhr.readyState == 4) { var jsCode = xhr.responseText;

// evaluate JS via eval / inline tag if (self.isIE) { // in IE eval is about 50% faster then inline script eval(jsCode); }				else { var scriptNode = document.createElement('script'); scriptNode.type = "text/javascript"; scriptNode.text = jsCode;

self.headNode.appendChild(scriptNode); }

if (typeof onloadCallback == 'function') { onloadCallback; }			}		};

xhr.open("GET", url, true); xhr.send(''); },

// load CSS loadCSS: function(url, media) { var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.media = (media || ''); link.href = url; this.headNode.appendChild(link); },

// add event handler addHandler: function(elem, type, func) { if (window.addEventListener) { window.addEventListener(type, func, false); }		else if (window.attachEvent) { window.attachEvent('on' + type, func); }	},

// get XHR object getXHRObject: function { var xhrObj = false;

try { xhrObj = new XMLHttpRequest; }		catch(e) { var types = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];

var len = types.length; for (var i=0; i<len; i++) { try { xhrObj = new ActiveXObject(types[i]); }				catch(e) { continue; }				break; }		}

return xhrObj; } }

window.wsl = new WikiaScriptLoader; // minified using http://closure-compiler.appspot.com/home var WikiaScriptLoader=function{var b=navigator.userAgent.toLowerCase;this.useDOMInjection=b.indexOf("opera")!=-1||b.indexOf("firefox")!=-1;this.isIE=b.indexOf("opera")==-1&&b.indexOf("msie")!=-1;this.headNode=document.getElementsByTagName("HEAD")[0]}; WikiaScriptLoader.prototype={loadScript:function(b,c){this.useDOMInjection?this.loadScriptDOMInjection(b,c):this.loadScriptDocumentWrite(b,c)},loadScriptDOMInjection:function(b,c){var a=document.createElement("script");a.type="text/javascript";a.src=b;var d=function{a.onloadDone=true;typeof c=="function"&&c};a.onloadDone=false;a.onload=d;a.onreadystatechange=function{a.readyState=="loaded"&&!a.onloadDone&&d};this.headNode.appendChild(a)},loadScriptDocumentWrite:function(b,c){document.write('<\/script>');b=function{typeof c=="function"&&c};typeof c=="function"&&this.addHandler(window,"load",b)},loadScriptAjax:function(b,c){var a=this,d=this.getXHRObject;d.onreadystatechange=function{if(d.readyState==4){var e=d.responseText;if(a.isIE)eval(e);else{var f=document.createElement("script");f.type="text/javascript";f.text=e;a.headNode.appendChild(f)}typeof c=="function"&&c}};d.open("GET",b,true);d.send("")},loadCSS:function(b,c){var a=document.createElement("link"); a.rel="stylesheet";a.type="text/css";a.media=c||"";a.href=b;this.headNode.appendChild(a)},addHandler:function(b,c,a){if(window.addEventListener)window.addEventListener(c,a,false);else window.attachEvent&&window.attachEvent("on"+c,a)},getXHRObject:function{var b=false;try{b=new XMLHttpRequest}catch(c){for(var a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"],d=a.length,e=0;e<d;e++){try{b=new ActiveXObject(a[e])}catch(f){continue}break}}return b}};window.wsl=new WikiaScriptLoader;