$(document).ready(function(){
	captions = new Array();
	$(".captionValue").each(function(){
		key = $(this).attr('name');
		val = $(this).val();
		captions[key] = val;
	})

	$(".captionValue").focus(function(){
		key = $(this).attr('name');
		val = $(this).val();
		origVal = captions[key];
		if(val == origVal){
			$(this).val('');
		}
	})
	
	$(".captionValue").blur(function(){
		key = $(this).attr('name');
		val = $(this).val();
		origVal = captions[key];
		if(val == ''){
			$(this).val(origVal);
		}
	})
	
	$("#regLogin").change(function(){
		//
		v = $(this).val();
		if(v){
			$.post('/ajax.php', {action: "suggest-login", login: v}, function(data){
				$("#suggestLogin").html(data);
			}, 'html');
		}
	})
	
	$(".setLogin").live("click", function(){
		$("#regLogin").val($(this).val()).change();
	})
	
	//alert(user_rate);
	$(".star").click(function(){
		if(!user_rate){
			$("form.i-block").submit();
			// var r = ($('.star').filter(":checked").val());		
			// document.location = document.location + '?rate=' + r;
		}
	});
	
	if(user_rate){
		$('.star').rating('readOnly', true)
	}

});

function redrawCaptcha(){
	var currentTime = new Date()
	t = currentTime.getTime();
	$("#kcaptcha").attr("src", "/kcaptcha/?rand=" + t);
	return false;
}
