
function checkForEnter (event) {
	if (event.keyCode == 13) {
		$("#qiuck_quantity").focus();
		$("#qiuck_quantity").select();
		event.preventDefault();
		return false;
	} 
}

$(document).ready(function(){
	
	$("#qiuck_code").focus();
	
	if ($.browser.mozilla) {
		$("#qiuck_code").keypress (checkForEnter);
	} else {
		$("#qiuck_code").keydown (checkForEnter);
	}

	$("a.sh_extra").click(function(){
	
		idParts = this.id.split("_");
		
		// Dohvati value polja
		value = $("tr#h_" + idParts[1] + " td").text();
		
		if(value == ''){
		
			// Postavi loading animation
			$("tr#h_" + idParts[1] + " td").html("<p align='center'><img width='24' height='24' align='center' src='data/template/images/loading.gif' alt='Loading' /></p>");
			$("tr#h_" + idParts[1]).toggle();
			
			// Dohvati extra informacije
			$.post("files/script/live/get_extra.php", { id: idParts[1] },
				function(data){
					if(data != 'false'){
						$("tr#h_" + idParts[1] + " td").html(data);
					}
				}
			);
		}
		else {
			$("tr#h_" + idParts[1]).toggle();
		}
				
		return false;
	});
	
	// Prikazi naprednu pretragu
	$("a#show_adv_search").click(function(){
		value = $("div.search input#search").val();
		$("div.search").hide();
		$("div.advanced_search").show();
		$("div.advanced_search input#srch").val(value);
		return false;
	});
	
	// Prikazi jednostavnu pretragu
	$("a#show_sim_search").click(function(){
		value = $("div.advanced_search input#srch").val();
		$("div.advanced_search").hide();
		$("div.search").show();
		$("div.search input#search").val(value);
		return false;
	});

	// Prikazi legendu raspolozivosti
	$("div#legend a").hover(
		function() {
			$("p.legend").show();
		}, 
		function() {
			$("p.legend").hide();
		}
	);
	
	// Prikazi inpage_search
	$("a#sh_inpage_search").click(function(){
		$("div#inpage_search").toggle();
		return false;
	});
	
	// Prikazi help info
	$("a#show_help_info").click(function(){
		$("div#help_info").toggle();
		return false;
	});
});
