/**
*
* Este archivo contiene todas las validaciones necesarias en javascript. El resto se encuentra en el archivo validaciones.php para otros casos.
* En caso de que el formulario haya cumplido satisfactoriamente la validacion será ejecutado el formulario por medio de submit() o redirección.
*
*/

/**
* Valida que estén correctamente digitados los valores en el formulario crear pagina.
*/
function crear_pagina()
{
	var nombre = document.getElementById("nombre").value;
	var titulo = document.getElementById("titulo").value;
	var meta_descripcion = document.getElementById("meta_descripcion").value;
	var meta_keywords = document.getElementById("meta_keywords").value;
	var menu = document.getElementById("directorio").value;

	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre esta vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(meta_descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la meta descripci&oacute;n est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(meta_keywords.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la meta keywords est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;				
	}
	else if(menu == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione el directorio.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{	
//		document.forms['form_boxy'].submit();
		globalUrl = "admin_edit_opciones.php";
		show("opc=crear_pagina_action&nombre="+nombre+"&titulo="+titulo+"&meta_descripcion="+meta_descripcion+"&meta_keywords="+meta_keywords+"&directorio="+menu);

	}
}

/**
* Valida el formulario con el que se crea una publicidad.
*/
function crear_publicidad(zonas)
{
	var adnetwork = document.getElementById("adnetwork").value;
	var idadnetwork = document.getElementById("idadnetwork").value;
	var zona = document.getElementById("zona").value;

	if(adnetwork.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(idadnetwork.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del c&oacute;digo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(zona == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione el bloque de publicidad.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var val = true;
		for(var i=0; i<zonas; i++)
		{
			var ob = document.getElementById("zona"+i).value;
			
			if(ob == zona && ob != 0)
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("El bloque "+ob+" ya est&aacute; en uso.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
				val = false;
				break;
			}
		}
		if(val)
		{
			//document.forms['form_boxy'].submit();			
			globalUrl = "admin_edit_opciones.php";
			show("opc=crear_publicidad_action&zona="+zona+"&adnetwork="+adnetwork+"&idadnetwork="+idadnetwork);
		}
	}
}

/**
* Verirfica si está bien modificado el titulo
*/
function modificar_titulo_video(titulo)
{
	var titulo = document.getElementById("titulo").value;
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.replace(/\s/g,"").length < 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo debe contener m&iacute;nimo 10 caracteres", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
* Verirfica si está bien modificado el titulo
*/
function modificar_titulo_rastreo(titulo)
{
	var titulo = document.getElementById("titulo").value;
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
* Verirfica si está bien modificado el titulo
*/
function modificar_lista_rastreo(titulo)
{
	document.forms["form_boxy"].submit();
}

/**
* Hace submit del formularuio.
*/
function modificar_items_rastreo()
{
	document.forms["form_boxy"].submit();
}


/**
* Verfica si está bien modificada la descripción del video.
*/
function modificar_desc_video()
{
	var descripcion = document.getElementById("desc").value;
	
	if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(descripcion.length > 1700)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La descripcion solo uede tener m&aacute;ximo 1700 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/*
* valida los primeros datos dados en el formulario
*/
function ingresar_video2_2(lista, ord, ord2, lista_video)
{
	var titulo = document.getElementById("titulo").value;
	var descripcion = document.getElementById("descripcion").value;	
	var url_img = document.getElementById("url_img").value;
	var tags = document.getElementById("tags").value;
	
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.replace(/\s/g,"").length < 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo debe contener m&iacute;nimo 10 caracteres", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.length > 70)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El titulo solo puede tener m&aacute;ximo 70 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(descripcion.length > 1700)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La descripcion solo uede tener m&aacute;ximo 1700 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(tags.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese tags.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var tamano = tags.split(",");
		if(tamano.length >= 3 && tamano.length < 10)
		{
			globalUrl = "add-video2.php";
			show("tercera_parte=1&titulo="+titulo+"&descripcion="+descripcion+"&url_img="+url_img+"&tags="+tags+"&lista="+lista+"&ord="+ord+"&ord2="+ord2+"&lista_video="+lista_video);
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;			
		}
	}	
}

/**
* valida las categorias del video
*/
function ingresar_video_2_3()
{
	var pagina =  document.getElementById("pagina");
	var seccion =  document.getElementById("seccion");
	var categoria =  document.getElementById("categoria");
	var subcategoria =  document.getElementById("subcategoria");
	if(pagina && pagina.value == 0 && pagina.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else if(seccion && seccion.value == 0 && seccion.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else if(categoria && categoria.value == 0 && categoria.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;	
	}
	else if(subcategoria && subcategoria.value == 0 && subcategoria.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		if(pagina){ pagina = pagina.value; }else{ pagina = 0; }
		if(seccion){ seccion = seccion.value }else{ seccion = 0; }
		if(categoria){ categoria = categoria.value; }else{ categoria = 0; }
		if(subcategoria){ subcategoria = subcategoria.value; }else{ subcategoria = 0; }
//		document.forms["form_add_video"].submit();
		globalUrl = "admin_edit_opciones.php";
		show("opc=agregar_video_action&pagina="+pagina+"&seccion="+seccion+"&categoria="+categoria+"&subcategoria="+subcategoria+"&lista_video="+document.getElementById("lista_video").value);
	}
}

/**
* Valida que estén correctamente digitados los valores en el formulario ingresar video.
*/
function ingresar_video_primera_parte()
{	
	var subcategoria = "", subcategoria2 = "";
	var tipo_insercion = document.getElementById("tipo_insercion").value;
	var titulo = document.getElementById("titulo").value;
	var descripcion = document.getElementById("descripcion").value;	
	var url_img = document.getElementById("url_img").value;
	var usuario_externo = document.getElementById("usuario_externo").value;
	var pagina = document.getElementById("pagina").value;
	var tiempo = document.getElementById("tiempo").value;	
	var tags = document.getElementById("tags").value;	
	
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.replace(/\s/g,"").length < 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo debe contener m&iacute;nimo 10 caracteres", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.length > 70)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El titulo solo puede tener m&aacute;ximo 70 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(descripcion.length > 1700)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La descripcion solo uede tener m&aacute;ximo 1700 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(pagina == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una p&aacute;gina.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(tags.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese tags.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{		
		var tamano = tags.split(",");
		if(tamano.length >= 3 && tamano.length < 10)
		{
			document.getElementById("segunda_parte").value = 1;
			document.forms["formulario_ingresar_video"].submit();
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";			
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;			
		}
	}
}
		
/**
* Valida que estén correctamente digitados los valores en el formulario ingresar video.
*/
function ingresar_video_segunda_parte()
{
	var categoria = "", subcategoria = "";
	var tipo_insercion = document.getElementById("tipo_insercion").value;
	var titulo = document.getElementById("titulo").value;
	var url = document.getElementById("url").value;
	var descripcion = document.getElementById("descripcion").value;	
	var url_img = document.getElementById("url_img").value;
	var usuario_externo = document.getElementById("usuario_externo").value;
	var pagina = document.getElementById("pagina").value;
	var tiempo = document.getElementById("tiempo").value;
	var seccion = document.getElementById("seccion").value;
	
	if(seccion != 0)
	{
		if(document.getElementById("cantidad_categorias").value > 0)
		{	
			categoria = document.getElementById("categoria").value;
			if(categoria != 0)
			{
				if(document.getElementById("cantidad_subcategorias").value > 0)
				{
					subcategoria = document.getElementById("subcategoria").value;
				}
			}			
		}
	}
	
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}	
	else if(pagina == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else if(seccion == 0 && document.getElementById("cantidad_secciones").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else if(seccion != 0 && categoria == 0 && document.getElementById("cantidad_categorias").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";			
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;	
	}
	else if(seccion != 0 && categoria != 0 && subcategoria == 0 && document.getElementById("cantidad_subcategorias").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("finalizar_registro_video").value = 1;
		document.forms["agregar_video"].submit();
	}
}

/**
* Valida que estén correctamente digitados los valores en el formulario de crear apariencia.
*/
function crear_apariencia()
{
	var dominio = document.getElementById("dominio").value;
	var analyti = document.getElementById("analyti").value;
	var logo = document.getElementById("archivo").value;
	
	if(dominio.replace(/\s/g,"") == "")
	{
		alert("Por favor, ingrese el dominio.");
	}	
	else
	{
		document.getElementById("validacion").value = 2;
		document.forms["form_crear_apariencia"].submit();
	}
}

/**
* Crea un canal.
*/
function crear_canal()
{
	var nombre = document.getElementById("nombre").value;
	var descripcion = document.getElementById("descripcion").value;
	var url = document.getElementById("url_img").value;
	var tags = document.getElementById("tags").value;
	url = urlencode(url);

	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese el nombre del canal.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese una descripci&oacute;n.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(tags.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese al menos un tag.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
//		document.forms['form_boxy'].submit();
		globalUrl = "admin_edit_opciones.php";
		show("opc=agregar_canal_action&nombre="+nombre+"&descripcion="+descripcion+"&tags="+tags+"&url_img="+url);
	}
}

/**
* valida si fue ingresado un nuevo titulo para un juego.
*/
function modificar_titulo_juego()
{
	var titulo = document.getElementById("titulo").value;
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El campo del t&iacute;tulo est&aacute; vac&iacute;o.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
* Verifica que haya sido ingresado la descripcion para un juego.
*/
function modificar_desc_juego()
{
	var descripcion = document.getElementById("desc").value;
	if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n esta vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.length > 1700)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Las instrucciones solo puede contener 1700 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
*  Valida el formulario de agregar flash.
*/
function agregar_flash_primera_parte()
{
	var titulo = document.getElementById("titulo").value;
	var descripcion = document.getElementById("descripcion").value;	
	var url_img = document.getElementById("url_img").value;
	var usuario_externo = document.getElementById("usuario_externo").value;
	var pagina = document.getElementById("pagina").value;
	var tags = document.getElementById("tags").value;
	
	document.getElementById("url_flash").value = document.getElementById(document.getElementById("pos").value).value;
	
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(titulo.replace(/\s/g,"").length < 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo debe contener m&iacute;nimo 10 caracteres", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo de la descripci&oacute;n esta vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.length > 1700)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Las instrucciones solo puede contener 1700 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(pagina == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una p&aacute;gina.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(tags.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese tags.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var tamano = tags.split(",");
		if(tamano.length >= 3 && tamano.length < 10)
		{
			document.forms["formulario_ingresar_flash"].submit(); 
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
	}
}

/**
* Valida el segundo formulario.
*/
function agregar_flash_segunda_parte()
{
	var categoria = "", subcategoria = "";
	var url = document.getElementById("url").value;
	var url_img = document.getElementById("url_img").value;
	var pagina = document.getElementById("pagina").value;
	var seccion = document.getElementById("seccion").value;
	
	if(seccion != 0)
	{
		if(document.getElementById("cantidad_categorias").value > 0)
		{	
			categoria = document.getElementById("categoria").value;
			if(categoria != 0)
			{
				if(document.getElementById("cantidad_subcategorias").value > 0)
				{
					subcategoria = document.getElementById("subcategoria").value;
				}
			}			
		}
	}
	if(pagina == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(seccion == 0 && document.getElementById("cantidad_secciones").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(seccion != 0 && categoria == 0 && document.getElementById("cantidad_categorias").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(seccion != 0 && categoria != 0 && subcategoria == -1 && document.getElementById("cantidad_subcategorias").value > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("agregar_flash").value = 1;
		document.forms["formulario_ingresar_flash2"].submit();
	}
}

/**
* Controla la cantidad de craacteres ingresado por un usuario para dar un comentario.
*/
function cantidad_caracteres_comentario()
{
	if(document.getElementById('comentario').value.length > 300)
	{
		document.getElementById('comentario').value = document.getElementById('comentario').value.substring(0,300);
	}
	else
	{
		document.getElementById('marcador').innerHTML=(300-document.getElementById('comentario').value.length);
	}
}

/**
* Controla la cantidad de craacteres ingresado por un usuario para dar un comentario.
*/
function cantidad_caracteres_comentario2()
{
	if(document.getElementById('descripcion').value.length > 1700)
	{
		document.getElementById('descripcion').value = document.getElementById('descripcion').value.substring(0,1700);
	}
	else
	{
		document.getElementById('marcador').innerHTML=(1700-document.getElementById('descripcion').value.length);
	}
}

/**
* Controla la cantidad de craacteres ingresado por un usuario para dar un comentario.
*/
function cantidad_caracteres_comentario3()
{
	if(document.getElementById('titulo').value.length > 70)
	{
		document.getElementById('titulo').value = document.getElementById('titulo').value.substring(0,70);
	}
	else
	{
		document.getElementById('marcador2').innerHTML=(70-document.getElementById('titulo').value.length);
	}
}

/**
* Controla la cantidad de craacteres ingresado por un usuario para dar un comentario.
*/
function cantidad_caracteres_comentario4()
{
	var destino = document.getElementById("destino").value;
	if(document.getElementById('mensaje').value.length > 160 && !isNaN(destino) && destino.replace(/\s/g,"") != "")
	{
		document.getElementById('mensaje').value = document.getElementById('mensaje').value.substring(0,160);
	}
	else
	{
		document.getElementById('marcador').innerHTML=(160-document.getElementById('mensaje').value.length);
	}
}

/**
* Controla la cantidad de craacteres ingresado por un usuario para dar un comentario.
*/
function cantidad_caracteres_comentario5()
{
	if(document.getElementById('respuesta').value.length > 2000)
	{
		document.getElementById('respuesta').value = document.getElementById('respuesta').value.substring(0,2000);
	}
	else
	{
//		document.getElementById('marcador2').innerHTML=(160-document.getElementById('respuesta').value.length);
	}
}

/**
* Se encarga de asegurar que el usuario haya escogido las opciones posibles de categorias.
*/
function modificar_categorias_contenido()
{
	var paginas = document.getElementById("pagina");
	var secciones = document.getElementById("seccion");
	var categorias = document.getElementById("categoria");
	var subcategorias = document.getElementById("subcategoria");

	if(paginas && paginas.value == 0 && paginas.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(secciones && secciones.value == 0 && secciones.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(categorias && categorias.value == 0 && categorias.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(subcategorias && subcategorias.value == 0 && subcategorias.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById('modificar_categorias').value = 1; 
		document.forms['formulario_box'].submit();		
	}
}

/**
* Modifica el campo de los privilegios en listar reglas.
*/
function modificar_privilegios(cantidad)
{
	var id_objeto = document.getElementById("id_obj").value;
	var contador = 0;
	var concadena = "";	
	
	for(var i=0; i<cantidad; i++)
	{		
		var objeto = document.getElementById(i).checked;
		if(objeto)		
		{
			concadena = concadena+"&"+i+"="+document.getElementById(i).value;
		}
		else{ contador++; }
	}
	
	if(contador == cantidad)		
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, escoja al menos un privilegio.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.zIndex = Boxy.zIndex+1;		
		Boxy.ask("&#191;Aplicar este cambio a todos los usuarios de este perfil&#63;", {"1":"Si", "2":"No"}, function(r)
		{			
			document.getElementById('aplicar_usuarios').value = r;
			globalUrl = "admin_edit_opciones.php";
			show("opc=modificar_aplicaciones_action&cantidad="+cantidad+"&aplicar_usuarios="+r+concadena+"&id_objeto="+id_objeto);
//			document.forms['form_boxy'].submit();			
		});
		Boxy.zIndex = Boxy.zIndex-1;		
	}
}

/**
* Se ecnaerga de validar el formulario para agregar reglas o perfiles de usuarios para el sistema.
*/
function agregar_regla(cantidad)
{
	var nombre = document.getElementById("nombre").value;
	var descripcion = document.getElementById("descripcion").value;
	var inicio = document.getElementById("iniciar_sesion").value;
	var concadena = "";

	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el nombre.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese la descripci&oacute;n.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(inicio == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, elija con qu&eacute; aplicaci&oacute;n iniciar sessi&oacute;n.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var contador = 0;
		for(var i=0; i<cantidad; i++)
		{
			var objeto = document.getElementById(i).checked;
			if(objeto){ concadena = concadena+"&"+i+"="+document.getElementById(i).value; }
			else{ contador++; }
		}
		
		if(contador == cantidad)		
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("Por favor, escoja al menos un privilegio.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else
		{
//			document.forms['form_boxy'].submit();
			globalUrl = "admin_edit_opciones.php";
			show("opc=agregar_marketing_action&nombre="+nombre+"&descripcion="+descripcion+"&inicio="+inicio+"&cantidad="+cantidad+concadena);

		}
	}
}

/**
* Se encarga de validar los campos digitados por el usuario en el caso de uso agregar premio.
*/
function agregar_premio(cantidad)
{
	var nombre = document.getElementById("nombre").value;
	var tipo_premio = document.getElementById("tipo_premio").value;
	var perfil_usuario = document.getElementById("perfil_usuario").value;
	var puntos = document.getElementById("puntos").value;
	var stop_disponibles = document.getElementById("stop_disponibles").value;
	var fecha = document.getElementById("dateArrival").value;
	document.getElementById("perfil_usuario").value = "";
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el nombre.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(tipo_premio == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, escoja el tipo de premio.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else 
	{
		var contador = 0;
		for(var i=0; i<cantidad; i++)
		{
			var objeto = document.getElementById(i).checked;
			if(!objeto){ contador++; }
			else{document.getElementById("perfil_usuario").value = document.getElementById(i).value+","+document.getElementById("perfil_usuario").value; }
		}
		document.getElementById("perfil_usuario").value = document.getElementById("perfil_usuario").value.substring(0, (document.getElementById("perfil_usuario").value.length)-1);
		if(contador == cantidad)		
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("Por favor, escoja al menos un perfil de usuario.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else
		{
			if(puntos.replace(/\s/g,"") == "")
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("Por favor, digite los puntos.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}	
			else if(isNaN(puntos))
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("Los puntos requeridos deben ser enteros.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
			else if(stop_disponibles.replace(/\s/g,"") == "")
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("Por favor, digite el stop de premios.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
			else if(isNaN(stop_disponibles))
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("El stop debe ser entero.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
			else if(fecha.replace(/\s/g,"") == "")
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("Por favor, digite la fecha de cierre.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
			else
			{
				perfil_usuario = document.getElementById("perfil_usuario").value;
				globalUrl = "admin_edit_opciones.php";
				show("opc=agregar_premio_action&nombre="+nombre+"&tipo_premio="+tipo_premio+"&perfil_usuario="+perfil_usuario+"&puntos="+puntos+"&stop_disponibles="+stop_disponibles+"&fecha="+fecha);
			}
		}		
	}	
}

/**
* Valida el formulario de modificar puntos del premio
*/
function modificar_puntos_premios()
{
	var puntos = document.getElementById("puntos").value;
	if(puntos.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor ingrese los puntos requeridos.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(isNaN(puntos))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El valor debe ser num&eacute;rico.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();	
	}
}

/**
* Valida el formulario de modificar stops del premio
*/
function modificar_stops_premios()
{
	var puntos = document.getElementById("stop_premio").value;
	if(puntos.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor ingrese el stop disponible.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(isNaN(puntos))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El valor debe ser num&eacute;rico.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();	
	}
}

/**
* Valida el futuro numero celular que se le asignara a un usuario. 
*/
function redimir_recarga()
{
	var celular = document.getElementById("celular").value;
	var ccelular = document.getElementById("ccelular").value;
	
	if(celular.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese su numero celular.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(celular))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El valor debe ser numérico.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(celular.substring(0,1) != "3")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El numero debe empezar con 3", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(celular.length != 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El número celular debe tener 10 digitos.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(celular != ccelular)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La confirmación del número está errado.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Eliminar";
		Boxy.confirm("&#191;Est&aacute; seguro que desea redimir el premio al "+celular+"&#63;", function() 
		{ 
			document.forms["form_boxy"].submit();			
		});
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

/**
* Valida que el usuario este ingresando un nombra para la pagina.
*/
function modificar_nombre_pagina()
{
	var nombre = document.getElementById("nombre").value;
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese un nombre para la p&aacute;gina.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Valida que el usuario este ingresando un nombra para la seccion.
*/
function modificar_nombre_seccion()
{
	var nombre = document.getElementById("nombre").value;
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese un nombre para la secci&oacute;n.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Valida que el usuario este ingresando un nombra para la categoria.
*/
function modificar_nombre_categoria()
{
	var nombre = document.getElementById("nombre").value;
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese un nombre para la categoria.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Valida que el usuario este ingresando un nombra para la categoria.
*/
function modificar_nombre_subcategoria()
{
	var nombre = document.getElementById("nombre").value;
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese un nombre para la subcategoria.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Verifica que la persona haya escogido al menos un video para asociar auna lista de videos.
*/
function asociar_videos(cantidad)
{
	var contador = 0;
	for(var i=0; i<cantidad; i++)
	{
		var objeto = document.getElementById("c"+i).checked;
		if(!objeto){ contador++; }
	}
	
	if(contador == cantidad)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, escoja al menos un contenido.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Eliminar";
		Boxy.confirm("<div class='alerta'>&#191;Est&aacute;s seguro que deseas asociar esto&#63;</div>", function() 
		{ 
			document.getElementById("asociar").value = 1;
			document.getElementById("cantidad").value = cantidad;
			document.forms["formulario_box"].submit();			
		});
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

/**
* Se encarga de validar algunos asuntos sobre el formulario de publicar post.
*/
function publicar_post()
{
	var categoria = "", subcategoria = "", pagina = "", seccion = "";
	var paginas = document.getElementById("pagina");
	var secciones = document.getElementById("seccion");
	var categorias = document.getElementById("categoria");
	var subcategorias = document.getElementById("subcategoria");
	

	if(paginas && paginas.value == 0 && paginas.length > 1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(secciones && secciones.value == 0 && secciones.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(categorias && categorias.value == 0 && categorias.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(subcategorias && subcategorias.value == 0 && subcategorias.length > 0)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja una categor&iacute;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		if(paginas){ pagina = paginas.value; }else{ pagina = 0; }
		if(secciones){ seccion = secciones.value; }else{ seccion = 0; }
		if(categorias){ categoria = categorias.value; }else{ categoria = 0; }
		if(subcategorias){ subcategoria = subcategorias.value; }else{ subcategoria = 0; }
		globalUrl = "admin_edit_opciones.php";
		show("opc=publicar_post&pagina="+pagina+"&seccion="+seccion+"&categoria="+categoria+"&subcategorias="+subcategoria);				
	}	
}

/**
* Modifica las meta keywords de un video
*/
function modificar_metakeywords()
{	
	var tags = document.getElementById("metakey").value;
	if(tags.replace(/\s/g,"") != "")
	{
		document.forms['form_boxy'].submit();
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese al menos un tag.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
}

/**
* Verifica que se haya ingresado un titulo al canal.
*/
function modificar_titulo_canal()
{
	var titulo = document.getElementById("titulo").value;
	if(titulo.replace(/\s/g,"") == "" || titulo == "Ingrese el titulo")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese el nombre del canal.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
* Verifica que se haya ingresado una descripcion al canal.
*/
function modificar_desc_canal()
{
	var descripcion = document.getElementById("desc").value;
	if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese una descripci&oacute;n.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Valida la modificación del titulo de un post.
*/
function modificar_titulo()
{
	var titulo = document.getElementById("titulo").value;
	if(titulo.replace(/\s/g,"") == "" || titulo == "Ingrese el titulo")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, agrege el t&iacute;tulo.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	else if(titulo.replace(/\s/g,"").length < 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El t&iacute;tulo debe contener m&iacute;nimo 10 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;		
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

/**
* Se encarga de validar algunos asuntos sobre el formulario de publicar post.
*/
function publicar_post_primera_parte()
{
	var titulo = document.getElementById("titulo").value;	
	var mensaje = CKEDITOR.instances.editor.getData();
	var tags = document.getElementById("tags").value;
	
	if(titulo.replace(/\s/g,"") == "" || titulo == "Ingrese el titulo")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, agregue el t&iacute;tulo.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	else if(mensaje.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese el contenido.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;		
	}		
	else if(tags.replace(/\s/g,"") == "" || tags == "Ingrese los tags")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, ingrese al menos un tag.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;		
	}
	else
	{
		var tamano = tags.split(",");
		if(tamano.length >= 1)
		{			
			globalUrl = "admin_edit_opciones.php";
			globalTitle = "Crear post";		
			
			Boxy.DEFAULTS.title = globalTitle; // EL TITULO DE ASIGNA DE ACUERDO A LA VARIABLE GLOBAL QUE SE ACTUALIZA DEPENDIENDO DE LA OPCION QUE ESCOJA.
			boxy = new Boxy("<div id='documento' style='min-width:200px;'><div class='cargando'>Cargando...</div></div>", {
			modal: true, behaviours: function(c) {
			  c.find('a:first').click(function() {
				//newModal();
			  });				  
			}
			});
			show("opc=editor_segunda_parte&titulo="+titulo+"&tags="+tags+"&contenido="+urlencode(mensaje));			
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;			
			Boxy.alert("Por favor ingrese tags.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
	}
}

/**
* Valida que la persona haya escogido al mejor una plantilla
*/
function cambiar_plantilla()
{
	var cantidad = document.getElementById("cantidad").value;
	
	var contador = 0;
	for(var i=0; i<cantidad; i++)
	{
		var objeto = document.getElementById("c"+i).checked;
		if(objeto){ contador++; }
	}
	
	if(contador == 1)
	{
		document.forms["formulario_box"].submit();			
	}		
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione una plantilla.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
}

/**
* Verifica que la persona haya escogido al menos un icono.
*/
function agregar_icono()
{
	var cantidad = document.getElementById("cantidad").value;
	var folder = document.getElementById("dir").value;
	
	if(folder == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione una galeria.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
		var contador = 0, icono = "";
		for(var i=-1; i<cantidad; i++)
		{
			var objeto = document.getElementById("c"+i).checked;
			if(objeto){ contador++; icono = document.getElementById("c"+i).value; }
		}
		
		if(contador == 1)
		{
			document.getElementById("asociar_icono").value = 1;
			if(icono == -1){ document.getElementById("icono").value = "-1"; }
			else{ document.getElementById("icono").value = folder+"/"+icono; }
			document.forms["formulario_box"].submit();			
		}		
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("Por favor, seleccione un icono.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;		
		}		
	}
}

/**
* Resulve el login
*/
function login()
{
	globalTitle = "Login"; 
	$("#linklogin").click();
}

function register()
{
	globalUrl = 'login/register.php'; 
	globalTitle = 'Registrarme';
	$("#formulario").click();
}

/**
* Valida el formulario de login
*/
function validar_login()
{
	var usuario = document.getElementById("usuario2").value;
	var clave = document.getElementById("clave2").value;
	
	if(usuario.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese su nombre de usuario.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(clave.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, su contrase&ntilde;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{  
		document.forms["form_login2"].submit();
	}
}

/**
* Valida que no pasen mas de cuatro saldos de linea.
*/
function validar_saltos_de_linea()
{
	var Cadena = document.getElementById("comentario").value;
	var Search = "\n";
	var i = 0;
	var counter = 0;
	var pos = 0;
	while (i != -1)
	{
		var i = Cadena.indexOf(Search,i);
		if (i != -1)
		{			
			counter++;
			if(counter == 4){ pos = i; }
			i++;			
		}
	}
	if(counter >= 4){ eliminar_ultimo_salto(pos); }
	
}

/**
* Elimina el ultimo salto de linea.
*/
function eliminar_ultimo_salto(pos)
{
	var cadena = document.getElementById("comentario").value;

	var navegador = navigator.appName;
	if (navegador == "Microsoft Internet Explorer"){ cadena = cadena.substring(0, (pos-1));  }
	else{ cadena = cadena.substring(0, pos); }
	
	document.getElementById("comentario").value = cadena;
}

/**
* ingresa un video en la forma de boxy.
*/
function crear_video(arreglo)
{
	var id_objeto = arreglo[0], lista = arreglo[1], ord = arreglo[3], ord2 = arreglo[4], lista_video = arreglo[2];
	var url = document.getElementById("url").value;

	url = url.replace(/\n/gi,"");

	if(url.replace(/\s/g,"") == "" || url.replace(/\s/g,"") == "http://")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrse la url.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var validado = true;
		if(url.indexOf("<embed") == -1 && url.indexOf("<object") && -1 && url.indexOf("</embed>") == -1 && url.indexOf("</object>") == -1)
		{
			validado = validar_url(url);
			if(!validado)
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("La url que acaba de ingresar no es valida o soportada por el sistema.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
		}
		else
		{ 
			validado = validar_embed(url); 
			if(!validado)
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("Al c&oacute;digo de inserci&oacute;n le falta una o m&aacute;s etiquetas por cerrar.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
			}
		}

		if(validado)
		{
			url = urlencode(url);
			globalUrl = "add-video2.php";
			show("vista_previa=1&id_objeto="+id_objeto+"&lista="+lista+"&ord="+ord+"&ord2="+ord2+"&lista_video="+lista_video+"&url="+url);
		}
	}
}

/**
* Recibe la orden de reemplazar un video dado su url o embed
*/
function reemplazar_video(arreglo)
{
	var id_objeto = arreglo[0], lista = arreglo[1], ord = arreglo[3], ord2 = arreglo[4], lista_video = arreglo[2];
	var url = document.getElementById("url").value;
	var palabras = document.getElementById("buscar").value;

	if(url.replace(/\s/g,"") == "" || url.replace(/\s/g,"") == "http://")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrse la url.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var validado = false;
		var insercion = "";
		
		if(url.indexOf("<embed") !=-1 || url.indexOf("<object") !=-1 || url.indexOf("</embed>") !=-1 || url.indexOf("</object>") !=-1){ validado =  true; }
		if(url.indexOf("ustream.tv") !=-1){ validado =  true; }
		if(url.indexOf("www.youtube.com") !=-1){ validado = true; }
		if(url.indexOf("break.com") !=-1){ validado = true; }
		if(url.indexOf("vimeo.com") !=-1){ validado = true; }
		if(url.indexOf("metacafe.com") !=-1){ validado = true; }
		if(url.indexOf("dailymotion.com") !=-1){ validado = true; }
		if(url.indexOf("blip.tv") !=-1){ validado = true; }
		if(url.indexOf("revver.com") !=-1){ validado = true; }
		if(url.indexOf("myspace.com") !=-1){ validado = true; }
		if(url.indexOf("kewego.es") !=-1){ validado = true; }
		if(url.indexOf("livestream.com") !=-1){ validado = true; }
		if(url.indexOf("tu.tv") !=-1){ validado = true; }
		if(url.indexOf(".flv") !=-1){ validado = true; }
		if(url.indexOf("http://") !=-1 && url.length > 7){ validado = true; }

		if(validado)
		{
			url = urlencode(url);
			globalUrl = "cambiar-video.php";
			show("reemplazar=1&id_objeto="+id_objeto+"&lista="+lista+"&ord="+ord+"&ord2="+ord2+"&lista_video="+lista_video+"&url="+url+"&palabras="+palabras);
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("La url que acaba de ingresar no es valida o soportada por el sistema.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
	}	
}

/**
* Indica que las validaciones se han cumplido y se procede a reemplazar el video.
*/
function reemplazar_video_confirmado()
{
	document.forms["form_reemplazo"].submit();
}

/**
* Valida el formulario agregar item.
*/
function agregar_item_action()
{
	var url = document.getElementById("destino").value;
	url = urlencode(url);
	var nombre = document.getElementById("nombre").value;
	var texto = document.getElementById("texto").value;
	var desplegar = document.getElementById("desplegar").value;
	var titulo = document.getElementById("titulo").value;
	var niveles = document.getElementById("niveles").value;
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el nombre.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(texto.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el texto alternativo.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(url.replace(/\s/g,"") == "" || url.replace(/\s/g,"") == "http://")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese la url destino.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
//		cerrar_boxy();
		document.forms["form_boxy"].submit();
	}
}

/**
* Se encarga de modificar lso datos de una publicidad.
*/
function modificar_publicidad(zonas)
{
	var nombre = document.getElementById("nombre").value;
	var codigo = document.getElementById("codigo").value;
	var zona = document.getElementById("zona").value;
	var zona_original = document.getElementById("bloque").value;

	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(codigo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del c&oacute;digo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(zona == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione el bloque de publicidad.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var val = true;
		for(var i=0; i<zonas; i++)
		{
			var ob = document.getElementById("zona"+i).value;
			if(ob == zona && zona_original != zona && ob != 0)
			{
				Boxy.DEFAULTS.title = "Alerta!";
				Boxy.zIndex = Boxy.zIndex+1;
				Boxy.alert("El bloque "+ob+" ya est&aacute; en uso.", function() { /*accion*/ });
				Boxy.zIndex = Boxy.zIndex-1;
				val = false;
				break;
			}
		}
		if(val)
		{
			document.forms["form_boxy"].submit();
		}
	}
}

/**
* Agrega una excepcion a la publicidad.
*/
function agregar_excepcion_publicidad()
{
	document.forms['form_boxy'].submit();		
}

/*
* verifica que se haya ingresado un titulo a la pagina.
*/
function modificar_titulo_pagina()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del t&iacute;tulo est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Verifica que se haya ingresado correctamente la metadescripcion de una pagina.
*/
function modificar_pagina_metadesc()
{
	var meta = document.getElementById("metadesc").value;

	if(meta.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese una meta descripci&oacute;n", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Motifica la metadescripcion de una seccion.
*/
function modificar_seccion_metadesc()
{
	var meta = document.getElementById("metadesc").value;

	if(meta.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese una meta descripci&oacute;n", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Verifica si se ha digitado los tags de la pagina.
*/
function modificar_pagina_metakey()
{
	var tags = document.getElementById("metakey").value;
	var tamano = tags.split(",");
	if(tamano.length >= 3 && tamano.length < 10)
	{
		document.forms['form_boxy'].submit();
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
}

/**
* Verifica si se ha digitado los tags de la pagina.
*/
function modificar_seccion_metakey()
{
	var tags = document.getElementById("metakey").value;
	var tamano = tags.split(",");
	if(tamano.length >= 3 && tamano.length < 10)
	{
		document.forms['form_boxy'].submit();
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
}

/*
* Verificca que haya seleccionado un tipo de diseño en la pagina.
*/
function modificar_pagina_tipodiseno()
{
	var themes = document.getElementById("themes").value;
	if(themes.replace(/\s/g,"") == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escoja un tipo de dise&ntilde;o", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else
	{
		document.forms['form_boxy'].submit();
	}	
}

/**
* verifica si se ha ingresado un titulo para la seccion.
*/
function modificar_titulo_seccion()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";		
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el t&iacute;tulo para la secci&oacute;", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* verifica si se ha ingresado un titulo para la seccion.
*/
function modificar_titulo_categoria()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el t&iacute;tulo para la categoria.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* verifica si se ha ingresado un titulo para la seccion.
*/
function modificar_titulo_subcategoria()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el t&iacute;tulo para la subcategoria.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Modifica el titulo de una regla
*/
function modificar_titulo_regla()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el t&iacute;tulo para la regla.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Modifica la descripcion de una regla.
*/
function modificar_regla_desc()
{
	var desc = document.getElementById("desc").value;

	if(desc.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la descripci&oacute;n para la regla.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}	
}

/**
* Modifica la descripcion de una regla.
*/
function modificar_regla_inicio()
{
		document.forms['form_boxy'].submit();
}

/**
* Modifica el titulo de una regla
*/
function modificar_premio_titulo()
{
	var titulo = document.getElementById("titulo").value;

	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el t&iacute;tulo del premio.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Modifica el titulo de una regla
*/
function modificar_premio_fecha()
{
	var fecha = document.getElementById("dateArrival").value;

	if(fecha.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la fecha.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms['form_boxy'].submit();
	}
}

/**
* Valida que todos los campos esten debidamente diligenciados.
*/
function formulario_ingreso(config)
{
	var validacion = true;
	if(document.getElementById("nombre").value.replace(/\s/g,"") == "")
	{
		document.getElementById('nombre').className = "mensaje_advertencia";
		validacion = false;
		document.getElementById("mensaje_registro").innerHTML = '<div class="error">Es necesario llenar todos los campos.</div>';
	}
	if(document.getElementById("apellidos").value.replace(/\s/g,"") == "")
	{
		if(validacion)
		{
			document.getElementById('apellidos').className = "mensaje_advertencia";			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>"; 
		}
		validacion = false;			
	}
	if(document.getElementById("email").value.replace(/\s/g,"") == "")
	{
		if(validacion)
		{
			document.getElementById('email').className = "mensaje_advertencia";			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";	
		}
		validacion = false;		
	}
	if(!mail(document.getElementById("email").value))
	{
		if(validacion)
		{
			document.getElementById('email').className = "mensaje_advertencia";			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Debe escribir un email v&aacute;lido.</div>"; 
		}
		validacion = false;		
	}
	if(document.getElementById("sexo").value == -1)
	{
		if(validacion)
		{
			document.getElementById('sexo').className = "mensaje_advertencia";			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";	
		}
		validacion = false;		
	}	
	if(document.getElementById("pais").value == 0)
	{
		if(validacion)
		{
			document.getElementById('pais').className = "mensaje_advertencia";			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";		
		}
		validacion = false;		
	}
	if(document.getElementById("estado").value == 0)
	{
		if(validacion)
		{			
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";
		}
		validacion = false;		
	}	
	
	if(validacion)
	{
		document.getElementById("validado").value = "1";
		cargar_componente_registro_segunda_parte(config);
	}
}

/**
* Valida la redacción de un email en Javascript.
*/
function mail(texto){ 

    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
                 
    return mailres; 
}

/**
* Valida que todos los campos esten debidamente diligenciados.
*/
function formulario_ingreso2(config)
{
	var validacion = true;
	if(document.getElementById("nombre").value.replace(/\s/g,"") == "" || document.getElementById("nombre").value == "Escribe tu nombre")
	{
		document.getElementById('nombre').className = "textarea-alerta";
		validacion = false;
		document.getElementById("mensaje_registro").innerHTML = '<div class="error">Es necesario llenar todos los campos.</div>';
	}
	if(document.getElementById("apellidos").value.replace(/\s/g,"") == "" || document.getElementById("apellidos").value == "Escribe tus apellidos")
	{
		document.getElementById('apellidos').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>"; 
		}
		validacion = false;			
	}
	if(document.getElementById("email").value.replace(/\s/g,"") == "" || document.getElementById("email").value == "Escribe tu correo electronico")
	{
		document.getElementById('email').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";	
		}
		validacion = false;		
	}
	if(!mail(document.getElementById("email").value))
	{
		document.getElementById('email').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Por favor, verifique el email.</div>"; 
		}
		validacion = false;		
	}
	
	if(document.getElementById("comprobacion_email").innerHTML.indexOf("chulo-icon.png") == -1)
	{
		//if(document.getElementById("comprobacion_email").innerHTML.indexOf("loading.gif") != -1){ formulario_ingreso2(); }
		if(document.getElementById("comprobacion_email").innerHTML.indexOf("chulo-icon.png") == -1)
		{
			document.getElementById('email').className = "textarea-alerta";
			if(validacion)
			{
				document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Por favor, verifique el email.</div>"; 
			}
			validacion = false;			
		}
	}
	if(document.getElementById("sexo").value == -1)
	{
		document.getElementById('sexo').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";	
		}
		validacion = false;		
	}
	if(document.getElementById("pais").value == 0)
	{
		document.getElementById('pais').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";
		}
		validacion = false;		
	}	
	
	if(document.getElementById("estado").value == 0)
	{
		document.getElementById('estado').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";
		}
		validacion = false;		
	}	
	if(document.getElementById("nombre_usuario").value.replace(/\s/g,"") == "" || document.getElementById("nombre_usuario").value == "Escribe un nombre de Usuario")
	{
		document.getElementById('nombre_usuario').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";
		}
		validacion = false;
	}
	if(document.getElementById("comprobacion_usuario").innerHTML.indexOf("chulo-icon.png") == -1)
	{
		//if(document.getElementById("comprobacion_usuario").innerHTML.indexOf("loading.gif") != -1){ formulario_ingreso2(); }
		if(document.getElementById("comprobacion_usuario").innerHTML.indexOf("chulo-icon.png") == -1)
		{
			document.getElementById('nombre_usuario').className = "textarea-alerta";
			if(validacion)
			{
				document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Por favor, verifique el nombre de usuario.</div>"; 
			}
			validacion = false;			
		}
	}

	if(document.getElementById("clave1").value.replace(/\s/g,"") == "" || document.getElementById("clave1").value == "xxxxxxxxxxxx")
	{
		document.getElementById('clave1').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";
		}
		validacion = false;
	}
	if(document.getElementById("clave2").value.replace(/\s/g,"") == "" || document.getElementById("clave2").value == "xxxxxxxxxxxx")
	{
		document.getElementById('clave2').className = "textarea-alerta";
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>Es necesario llenar todos los campos.</div>";		
		}
		validacion = false;
	}
	if(document.getElementById("clave1").value.length < 4 || document.getElementById("clave1").value.length > 10 && document.getElementById("clave2").value.length < 4 || document.getElementById("clave2").value.length > 10)
	{
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>La clave debe tener entre 4 y 10 caracteres.</div>";
		}
		validacion = false;
	}
	if(document.getElementById("clave1").value != document.getElementById("clave2").value && document.getElementById("clave1").value.replace(/\s/g,"") != "" && document.getElementById("clave2").value.replace(/\s/g,"") != "")
	{
		if(validacion)
		{
			document.getElementById("mensaje_registro").innerHTML = "<div class='error'>La confirmacion de la clave esta errada.</div>";
		}
		validacion = false;		
	}
	
	if(validacion)
	{
		cargar_componente_registro_usuario_validado();
	}
	else
	{
		scrollTo(0,0);
	}
}

/**
* valida que una url se haya digitado correctamente.
* Puede que empiece con http://www ó https://www ó http:// ó https:// ó www.
*/
function validar_url(url)
{
	var regex=/^(http|https):\/\/\w+([\.\-\w]+)?\.([a-z]{2,3}|info|mobi|aero|asia|name)(:\d{2,5})?(\/)?((\/).+)?$/i;
	var regex2=/^www+([\.\-\w]+)?\.([a-z]{2,3}|info|mobi|aero|asia|name)(:\d{2,5})?(\/)?((\/).+)?$/i;
	if(regex.test(url) || regex2.test(url)){ return true; }
	else{ return false; }
}

/**
* Valida que el embed tenga las etiquetas object o embed.
*/
function validar_embed(url)
{
	if(url.indexOf("<object") != -1 && url.indexOf("<embed") != -1)
	{
		if(url.indexOf("</object>") != -1 && url.indexOf("</embed>") != -1){ return true; }
		else{ return false; }
	}
	else if(url.indexOf("<object") != -1 && url.indexOf("<embed") == -1)
	{
		if(url.indexOf("</object>") != -1 && url.indexOf("</embed>") == -1){ return true; }
		else{ return false; }
	}
	else if(url.indexOf("<object") == -1 && url.indexOf("<embed") != -1)
	{
		if(url.indexOf("</object>") == -1 && url.indexOf("</embed>") != -1){ return true; }
		else{ return false; }
	}
	else{ return false; }
} 

/**
* Función que valida los parametros ingresados en el formulario creau url para rastreo de youtube.
*/
function crear_url()
{
	var titulo = document.getElementById("titulo").value;
	var palabras = document.getElementById("palabras").value;
	var ordenamiento = document.getElementById("ordenamiento").value;
	var criterio = document.getElementById("criterio").value;
	var categoria_r = document.getElementById("categoria_r").value;
	var usuario = document.getElementById("usuario").value;
	
	var pagina = document.getElementById("pagina");
	if(pagina){ pagina = document.getElementById("pagina").value; }else{ pagina = 0; }
	var seccion = document.getElementById("seccion");
	if(seccion){ seccion = document.getElementById("seccion").value; }else{ seccion = 0; } 
	var categoria = document.getElementById("categoria");
	if(categoria){ categoria = document.getElementById("categoria").value; }else{ categoria = 0; }
	var subcategoria = document.getElementById("subcategoria");
	if(subcategoria){ subcategoria = document.getElementById("subcategoria").value; }else{ subcategoria = 0; }
	
	var lista_video = document.getElementById("lista_video").value;
	var pais = document.getElementById("pais").value;
	var tiempo = document.getElementById("tiempo").value;
	var url = "http://gdata.youtube.com/feeds/api/";
	var acarreo = false;
	
	var l_alfabeto = document.getElementById("l_alfabeto").checked;
	var p_buscar = document.getElementById("p_buscar").value;
	var p_reemplazar = document.getElementById("p_reemplazar").value;
	var ins_palabra = document.getElementById("ins_palabra").value;
	var a_palabras = document.getElementById("a_palabras").value;
	var l_especiales = document.getElementById("l_especiales").value;
	
	if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el t&iacute;tulo.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}	
	
	if(usuario.replace(/\s/g,"") == "")
	{
		if(criterio != "videos")
		{
			if(pais != -1){ url = url+"standardfeeds"+pais+criterio; }
			else{ url = url+"standardfeeds"+criterio; }
			
			if(tiempo != -1)
			{
				if(criterio == "/top_rated" || criterio == "/top_favorites" || criterio == "/most_viewed" || criterio == "/most_discussed" || criterio == "/most_linked" || criterio == "/most_responded"){ url = url+"?time="+tiempo; acarreo = true; }
			}
		}
		else
		{
			url = url+criterio;
			if(tiempo != -1){ url = url+"?time="+tiempo; acarreo = true; }
		}
		
		if(pais != -1 && criterio == "videos")
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Para hacer la consulta sobre un pa&iacute;s, debe escoger una opci&oacute;n de la lista Ranking.</div>", function() { /*accion*/  });
			Boxy.zIndex = Boxy.zIndex-1;
			return false;
		}
	}
	else
	{
		url = url+"users/"+usuario+"/uploads";
		if(tiempo != -1){ url = url+"?time="+tiempo; acarreo = true; }
	}

	if(palabras.replace(/\s/g,"") == "")
	{
		if(categoria_r != -1)
		{
			if(acarreo){ url = url+"&category="+categoria_r; }
			else{ url = url+"?category="+categoria_r; acarreo = true; }			
		}
	}
	else
	{
		if(categoria_r == -1)
		{
			var palabras = palabras.split(" ");
			
			if(acarreo){ url = url+"&vq="; }
			else{ url = url+"?vq="; acarreo = true; }
			
			for(var i=0; i<palabras.length; i++)
			{
				if((i+1) == palabras.length){ url = url+palabras[i]; }
				else{ url = url+palabras[i]+"+"; }
			}
			
		}
		else
		{
			if(acarreo){ url = url+"&category="+categoria_r; }
			else{ url = url+"?category="+categoria_r; acarreo = true; }
			
			var palabras = palabras.split(" ");
			url = url+"&vq=";
			for(var i=0; i<palabras.length; i++)
			{
				if((i+1) == palabras.length){ url = url+palabras[i]; }
				else{ url = url+palabras[i]+"+"; }
			}			
		}
	}
	
	if(acarreo){ url = url+"&orderby="+ordenamiento; }
	else{ url = url+"?orderby="+ordenamiento; }
	
	if(document.getElementById("pagina").value == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione al menos una p&aacute;gina.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	
	if(p_buscar.replace(/\s/g,"") != "" && p_reemplazar.replace(/\s/g,"") == "" || p_buscar.replace(/\s/g,"") == "" && p_reemplazar.replace(/\s/g,"") != "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Si desea reemplazar palabras aeg&uacute;rese de haber llenado los campos buscar y reemplazar.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	
	if(l_alfabeto && p_buscar.replace(/\s/g,"") != "" || l_alfabeto && p_reemplazar.replace(/\s/g,"") != "")
	{  
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Si desea limpiar el alfabeto del titulo, no agrege palabras en los campos buscar y reemplazar.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}	

//	document.getElementById("crear").value = 1;
	document.getElementById("url_creada").value = urlencode(url);
//	document.forms['form_boxy'].submit();

	var mes = document.getElementById("mes").value;
	var dias = document.getElementById("dias").value;
	var horas = document.getElementById("horas").value;	
	var minutos = document.getElementById("minutos").value;	
	var cantidad = document.getElementById("cantidad").value;	

	globalUrl = "admin_edit_opciones.php";
	show("opc=agregar_regla_action&url_creada="+document.getElementById("url_creada").value+"&lista_video="+lista_video+"&pagina="+pagina+"&seccion="+seccion+"&categoria="+categoria+"&subcategoria="+subcategoria+"&titulo="+titulo+"&l_alfabeto="+l_alfabeto+"&p_buscar="+p_buscar+"&p_reemplazar="+p_reemplazar+"&ins_palabra="+ins_palabra+"&l_especiales="+l_especiales+"&a_palabras="+a_palabras+"&mes="+mes+"&dias="+dias+"&horas="+horas+"&minutos="+minutos+"&cantidad="+cantidad);

}

/**
* Modifica la url de la búsqueda.
*/
function modificar_url()
{
	var palabras = document.getElementById("palabras").value;
	var ordenamiento = document.getElementById("ordenamiento").value;
	var criterio = document.getElementById("criterio").value;
	var categoria_r = document.getElementById("categoria_r").value;
	var usuario = document.getElementById("usuario").value;
	var pais = document.getElementById("pais").value;
	var tiempo = document.getElementById("tiempo").value;
	var url = "http://gdata.youtube.com/feeds/api/";
	var acarreo = false;

	var l_alfabeto = document.getElementById("l_alfabeto").checked;
	var p_buscar = document.getElementById("p_buscar").value;
	var p_reemplazar = document.getElementById("p_reemplazar").value;
	var ins_palabra = document.getElementById("ins_palabra").value;
	var a_palabras = document.getElementById("a_palabras").value;
	var l_especiales = document.getElementById("l_especiales").value;

	if(usuario.replace(/\s/g,"") == "")
	{
		if(criterio != "videos")
		{
			if(pais != -1){ url = url+"standardfeeds"+pais+criterio; }
			else{ url = url+"standardfeeds"+criterio; }
			
			if(tiempo != -1)
			{
				if(criterio == "/top_rated" || criterio == "/top_favorites" || criterio == "/most_viewed" || criterio == "/most_discussed" || criterio == "/most_linked" || criterio == "/most_responded"){ url = url+"?time="+tiempo; acarreo = true; }
			}
		}
		else
		{
			url = url+criterio;
			if(tiempo != -1){ url = url+"?time="+tiempo; acarreo = true; }
		}
		
		if(pais != -1 && criterio == "videos")
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("Para hacer la consulta sobre un pa&iacute;s, debe escoger una opci&oacute;n de la lista Ranking.", function() { /*accion*/  });
			Boxy.zIndex = Boxy.zIndex-1;
			return false;
		}
	}
	else
	{
		url = url+"users/"+usuario+"/uploads";
		if(tiempo != -1){ url = url+"?time="+tiempo; acarreo = true; }
	}

	if(palabras.replace(/\s/g,"") == "")
	{
		if(categoria_r != -1)
		{
			if(acarreo){ url = url+"&category="+categoria_r; }
			else{ url = url+"?category="+categoria_r; acarreo = true; }			
		}
	}
	else
	{
		if(categoria_r == -1)
		{
			var palabras = palabras.split(" ");
			
			if(acarreo){ url = url+"&vq="; }
			else{ url = url+"?vq="; acarreo = true; }
			
			for(var i=0; i<palabras.length; i++)
			{
				if((i+1) == palabras.length){ url = url+palabras[i]; }
				else{ url = url+palabras[i]+"+"; }
			}
			
		}
		else
		{
			if(acarreo){ url = url+"&category="+categoria_r; }
			else{ url = url+"?category="+categoria_r; acarreo = true; }
			
			var palabras = palabras.split(" ");
			url = url+"&vq=";
			for(var i=0; i<palabras.length; i++)
			{
				if((i+1) == palabras.length){ url = url+palabras[i]; }
				else{ url = url+palabras[i]+"+"; }
			}			
		}
	}
	
	if(acarreo){ url = url+"&orderby="+ordenamiento; }
	else{ url = url+"?orderby="+ordenamiento; }

	if(p_buscar.replace(/\s/g,"") != "" && p_reemplazar.replace(/\s/g,"") == "" || p_buscar.replace(/\s/g,"") == "" && p_reemplazar.replace(/\s/g,"") != "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Si desea reemplazar palabras aeg&uacute;rese de haber llenado los campos buscar y reemplazar.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}
	
	if(l_alfabeto && p_buscar.replace(/\s/g,"") != "" || l_alfabeto && p_reemplazar.replace(/\s/g,"") != "")
	{  
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Si desea limpiar el alfabeto del titulo, no agrege palabras en los campos buscar y reemplazar.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
		return false;
	}	

	document.getElementById("url_creada").value = url;
	document.forms['form_boxy'].submit();
}

/**
* Valida los datos ingresados de este formulario
*/
function modificar_rastreo_guardar()
{
	var pagina = document.getElementById("pagina").value;
	if(pagina == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, seleccione al menos una p&aacute;gina.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("modificar_guardar_rastreo").value = 1;
		document.forms["formulario_box"].submit();
	}
}

function modificar_cronjob_horario()
{
	document.forms["form_boxy"].submit();
}

/**
* Valida que al menos se haya seleccionado una opcion
*/
function validar_sel(formulario)
{
	var obj, validado = false;
	for(var i=0; true; i++)
	{
		obj = document.getElementById("sel"+i);
		if(obj){ if(obj.checked){ validado = true; } }
		else{ break; }
	}
	
	if(validado)
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Eliminar";
		Boxy.confirm("<div class=alerta>&#191;Est&aacute; seguro que desea eliminar estos items&#63;</div>", function() 
		{ 
			document.getElementById('eliminar_sel').value = 1;
			if(formulario){ document.forms[formulario].submit(); }
			else{ document.forms['form_lista_videos'].submit(); }
			
		});
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class=alerta>Por favor, seleccione al menos un item.</div>", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

/**
* Valida que al menos se haya seleccionado una opcion
*/
function validar_sel_menu()
{
	var obj, validado = false, lista = "";
	for(var i=0; true; i++)
	{
		obj = document.getElementById("sel"+i);
		if(obj){ if(obj.checked){ validado = true; lista = lista+obj.value+","; } }
		else{ break; }
	}
	
	lista = lista.substr(0, (lista.length-1));
	
	if(validado)
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Eliminar";
		Boxy.confirm("<div class='alerta'>&#191;Est&aacute; seguro que desea eliminar estas p&aacute;ginas&#63;</div>", function() 
		{
			var contenedor;
			contenedor = document.getElementById("muestra");
			ajax = nuevoAjax();
			ajax.open("POST", "http://"+globalConfig+"/apps/modificar_item_menu.php?eliminar_sel=1&lista="+lista, true);
				 
			ajax.onreadystatechange = function()
			{
				if(ajax.readyState == 4)
				{
					contenedor.innerHTML = ajax.responseText;
				}
			}
			ajax.send(null);
		});
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Por favor, seleccione al menos una p&aacute;gina.</div>", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

/**
* Selecciona todos los checkbox habidos y por haber.
*/
function sel_todo()
{
	for(var i=0; true; i++)
	{
		obj = document.getElementById("sel"+i);
		if(obj)
		{  
			document.getElementById("col"+i).bgColor="#F0F0F0";
			document.getElementById("sel"+i).checked = "true"; 
		}
		else{ break; }
	}	
}

/**
* Selecciona todos los checkbox habidos y por haber.
*/
function quit_todo()
{
	for(var i=0; true; i++)
	{
		obj = document.getElementById("sel"+i);
		if(obj)
		{  
			document.getElementById("col"+i).bgColor="";
			document.getElementById("sel"+i).checked = ""; 
		}
		else{ break; }
	}	
}

/**
* Valida los datos de las paginas.
*/
function editar_menu_contenido()
{
	var nombre = document.getElementById("nombre").value;
	var titulo = document.getElementById("titulo").value;
	var descripcion = document.getElementById("meta_descripcion").value;
	var tags = document.getElementById("tags").value;
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el nombre.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(titulo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese el titulo.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(descripcion.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrese la descripci&oacute;n.", function() { /*accion*/  });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var tamano = tags.split(",");
		if(tamano.length >= 3 && tamano.length < 10)
		{
			document.forms["formulario_box"].submit();
		}
		else
		{
			Boxy.DEFAULTS.title = "Alerta!";			
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("El tag debe tener entre 3 y 10 frases o palabras.", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;			
		}
	}
}

function vista_previa_img(ruta)
{
	if(ruta.replace(/\s/g,"") == ""){ document.getElementById("vpreviaimg").innerHTML = "No hay imagen"; }
	else{ document.getElementById("vpreviaimg").innerHTML = '<img id="ico" src="'+ruta+'" style="max-height:32px;" border="0"/>'; }
}

/**
* Modifica la imagen de un video.
*/
function modificar_imagen()
{
	var url = document.getElementById("url").value;
	if(url.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrse la url.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		Boxy.zIndex = Boxy.zIndex+1;		
		Boxy.DEFAULTS.title = "Cambiar imagen"; 
		Boxy.confirm("<div class='alerta'>&#191;Est&aacute; seguro de reemplazar la imagen&#63;</div>", function(){ 
			document.forms["form_boxy"].submit();
		});
		Boxy.zIndex = Boxy.zIndex-1;
	}	
}

function insertar_iframe()
{
	var frame = document.getElementById("frame").value;

	if(frame.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor, ingrse el iframe.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{		
		var insercion = "[iframe]"+frame+"[/iframe]";
		var navegador = navigator.appName;
		var lasttext = document.getElementById("vB_Editor_001_textarea"); 
		if (navegador == "Microsoft Internet Explorer")
		{
			var oldtext = lasttext.value;
			var marker = "##MARKER##";
			lasttext.focus();
			var sel = global_explorer;
			sel.text = marker;
			var tmptext = lasttext.value;
			var curpos = tmptext.indexOf(marker);
			pretext = oldtext.substring(0,curpos);
			posttest = oldtext.substring(curpos,oldtext.length);
			lasttext.value = pretext + insercion + posttest+ "\n";
		}
		if (navigator.appName=="Netscape")
		{
			var oldtext = lasttext.value;
			var curpos = lasttext.selectionStart;
			lasttext.focus();
			pretext = oldtext.substring(0,curpos);
			posttest = oldtext.substring(curpos,oldtext.length);
			lasttext.value = pretext + insercion + posttest+ "\n";
		}			
		$('#close').click();
	}
}

/**
* Guarda los cambios de un archivo
*/
function guardar_cambios_archivo(directorio, archivo)
{
	var fuente = urlencode(document.getElementById("fuente").value);
	Boxy.zIndex = Boxy.zIndex+1;
	Boxy.DEFAULTS.title = "Guardar";
	Boxy.confirm("<div class='alerta'>&#191;Est&aacute; seguro que desea guardar estos cambios&#63;</div>", function() 
	{
		ajax = nuevoAjax();
		contenedor = document.getElementById("vista_previa");
		contenedor.innerHTML="<div class='cargando'>Guardando...</div>";
		ajax.open("POST", "admin_edit_opciones.php", true);
		 
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		 
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		
		ajax.send("&opc=mostrar_fuente_archivo&sopc=guardar&directorio="+directorio+"&archivo="+archivo+"&fuente="+fuente);
	});
	Boxy.zIndex = Boxy.zIndex-1;
	
}

/**
* Verirfica si está bien modificado el titulo
*/
function modificar_usuario(id_usuario)
{
	var nombre = document.getElementById("nombre").value;
	var apellidos = document.getElementById("apellidos").value;
	var nombre_usuario = document.getElementById("nombre_usuario").value;
	var password = document.getElementById("password").value;	
	var perfil = document.getElementById("perfil").value;		
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{		
		document.forms["formulario_box"].submit();
	}
}

/**
* Verirfica si está bien modificado el titulo
*/
function modificar_usuario2()
{
	var email = document.getElementById("email").value;
	
	if(email.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Escriba su email.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(!mail(email))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Debe escribir un email v&aacute;lido.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{		
		document.forms["formulario_box"].submit();
	}
}

function cambiar_password(viejo)
{
	var actual = document.getElementById("actual").value;
	var password = document.getElementById("password").value;	
	var nuevo = document.getElementById("confirmar").value;	
	

	if(actual.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el password actual.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(actual != viejo)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El password actual no es correcto.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el nuevo password.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(nuevo.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Confirme el nuevo password.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 4 || nuevo.replace(/\s/g,"").length < 4)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El password debe tener m&iacute;nimo 4 caracteres.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}		
	else if(password != nuevo)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>La confirmaci&oacute;n de la clave est&aacute; errada.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

function crear_usuario()
{
	var nombre = document.getElementById("nombre").value;
	var apellidos = document.getElementById("apellidos").value;
	var nombre_usuario = document.getElementById("nombre_usuario").value;
	var password = document.getElementById("password").value;
	var perfil = document.getElementById("perfil").value;
	var sexo = document.getElementById("sexo").value;
	var telefono = document.getElementById("telefono").value;
	var celular = document.getElementById("celular").value;
	var ciudad = document.getElementById("ciudad").value;
	var email = document.getElementById("email").value;

	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(email.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Escriba su email.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(!mail(email))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Debe escribir un email v&aacute;lido.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(nombre_usuario.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del nombre de usuario est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El campo del password est&aacute; vac&iacute;o.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 6 || password.replace(/\s/g,"").length > 10)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El password debe tener entre 6 y 10 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(document.getElementById("perfil").value == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Por favor seleccione un perfil.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else
	{
		contenedor = document.getElementById("documento");
		ajax = nuevoAjax();
		ajax.open("POST", "http://"+globalConfig+"/apps/crear_usuario.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				if(ajax.responseText == "1"){ document.getElementById("documento").innerHTML = '<div class="exito">la operaci&oacute;n se ha realizado satisfactoriamente.</div><div align="center"><table class="boxyButton"><tr><td align="center"><div class="boxyButtonFooter" style="display: block; "><label class="boxyButtonblue"><input type="button" onclick="document.location = document.location;" value="Actualizar"></label><label class=""><input type="button" value="Cerrar" onclick="cerrar_boxy();" class="close"></label></div><div style="top: 28px; visibility: hidden; zoom: 1; opacity: 0; " class="boxyButtonOverlay">&nbsp;</div></tr></table></div>'; }
				else{ document.getElementById("mensajes").innerHTML = ajax.responseText; }
			}
		}
		ajax.send("opc=crear_usuario&nombre="+nombre+"&apellidos="+apellidos+"&sexo="+sexo+"&email="+email+"&nombre_usuario="+nombre_usuario+"&password="+password+"&ciudad="+ciudad+"&telefono="+telefono+"&celular="+celular+"&perfil="+perfil);
	}
}

/**
* Valida si la persona puede hacer una recarga.
*/
function recargar(id_usuario)
{
	var monto = document.getElementById("monto").value;
	if(monto.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("ingrese el valor a recargar.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(isNaN(monto))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("la cantidad debe ser num&eacute;rica.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=recargar&id_objeto="+id_usuario+"&monto="+monto);
	}
}

/**
* Valida si la persona puede hacer una recarga.
*/
function comprar_recarga(cantidad_minima, cantidad_maxima, id)
{
	var monto = document.getElementById("monto").value;
	if(monto.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el valor a recargar.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(isNaN(monto))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La cantidad debe ser num&eacute;rica.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=comprar_recarga&id_objeto="+id+"&monto="+monto+"&cantidad_minima="+cantidad_minima+"&cantidad_maxima="+cantidad_maxima);
	}
}

function recargar_virtual(id_usuario, id_cuenta)
{
	var monto = document.getElementById("monto").value;
	id_cuenta = document.getElementById("ncuenta").value;
	if(monto.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("ingrese el valor a recargar.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(isNaN(monto))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("la cantidad debe ser num&eacute;rica.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{		
		document.getElementById("label_boton").className = "";
		document.getElementById('boton').value='Espere un momento...';
		document.getElementById('boton').disabled='disabled';
	
		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=recarga&id_objeto="+id_usuario+"&monto="+monto+"&cuenta="+id_cuenta, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}	
}

function crear_cuenta(id_usuario)
{
	var usuario = document.getElementById("user").value;
	var password = document.getElementById("password").value;
	var lista = document.getElementById("lista_tarifas").value;
	var credito = document.getElementById("credito").value;
	
	if(usuario.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el nombre de usuario.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la contrase&ntilde;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 4 || password.replace(/\s/g,"").length > 39)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El tama&ntilde;o del password debe estar entre 4 y 39 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(credito.replace(/\s/g,"") != "" && isNaN(credito))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El cr&aacute;dito debe ser num&eacute;rico.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		if(credito.replace(/\s/g,"") == ""){ credito = 0; }
		document.getElementById("label_boton").className = "";
		document.getElementById('boton').value='Espere un momento...';
		document.getElementById('boton').disabled='disabled';

		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=crear_cuenta&id_objeto="+id_usuario+"&usuario="+usuario+"&password="+password+"&credito="+credito+"&lista="+lista, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}
}

/**
* Valida el formulario modificar password voip.
*/
function modificar_password_voip(id_usuario)
{
	var password = document.getElementById("password").value;
	var lista = document.getElementById("ratelist").value;
	
	if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la contrase&ntilde;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 4 || password.replace(/\s/g,"").length > 39)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El tama&ntilde;o del password debe estar entre 4 y 39 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=modificar_password_action&id_objeto="+id_usuario+"&password="+password+"&ratelist="+lista);
	}
}

function guardar_cambios_tarifas()
{
	var letra = document.getElementById("letra").value;
	var id_lista = document.getElementById("id_lista").value;	

	var cambiorate = document.getElementById("cambios-rate").value;
	var cambiofree = document.getElementById("cambios-free").value;
	var cambioinc = document.getElementById("cambios-inc").value;
	var cambioini = document.getElementById("cambios-ini").value;
	var ids = "", obj, valores = "", val = true;
	for(var i=0; true; i++)
	{
		obj = document.getElementById("id-"+i);
		if(obj)
		{ 
			ids = ids+obj.value+"-";
			if(isNaN(document.getElementById("rate-"+i).value) || isNaN(document.getElementById("free-"+i).value) || isNaN(document.getElementById("inc-"+i).value) || isNaN(document.getElementById("ini-"+i).value)){ val = false; }
		}
		else{ break; }
		
		if(cambiorate.indexOf(i) != -1){ valores = valores+"&rate"+i+"="+document.getElementById("rate-"+i).value; }
		if(cambiofree.indexOf(i) != -1){ valores = valores+"&free"+i+"="+document.getElementById("free-"+i).value; }
		if(cambioinc.indexOf(i) != -1){ valores = valores+"&inc"+i+"="+document.getElementById("inc-"+i).value; }
		if(cambioini.indexOf(i) != -1){ valores = valores+"&ini"+i+"="+document.getElementById("ini-"+i).value; }
	}

	if(val)
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Cambiar imagen";
		Boxy.confirm("<div class='alerta'>&#191;Est&aacute; seguro de guardar estos cambios&#63;</div>", function(){
		
		contenedor = document.getElementById("lista_tarifas");
		ajax = nuevoAjax();
		ajax.open("POST", "http://"+globalConfig+"/apps/tarifas_por_letra.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		ajax.send("id_lista="+id_lista+"&letra="+letra+"&op=guardar_cambios&ids="+ids+"&cambios-rate="+cambiorate+"&cambios-free="+cambiofree+"&cambios-inc="+cambioinc+"&cambios-ini="+cambioini+valores);
		});
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;		
		Boxy.alert("<div class='alerta'>Los valores deben ser nu&eacute;ricos.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

function guardar_cambios_tarifas_sms()
{
	var letra = document.getElementById("letra").value;
	var id_lista = document.getElementById("id_lista").value;	

	var cambiorate = document.getElementById("cambios-rate").value;
	var ids = "", obj, valores = "", val = true;
	for(var i=0; true; i++)
	{
		obj = document.getElementById("id-"+i);
		if(obj)
		{ 
			ids = ids+obj.value+"-";
			if(isNaN(document.getElementById("rate-"+i).value)){ val = false; }
		}
		else{ break; }
		
		if(cambiorate.indexOf(i) != -1){ valores = valores+"&rate"+i+"="+document.getElementById("rate-"+i).value; }
	}

	if(val)
	{
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.DEFAULTS.title = "Cambiar imagen";
		Boxy.confirm("<div class='alerta'>&#191;Est&aacute; seguro de guardar estos cambios&#63;</div>", function(){
		
		contenedor = document.getElementById("lista_tarifas");
		ajax = nuevoAjax();
		ajax.open("POST", "http://"+globalConfig+"/apps/tarifas_por_letra_sms.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		ajax.send("id_lista="+id_lista+"&letra="+letra+"&op=guardar_cambios&ids="+ids+"&cambios-rate="+cambiorate+valores);
		});
		Boxy.zIndex = Boxy.zIndex-1;			
	}
	else
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;		
		Boxy.alert("<div class='alerta'>Los valores deben ser nu&eacute;ricos.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
}

/**
* Valida el formulario de crear una lista.
*/
function validar_modificar_lista(id_lista)
{
	var nombre = document.getElementById("nombre").value;
	var free = document.getElementById("free").value;
	var incremento = document.getElementById("incremento").value;
	var inicio = document.getElementById("inicio").value;
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el nombre de la lista.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(free.replace(/\s/g,"").length != "" && isNaN(free))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del free time debe ser nume&eacute;rico.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(incremento.replace(/\s/g,"") != "" && isNaN(incremento))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del incremento debe ser num&eacute;rico.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(inicio.replace(/\s/g,"") != "" && isNaN(inicio))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del inicio debe ser num&eacute;rico</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=modificar_lista_tarifa&nombre="+nombre+"&free="+free+"&incremento="+incremento+"&inicio="+inicio+"&id_lista="+id_lista);
	}
}

/**
* Valida el formulario de crear una lista.
*/
function validar_crear_lista()
{
	var nombre = document.getElementById("nombre").value;
	var free = document.getElementById("free").value;
	var incremento = document.getElementById("incremento").value;
	var inicio = document.getElementById("inicio").value;
	var id_lista = document.getElementById("lista").value;
	
	if(nombre.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el nombre de la lista.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(free.replace(/\s/g,"").length == 0 )
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el free time.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(free))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del free time debe ser nume&eacute;rico.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(incremento.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el incremento.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(incremento))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del incremento debe ser num&eacute;rico.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}	
	else if(inicio.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el inicio.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(inicio))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor del inicio debe ser num&eacute;rico</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=agregar_lista_tarifa_action&nombre="+nombre+"&lista="+id_lista+"&free="+free+"&incremento="+incremento+"&inicio="+inicio);
	}		
}

function cambiar_config_cuenta(id_usuario, sms)
{
	var lista = document.getElementById("lista_tarifas").value;
	var cuenta = document.getElementById("ncuenta").value;

	if(lista.replace(/\s/g,"") == -1)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Debe escoger una lista de tarifas.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("label_boton").className = "";
		document.getElementById('boton').value='Espere un momento...';
		document.getElementById('boton').disabled='disabled';
		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=modificar_lista_tarifa&id_objeto="+id_usuario+"&lista="+lista+"&cuenta="+cuenta+"&sms="+sms, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}
}

function cambiar_password_cuenta(id_usuario)
{
	var password = document.getElementById("password").value;
	var cuenta = document.getElementById("ncuenta").value;

	if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la contrase&ntilde;a.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 4 || password.replace(/\s/g,"").length > 39)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El tama&ntilde;o del password debe estar entre 4 y 39 caracteres.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("label_boton").className = "";
		document.getElementById('boton').value='Espere un momento...';
		document.getElementById('boton').disabled='disabled';

		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=modificar_password&id_objeto="+id_usuario+"&password="+password+"&cuenta="+cuenta, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}
}

function cambiar_notificacion_cuenta(id_usuario)
{
	var notificacion = document.getElementById("notificacion").value;
	var min_valor = document.getElementById("min-valor").value;
	var celular = document.getElementById("celular").value;
	
	if(min_valor.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese el valor m&iacute;nimo.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(min_valor))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El valor debe ser num&eacute;rica.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(celular.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese un n&uacute;mero celular para enviar la confirmaci&oacute;n.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(celular))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("El celular no debe contener letras.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("label_boton").className = "";		
		document.getElementById('boton').value='Espere un momento...';		
		document.getElementById('boton').disabled='disabled';		

		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=modificar_notificacion&id_objeto="+id_usuario+"&notificacion="+notificacion+"&min-valor="+min_valor+"&celular="+celular, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}
}

function cambiar_notificacion_cuenta2(id_usuario)
{
	var notificacion = document.getElementById("notificacion").value;
	var min_valor = document.getElementById("min-valor").value;
	var celular = document.getElementById("celular").value;

	if(min_valor.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el valor m&iacute;nimo.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(min_valor))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El valor debe ser num&eacute;rica.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(celular.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese un n&uacute;mero celular para enviar la confirmaci&oacute;n.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(celular))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El celular no debe contener letras.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.forms["form_boxy"].submit();
	}
}

function cambiar_autobuy_cuenta(id_usuario)
{
	var autobuy = document.getElementById("autobuy").value;
	var cantidad = document.getElementById("cantidad_maxima").value;

	if(cantidad.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("Ingrese la cantidad m&aacute;xima de monto.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(isNaN(cantidad))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("La cantidad debe ser num&eacute;rica.", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		document.getElementById("label_boton").className = "";		
		document.getElementById('boton').value='Espere un momento...';		
		document.getElementById('boton').disabled='disabled';		

		var contenedor = document.getElementById("acciones");
		ajax = nuevoAjax();
		ajax.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=modificar_autobuy&id_objeto="+id_usuario+"&autobuy="+autobuy+"&cantidad="+cantidad, true);
		ajax.onreadystatechange = function()
		{				 
			if(ajax.readyState == 4)
			{
				var contenedor2 = document.getElementById("actualizar");
				ajax2 = nuevoAjax();
				ajax2.open("GET", "http://"+globalConfig+"/apps/voipacciones.php?opc=actualizar_tabla&id_objeto="+id_usuario, true);
				ajax2.onreadystatechange = function()
				{				 
					if(ajax2.readyState == 4)
					{
						contenedor.innerHTML = ajax.responseText;
						contenedor2.innerHTML = ajax2.responseText;
					}
				}
				ajax2.send(null);
			}
		}
		ajax.send(null);
	}
}

function enviar_mensaje()
{
	var mensaje = urlencode(document.getElementById("mensaje").value);	

	if(document.getElementById("destino").value.replace(/\s/g,"").length == 0 || document.getElementById("destino").value == "Escriba el destino aqui")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el destino.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(document.getElementById("mensaje").value.replace(/\s/g,"").length == 0 || document.getElementById("mensaje").value == "Escriba el mensaje aqui")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Escribe el mensaje.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(document.getElementById("mensaje").value.length > 160 && !isNaN(document.getElementById("destino").value))
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El contenido del mensaje no debe superar 160 caracteres.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		var destino = document.getElementById("destino").value;
		mensaje = mensaje.replace(/%0D%0A/g, "<br/>");
		mensaje = mensaje.replace(/%0A/g, "<br/>");		
	
		globalUrl = "send-messages.php";
		ajax = nuevoAjax();	
		contenedor = document.getElementById("documento");
		contenedor.innerHTML="<div class='cargando'>Enviando...</div>";
		boxy.center("x");
		boxy.center("y");
		
		ajax.open("POST", "http://"+globalConfig+"/apps/"+globalUrl, true);
		
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
				boxy.center("x");
				boxy.center("y");
			}
		}
		ajax.send("opc=enviar_mensaje&destino="+destino+"&mensaje="+mensaje);		
	}
}

function responder_mensaje(destino)
{
	var mensaje = urlencode(document.getElementById("respuesta").value);		

	if(document.getElementById("respuesta").value.replace(/\s/g,"").length == 0 || document.getElementById("respuesta").value == "Escriba una respuesta aqui")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Escribe el mensaje.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(document.getElementById("respuesta").value.length > 2000)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El contenido del mensaje no debe superar 2000 caracteres.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		mensaje = mensaje.replace(/%0D%0A/g, "<br/>");
		mensaje = mensaje.replace(/%0A/g, "<br/>");
		
		globalUrl = "refresh_mensaje.php";
		ajax = nuevoAjax();	
		contenedor = document.getElementById("muestra");
		
		ajax.open("POST", "http://"+globalConfig+"/apps/auxiliares/"+globalUrl, true);
		
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
				document.getElementById("respuesta").value = "Escriba una respuesta aqui";
			}
		}
		ajax.send("opc=enviar_mensaje&tipo_mensaje=response_message&destino="+destino+"&mensaje="+mensaje);		
	}
}

function eliminar_mensaje(id)
{
	Boxy.DEFAULTS.title = "Eliminar"; 
	Boxy.confirm("<div class=alerta>&#191;Est&aacute; seguro de querer eliminar este mensaje&#63;</div>", function() 
	{ 
		globalUrl = "refresh_mensaje.php";
		ajax = nuevoAjax();	
		contenedor = document.getElementById("muestra");
		
		ajax.open("POST", "http://"+globalConfig+"/apps/auxiliares/"+globalUrl, true);
		
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				contenedor.innerHTML = ajax.responseText;
			}
		}
		ajax.send("opc=eliminar&id="+id);
	});	
}

function actualizar_services_config(formulario)
{
	if(formulario == 1)
	{
		if(document.getElementById("host_name").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba el nombre del host.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else if(document.getElementById("hosting_user").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba el usuario.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else if(document.getElementById("host").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba el host.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1; 
		}		
		else if(document.getElementById("api_key").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba el Api key.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}				
		else{ document.forms['form_boxy'].submit(); }
	}
	else if(formulario == 2)
	{
		if(document.getElementById("name").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba el nombre.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else if(document.getElementById("monto").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>Escriba la cantidad m&iacute;nima.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		else if(isNaN(document.getElementById("monto").value))
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>La cantidad debe ser num&eacute;rica.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1;
		}
		
		else if(document.getElementById("img").value.replace(/\s/g,"").length == 0)
		{
			Boxy.DEFAULTS.title = "Alerta!";
			Boxy.zIndex = Boxy.zIndex+1;
			Boxy.alert("<div class='alerta'>ingrese la url de la imagen.</div>", function() { /*accion*/ });
			Boxy.zIndex = Boxy.zIndex-1; 
		}		
		else{ document.forms['form_boxy'].submit(); }		
	}
	else{ document.forms['form_boxy'].submit(); }
}

function cambiar_email()
{
	url = urlencode(url);
	globalUrl = "administrar.php";
	show("=1&id_objeto="+id_objeto+"&lista="+lista+"&ord="+ord+"&ord2="+ord2+"&lista_video="+lista_video+"&url="+url);
}

function cambiar_img()
{
	document.forms['form_boxy'].submit();
}

function crear_cuenta2()
{
	var usuario = document.getElementById("user").value;	
	var password = document.getElementById("password").value;
	
	if(usuario.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese el nombre de usuario.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;		
	}
	else if(password.replace(/\s/g,"") == "")
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>Ingrese la contrase&ntilde;a.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else if(password.replace(/\s/g,"").length < 4 || password.replace(/\s/g,"").length > 39)
	{
		Boxy.DEFAULTS.title = "Alerta!";
		Boxy.zIndex = Boxy.zIndex+1;
		Boxy.alert("<div class='alerta'>El tama&ntilde;o del password debe estar entre 4 y 39 caracteres.</div>", function() { /*accion*/ });
		Boxy.zIndex = Boxy.zIndex-1;
	}
	else
	{
		globalUrl = "admin_edit_opciones.php";
		show("opc=crear_cuenta2&user="+usuario+"&password="+password);

	}
}
