/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/


function lookup(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		$.post("live.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').slideDown(600); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}
function lookupMp3(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		$.post("liveMp3.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').slideDown(600); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}



$(document).ready(function() {
	/*			   
	var hash = window.location.hash.substr(1);
	var href = $('#nav li a').each(function(){
		var href = $(this).attr('href');
		if(hash== $(this).attr('href')){
			var toLoad = "p/codeLoader.php?id=" + hash;
			$('#code').load(toLoad)
		}											
	});
*/
	$('#clipParts a').click(function(){
								  
		var toLoad = "page/clipLoader.php" + $(this).attr('href');
		$('#embedCodeBox').slideUp('slow',loadContent);
		$('#clipLoad').remove();
		$('#embedCodeBox').append('<span id="clipLoad">LOADING...</span>');
		$('#clipLoad').fadeIn('slow');
		//window.location.hash = $(this).attr('href');
		function loadContent() {
			$('#embedCodeBox').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#embedCodeBox').fadeIn('slow',hideLoader());
		}
		function hideLoader() {
			$('#clipLoad').fadeOut('normal');
		}
		return false;
		
	});
	
	$('#sectionParts a').click(function(){
								  
		var toLoad = "page/clipLoader.php?load=playlist&id=" + $(this).attr('href');
		$('#embedCodeBox').slideUp('slow',loadContent);
		$('#clipLoad').remove();
		$('#embedCodeBox').append('<span id="clipLoad">LOADING...</span>');
		$('#clipLoad').fadeIn('slow');
		//window.location.hash = $(this).attr('href');
		function loadContent() {
			$('#embedCodeBox').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#embedCodeBox').fadeIn('slow',hideLoader());
		}
		function hideLoader() {
			$('#clipLoad').fadeOut('normal');
		}
		return false;
		
	});


});
