/* store.js
 *
 * Java scripts function that will be used in Store section.
 * 
 */

function populateAddress()
{
	if(document.billingdata.copy.checked == true)
	{
		document.billingdata.bill_address.value = document.billingdata.ship_address.value;
		document.billingdata.bill_city.value    = document.billingdata.ship_city.value;
		document.billingdata.bill_state.value   = document.billingdata.ship_state.value;
		document.billingdata.bill_zip.value     = document.billingdata.ship_zip.value;
		document.billingdata.bill_phone.value   = document.billingdata.ship_phone.value;
		var selectCountry   = YUI.get("bill_country"); 
		selectCountry.value = document.billingdata.ship_country.value;
	}
	else
	if(document.billingdata.copy.checked == false)
	{
		document.billingdata.bill_address.value         = '';
		document.billingdata.bill_city.value            = '';
		document.billingdata.bill_state.value           = '';
		document.billingdata.bill_country.value         = '';
		document.billingdata.bill_zip.value             = '';
		document.billingdata.bill_phone.value           = '';
		document.billingdata.bill_country.selectedIndex = 0;
	}
}
function process_popup(service_id)
{
	var xml_path = '/en_US/xml/8.8_en_US/store/assets/process_' + service_id + '.xml';
	dialogFromTemplate(xml_path);
}

function learn_popup(service_id)
{
	var xml_path = '/en_US/xml/8.8_en_US/store/assets/learn_' + service_id + '.xml';
	dialogFromTemplate(xml_path);
}

function calculate_total_amount()
{
	var employee_count = YUI.get('number_of_employees').value;
	var total_amount;
	if (employee_count > 0 && employee_count <= 24)
	{
		total_amount = employee_count * 19.95;
	}
	else if (employee_count > 24 && employee_count <= 49)
	{
		total_amount = employee_count * 18.99;
	}
	else if (employee_count > 49 && employee_count <= 99)
	{
		total_amount = employee_count * 17.99;
	}
	else if (employee_count > 99 && employee_count <= 249)
	{
		total_amount = employee_count * 15.99;
	}
	else if (employee_count > 249 && employee_count <= 499)
	{
		total_amount = employee_count * 12.99;
	}
	else if (employee_count > 499 && employee_count <= 999)
	{
		total_amount = employee_count * 8.99;
	}
	else if (employee_count > 999)
	{
		total_amount = employee_count * 3.99;
	}
	YUI.get('total_amount').innerHTML="Total amount to be paid : "+total_amount;
	YUI.get('purchase_paypal_link').href="/store/paypal?service_id=1006&number_of_employees="+employee_count;
	return;
}
