// surveyForm.js

function showCalendar(fieldName){
	var windowName = 'calendarWindow';
	window.open("/security/Calendar.jsp?fieldName=" + fieldName + "&formName=surveyForm", windowName, "width=200,height=270,menubar=yes,dependent=yes");
}

function showZipLookup(fieldName,cityName, stateName){
	var windowName = 'zipLookupWindow';
	window.open("/householdmove/action/zipLookUp.do?fieldName=" + fieldName + "&cityName=" + cityName + "&stateName=" + stateName + "&formName=surveyForm", windowName, "width=300,height=350,menubar=yes,dependent=yes");
}

function switchWeightUnits(type){
	if(document.surveyForm.weight.type == "text")
		return;
	var metricDisplay = new Array("Select...",
		"Less than 500 kg.",
		"501 to 1,000 kg.",
		"1,001 to 1,500 kg.",
		"1,501 to 2,000 kg.",
		"2,001 to 3,000 kg.",
		"3,001 to 4,000 kg.",
		"4,001 to 5,000 kg.",
		"5,001 to 6,000 kg.",
		"More than 6,000 kg.");
	var englishDisplay = new Array("Select...",
		"Less than 1,000 lb.",
		"1,000 to 2,000 lb.",
		"2,001 to 3,000 lb.",
		"3,001 to 4,000 lb.",
		"4,001 to 6,000 lb.",
		"6,001 to 8,000 lb.",
		"8,001 to 10,000 lb.",
		"10,001 to 12,000 lb.",
		"More than 12,000 lb." );
	var unitValues = new Array("0", "500", "1000", "2000", "3000", "4000", "6000", "8000", "10000", "14000" );

	if(type == 'Metric'){
		for(var i = 1; i < document.surveyForm.weight.options.length; i++)
			document.surveyForm.weight.options[i] = new Option(metricDisplay[i],unitValues[i]);
	}
	else{
		for(var i = 1; i < document.surveyForm.weight.options.length; i++)
			document.surveyForm.weight.options[i] = new Option(englishDisplay[i],unitValues[i]);
	}
}

function setSurveySource(){
	var cubes = document.surveyForm.cubes.value;
	var weight = document.surveyForm.weight.value;
	if((cubes != null && cubes.length > 0  && cubes != '0') ||	(weight != null && weight.length > 0 && weight.indexOf("Select") != -1 && weight != '0')){
			document.surveyForm.surveySourceCode.value = '01';
	}
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}


