
		function gaincalc(){
		var xnab =(pform.price.value*1) + (pform.improvements.value*1)-(pform.depreciation.value*1);    
    	var capitalgain = (pform.salesprice.value*1) - xnab - (pform.costsofsale.value*1);
		var fedcapgain=(capitalgain - pform.depreciation.value) * .15;
		if (fedcapgain < 0) {fedcapgain = 0;}
		var depRecapture;
		if (pform.depreciation.value > capitalgain)
		{
			depRecapture = capitalgain * .25;
		}
		else
		{
			depRecapture = pform.depreciation.value * .25;
		}
		var statecapgain=(pform.rate.value*1/100)*capitalgain;
		document.pform.xnab.value = xnab;
		document.pform.depRecapture.value = depRecapture;
		document.pform.xnab2.value = xnab;
		document.pform.capitalgain.value = capitalgain;
		document.pform.fedcapgain.value = fedcapgain;
		document.pform.statecapgain.value = statecapgain;
		document.pform.taxesdue.value=fedcapgain+ statecapgain + depRecapture;
	}
	function emailCheck (emailStr)
	{
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
		{
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
		}
	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null)
		{
    	alert("The username doesn't seem to be valid.");
    	return false;
		}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
		{
    	for (var i=1;i<=4;i++)
			{
	    	if (IPArray[i]>255)
				{
	        	alert("Destination IP address is invalid!");
				return false;
	    		}
    		}
    	return true;
		}
	var domainArray=domain.match(domainPat)
	if (domainArray==null)
		{
		alert("The domain name doesn't seem to be valid.");
    	return false;
		}
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
		{
   		alert("The address must end in a three-letter domain, or two letter country.");
		return false;
		}
	if (len<2)
		{
   		var errStr="This address is missing a hostname!";
		alert(errStr);
		return false;
		}
	return true;
	}
	function CheckContact()
		{
		var error = 0;
		var errormsg = "Please check the following items.";
		if (document.ContactForm.sname.value == "")
			{
			var error = 1;
			var errormsg = errormsg + "\n - Name";
			}
		if (document.ContactForm.semail.value == "")
			{
			var error = 1;
			var errormsg = errormsg + "\n - Email";
			}
		if (error == 1)
			{
			alert(errormsg);
			return false;
			}
		else
			{
			return true;
			}
		};

function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }


function _CF_hasValue(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}

function  _CF_checkCFForm_1(_CF_this)
    {
    if  (!_CF_hasValue(_CF_this.Name, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Name, _CF_this.Name.value, "You must enter your name!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Address, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Address, _CF_this.Address.value, "You must enter your address!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.City, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.City, _CF_this.City.value, "You must enter your city!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.State, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.State, _CF_this.State.value, "You must enter your state!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.zip, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.zip, _CF_this.zip.value, "You must enter your Zip/Postal Code!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.HomePhone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.HomePhone, _CF_this.HomePhone.value, "You must enter your home phone number"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.email, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "You must enter your e-mail address!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.ClosingDate, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.ClosingDate, _CF_this.ClosingDate.value, "You must enter the closing date!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.ContractDate, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.ContractDate, _CF_this.ContractDate.value, "You must enter the contract date!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.Customername, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.Customername, _CF_this.Customername.value, "You must enter the customer's name as it appears on title commitment!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.buyername, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.buyername, _CF_this.buyername.value, "You must enter the buyer's name as it appears on title commitment!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.ClosingAgent, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.ClosingAgent, _CF_this.ClosingAgent.value, "You must enter the name of the closing agent!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.TitleCompany, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.TitleCompany, _CF_this.TitleCompany.value, "You must enter the name of the title company!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.FileNumber, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.FileNumber, _CF_this.FileNumber.value, "You must enter file number from the title company!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.ClosingAgentPhone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.ClosingAgentPhone, _CF_this.ClosingAgentPhone.value, "You must enter the phone number for closing agent"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.PropertyAddress, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.PropertyAddress, _CF_this.PropertyAddress.value, "You must enter the property address!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.PropertyCity, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.PropertyCity, _CF_this.PropertyCity.value, "You must enter the property city!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.PropertyState, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.PropertyState, _CF_this.PropertyState.value, "You must enter the property State!"))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.PropertyZip, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.PropertyZip, _CF_this.PropertyZip.value, "You must enter the property Zip/Postal Code!"))
            {
            return false; 
            }
        }

    return true;
    }
