//Validate WTB equipment submission form.

function validateWTBequip(){
	alrtCode = "";
		if (document.WTBform.Category.value == ""){
			alrtCode = alrtCode += "\n  -  Category must be provided";
		 }
		if (document.WTBform.Manufacturer.value == ""){
			alrtCode = alrtCode += "\n  -  Manufacturer must be provided";
		 }
		if (document.WTBform.Model.value == ""){
			alrtCode = alrtCode += "\n  -  Model must be provided";
		 }
		if (document.WTBform.description.value == ""){
			alrtCode = alrtCode += "\n  -  Description must be provided";
		 }			 		 		 
		if (document.WTBform.Price_From.value.indexOf(",") != -1 ||
			document.WTBform.Price_From.value.indexOf(".") != -1 ||
			document.WTBform.Price_From.value.indexOf("-") != -1 ||
			document.WTBform.Price_From.value.indexOf("\\") != -1 ||
			document.WTBform.Price_From.value.indexOf("/") != -1){
			alrtCode = alrtCode += "\n  -  Price From can not contain punctuation";
		}
			if (document.WTBform.Price_To.value.indexOf(",") != -1 ||
			document.WTBform.Price_To.value.indexOf(".") != -1 ||
			document.WTBform.Price_To.value.indexOf("-") != -1 ||
			document.WTBform.Price_To.value.indexOf("\\") != -1 ||
			document.WTBform.Price_To.value.indexOf("/") != -1){
			alrtCode = alrtCode += "\n  -  Price To can not contain punctuation";
		}		
		if (alrtCode != ""){
			alrtCode ="____________________________________\n" +
			"You failed to correctly fill in the following field(s):\n" +
			alrtCode + "\n__________________________________" +
			"\nWe can not process your Equipment Entry\nwithout this information.\n\nPlease edit the form and submit again!";
			
			alert(alrtCode);
			return false;
		}
		else
		return true;
}

function ValidateEquipment(){
	alrtCode = "";
	/* venu added this to for external customers need add only serial num or year for a new record*/
		if (document.ADDEDITEQUIP.button1.value == "Create New Record") {
		 var eitherone =0;
			if (document.ADDEDITEQUIP.MFGYR.value != "") {
			 	eitherone =1;
			 	today = new Date();
			 	CurYear = today.getYear();
			 	NxtYear = CurYear + 1;
				//alert(document.ADDEDITEQUIP.MFGYR.value + ' ' + NxtYear);
				if (document.ADDEDITEQUIP.MFGYR.value < 1899 || document.ADDEDITEQUIP.MFGYR.value > NxtYear)
				{	//alert(document.ADDEDITEQUIP.MFGYR.value + ' ' + NxtYear);
				alrtCode = alrtCode += "\n  -  Year must be between 1899 and " + NxtYear + " ";
				}
				if (isNaN(parseFloat(document.ADDEDITEQUIP.MFGYR.value)) || 
				document.ADDEDITEQUIP.MFGYR.value.length != 4){
				alrtCode = alrtCode += "\n  -  Year must be a four digit number";
				}
		
				if (document.ADDEDITEQUIP.MFGYR.value.indexOf(",") != -1 ||
					document.ADDEDITEQUIP.MFGYR.value.indexOf(".") != -1 ||
					document.ADDEDITEQUIP.MFGYR.value.indexOf("-") != -1 ||
					document.ADDEDITEQUIP.MFGYR.value.indexOf("\\") != -1 ||
					document.ADDEDITEQUIP.MFGYR.value.indexOf("/") != -1){
					alrtCode = alrtCode += "\n  -  Year can not contain punctuation";
				}
			}
			/*
			if (document.ADDEDITEQUIP.SERIALNBR.value != "") {
			 eitherone =1;
			}
			if (eitherone ==0){
				alrtCode = alrtCode += "\n  - Please add either a Year or Serial number";
			}
			*/
			
		}
	
		if (document.ADDEDITEQUIP.MFGCODE.value == ""){
			alrtCode = alrtCode += "\n  -  Manufacturer must be provided";
		 }
		/*
		if (document.ADDEDITEQUIP.MODEL.value == ""){
			alrtCode = alrtCode += "\n  -  Model must be provided";
		}
		*/
		
		/*if (document.ADDEDITEQUIP.PRICE.value == 0){
			alrtCode = alrtCode += "\n  -  Asking Price must be provided";
		}*/
		
		/*today = new Date();
		CurYear = today.getYear();
		NxtYear = CurYear + 1;*/
		/*Added code to check for submit button. If = Update Record then do not validate year*/
		/*if (document.ADDEDITEQUIP.button1.value != "Update Record"  )
		{
		if (document.ADDEDITEQUIP.MFGYR.value < 1899 || document.ADDEDITEQUIP.MFGYR.value > NxtYear){
			alrtCode = alrtCode += "\n  -  Year must be between 1899 and " + NxtYear + " ";
		}
		
		if (isNaN(parseFloat(document.ADDEDITEQUIP.MFGYR.value)) || 
			document.ADDEDITEQUIP.MFGYR.value.length != 4){
			alrtCode = alrtCode += "\n  -  Year must be a four digit number";
		}
		
		if (document.ADDEDITEQUIP.MFGYR.value.indexOf(",") != -1 ||
			document.ADDEDITEQUIP.MFGYR.value.indexOf(".") != -1 ||
			document.ADDEDITEQUIP.MFGYR.value.indexOf("-") != -1 ||
			document.ADDEDITEQUIP.MFGYR.value.indexOf("\\") != -1 ||
			document.ADDEDITEQUIP.MFGYR.value.indexOf("/") != -1){
			alrtCode = alrtCode += "\n  -  Year can not contain punctuation";
		}
		}*/
			
		if (document.ADDEDITEQUIP.PRICE.value.indexOf(",") != -1 ||
			document.ADDEDITEQUIP.PRICE.value.indexOf(".") != -1 ||
			document.ADDEDITEQUIP.PRICE.value.indexOf("-") != -1 ||
			document.ADDEDITEQUIP.PRICE.value.indexOf("\\") != -1 ||
			document.ADDEDITEQUIP.PRICE.value.indexOf("/") != -1){
			alrtCode = alrtCode += "\n  -  Price can not contain punctuation";
		}
			
		if (alrtCode != ""){
			alrtCode ="____________________________________\n" +
			"You failed to correctly fill in the following field(s):\n" +
			alrtCode + "\n__________________________________" +
			"\nWe can not process your Equipment Entry\nwithout th(is/ese) field(s)\n\nPlease edit the form and submit again!";
			
			alert(alrtCode);
			document.ADDEDITEQUIP.MFGCODE.focus();
			return false;
		}
		else
		return true;
}
