function orderNextStep(mode){

	if (mode == 2) {
	
		if (document.getElementById('order_address_block') == '[object]') {
		if (document.getElementById('order_address_block').style.display == 'none') {
			document.getElementById('check_person').value=1;
	
		}else{
			document.getElementById('check_person').value=0;
	
		}
	}

}
	document.getElementById('order_step').value=mode;

document.forms['bin'].submit();
}

function openAdd(mode, action)
{
	 wnd = window.open("?action=address&mode="+mode+"&last_action="+action, "addAddr", "toolbar=no,width=420,height=390,directories=no,status=no,scrollbars=no,resizable=no,menubar=no");
}

function openBankPopup(){
	popupWin = window.open("?action=bank_request", "bank", "location,width=1000,height=800,top=0,scrollbars=yes");
	popupWin.focus();
	return popupWin;
	
}
function changePayment(mode, action, popupWin)
{
	closeBankPopup(popupWin);
	
	if (action == 'seminar_order')
	{
		document.getElementById('submode').value='change_payment';
		document.seminar_order_form.submit();
	}
	else if (action == 'abo')
	{
		document.getElementById('submode').value='change_payment';
		document.abo_order_form.submit();
	}
	else
	{
		document.getElementById('update_data').value=1;
		orderNextStep(mode);
	}
}

function closeBankPopup(popupWin){
	try{
		popupWin.close();	
	}
	
	catch(e){
		
	}
	
}

function changeDelivery(mode, action)
{
	if (action == 'seminar_order')
	{
		document.getElementById('submode').value='change_delivery';
		document.seminar_order_form.submit();
	}
	else if (action == 'abo')
	{
		document.getElementById('submode').value='change_delivery';
		document.abo_order_form.submit();
	}
	else
	{
		document.getElementById('update_data').value=1;
		orderNextStep(mode);
	}
}


function recalculateBin(mode){
	document.getElementById('update_data').value=1;
	orderNextStep(mode);
}

function removeFromBin(product_id){

	document.getElementById('remove_product_id').value=product_id;
	document.forms['bin'].submit();
}

function setOptionSelected(opt_name, new_opt_id) {

	person_country_hidden = document.getElementById('person_country_hidden');
	if (person_country_hidden) {
		document.getElementById('person_country_hidden').value=new_opt_id;	
	}
	
	var opt = document.getElementById(opt_name).options;
	for (i=0;i<opt.length;i++) {
		if (opt[i].value == new_opt_id) {
			 opt[i].selected = true;
			 return;
		}
	}
	

}


function personBlock(){
    if ($j('#openPersonBlock').is(':visible')){    
    
        $j('#openPersonBlock').hide();
        $j('#personBlock').show();
        $j('#closePersonBlock').css('display','inline');
    }else{
        $j('#openPersonBlock').show();
        $j('#personBlock').hide();
        $j('#closePersonBlock').hide();
    }
}


