function searchSong(sourceId, action) {

	var sourceId = (sourceId == null) ? "search" : sourceId;	
	var action = (action == null) ? "" : action;
	
	var searchString = $('#'+sourceId).val();
	searchString = searchString.replace(/ /gi,"/");	
	
	if (searchString.length > 2 || action == 'init') {
			
		$.get("/page/xml_search_title_all/" + searchString, {}, function(data) {
			// doe iets
	
			$('#' + sourceId + '_content').html('');			
			
			$(data).find("item").each(function(){
				
				var id = $(this).attr("id");
				var result = $(this).text();
				if (result.length > 23) {
					result = result.substring(0,23) + "...";
				}
									
				/* WHAT TO DISPLAY */						
				if (sourceId == 'search') {						
					$('#' + sourceId + '_content').append('<li id="' + id + '"><img class="bullet" src="img/bullet_searchmenu.png" /><a class="list_link" href="javascript:dummy()" onclick="getSongData('+ id + ')">' + result + '</a></li>');
				} else {
					$('#' + sourceId + '_content').append('<a href="javascript:dummy()" onclick="selectSong('+ id + ')"><li id="' + id + '">' + result + '</li></a>');
					
				}
				/* END WHAT TO DISPLAY */
			});
					
			$('#'  + sourceId + '_content').jScrollPane();	
						
			if (action == 'init') {
				toggleSongPicker();			
			}		
			
		}, "xml");
	
	}
	
	if (sourceId == 'pep_search') {	
							
		if ($('#pep_form').height() < 121 || $('#pep_form').height() > 242) {
			$('#pep_form').animate({height: "242px", duration: 1000});	
		}
		if ($('#pep_form_part1 .jScrollPaneContainer').is(':hidden')) {
				$('#pep_form_part2').fadeOut();
				$('#pep_form_part3').fadeOut();
				$('#pep_form_part1 .jScrollPaneContainer').fadeIn();		
		}

		$('#pep_check_song').html("");
		$('#id_masterlist').val('');
	}
		
}

function selectSong(id) {
	
	$.get("/page/xml_search_id/" + id, {}, function(data) {	

		$(data).find("item").each(function(){
		
			var id = $(this).attr("id");
			var result = $(this).text();
	
			$('#pep_search').val(result);
			$('#pep_form_part1 .jScrollPaneContainer').fadeOut();	

			$('#pep_form_part2').show("fast");
			if (locationSelected && targetIdentifier == 'pep') {
				$('#pep_form').animate({height: "318px", duration: 300});				
				$('#pep_form_part3').show("fast");
			}
								
//			$('#pep_form_part2').fadeTo(500, 1).fadeIn(500);
			// groene vinkje laten zien
			
			$('#id_masterlist').val(id);
			$('#pep_check_song').html("<img src='./img/vink.png' />");
			
		});
				
	}, "xml");
}