var AjaxError, AjaxMsg = '';

function AgregarInstruccion()
{

	/* Contenedores */

		Contenedor 		 		= GetById('Instrucciones')
		Instruciones 	 		= GetByTagObj('div', Contenedor)
		
		NuevoConjunto 	 		= Instruciones[0].cloneNode(true)
		NuevoConjunto.id 		= 'Instruccion_'+parseInt(Instruciones.length+1)


		
	/* Boton Borrar */
	
		/* Creando Boton */
		BotonBorrar				= document.createElement('img')
		AtribOnlick				= document.createAttribute('onclick');
		AtribOnlick.nodeValue   = "RemoverInstruccion('"+NuevoConjunto.id+"')" 
		BotonBorrar.setAttributeNode(AtribOnlick); 
		
		
		/* Creando Propiedades */
		BotonBorrar.className   = 'Mano'
		BotonBorrar.src			= 'Estilo/Imagenes/Iconos/Borrar.png'
		BotonBorrar.alt			= 'Quitar'
		BotonBorrar.title		= 'Quitar'

	
	
	
	/* Mostrando Objetos */
	
		Contenedor.appendChild(NuevoConjunto)
		NuevoConjunto.appendChild(BotonBorrar)

}



function RemoverInstruccion(ElementoId)
{
	Elemento = GetById(ElementoId)
	Padre = Elemento.parentNode
	Padre.removeChild(Elemento)
}






function EliminarJuego(IdJuego)
{

	if(Confirmar('¿Desea eliminar este juego?') == true)
	{

		new Ajax.Request('Run/Ajax/Ajax.Juego.php', 
		{

			method: 'post',
			parameters:'IdJuego='+IdJuego+'&Accion=EliminarJuego',
			onSuccess: function(back)
			{
				Respuesta = back.responseText

				if(Respuesta.search(/#SinPermiso/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No tienes permisos para esta acción \n';
				}
				
				
				if(Respuesta.search(/#NoExisteJuego/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No existe este juego, imposible eliminar \n';
				}
				
				
				if(!AjaxError)
				{
					DisplayNone('juego_'+IdJuego)
				}
				else
				{
					alert(AjaxMsg);
				}
				
			}
			
		})
	
	}
	
}




function EliminarCategoria(IdCategoria)
{

	if(Confirmar('¿Desea eliminar esta categoria?') == true)
	{

		new Ajax.Request('Run/Ajax/Ajax.Categoria.php', 
		{

			method: 'post',
			parameters:'IdCategoria='+IdCategoria+'&Accion=EliminarCategoria',
			onSuccess: function(back)
			{
				Respuesta = back.responseText

				if(Respuesta.search(/#SinPermiso/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No tienes permisos para esta acción \n';
				}
				
				
				if(Respuesta.search(/#NoExisteCategoria/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No existe esta categoria, imposible eliminar \n';
				}
				
				
				if(!AjaxError)
				{
					DisplayNone('categoria_'+IdCategoria)
				}
				else
				{
					alert(AjaxMsg);
				}
				
			}
			
		})
	
	}
	
}




function EliminarWebAmiga(IdWebAmiga)
{

	if(Confirmar('¿Desea eliminar esta web amiga?') == true)
	{

		new Ajax.Request('Run/Ajax/Ajax.WebAmiga.php', 
		{

			method: 'post',
			parameters:'IdWebAmiga='+IdWebAmiga+'&Accion=EliminarWebAmiga',
			onSuccess: function(back)
			{
				Respuesta = back.responseText

				if(Respuesta.search(/#SinPermiso/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No tienes permisos para esta acción \n';
				}
				
				
				if(Respuesta.search(/#NoExisteDestacado/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No existe este destacado, imposible eliminar \n';
				}
				
				
				if(!AjaxError)
				{
					DisplayNone('web_amiga_'+IdWebAmiga)
				}
				else
				{
					alert(AjaxMsg);
				}
				
			}
			
		})
	
	}
	
}



function EliminarTecla(IdTecla)
{

	if(Confirmar('¿Desea eliminar esta web tecla?') == true)
	{

		new Ajax.Request('Run/Ajax/Ajax.Tecla.php', 
		{

			method: 'post',
			parameters:'IdTecla='+IdTecla+'&Accion=EliminarTecla',
			onSuccess: function(back)
			{
				Respuesta = back.responseText

				if(Respuesta.search(/#SinPermiso/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No tienes permisos para esta acción \n';
				}
				
				
				if(Respuesta.search(/#NoExisteTecla/) != -1)
				{
					AjaxError	= true;
					AjaxMsg		+= 'No existe esta tecla, imposible eliminar \n';
				}
				
				
				if(!AjaxError)
				{
					DisplayNone('tecla_'+IdTecla)
				}
				else
				{
					alert(AjaxMsg);
				}
				
			}
			
		})
	
	}
	
}