// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
	TwinkleConfig = {};
}
 
/**
 TwinkleConfig.summaryAd (string)
 If ad should be added or not to summary, default ]
 */
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
	TwinkleConfig.summaryAd = " Usando ]";
}
 
/**
 TwinkleConfig.markAIVReportAsMinor (boolean)
 Defines if a reports to AIV should be marked as minor, if false, default is applied as per preference.
 */
if( typeof( TwinkleConfig.markAIVReportAsMinor ) == 'undefined' ) {
	TwinkleConfig.markAIVReportAsMinor = true;
}
 
/**
 TwinkleConfig.confirmUsernameToAIV (boolean) (deprecated)
 Defines if a username reports to AIV should be confirmed before sent.
 */
if( typeof( TwinkleConfig.confirmUsernameToAIV ) == 'undefined' ) {
	TwinkleConfig.confirmUsernameToAIV = true;
}
 
/**
 TwinkleConfig.toolboxButtons (string)
 If id defined in this array, the button of the action is located inthe toolbox instead of in
 the actions bar.
 */
if( typeof( TwinkleConfig.toolboxButtons ) == 'undefined' ) {
	TwinkleConfig.toolboxButtons = ;
}
 
function getChecked( nodelist ) {
	if( !( nodelist instanceof NodeList ) ) {
		throw nodelist + " not instance of NodeList";
	}
	var result = ;
	for(var i  = 0; i < nodelist.length; ++i ) {
		if( nodelist.checked ) {
			result.push( nodelist.value );
		}
	}
	return result;
}
 
function getTexts( nodelist ) {
	if ( nodelist instanceof HTMLInputElement ) {
		return ;
	}
	if( !( nodelist instanceof NodeList ) ) {
		throw nodelist + " not instance of NodeList";
	}
	var result = ;
	for(var i = 0; i < nodelist.length; ++i ) {
		if( nodelist.type == 'text' && nodelist.value != '' ) {
			result.push( nodelist.value );
		}
	}
	return result;
}
 
function num2order( num ) {
	switch( num ) {
	case 1: return '';
	case 2: return '2nd';
	case 3: return '3rd';
	default: return num + 'th';
	}
}
 
$( twinklearv );
function twinklearv(){
	var username;
 
 
	if ( mw.config.get('wgNamespaceNumber') == 3 || mw.config.get('wgNamespaceNumber') == 2 || ( mw.config.get('wgNamespaceNumber') == -1 && mw.config.get('wgTitle') == "Contributions" )){
 
		// If we are on the contributions page, need to parse some then
		if( mw.config.get('wgNamespaceNumber') == -1 && mw.config.get('wgTitle') == "Contributions" ) {
			var href = document.evaluate( '//div//a/@href', document, null, XPathResult.STRING_TYPE, null).stringValue;
			var queryString = new QueryString( href.replace( /^.*\?/, '' ) );
			if( queryString.exists( 'title' ) ) {
				username =  queryString.get('title');
			} else {
				username = href.split( mw.config.get('wgArticlePath').replace('$1','') );
			}
		} else {
			username = mw.config.get('wgTitle').split( '/' ).replace( /\"/, "\\\""); // only first part before any slashes
		}
 
		if( !username ) {
			// Something is fishy, there was no user? lets about everything
			throw "given username was " + username + " and thus makes no sense.";
		}
 
		username = username.replace( /^.*?\:/, '' );
 
		var name = isIPAddress( username ) ? 'Reportar IP' : 'Reportar';
		var title =  isIPAddress( username ) ? 'Reportar IP a bibliotecarios' : 'Reportar usuario a bibliotecarios';
		if (twinkleConfigExists)
		{
			mw.util.addPortletLink( 'p-cactions', "javascript:twinklearv.callback(\"" + username + "\")", "VEC", "tw-arv", name, title );
		}
		else
		{
			mw.util.addPortletLink('p-cactions', 'javascript:alert("Your account is too new to use Twinkle.");', 'arv', 'tw-arv', name, title);
		}
	}
}
 
twinklearv.callback = function twinklearvCallback( uid ) {
	if( uid == mw.config.get('wgUserName') ){
		alert( 'No te quieres reportar, ¿o si?' );
	}
 
	var Window = new SimpleWindow( 600, 450 );
	Window.setTitle( "Reportes avanzados a VEC y SVU" ); //Backronym
 
	var form = new QuickForm( twinklearv.callback.evaluate );
	var categories = form.append( {
			type: 'select',
			name: 'category',
			label: 'Selecciona un tipo de reporte: ',
			event: twinklearv.callback.change_category
		} );
	categories.append( {
			type: 'option',
			label: 'Vandalismo',
			value: 'aiv'
		} );
 
	form.append( {
			type: 'field',
			label:'Work area',
			name: 'work_area'
		} );
	form.append( {
			type: 'hidden',
			name: 'uid',
			value: uid
		} );
 
	var result = form.render();
	Window.setContent( result );
	Window.display();
 
	// We must init the
	var evt = document.createEvent( "Event" );
	evt.initEvent( 'change', true, true );
	result.category.dispatchEvent( evt );
 
}
 
twinklearv.callback.change_category = function twinklearvCallbackChangeCategory(e) {
	var value = e.target.value;
	var root = e.target.form;
	var old_area;
	for( var i = 0; i < root.childNodes.length; ++i ) {
		var node = root.childNodes;
		if( 
			node instanceof Element &&
			node.getAttribute( 'name' ) == 'work_area' 
		) {
			old_area = node;
			break;
		}
	}
	var work_area = null;
 
	switch( value ) {
	default:
	case 'aiv':
		work_area = new QuickForm.element( { 
				type: 'field',
				label: 'Reportar a usuario por vandalismo',
				name: 'work_area'
			} );
		work_area.append( {
				type: 'input',
				name: 'page',
				label: 'Artículo primario: ',
				tooltip: 'Déjalo en blanco si no hay algún artículo donde se cometió vandalismo',
				value: QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '',
				event: function(e) {
					var value = e.target.value;
					var root = e.target.form;
					if( value == '' ) {
						root.badid.disabled = root.goodid.disabled = true;
					} else {
						root.badid.disabled = false;
						root.goodid.disabled = root.badid.value == '';
					}
				}
			} );
		work_area.append( {
				type: 'checkbox',
				name: 'arvtype',
				list: [
					{ 
						label: 'Vandalismo después de que fue dada la alerta final',
						value: 'final'
					},
					{ 
						label: 'Spam después de que fue dada la alerta final',
						value: 'spam'
					},
					{ 
						label: 'Usuario utiliza Wikipedia como un foro después de que fue dada la alerta final',
						value: 'forum'
					},
					{ 
						label: 'Vandalismo inmediato después de que su bloqueo expiró',
						value: 'postblock'
					},
					{ 
						label: 'Cuenta creada con el único propósito de vandalizar',
						value: 'vandalonly',
						disabled: isIPAddress( root.uid.value )
					},
					{ 
						label: 'Usuario con un historial de múltiples bloqueos',
						value: 'blocklog'
					},
					{ 
						label: 'Cuenta que evidentemente es un spam bot o fue corrompida',
						value: 'spambot'
					},
					{ 
						label: 'Proxy abierto confirmado',
						tooltip: 'Si utilizas esta opción, asegúrate de colocar los datos necesarios en la sección de comentarios',
						value: 'proxy'
					}
				]
			} );
		work_area.append( {
				type: 'textarea',
				name: 'reason',
				label: 'Comentario: '
			} );
		work_area.append( { type:'submit', label:'Aceptar' } );
		work_area = work_area.render();
		old_area.parentNode.replaceChild( work_area, old_area );
		break;
	case 'username':
		work_area = new QuickForm.element( { 
				type: 'field',
				label: 'Reportar violación a la política de nombre de usuario',
				name: 'work_area'
			} );
		var types = work_area.append( {
				type: 'field',
				label: 'Type of violation',
				tooltip: 'A valid report must include at least one of following types'
			} );
 
		types.append ( { 
				type:'header', 
				label:'Confusing usernames',
				tooltip: 'Confusing usernames that make it unduly difficult to identify users by their username'
			} );
		types.append( {
				type: 'checkbox',
				name: 'arvtype',
				list: [
					{ 
						label: 'Confusing username',
						value: 'confusing',
						tooltip: 'Confusing usernames make it unnecessarily difficult to identify contributors'
					},
					{
						label: 'Misleading username',
						value: 'misleading',
						tooltip: 'Misleading usernames imply relevant, misleading things about the user, such as falsely conveying authority or impersonating another user.'
					},
					{ 
						label: 'Promotional username',
						value: 'promotional',
						tooltip: 'Promotional usernames are used to promote a group or company on Wikipedia.'
					},
					{ 
						label: 'Offensive username',
						value: 'offensive',
						tooltip: 'Offensive usernames make harmonious editing difficult or impossible.'
					},
					{ 
						label: 'Disruptive username',
						value: 'disruptive',
						tooltip: 'Disruptive usernames that disrupt or misuse Wikipedia, or imply an intent to do so'
					}
				]
			} );
		work_area.append( {
				type: 'textarea',
				name: 'reason',
				label: 'Comment:'
			} );
		work_area.append( { type:'submit', label:'Aceptar' } );
		work_area = work_area.render();
		old_area.parentNode.replaceChild( work_area, old_area );
		break;
 
	case 'sock':
		work_area = new QuickForm.element( { 
				type: 'field',
				label: 'Reportar usuario sospechoso de ser títere',
				name: 'work_area'
			} );
		var sock_area = work_area.append( { type:'div' } );
		sock_area.append( {
				type: 'button',
				label: 'Más títeres',
				name: 'more_socks_button',
				event: function (e){
					var area = e.target.parentNode.parentNode;
					var new_node = new QuickForm.element( {
							type: 'input',
							label: 'Títere: ',
							name: 'sockpuppet'
						} );
					if( area.childNodes.length > 1 ) {
						new_node.append( {
								type: 'button',
								label: 'Remover',
								event: function (e){
									var node_to_remove = e.target.parentNode.parentNode;
									node_to_remove.parentNode.removeChild( node_to_remove );
								}
							} );
					}
					area.insertBefore( new_node.render(), area.lastChild );
				}
			} );
 
		work_area.append( {
				type: 'textarea',
				label: 'Evidencia:',
				name: 'evidence'
			} );
		work_area.append( { type:'submit', label:'Aceptar' } );
		work_area = work_area.render();
		old_area.parentNode.replaceChild( work_area, old_area );
 
		var evt = document.createEvent( "MouseEvent" );
		evt.initEvent( 'click', true, true );
		work_area.form.more_socks_button.dispatchEvent( evt );
		break;
	}
}
 
twinklearv.callbacks = {
	aiv: function( self ) {
		uid = self.params.uid;
		reason = self.params.reason;
		var form = self.responseXML.getElementById('editform');
 
		if( !form ) {
			self.statelem.error( 'Failed to retrieve edit form.' );
			return;
		}
		var text = form.wpTextbox1.value;
 
		var re = new RegExp( "\\{\\{\\subst:s*(?:(?:)?ándalo|serlinks)\\s*\\|\\s*(?:1=)?\\s*" + RegExp.escape( uid, true ) + "\\s*\\}\\}" );
 
		var myArr;
		if( ( myArr = re.exec( text ) ) ) {
			self.statelem.info( 'Report already present, will not add a new one' );
			return;
		}
		self.statelem.status( 'Adding new report...' );
		var postData = {
			'wpMinoredit': TwinkleConfig.markAIVReportAsMinor ? '' : form.wpMinoredit.checked ? '' : undefined, 
			'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
			'wpStarttime': form.wpStarttime.value,
			'wpEdittime': form.wpEdittime.value,
			'wpAutoSummary': form.wpAutoSummary.value,
			'wpEditToken': form.wpEditToken.value,
			'wpSection': form.wpSection.value,
			'wpSummary': 'Reportando a ].'+ TwinkleConfig.summaryAd,
			'wpTextbox1': text + '\{\{'+'subst:' + ( isIPAddress( uid ) ? 'VandalIP' : 'vandal' ) + '|' + (/\=/.test( uid ) ? '1=' : '' ) + uid + '\}\}\{\{subst:Usuario:Pericallis/vec| ' + reason + '|~~' + '~~' +  '\}\}'
		};
 
		self.post( postData );
	},
	username: function( self ) {
		uid = self.params.uid;
		reason = self.params.reason;
		var form = self.responseXML.getElementById('editform');
 
		if( !form ) {
			self.statelem.error( 'Failed to retrieve edit form.' );
			return;
		}
		var text = form.wpTextbox1.value;
 
		self.statelem.status( 'Adding new report...' );
		var postData = {
			'wpMinoredit': form.wpMinoredit.checked ? '' : undefined, 
			'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
			'wpStarttime': form.wpStarttime.value,
			'wpEdittime': form.wpEdittime.value,
			'wpAutoSummary': form.wpAutoSummary.value,
			'wpEditToken': form.wpEditToken.value,
			'wpSection': form.wpSection.value,
			'wpSummary': 'Reporting ].'+ TwinkleConfig.summaryAd,
			'wpTextbox1': text.replace( /-->/, "-->\n" + reason.replace( '\$', "$$$$" ) )
		};
		self.post( postData );
	},
	sock: {
		main: function( self ) { 
			var xmlDoc = self.responseXML;
			var titles = xmlDoc.evaluate( '//allpages/p/@title', xmlDoc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
 
			var number = 0;
			for( var i = 0; i < titles.snapshotLength; ++i ) {
				var title = titles.snapshotItem(i).value;
				title = title.replace( /(first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh)/, function(v) {
						return {
							'first': '1st',
							'second': '2nd',
							'third': '3rd',
							'fourth': '4th',
							'fifth': '5th',
							'sixth': '6th',
							'seventh': '7th',
							'eighth': '8th',
							'ninth': '9th',
							'tenth': '10th',
							'eleventh': '11th'
						};
					} );
				var n = /\(\s*(\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\s*\)\s*$/.exec( title );
				if( n && n > number ) {
					number = n;
				} else if( number == 0 ) {
					number = 1;
				}
			}
 
			if( number == 0 ) {
				self.params.numbering = self.params.number = '';
				numbering = number = '';
			} else {
				self.params.number = num2order( parseInt( number ) + 1);
				self.params.numbering = ' (' + self.params.number + ' nomination)';
			}
			self.statelem.info( 'next in order is ]');
 
			var query = {
				'title': 'Wikipedia:Solicitudes de verificación de usuarios/' +  self.params.uid + self.params.numbering,
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Creating discussion page', query, twinklearv.callbacks.sock.discussionPage );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.get();
 
			var query = {
				'title': 'Wikipedia:Solicitudes de verificación de usuarios',
				'section': 3,
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Linking report to open cases', query, twinklearv.callbacks.sock.openCases );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.get();
 
			var query = {
				'title': 'User talk:' + self.params.uid,
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Notifying suspected sockpuppeter', query, twinklearv.callbacks.sock.notifySock );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.get();
 
			var query = {
				'title': 'User:' + self.params.uid,
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Tag suspected sockpuppeter', query, twinklearv.callbacks.sock.tagSockpuppeter );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.get();
 
 
			var statusIndicator1 = new Status('Tagging suspected sockpuppets', '0%');
			var statusIndicator2 = new Status('Notifying suspected sockpuppets', '0%');
 
			var total = self.params.sockpuppets.length * 2;
 
			var onsuccess = function( self ) {
				var obj = self.params.obj;
				var total = self.params.total;
				var now = parseInt( 100 * ++(self.params.current)/total ) + '%';
				obj.update( now );
				self.statelem.unlink();
				if( self.params.current >= total ) {
					obj.info( now + ' (completed)' );
					Wikipedia.removeCheckpoint();
				}
			}
			var onloaded = onsuccess;
 
			var onloading = function( self ) {}
 
			Wikipedia.addCheckpoint();
 
			var params1 = clone( self.params );
			params1.total = total;
			params1.obj = statusIndicator1;
			params1.current =   0;
 
			var params2 = clone( self.params );
			params2.total = total;
			params2.obj = statusIndicator2;
			params2.current =   0;
 
			var socks = self.params.sockpuppets;
			for( var i = 0; i < socks.length; ++i ) {
				var query = {
					'title': 'User:' + socks,
					'action': 'submit'
				};
				var wikipedia_wiki = new Wikipedia.wiki( "Tagging of " +  socks, query, twinklearv.callbacks.sock.tagSockpuppet );
				wikipedia_wiki.params = params1;
				wikipedia_wiki.onloaded = onloaded;
				wikipedia_wiki.onsuccess = onsuccess;
				wikipedia_wiki.get();
				var query = {
					'title': 'User talk:' + socks,
					'action': 'submit'
				};
				var wikipedia_wiki = new Wikipedia.wiki( "Notification for " +  socks, query, twinklearv.callbacks.sock.notifySock );
				wikipedia_wiki.params = params2;
				wikipedia_wiki.onloaded = onloaded;
				wikipedia_wiki.onsuccess = onsuccess;
				wikipedia_wiki.get();
 
			}
		},
		discussionPage: function( self ) {
			var form = self.responseXML.getElementById('editform');
			var text = 
				"===]===\n" +
				";Suspected sockpuppeteer\n" +
				":\{\{Checkuser|" + self.params.uid + "\}\}\n\n" +
				";Suspected sockpuppets\n" + 
				self.params.sockpuppets.map( function(v) { return ":\{\{user5|" + v + "\}\}" } ).join( "\n" ) + "\n\n" +
				";Report submission by\n" +
				"\~\~\~\~\n\n" +
				";Evidence\n" +
				self.params.evidence + "\n\n" +
				";Comentarios\n\n\n" +
				";Resolución\n\n\n" +
				"----\n</div>\n";
 
 
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': form.wpSection.value,
				'wpSummary': "Creating report for ].' + TwinkleConfig.summaryAd,
				'wpTextbox1': text
			};
			self.post( postData );
		},
		openCases: function( self ) {
			var form = self.responseXML.getElementById('editform');
			text = form.wpTextbox1.value.replace( /(<!-- ADD CASES TO THE TOP OF THIS LIST, JUST BELOW THIS LINE\. This tag indicates the top of the list\. -->)/, "$1\n\{\{Wikipedia:Suspected sock puppets/" + self.params.uid + self.params.numbering + "\}\}");
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': form.wpSection.value,
				'wpSummary': "Adding report for ].' + TwinkleConfig.summaryAd,
				'wpTextbox1': text
			};
 
			self.post( postData );
		},
		tagSockpuppeter: function( self ) {
			var form = self.responseXML.getElementById('editform');
			var text = form.wpTextbox1.value;
			if( /\{\{sockpuppeteer.*?\}\}/.exec( text ) ) { // already marked as a sock, just ignore then
				self.onsuccess( self );
				Wikipedia.actionCompleted();
				return;
			}
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': form.wpSection.value,
				'wpSummary': "Adding suspected sockpuppeter tag." + TwinkleConfig.summaryAd,
				'wpTextbox1': "\{\{sockpuppeteer\}\}\n" + text
			};
 
			self.post( postData );
		},
		tagSockpuppet: function( self ) {
			var form = self.responseXML.getElementById('editform');
			var text = form.wpTextbox1.value;
			if( /\{\{sockpuppet.*?\}\}/.exec( text ) ) { // already marked as a sock, just ignore then
				self.onsuccess( self );
				Wikipedia.actionCompleted();
				return;
			}
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': form.wpSection.value,
				'wpSummary': "Adding suspected sockpuppet tag for suspected sockpuppeter ].' + TwinkleConfig.summaryAd,
				'wpTextbox1': "\{\{subst:sockpuppet|1=" + self.params.uid + "\}\}\n" + text
			};
 
			self.post( postData );
		},
 
		notifySock: function( self ) {
			var form = self.responseXML.getElementById('editform');
			text = form.wpTextbox1.value;
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': form.wpSection.value,
				'wpSummary': "Notificando sobre posible titiriteo." + TwinkleConfig.summaryAd,
				'wpTextbox1': text + "\n\{\{subst:socksuspectnotice|1=" + self.params.uid + self.params.numbering + "\}\} \~\~\~\~"
			};
 
			self.post( postData );
		}
	}
}
 
twinklearv.callback.evaluate = function(e) {
	var form = e.target;
	var reason = "";
	if( form.reason ) {
		comment = form.reason.value;
	}
	var uid = form.uid.value;
	switch( form.category.value ) {
	default:
	case 'aiv':
		var types = getChecked( form.arvtype );
		if( types.length == 0 && comment == '' ) {
			alert( 'Debes especificar un motivo' );
			return;
		}
 
		types = types.map( function(v) {
				switch(v) {
				case 'final':
					return 'Vandalismo después de la alerta final';
					break;
				case 'spam':
					return 'Spam después de la alerta final';
					break;
				case 'forum':
					return 'Usuario persiste en utilizar Wikipedia como un foro';
					break;
				case 'postblock':
					return 'Vandalismo directamente después de que expiró el bloqueo';
					break;
				case 'spambot':
					return 'La cuenta es evidentemente un spambot o una cuenta corrompida';
					break;
				case 'blocklog':
					return 'Usuario con un historial de múltiples bloqueos';
					break;
				case 'vandalonly':
					return 'Las acciones muestran que es una cuenta creada con el único propósito de vandalizar';
					break;
				case 'proxy':
					return 'Proxy abierto confirmado';
					break;
				}
			} ).join( ', ' );
 
 
		if( form.page.value != '' ) {
			reason += ' Vandalismo en ]';
 
			reason += ';';
		}
 
		if( types ) {
			reason += " " + types;
		}
		if (comment != '' ) {
			reason += ". " + comment + '.';
		}
		Status.init( form );
 
		var query = {
			'title': 'Wikipedia:Vandalismo en curso',
			'action': 'submit',
			'section': 1
		};
		wikipedia_wiki = new Wikipedia.wiki( 'Procesando petición a VEC', query, twinklearv.callbacks.aiv );
		wikipedia_wiki.params = { reason:reason, uid:uid };
		wikipedia_wiki.get();
		break;
	case 'username':
		var types = getChecked( form.arvtype );
		if( types.length == 0 ) {
			alert( 'Deberías de especificar una violación' );
			return;
		}
		types = types.map( function( v ) { return v.toLowerCaseFirstChar(); } );
 
		if( types.length <= 2 ) {
			types = types.join( ' and ' );
		} else {
			types = .join( ', and ' );
		}
		reason = "*\{\{user-uaa|1=" + uid + "\}\} &mdash; Violation of username policy because it's a " + types + " username; ";
		if (comment != '' ) {
			reason += "''" + comment.toUpperCaseFirstChar() + "''. ";
		}
		reason += "\~\~\~\~";
		Status.init( form );
 
		var query = {
			'title': 'Wikipedia:Solicitudes de verificación de usuarios',
			'action': 'submit',
			'section': 1
		};
 
		wikipedia_wiki = new Wikipedia.wiki( 'Processing UAA request', query, twinklearv.callbacks.username );
		wikipedia_wiki.params = { reason:reason, uid:uid };
		wikipedia_wiki.get();
		break;
	case 'sock':
		var sockpuppets = getTexts( form.sockpuppet );
		var evidence = form.evidence.value;
		Status.init( form );
 
		var query = {
			'action': 'query',
			'list': 'allpages',
			'apprefix': 'Suspected sock puppets/' + uid,
			'apnamespace': 4,
			'apfilterredir': 'nonredirects',
			'aplimit': userIsInGroup( 'sysop' ) ? 5000 : 500
		};
 
		var wikipedia_api = new Wikipedia.api( 'Quering allpages', query, twinklearv.callbacks.sock.main );
		wikipedia_api.params = { uid:uid, sockpuppets:sockpuppets, evidence:evidence };
		wikipedia_api.post();
	}
}