function explode (delimiter, string, limit) {
	// Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.
	//
	// version: 909.322
	// discuss at: http://phpjs.org/functions/explode	// +	original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +	improved by: kenneth
	// +	improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +	improved by: d3x
	// +	bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)	// *	example 1: explode(' ', 'Kevin van Zonneveld');
	// *	returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
	// *	example 2: explode('=', 'a=bc=d', 2);
	// *	returns 2: ['a', 'bc=d']
	var emptyArray = { 0: '' };

	// third argument is not required
	if ( arguments.length < 2 ||
		typeof arguments[0] == 'undefined' ||		typeof arguments[1] == 'undefined' )
	{
		return null;
	}
	if ( delimiter === '' ||
		delimiter === false ||
		delimiter === null )
	{
		return false;	}

	if ( typeof delimiter == 'function' ||
		typeof delimiter == 'object' ||
		typeof string == 'function' ||		typeof string == 'object' )
	{
		return emptyArray;
	}
	if ( delimiter === true ) {
		delimiter = '1';
	}

	if (!limit) {		return string.toString().split(delimiter.toString());
	} else {
		// support for limit argument
		var splitted = string.toString().split(delimiter.toString());
		var partA = splitted.splice(0, limit - 1);		var partB = splitted.join(delimiter.toString());
		partA.push(partB);
		return partA;
	}
}

function selectSubjects()
{
	selectedItems = $('.wanted-learn-list a.selected').not("a[rel='no-search']");
	
	if(selectedItems.length == 0) {
		//alert('Please select at least 1 subject');
		//return;
	}
	
	var selectedItemsString = '';
	
	selectedItems.each(
		function() {
			urlParts = explode('/', $(this).attr('href'));
			selectedItemsString += (selectedItemsString ? ',' : '') + urlParts[2];
		}
	);
	location.href = '/select-locations.php?subject=' + selectedItemsString;
}


function selectCities()
{
	selectedItems = $('.cities-list a.selected');

	if(selectedItems.length == 0) {
		//alert('Please select at least 1 location');
		//return;
	}

	selectedItemsString = '';

	selectedItems.each(
		function() {
			urlParts = explode('/', $(this).attr('href'));
			selectedItemsString += (selectedItemsString ? ',' : '') + urlParts[2];
		}
	);


	location.href = '/tutor/search' + location.search + '&city=' + selectedItemsString;
}
