function next_form(form_action)
{
	document.admin_form.action=form_action;
	document.admin_form.submit();
}

function openBrWin(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}

function openEditorWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}

function openBrWin(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}

function isBlank(s)
{
	var len=s.length;
	var i;
	for(i=0;i<len;++i)
	{
		if(s.charAt(i)!=" ") return false;
	}
	return true;
}

function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1)
	{
	  return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
	   return false
	}

	 if (str.indexOf(at,(lat+1))!=-1)
	 {
	   return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	 {
	   return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1)
	 {
	   return false
	 }
	
	 if (str.indexOf(" ")!=-1)
	 {
		return false
	 }

	 return true					
}


function openCalwin(theURL,winName,features)
{
	cwin=window.open(theURL,winName,features);
	cwin.focus();
}

function valid_date(obj_val,min_yyyy)
{
	//Returns true if value is a date format or is NULL
	//otherwise returns false
	if (obj_val.length == 0)
	return true;
	
	//Returns true if value is a date in the dd/mm/yyyy format
	isplit = obj_val.indexOf('/');
	
	if (isplit == -1 || isplit == obj_val.length)
	return false;
	
	sDay = obj_val.substring(0, isplit);

	if (sDay.length == 0)
	return false;	

	isplit = obj_val.indexOf('/', isplit + 1);
	
	if (isplit == -1 || (isplit + 1 ) == obj_val.length)
	return false;
	
	sMonth = obj_val.substring((sDay.length + 1), isplit);

	if (sMonth.length == 0)
	return false;
	
	sYear = obj_val.substring(isplit + 1);
	
	if (!check_integer(sMonth)) //check month
		return false;
	else if (!check_range(sMonth, 1, 12)) //check month
		return false;
	else if (!check_integer(sYear)) //check year
		return false;
	else if (!check_range(sYear, min_yyyy, 9999)) //check year
		return false;
	else if (!check_integer(sDay)) //check day
		return false;
	else if (!check_day(sYear, sMonth, sDay)) // check day
		return false;
	else return true;
}

function check_day(checkYear, checkMonth, checkDay)
{
	maxDay = 31;
	
	if (checkMonth == 4 || checkMonth == 6 || checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	{
		if (checkMonth == 2)
		{
			if (checkYear % 4 > 0)
				maxDay =28;
			else if (checkYear % 100 == 0 && checkYear % 400 > 0)
				maxDay = 28;
			else
				maxDay = 29;
		}
	}
	return check_range(checkDay, 1, maxDay); //check day
}

function check_integer(obj_val)
{
	//Returns true if value is a number or is NULL
	//otherwise returns false
	
	if (obj_val.length == 0)
		return true;
	
	//Returns true if value is an integer defined as
	//   having an optional leading +.
	//   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;
	
	//The first character can be + blank or a digit.
	check_char = obj_val.indexOf(decimal_format)
	//Was it a decimal?
	if (check_char < 1)
		return check_number(obj_val);
	else
		return false;
}

function number_range(obj_val, min_val, max_val)
{
	// check minimum
	if (min_val != null)
	{
		if (obj_val < min_val) return false;
	}
	
	// check maximum
	if (max_val != null)
	{
		if (obj_val > max_val) return false;
	}
	
	//All tests passed, so...
	return true;
}

function check_number(obj_val)
{
	//Returns true if value is a number or is NULL
	//otherwise returns false
	
	if (obj_val.length == 0) return true;
	
	//Returns true if value is a number defined as
	//   having an optional leading +.
	//   having at most 1 decimal point.
	//   otherwise containing only the characters 0-9.
	var start_format = " .+0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;
	
	//The first character can be + .  blank or a digit.
	check_char = start_format.indexOf(obj_val.charAt(0))
	//Was it a decimal?
	if (check_char == 1) decimal = true;
	else if (check_char < 1) return false;
	
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < obj_val.length; i++)
	{
		check_char = number_format.indexOf(obj_val.charAt(i))
		if (check_char < 0) return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)
				trailing_blank = true;
			// ignore leading blanks
		}
		else if (trailing_blank) return false;
		else digits = true;
	}
	//All tests passed, so...
	return true
}

function check_range(obj_val, min_val, max_val)
{
	//if value is in range then return true else return false
	
	if (obj_val.length == 0) return true;
	
	if (!check_number(obj_val))
	{
		return false;
	}
	else
	{
		return (number_range((eval(obj_val)), min_val, max_val));
	}
	
	//All tests passed, so...
	return true;
}

function trim_last(str_val)
{
	var l;
	l=str_val.length;
	str_val=str_val.substr(0,l-1);
	return str_val;
}