﻿function aipChk(target_form)
{	
	if ( confirm(" Total Price is $ " + target_form.total.value + ".  Right?") )
	{
		if( check_aip(target_form) )
		{
			target_form.action = "../formmail/aipMailEng.asp";
			target_form.submit();

			return true;
		}
		else
		{
			return false;
		}
	}

	return false;
}

function check_aip(target_form)
{
	if (!target_form.icompany.value)
	{
		alert("[Invoice Address - Company name] is Empty!");
		target_form.icompany.focus();

		return false;
	}

	if (!target_form.in_attention.value)
	{
		alert("[Invoice Address - Attention]  is Empty!");
		target_form.in_attention.focus();

		return false;
	}

	if (!target_form.in_address.value)
	{
		alert("[Invoice Address - Address]  is Empty!");
		target_form.in_address.focus();

		return false;
	}

	if (!target_form.in_tel1.value)
	{
		alert("[Invoice Address - Telephone]  is Empty!");
		target_form.in_tel1.focus();

		return false;
	}

	if (!target_form.in_tel2.value)
	{
		alert("[Invoice Address - Telephone]  is Empty!");
		target_form.in_tel2.focus();

		return false;
	}

	if (!target_form.in_tel3.value)
	{
		alert("[Invoice Address - Telephone]  is Empty!");
		target_form.in_tel3.focus();

		return false;
	}

	if (!target_form.in_fax_1.value)
	{
		alert("[Invoice Address - FAX]  is Empty!");
		target_form.in_fax_1.focus();

		return false;
	}

	if (!target_form.in_fax_2.value)
	{
		alert("[Invoice Address - FAX]  is Empty!");
		target_form.in_fax_2.focus();

		return false;
	}

	if (!target_form.in_fax_3.value)
	{
		alert("[Invoice Address - FAX]  is Empty!");
		target_form.in_fax_3.focus();

		return false;
	}

	if (!target_form.iemail.value)
	{
		alert("[Invoice Address - E-mail]  is Empty!");
		target_form.iemail.focus();
//target_form.in_email.focus();
		return false;
	}



	if (!target_form.de_company.value)
	{
		alert("[Delivery Address - Company name]  is Empty!.");
		target_form.de_company.focus();

		return false;
	}

	if (!target_form.de_attention.value)
	{
		alert("[Delivery Address - Attention]  is Empty!");
		target_form.de_attention.focus();

		return false;
	}

	if (!target_form.de_address.value)
	{
		alert("[Delivery Address - Address]  is Empty!");
		target_form.de_address.focus();

		return false;
	}

	if (!target_form.de_tel_1.value)
	{
		alert("[Delivery Address - Telephone]  is Empty!.");
		target_form.de_tel_1.focus();

		return false;
	}

	if (!target_form.de_tel_2.value)
	{
		alert("[Delivery Address - Telephone]  is Empty!");
		target_form.de_tel_2.focus();

		return false;
	}

	if (!target_form.de_tel_3.value)
	{
		alert("[Delivery Address - Telephone]  is Empty!");
		target_form.de_tel_3.focus();

		return false;
	}

	if (!target_form.de_fax_1.value)
	{
		alert("[Delivery Address - FAX]  is Empty!");
		target_form.de_fax_1.focus();

		return false;
	}

	if (!target_form.de_fax_2.value)
	{
		alert("[Delivery Address - FAX]  is Empty!");
		target_form.de_fax_2.focus();

		return false;
	}

	if (!target_form.de_fax_3.value)
	{
		alert("[Delivery Address - FAX]  is Empty!");
		target_form.de_fax_3.focus();

		return false;
	}

	if (!target_form.de_email.value)
	{
		alert("[Delivery Address - E-mail]  is Empty!.");
		target_form.de_email.focus();

		return false;
	}

	return true;
}


function sameClick(target_form)
{
	if( target_form.same.checked )
	{
		same_aip(target_form)
	}
}

function same_aip(target_form)
{
	target_form.de_company.value	= target_form.icompany.value;
	target_form.de_attention.value	= target_form.in_attention.value;
	target_form.de_address.value	= target_form.in_address.value;
	target_form.de_tel_1.value			= target_form.in_tel1.value;
	target_form.de_tel_2.value			= target_form.in_tel2.value;
	target_form.de_tel_3.value			= target_form.in_tel3.value;
	target_form.de_fax_1.value		= target_form.in_fax_1.value;
	target_form.de_fax_2.value		= target_form.in_fax_2.value;
	target_form.de_fax_3.value		= target_form.in_fax_3.value;
	target_form.de_email.value		= target_form.iemail.value;
}

function cal_sum(target_item, target_price, target_sum, target_form)
{
	target_sum.value = parseFloat( target_item.value ) *  parseFloat( target_price.value ) ;

	target_form.total.value	= parseFloat( target_form.sum01.value ) 
										+ parseFloat( target_form.sum02.value ) 
										+ parseFloat( target_form.sum03.value ) 
										+ parseFloat( target_form.sum04.value );
}