/*	PAX option transfer demo.
*/
pax.load.onloaded( function() {
	
	var options1 = [
		{ 'value': '1', 'text': 'honey cake' },
		{ 'value': '2', 'text': 'jam donut' },
		{ 'value': '3', 'text': 'chocolate chip muffin' },
		{ 'value': '7', 'text': 'Blueberry tart' }
	];
	
	var options2 = [
		{ 'value': '5', 'text': 'Vanilla slice' },
		{ 'value': '4', 'text': 'Rasphberry tartlet' },
		{ 'value': '6', 'text': 'Lemon merang' },
		{ 'value': '9', 'text': 'Banana split' }
	];

	//	Sorting optiontransfer example
	pax.widget.optiontransfer.init( pax.$('pax.widget.optiontransfer.example3'), {
		options1: options1,
		options2: options2,
		header1: 'Desserts I have eaten',
		header2: 'Desserts I am yet to try!',
		//	Custom sort: reverse alphabetical
		//	Note: a and b are option elements, you can also access a.value
		sort: function( a, b ) {
			var aText = (a.text)? a.text.toLowerCase(): '';
			var bText = (b.text)? b.text.toLowerCase(): '';
			if( ( aText + '' ) < ( bText + '' ) )return 1;
			if( ( aText + '' ) > ( bText + '' ) )return -1;
			return 0;
		}

	} );
	
} );
