function print_order() {
	var o=document.getElementById('print_button');
	if (o) {
		o.style.display='none';
		window.print();
		o.style.display='block';
	}		
}
function load_sender() {
	select=document.getElementById('sender_id');
	if (select && senders) {
		id=select.options[select.selectedIndex].value;
		for(key in senders) {
			if (senders[key].sender_id==id) {
				for(k in senders[key]) {
					target=document.getElementById(k);
					if (target) target.value=senders[key][k];
				}
			}
		}
		select.selectedIndex=0;
	}
}

function load_recipient() {
	select=document.getElementById('recipient_id');
	if (select && recipients) {
		id=select.options[select.selectedIndex].value;
		for(key in recipients) {
			if (recipients[key].recipient_id==id) {
				for(k in recipients[key]) {
					target=document.getElementById(k);
					if (target) target.value=recipients[key][k];
				}
				return;
			}
		}
		select.selectedIndex=0;
	}
}

function check_order_form() {
	var d_i_air=document.getElementById('delivery_international_air');
	if (d_i_air && d_i_air.checked) {
		show_div('international_air');
		hide_div('international_ocean');
	}

	var d_i_ocean=document.getElementById('delivery_international_ocean');
	if (d_i_ocean && d_i_ocean.checked) {
		hide_div('international_air');
		show_div('international_ocean');
	}		//ort=document.getElementById('order_data[domestic]');	//ort.options[ort.length - 1] = null;	//ort.options[ort.length - 1] = null;

	var d_domestic=document.getElementById('delivery_domestic');
	if (d_domestic && d_domestic.checked) {
		show_div('domestic');
		hide_div('international');
		//hide_div('attachment');
		for(i=0;i<20;i++) {
			hide_div('kg_'+i);
			hide_div('hs_'+i);

			show_div('dim_'+i);
			hide_div('cf_'+i);
			hide_div('cm_'+i);
		}				
		
		if (document.getElementById('delivery_domestic_air').checked){						
			hide_div('selgrounddiv');						
			hide_div('selgrounddomdiv');			
			show_div('selairdiv');		
		}
		else if(document.getElementById('delivery_domestic_ground').checked){						
			hide_div('selairdiv');			
			hide_div('selgrounddiv');				
			show_div('selgrounddomdiv');			
		}			
		else{						
			hide_div('selairdiv');			
			hide_div('selgrounddomdiv');			
			show_div('selgrounddiv');		
		}		
	}

	var d_international=document.getElementById('delivery_international');
	if (d_international && d_international.checked) {
		hide_div('domestic');
		show_div('international');
		show_div('attachment');
		for(i=0;i<20;i++) {
			show_div('hs_'+i);
			show_div('kg_'+i);
		}			
		
	}

	var i_air=document.getElementById('international_air');
	var i_ocean=document.getElementById('international_ocean');
	//LCL
	if (d_international && d_international.checked && d_i_ocean && d_i_ocean.checked && i_ocean && i_ocean.selectedIndex==0) {
		for(i=0;i<20;i++) {
			hide_div('dim_'+i);
			show_div('cf_'+i);
			show_div('cm_'+i);
		}
	} else {
		for(i=0;i<20;i++) {
			show_div('dim_'+i);
			hide_div('cf_'+i);
			hide_div('cm_'+i);
		}
	}
	//FCL
	if (d_international && d_international.checked && d_i_ocean && d_i_ocean.checked && i_ocean && i_ocean.selectedIndex==1) {
		hide_div('items_details_general');
		show_div('items_details_fcl');
	} else {
		hide_div('items_details_fcl');
		show_div('items_details_general');
	}

	var d_freight=document.getElementById('freight');
	if (d_freight && d_freight.selectedIndex==2) {
		show_div('3');
	} else {
		hide_div('3');
	}
	
	//Hazardous
	flag=0;
	for(i=1;i<20;i++) {
		var d_hazardous=document.getElementById('hazardous_'+i);
		if (d_hazardous && d_hazardous.checked) {
			show_div('un_'+i);
			flag=1;
		} else {
			hide_div('un_'+i);
		}
	}
	//Hazardous header
	if (flag) {
		show_div('un_0');
	} else {
		hide_div('un_0');
	}
}

function open_new_order() {
	popup_window('/eng/edit_order');
	//popup_window('/eng/new_order');
}

function popup_window(url) {
	window.open(url,'_blank','resizable=yes,scrollbars=yes,width=800,height=650');
}

function open_track_order() {
	popup_window('/eng/track_orders');
}

function check_terms() {
	o=document.getElementById('order_data[terms]');
	b=document.getElementById('book');
	if (o && b) {
		b.disabled=!o.checked;
	}
}

function open_track_shipment() {
	window.open('http://platinumlogistics.net/track_zd.asp','_blank','resizable=no,scrollbars=yes,width=600,height=400');
}

function open_web_quote() {
	window.open('/eng/web_quote','_blank','resizable=no,scrollbars=yes,width=800,height=650');
}

