var aCityStates = sCityStates.split('|');

var aBadWords = decodeWords(sBadWords).split(",");

window.onError = handleError;

function handleError(sError, sURL, nLineNum) {
	alert("Error:" + sError + " at line " + nLineNum);
	return false;
}

function decodeWords(sWords) {
	var i;
	var nCharCode;
	var sReturn = "";

	for (i=0; i<sWords.length; ++i)
	{	if (sWords.charAt(i) != ",") {
			nCharCode = sWords.charCodeAt(i) - 1;
			sReturn += unescape('%' + nCharCode.toString(16));
		}
		else
			sReturn += sWords.charAt(i);
	}

	return sReturn;
}

function addDays(myDate,days) {
    return new Date(myDate.getTime() + days*24*60*60*1000);
}

function setfutureDate() {
    var futureDate = addDays(new Date(),14);
	document.formContact.MoveMonth.selectedIndex = futureDate.getMonth();
	document.formContact.MoveDay.selectedIndex = futureDate.getDate() -1;
	document.formContact.MoveYear.options[document.formContact.MoveYear.selectedIndex].value = futureDate.getYear();
}

function setMoveType()
{

	var nMType = document.formContact.MType.value;
	if (nMType == '1' || nMType == '2') {
//      if (navigator.userAgent.indexOf('MSIE')>=0)
   		document.getElementById("idMSize1").style.display = 'block';
		document.getElementById("idMSize1").style.visibility = 'visible';
	}
	else {
//      if (navigator.userAgent.indexOf('MSIE')>=0)
   		document.getElementById("idMSize1").style.display = 'none';
		document.getElementById("idMSize1").style.visibility = 'hidden';
	}
}

function setDefaults()
{
  setMoveType();
  setfutureDate();
}


var dtCh= "/";
var minYear=1900;
var maxYear=3000;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c < "0") || (c > "9")) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function setMonthDays()
{
	var optDay = document.formContact.MoveDay.options;
	var nMonth = document.formContact.MoveMonth.options[document.formContact.MoveMonth.selectedIndex].value;
	var nYear = document.formContact.MoveYear.options[document.formContact.MoveYear.selectedIndex].value;
	var nMaxDay;
	var i;
	var nCurrentDay = optDay.selectedIndex + 1;

	if (nMonth == 2)
	{	if (((nYear % 4 == 0) && (nYear % 100 != 0)) || (nYear % 400 == 0))
			nMaxDay = 29;
		else
			nMaxDay = 28;
	}
	else if (nMonth == 4 || nMonth == 30 || nMonth == 9 || nMonth == 11)
		nMaxDay = 30
	else
		nMaxDay = 31;

	if (nCurrentDay > nMaxDay)
		nCurrentDay = nMaxDay;

	optDay.length = 0;
	for (i=1; i<=nMaxDay; ++i)
	{	optDay[i-1] = new Option;
		optDay[i-1].text = i;
		optDay[i-1].value = i;
	}
	optDay.selectedIndex = nCurrentDay - 1;
}
