/*
  ===============================================================

  inGenio X
  http://ingenio.area421.com

  Created by 
  Julian Moreno Hidalgo (Software developer)
  Jesus Moreno Hidalgo (Communication's tree)

  inGenio X is a free software licensed under CC-GNU GPL

  ===============================================================
*/

/*
	funciones administrador
*/
function relleno(campo) {
	var cadena = / /g;
	campo = campo.replace(cadena, "");
	return (campo == "") ? true : false;
}

function validarFecha(campo) {
	var cadena = /^([1-9]|0[1-9]|[12][0-9]|3[01])\/([1-9]|0[1-9]|1[012])\/(19[0-9][0-9]|20[0-9][0-9])$/;
	return ( cadena.test(campo) ) ? true : false;
}

function mailcorrecto(campo) {
	var cadena = /^.+@.+\..{2,4}$/;
	var ini = 0;
	for (var i = 0; i <= campo.length; i++)
		if ( campo.charAt(i) == "@" )
			ini++;
	if ( ini > 1 )
		return false;
	else
		return ( cadena.test(campo) ) ? true : false;
}

function confirmar(text, url)
{
	sel_conf = window.confirm(text);
	// si confirma
	if (sel_conf)
	{
		window.location=url;
	}
}

/*
	Seleccion gral y paginas listado
	Incluye la opcion de ventana
*/
function selec(target,selObj,restaurar)
{
  if (target == '_blank')
  {
  	ventana(selObj.options[selObj.selectedIndex].value,750,500);
  } else {
  	eval(target+".location.href='"+selObj.options[selObj.selectedIndex].value+"'");
  }
  if (restaurar) selObj.selectedIndex=0;
}

/*
	Ventana para conex web externas y funphp
*/
function ventana (url,ancho,alto)
{
	var left = 0;
	var top = 0;
	var ven = "width="+ancho+",height="+alto+",left="+left+",top="+top+",menubar=yes,toolbar=yes,location=yes,resizable=yes,scrollbars=yes";
	vent_n = window.open(url,'ingenio_ven',ven);
	vent_n.focus();
}

/*
	Ventana de previsualizar web
*/
function prev (url,ancho)
{
	var alto = 650;
	var left = (screen.availWidth)?(screen.availWidth-ancho)/2:50;
	var top = (screen.availHeight)?(screen.availHeight-(alto+50))/2:50;
	var ven = "width="+ancho+",height="+alto+",left="+left+",top="+top+",toolbar=0,directories=no,menubar=no,location=no,resizable=yes,scrollbars=no";
	control = window.open(url,'admprev',ven);
	control.focus();
}

/*
	Ventana de previsualizar skin
*/
function verimg (url,ancho,alto)
{
	var left = 0;
	var top = 0;
	var ven = "width="+ancho+",height="+alto+",left="+left+",top="+top+",directories=no,menubar=no,toolbar=no,location=no,resizable=no,scrollbars=no";
	vent_n = window.open(url,'ingenio_skin',ven);
	vent_n.focus();
}
/*
	Ventana de ayuda y texto skin
*/
function vertext (url,ancho)
{
	var alto = 650;
	var left = (screen.availWidth)?(screen.availWidth-ancho)/2:50;
	var top = (screen.availHeight)?(screen.availHeight-(alto+50))/2:50;
	var ven = "width="+ancho+",height="+alto+",left="+left+",top="+top+",toolbar=0,directories=no,menubar=no,location=no,resizable=yes,scrollbars=yes";
	ayuda = window.open(url,'ingenio_ayuda',ven);
	ayuda.focus();
}
/*
  limit_textarea
  Original:  Ronnie T. Moore
  Web Site:  The JavaScript Source -> http://javascript.internet.com
  Dynamic 'fix' by: Nannette Thacker
  Web Site: http://www.shiningstar.net
*/
function input_textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	} else {
		countfield.value = maxlimit - field.value.length;
	}
}

