var radio_choice = false;



function Validator(theForm)

{

	

  if (theForm.t.value == "")

  {

    alert("Please enter a value for the \"First Name\" field.");

    theForm.t.focus();

    return (false);

  }

  

  if (theForm.t2.value == "")

  {

    alert("Please enter a value for the \"Last Name\" field.");

    theForm.t2.focus();

    return (false);

  }

  

  if (theForm.t3.value == "")

  {

    alert("Please enter a value for the \"Email Address\" field.");

    theForm.t3.focus();

    return (false);

  }

  

  if (theForm.t7.value == "")

  {

    alert("Please enter a value for the \"Home Phone\" field.");

    theForm.t7.focus();

    return (false);

  }



  if (theForm.t12.value < 0)

  {

    alert("Please select one of the \"Dates\" options.");

    theForm.t12.focus();

    return (false);

  }

  

  if (theForm.t13.value < 0)

  {

    alert("Please select one of the \"Months\" options.");

    theForm.t13.focus();

    return (false);

  }

  

  if (theForm.t14.value < 0)

  {

    alert("Please select one of the \"Years\" options.");

    theForm.t14.focus();

    return (false);

  }

  

  if (theForm.t15.value == "")

  {

    alert("Please enter a value for the \"Address From\" field.");

    theForm.t15.focus();

    return (false);

  }

  

  if (theForm.t16.value == "")

  {

    alert("Please enter a value for the \"City From\" field.");

    theForm.t16.focus();

    return (false);

  }  

  

  if (theForm.t17.value < 0)

  {

    alert("Please select one of the \"State You Are Moving From\" options.");

    theForm.t17.focus();

    return (false);

  }

  

  if (theForm.t24.value < 0)

  {

    alert("Please select one of the \"State You Are Moving To\" options.");

    theForm.t24.focus();

    return (false);

  }

  

  

  if (theForm.t18.value == "")

  {

    alert("Please enter a value for the \"Zip From\" field.");

    theForm.t18.focus();

    return (false);

  }

   

  if (theForm.t22.value == "")

  {

    alert("Please enter a value for the \"Address To\" field.");

    theForm.t22.focus();

    return (false);

  }

  

  if (theForm.t23.value == "")

  {

    alert("Please enter a value for the \"City To\" field.");

    theForm.t23.focus();

    return (false);

  }  

  

  if (theForm.t25.value == "")

  {

    alert("Please enter a value for the \"Zip To\" field.");

    theForm.t25.focus();

    return (false);

  }

  

  if (theForm.t19.value < 0)

  {

    alert("Please select one of the \"Size of Appartment (From)\" options.");

    theForm.t19.focus();

    return (false);

  }

  

  if (theForm.t26.value < 0)

  {

    alert("Please select one of the \"Size of Appartment (To)\" options.");

    theForm.t26.focus();

    return (false);

  }

  

  get_radio_value(theForm.t20); 

  if (!radio_choice)

  {

    alert("Please enter a value for the \"Elevator (From)\" field.");

	theForm.t26.focus();

    return (false);

  }  

  

  get_radio_value(theForm.t27);

  if (!radio_choice)

  {

    alert("Please enter a value for the \"Elevator (To)\" field.");

	theForm.t26.focus();

    return (false);

  }   

  

  if (theForm.t21.value == "")

  {

    alert("Please enter a value for the \"Number of Floors (From)\" field.");

    theForm.t21.focus();

    return (false);

  }  

  

  if (theForm.t28.value == "")

  {

    alert("Please enter a value for the \"Number of Floors  (To)\" field.");

    theForm.t28.focus();

    return (false);

  }  

  

  if (theForm.t32.value == "")

  {

    alert("Please answer how did you hear about us");

    theForm.t32.focus();

    return (false);

  }  



  return (true);  

}



function get_radio_value(field)

{

	radio_choice = false;

	for (var i=0; i < field.length; i++)

    {

	   if (field[i].checked)

	   {

		   radio_choice = true;

	   }

    }

}



function AddItem(){

	//debugger

		if (document.forms[0].ItemID == '')

		{	window.alert('Please select an item from the list'); exit; }

		var sel=document.forms[0].ItemID

		var opt=sel.options

		var ind=sel.selectedIndex

		var selItem=opt[ind]

		if (selItem.value=="0"){

			return

		}

		var qty=document.forms[0].qty.value

		var inv=document.forms[0].inventory.value

		var item=selItem.text

		j=document.forms[0].inventory.options.length+1

		k=j-1

		document.forms[0].inventory.options.length=j

		document.forms[0].inventory.options[k].text=qty+" "+item+"(s)"

		j++

		k++

		QF()

		document.forms[0].qty.value=1

		MakeList()

	}



	function RemoveItem(){

	//debugger

		var sel=document.forms[0].inventory

		var opt=sel.options

		var len=opt.length

		var ind=sel.selectedIndex

		var selItem=opt[ind]

		var val=selItem.value

		var rest

		id=(val.substring(0,val.indexOf(";")))

		rest=val.substring(id.length+1,val.length)

		var cuft

		cuft=eval(rest)



		while(ind<len-1){

			opt[ind].value=opt[ind+1].value

			opt[ind].text=opt[ind+1].text

			ind++

		}



		j=document.forms[0].inventory.options.length

		k=j-1

		document.forms[0].inventory.options.length=document.forms[0].inventory.options.length-1

		document.forms[0].totcuft.value=eval(document.forms[0].totcuft.value)-cuft

		document.forms[0].totlbs.value=document.forms[0].totcuft.value*7

		MakeList()

	}



function QF(){

//debugger

		var sel=document.forms[0].ItemID

		

		var totcf=eval(document.forms[0].totcuft.value)

		

		var opt=sel.options

		

		var ind=sel.selectedIndex

		var selItem=opt[ind]

		var SelVal=selItem.value

		var SelText=selItem.text

			

		

		var SelValArr=SelVal.split(";")

		var SelID=parseInt(SelValArr[0])

		var SelQty=document.forms[0].qty.value		

		var SelCuFt=parseInt(SelValArr[1])

			

		var totcfStr=document.forms[0].totcuft.value

		var totcf1=parseInt(totcfStr)

		var totcf1=totcf1+(SelCuFt * SelQty)

		var totlbs=totcf1*7

		

		var CuFtQty=SelCuFt*SelQty

				

		document.forms[0].totcuft.value=totcf1

		document.forms[0].totlbs.value=totlbs

		document.forms[0].inventory.options[k-1].value=SelID+";"+CuFtQty

		

	}	



function MakeList() {

		document.forms[0].items.value=""

		

		var sel=document.forms[0].inventory

		var opt=sel.options

		var len=opt.length

		var i=0

		var val=""

		var rest=""

		var qty=0

		var txt=""

		

		var SelValArr

		var SelID

		var SelQty

		var SelCuFt

		

		while(i<len)

		  {

			val=opt[i].value			

			SelValArr=val.split(";")

			SelID=parseInt(SelValArr[0])

			SelCuFt=parseInt(SelValArr[1])

			

			

			txt=opt[i].text

			qty=txt.substring(0,txt.indexOf(" "))

		//	document.forms[0].items.value=document.forms[0].items.value+SelID+":"+qty+";"

		document.forms[0].items.value=document.forms[0].items.value+txt+":"+qty+";<br>"

			i++

			

		  }

	}	




