function submitForm(message_order_type)
{
	var show_message = '';
	//check if we are in the registration form from the checkout point
	if (document.checkout) {
		//check if the order type was selected
		if (document.checkout.order_type[0].checked == false && 
			document.checkout.order_type[1].checked == false) {
			show_message = message_order_type;
		} 
		//validate submit
		if (show_message.length == 0) {
			if (document.checkout.order_type[0].checked) {
				document.register.order_type.value = document.checkout.order_type[0].value;
			} else {
				document.register.order_type.value = document.checkout.order_type[1].value;
			}
			document.register.submit();
		} else {
			alert(show_message);
		}
	} else {
		//normal user registration
		document.register.submit();
	}
}

function isCompany(is_company)
{
	if ( document.getElementById('company') &&  
		 document.getElementById('person') ) {
		if (!is_company) {
			hideCompany();
			emptyCompany();
		} else {
			hidePerson();
			emptyPerson();
		}
	}
}

function hideCompany()
{
	document.getElementById('company').style.display = 'none';
	document.getElementById('person').style.display  = '';
}

function hidePerson()
{
	document.getElementById('company').style.display = '';
	document.getElementById('person').style.display  = 'none';
}
function emptyCompany()
{
	document.getElementById('user_company').value = '';
}
function emptyPerson()
{
	document.getElementById('person_title1').value   = '';
	document.getElementById('person_name1').value    = '';
	document.getElementById('person_prefix1').value  = '';
	document.getElementById('person_surname1').value = '';
}

function getContactDetails(from,to)
{
	document.getElementById('person_title'+to).value   = document.getElementById('person_title'+from).value;
	document.getElementById('person_name'+to).value    = document.getElementById('person_name'+from).value;
	document.getElementById('person_prefix'+to).value  = document.getElementById('person_prefix'+from).value;
	document.getElementById('person_surname'+to).value = document.getElementById('person_surname'+from).value;
}

function getAddressDetails(from,to)
{
	document.getElementById('address_street'+to).value          = document.getElementById('address_street'+from).value;
	document.getElementById('address_house_nr'+to).value        = document.getElementById('address_house_nr'+from).value;
	document.getElementById('address_house_nr_suffix'+to).value = document.getElementById('address_house_nr_suffix'+from).value;
	document.getElementById('address_zip'+to).value             = document.getElementById('address_zip'+from).value;
	document.getElementById('address_city'+to).value            = document.getElementById('address_city'+from).value;
	document.getElementById('address_country'+to).options[0].text         = document.getElementById('address_country'+from).options[document.getElementById('address_country'+from).selectedIndex].text;
	document.getElementById('address_info'+to).value            = document.getElementById('address_info'+from).value;
	document.getElementById('address_box_office'+to).value      = document.getElementById('address_box_office'+from).value;		
	
	//alert(document.getElementById('address_country'+to).options[0].text);
	//alert(document.getElementById('address_country'+from).options[0].text);
}

/************************************************** 
 * functions used for customer refferer selection
 **************************************************/
 
function changeRefferersCombo(cmb, txt)
{
	if (cmb.value == -1) {
		txt.disabled = false;
		txt.focus();
	} else {
		txt.disabled = true;
		txt.value = '';	
	} 

}
 
// if the customer refferer is selected the other then 
// enable the textfield
function isOtherRefferer()
{
	//this happens in the register.php page
	//registration event
	if (document.register && document.register.address_refferer1) {
		if (document.register.address_refferer1.value == -1) {
			document.register.address_refferer_other1.disabled = false;
		} else {
			document.register.address_refferer_other1.disabled = true;
		} 
	}
	//this happens in the first step
	//checkout_1.php
	if (document.checkout_2 && document.checkout_2.address_refferer1) {
		if (document.checkout_2.address_refferer1.value == -1) {
			document.checkout_2.address_refferer_other1.disabled = false;
		} else {
			document.checkout_2.address_refferer_other1.disabled = true;
		} 
	}
	//this happens in the first step
	//checkout_1.php
	if (document.alternative_address && document.alternative_address.address_refferer2 ) {
		if (document.alternative_address.address_refferer2.value == -1) {
			document.alternative_address.address_refferer_other2.disabled = false;
		} else {
			document.alternative_address.address_refferer_other2.disabled = true;
		} 
	}
	//this happens in the first step
	//checkout_1.php
	if (document.checkout_unregistered_user && document.checkout_unregistered_user.address_refferer1 ) {
		if (document.checkout_unregistered_user.address_refferer1.value == -1) {
			document.checkout_unregistered_user.address_refferer_other1.disabled = false;
		} else {
			document.checkout_unregistered_user.address_refferer_other1.disabled = true;
		} 
	}	
	
	
}