var frm = document.forms['itemdonation'];
var focusfield;
function postFields(){
		frm.action.value='nopost'; 
		frm.submit();
		return true;
}

function noSubmit(){
		return false;
}
function doSubmit(){
		frm.submit();
		return true;
}

function validateItemDonor(){
	var ret = validateDonor();
	if (ret == "true"){
		showhide('donorinformation');
		showhide('iteminformation');
	}
	else{
		alert(ret);
	}
}

function validateGiftDonor(){
	var ret = validateDonor();
	if (ret == "true"){
		showhide('donorinformation');
		showhide('survey');
	}
	else{
		alert(ret);
	}
}

function validateDonor(){
	var good = true;
	var msg = "The following fields are required: "
	if (frm.First_Name.value==""){
		msg = msg + "First Name";
		good = false;
		document.getAcuElementById("lbl_First_Name").style.color='red';}
	if (frm.Last_Name.value==""){
		if (good){
			msg = msg + "Last Name";}
		else{
			msg = msg + ", Last Name";}
		good = false;
		document.getAcuElementById("lbl_Last_Name").style.color='red';} 
	if (frm.Address1.value==""){
		if (good){
			msg = msg + "Address";}
		else{
			msg = msg + ", Address";}
		good = false;
		document.getAcuElementById("lbl_Address1").style.color='red';} 
	if (frm.City.value==""){
		if (good){
			msg = msg + "City";}
		else{
			msg = msg + ", City";}
		good = false;
		document.getAcuElementById("lbl_City").style.color='red';} 
	if (frm.State.selectedIndex==0){
		if (good){
			msg = msg + "State";}
		else{
			msg = msg + ", State";}
		good = false;
		document.getAcuElementById("lbl_State").style.color='red';} 
	if (frm.Zip.value==""){
		if (good){
			msg = msg + "Zip";}
		else{
			msg = msg + ", Zip";}
		good = false;
		document.getAcuElementById("lbl_Zip").style.color='red';} 
	if (frm.Home_Phone.value==""){
		if (good){
			msg = msg + "Home Phone";}
		else{
			msg = msg + ", Home Phone";}
		document.getAcuElementById("lbl_Home_Phone").style.color='red';
		good = false;} 
	if (frm.Day_Phone.value==""){
		if (good){
			msg = msg + "Day Phone";}
		else{
			msg = msg + ", Day Phone";}
		good = false;
		document.getAcuElementById("lbl_Day_Phone").style.color='red';} 
	if (frm.Best_Time_To_Call.value==""){
		if (good){
			msg = msg + "Best Time to Call";}
		else{
			msg = msg + ", Best Time to Call";}
		good = false;
		document.getAcuElementById("lbl_Best_Time_To_Call").style.color='red';} 
	if (frm.donationtype.selectedIndex==0){
		if (good){
			msg = msg + "Donation Type";}
		else{
			msg = msg + ", Donation Type";}
		good = false;
		document.getAcuElementById("lbl_Donation_Type").style.color='red';} 
	if (good){
		return "true";}
	
	else{
		return msg;}
}

function validateBoat(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_location_zipcode.value==""){
		msg = msg + "Zipcode";
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';}
	if (frm.item_length.value==""){
		if (good){
			msg = msg + "Length";}
		else{
			msg = msg + ", Length";}
		good = false;
		document.getAcuElementById("lbl_item_length").style.color='red';}
	if (frm.item_year.value==""){
		if (good){
			msg = msg + "Year";}
		else{
			msg = msg + ", Year";}
		good = false;
		document.getAcuElementById("lbl_item_year").style.color='red';} 
	if (frm.item_other_material.selectedIndex==0 && frm.item_material.value==""){
		if (good){
			msg = msg + "Hull Material";}
		else{
			msg = msg + ", Hull Material";}
		good = false;
		document.getAcuElementById("lbl_item_material").style.color='red';}
	else {
		if (frm.item_other_material.value!="other"){
			frm.item_material.value=frm.item_other_material.value;
		}
	} 
	for (var i=0; i<frm.condition_has_trailer.length; i++)  {
		if (frm.condition_has_trailer[i].checked)  {
			found_it = frm.condition_has_trailer[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Has a Trailer";}
		else{
				msg = msg + ", Has a Trailer";}
		good = false;
		document.getAcuElementById("lbl_condition_has_trailer").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_has_motor.length; i++)  {
		if (frm.condition_has_motor[i].checked)  {
			found_it = frm.condition_has_motor[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Has a Motor";}
		else{
				msg = msg + ", Has a Motor";}
		good = false;
		document.getAcuElementById("lbl_condition_has_motor").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';} 
		
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateCycle(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_location_zipcode.value==""){
		msg = msg + "Zipcode";
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';}
	if (frm.item_year.value==""){
		if (good){
			msg = msg + "Year";}
		else{
			msg = msg + ", Year";}
		good = false;
		document.getAcuElementById("lbl_item_year").style.color='red';} 
	if (frm.item_make.value==""){
		if (good){
			msg = msg + "Make";}
		else{
			msg = msg + ", Make";}
		good = false;
		document.getAcuElementById("lbl_item_make").style.color='red';} 
	if (frm.item_model.value==""){
		if (good){
			msg = msg + "Model";}
		else{
			msg = msg + ", Model";}
		good = false;
		document.getAcuElementById("lbl_item_model").style.color='red';} 
	if (frm.item_mileage.value==""){
		if (good){
			msg = msg + "Mileage";}
		else{
			msg = msg + ", Mileage";}
		good = false;
		document.getAcuElementById("lbl_item_mileage").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_operable.length; i++)  {
		if (frm.condition_is_operable[i].checked)  {
			found_it = frm.condition_is_operable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Running";}
		else{
				msg = msg + ", If Running";}
		good = false;
		document.getAcuElementById("lbl_condition_is_operable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_drivable.length; i++)  {
		if (frm.condition_is_drivable[i].checked)  {
			found_it = frm.condition_is_drivable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Driveable";}
		else{
				msg = msg + ", If Driveable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_drivable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';} 
	
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateVehicle(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_location_zipcode.value==""){
		msg = msg + "Zipcode";
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';}
	if (frm.item_year.value==""){
		if (good){
			msg = msg + "Year";}
		else{
			msg = msg + ", Year";}
		good = false;
		document.getAcuElementById("lbl_item_year").style.color='red';} 
	if (frm.item_make.value==""){
		if (good){
			msg = msg + "Make";}
		else{
			msg = msg + ", Make";}
		good = false;
		document.getAcuElementById("lbl_item_make").style.color='red';} 
	if (frm.item_model.value==""){
		if (good){
			msg = msg + "Model";}
		else{
			msg = msg + ", Model";}
		good = false;
		document.getAcuElementById("lbl_item_model").style.color='red';} 
	if (frm.item_mileage.value==""){
		if (good){
			msg = msg + "Mileage";}
		else{
			msg = msg + ", Mileage";}
		good = false;
		document.getAcuElementById("lbl_item_mileage").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_specialty.length; i++)  {
		if (frm.condition_is_specialty[i].checked)  {
			found_it = frm.condition_is_specialty[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Specialty Item";}
		else{
				msg = msg + ", Specialty Item";}
		good = false;
		document.getAcuElementById("lbl_condition_is_specialty").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_operable.length; i++)  {
		if (frm.condition_is_operable[i].checked)  {
			found_it = frm.condition_is_operable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Running";}
		else{
				msg = msg + ", If Running";}
		good = false;
		document.getAcuElementById("lbl_condition_is_operable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_drivable.length; i++)  {
		if (frm.condition_is_drivable[i].checked)  {
			found_it = frm.condition_is_drivable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Driveable";}
		else{
				msg = msg + ", If Driveable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_drivable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';} 
			
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateAirplane(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_location_zipcode.value==""){
		msg = msg + "Zipcode";
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';}
	if (frm.item_year.value==""){
		if (good){
			msg = msg + "Year";}
		else{
			msg = msg + ", Year";}
		good = false;
		document.getAcuElementById("lbl_item_year").style.color='red';} 
	if (frm.item_make.value==""){
		if (good){
			msg = msg + "Make";}
		else{
			msg = msg + ", Make";}
		good = false;
		document.getAcuElementById("lbl_item_make").style.color='red';} 
	if (frm.item_model.value==""){
		if (good){
			msg = msg + "Model";}
		else{
			msg = msg + ", Model";}
		good = false;
		document.getAcuElementById("lbl_item_model").style.color='red';} 
	if (frm.item_sub_type.value==""){
		if (good){
			msg = msg + "Type";}
		else{
			msg = msg + ", Type";}
		good = false;
		document.getAcuElementById("lbl_item_sub_type").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_operable.length; i++)  {
		if (frm.condition_is_operable[i].checked)  {
			found_it = frm.condition_is_operable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Operational";}
		else{
				msg = msg + ", Operational";}
		good = false;
		document.getAcuElementById("lbl_condition_is_operable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';} 
			
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateJewelry(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';} 
			
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateMisc(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_sub_type.value==""){
		msg = msg + "Donation Type";
		good = false;
		document.getAcuElementById("lbl_item_sub_type").style.color='red';}
	found_it = null;
	for (var i=0; i<frm.condition_is_operable.length; i++)  {
		if (frm.condition_is_operable[i].checked)  {
			found_it = frm.condition_is_operable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Operable";}
		else{
				msg = msg + ", Operable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_operable").style.color='red';} 
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateIndustrial(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_sub_type.value==""){
		msg = msg + "Donation Type";
		good = false;
		document.getAcuElementById("lbl_item_sub_type").style.color='red';}
	found_it = null;
	for (var i=0; i<frm.condition_is_operable.length; i++)  {
		if (frm.condition_is_operable[i].checked)  {
			found_it = frm.condition_is_operable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Operable";}
		else{
				msg = msg + ", Operable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_operable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';}
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}


function validateRV(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: "
	if (frm.item_location_zipcode.value==""){
		msg = msg + "Zipcode";
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';}
	if (frm.item_sub_type.selectedIndex==0){
		if (good){
			msg = msg + "Type";}
		else{
			msg = msg + ", Type";}
		good = false;
		document.getAcuElementById("lbl_item_sub_type").style.color='red';}  
	found_it = null;
	for (var i=0; i<frm.condition_is_roadworthy.length; i++)  {
		if (frm.condition_is_roadworthy[i].checked)  {
			found_it = frm.condition_is_roadworthy[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Operable";}
		else{
				msg = msg + ", If Operable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_roadworthy").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_is_towable.length; i++)  {
		if (frm.condition_is_towable[i].checked)  {
			found_it = frm.condition_is_towable[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "If Towable";}
		else{
				msg = msg + ", If Towable";}
		good = false;
		document.getAcuElementById("lbl_condition_is_towable").style.color='red';} 
	found_it = null;
	for (var i=0; i<frm.condition_will_deduct.length; i++)  {
		if (frm.condition_will_deduct[i].checked)  {
			found_it = frm.condition_will_deduct[i].value;}}
	if(!found_it){ 
		if (good){
				msg = msg + "Tax deduction";}
		else{
				msg = msg + ", Tax deduction";}
		good = false;
		document.getAcuElementById("lbl_condition_will_deduct").style.color='red';} 
	if (frm.item_expected_deduction.selectedIndex==0){
		if (good){
			msg = msg + "Estimated Value";}
		else{
			msg = msg + ", Estimated Value";}
		good = false;
		document.getAcuElementById("lbl_item_expected_deduction").style.color='red';}
		
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function validateLand(){
	var good = true;
	var found_it;
	var msg = "The following fields are required: ";
	if (frm.item_other_sub_type.selectedIndex==0 && frm.item_sub_type.value==""){
		if (good){
			msg = msg + "Property Type";}
		else{
			msg = msg + ", Property Type";}
		good = false;
		document.getAcuElementById("lbl_item_sub_type").style.color='red';} 
	else {
		if (frm.item_other_sub_type.value!="other"){
			frm.item_sub_type.value=frm.item_other_sub_type.value;}
	}
	if (frm.item_city.value==""){
		if (good){
			msg = msg + "City";}
		else{
			msg = msg + ", City";}
		good = false;
		document.getAcuElementById("lbl_item_city").style.color='red';} 
	if (frm.item_state.selectedIndex==0){
		if (good){
			msg = msg + "State";}
		else{
			msg = msg + ", State";}
		good = false;
		document.getAcuElementById("lbl_item_state").style.color='red';} 
	if (frm.item_location_zipcode.value==""){
		if (good){
			msg = msg + "Zip";}
		else{
			msg = msg + ", Zip";}
		good = false;
		document.getAcuElementById("lbl_item_location_zipcode").style.color='red';} 
	if (good){
		showhide('survey');
		showhide('iteminformation');}
	else{
		alert(msg);}
}

function isNumeric(val, text, len, id){
	if (isNaN(val.value)){
		alert(text);
		val.value="";
		if (id.length > 0) 
		{focusfield = document.getAcuElementById(id);
		var timer = setTimeout("focusfield.focus();", 50);}
		return false;}
	else{
		if (len > 0 && val.value.length != len)
			{
			alert(text);
			val.value="";
			if (id.length > 0) 
			{focusfield = document.getAcuElementById(id);
			var timer = setTimeout("focusfield.focus();", 50);}
			return false;}
		else
			{return true;}}
}

/********Monetary Donations*****/
function validatePaypal(frm){
	var msg = checkRequiredLblFields(frm, ['firstname','lastname','address','city','statecode','postalcode','nightphone','dayphone','bestcall','email','donationarea'], ['First Name','Last Name','Address','City','State','Zip','Home Phone','Day Phone','Best Time to Call','E-mail','Donation Area']);
	if (frm.recur.value == '0'){
		if((frm["amount"].value == "" || frm["amount"].selectedIndex ==0) && frm["other"].value == ""){
			document.getAcuElementById("lbl_amount").style.color='red';
			msg=msg + "Donation Amount \n";
		}
	}
	else{
		msg = msg + checkRequiredLblFields(frm, ['recuramount', 'frequency', 'payments'], ['Donation Amount', 'Frequency', 'Number of Payments']);
	}
	if (msg.length == 0){
		return true;}
	else{
		alert("The following fields are required: \n" + msg);
		return false;}
}

function changeDonationType(frm, val){
	frm.recur.value=val;
	if (val ==0){
	document.getElementById("recurringdonation").className ="off";
	document.getElementById("singledonation").className ="on";
	}else{
	document.getElementById("recurringdonation").className ="on";
	document.getElementById("singledonation").className ="off";
	}
	document.forms.paypaldonate.amount.selectedIndex = 0;
	document.forms.paypaldonate.recuramount.selectedIndex = 0;
	document.forms.paypaldonate.frequency.selectedIndex = 0;
	document.forms.paypaldonate.payments.selectedIndex = 0;
	document.getAcuElementById("estdonation").innerHTML = "";
	
}

function updateEstimate(){
	var totalval = document.forms.paypaldonate.recuramount.value * document.forms.paypaldonate.payments.value
	if (totalval > 0){
		document.getAcuElementById("estdonation").innerHTML = totalval;}
	else
		{document.getAcuElementById("estdonation").innerHTML = "";}
}