function trim_last(str_val)
{
	var l;
	l=str_val.length;
	str_val=str_val.substr(0,l-1);
	return str_val;
}

function click_to_verify()
{
  features='scrollbars=yes,width=450,height=500,Left=20,Top=20,ScreenX=20,ScreenY=20';
  securewin=window.open('https://secure.comodo.net/ttb_searcher/trustlogo?v_querytype=W&v_shortname=SC2&v_search=acsremindme.com&x=6&y=5','secureseal',features);
  securewin.focus();
}

function isBlank(s)
{
	var len=s.length;
	var i;
	for(i=0;i<len;++i)
	{
		if(s.charAt(i)!=" ") return false;
	}
	return true;
}

function has_spaces(s)
{
	var len=s.length;
	var i;
	for(i=0;i<len;++i)
	{
		if(s.charAt(i)==" ") return true;
	}
	return false;
}


function valid_number(n)
{
	var l=n.length,flag=true,i;

	for (i=0;i<l;i++)
	{
		digit=n.charAt(i);
		if (!(digit>='0' && digit<='9'))
		{
			flag=false;
			break;
		}
	}
	return (flag);
}

function openQWin(theURL,winName) 
{
  features='scrollbars=yes,width=400,height=250,Left=0,Top=0,ScreenX=20,ScreenY=20';
  qwin=window.open(theURL,winName,features);
  qwin.focus();
}

function openCalendar() 
{
  winName="calwin";
  features='scrollbars=yes,resizable=yes,width=650,height=500,Left=0,Top=0,ScreenX=20,ScreenY=20';
  cwin=window.open("/popups/calendar.php",winName,features);
  cwin.focus();
}

function openDGPWin() 
{
  winName="dgpwin";
  features='scrollbars=yes,resizable=yes,width=650,height=500,Left=0,Top=0,ScreenX=20,ScreenY=20';
  dwin=window.open("/popups/DGP.php",winName,features);
  dwin.focus();
}

function openRewardWindow() 
{
  winName="rewardwin";
  features='scrollbars=yes,resizable=yes,width=650,height=500,Left=0,Top=0,ScreenX=20,ScreenY=20';
  cwin=window.open("/popups/redeem_points.php",winName,features);
  cwin.focus();
}

function openTestWindow() 
{
  winName="testwin";
  features='scrollbars=yes,resizable=yes,width=500,height=400,Left=0,Top=0,ScreenX=20,ScreenY=20';
  cwin=window.open("/popups/test_reminder.php",winName,features);
  cwin.focus();
}

function openSurvey() 
{
  winName="surveywin";
  features='scrollbars=yes,resizable=yes,width=580,height=450,Left=0,Top=0,ScreenX=0,ScreenY=0';
  swin=window.open("/popups/feedback.php",winName,features);
  swin.focus();
}

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 mm/dd/yyyy format
	isplit = obj_val.indexOf('/');
	
	if (isplit == -1 || isplit == obj_val.length)
	return false;
	
	sMonth = obj_val.substring(0, isplit);
	
	if (sMonth.length == 0)
	return false;
	
	isplit = obj_val.indexOf('/', isplit + 1);
	
	if (isplit == -1 || (isplit + 1 ) == obj_val.length)
	return false;
	
	sDay = obj_val.substring((sMonth.length + 1), isplit);
	
	if (sDay.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;
}

//Auto Tab Function

var isNS4 = (navigator.appName=="Netscape")?1:0; //verify for netscape/mozilla
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function containsElement(arr, ele)
{
	var found = false, index = 0;
	while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
	return found;
}

function getIndex(input)
{
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
	return index;
}

function autoTab(input,len, e)
{
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) 
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	return true;
}

// End Auto Tab Function

//Verisign Popup
function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}
