$(document).ready(function() {
	$("#searchQuery").focus(function() {
		if ($(this).val() == "Hledej...") {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).val("Hledej...");
		}
	});

	$("#UserLoginUsername").focus(function() {
		if ($(this).val() == "Login") {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).val("Login");
		}
	});

	$("#UserPassword").focus(function() {
		if ($(this).val() == "Heslo") {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).val("Heslo");
		}
	});

	$("#PhoneBrand").change(function() {
		var brand = $(this).val();
		$.ajax({
			url: '/dcciDevices/getDevicesForBrand/'+brand,
			dataType : 'json',
			success : function(data, textStatus){
				$("#PhoneModel").empty();
				$.each(data.devices, function(i, item) {
					$("#PhoneModel").append("<option>"+item+"</option>");
			});
			$("#PhoneModel").attr("disabled", brand == "");
			},
			error : function(x, txt, e){
				alert(txt);
			}
		});
	});
	
	$(".supportedPhones").each(function() {
		$(this).next().hide();
	})
	
	$(".supportedPhones").click(function() {
		$(this).next().toggle(500);
		return false;
	});

	$("table.hoverable tr:gt(0)").hover(function() {
		$(this).toggleClass("hover");
	}, function() {
		$(this).toggleClass("hover");
	});
});
