// подсвечиваем кнопки в ie
$j(document).ready(function() {//{{{
	if ($j.browser.msie) {
		$j("INPUT.btnlite").hover(function(){
			$j(this).addClass("over");
		}, function(){
			$j(this).removeClass("over");
		});
		$j("INPUT.btnmain").hover(function(){
			$j(this).addClass("over");
		}, function(){
			$j(this).removeClass("over");
		});
	}
});//}}}

// поле поиска
$j(document).ready(function() {//{{{
	if ($j('#search_field').val()=='поиск') {
		$j('#search_field').addClass("blurred").focus(function(){ $j('#search_field').val('').removeClass("blurred").unbind("focus"); });
	}
});//}}}

// фокус в поле логина
$j(document).ready(function() {//{{{
	if ($j('#UserLogin').length) {
		$j('#UserLogin')[0].focus();
	}
});//}}}

// подсказки к условиям входа
var facecontrol_hint='Неадекватные, нетрезвые лица и лица моложе 18 лет не допускаются к проходу в клуб';//{{{
var dresscode_hint='Опрятно одетые посетители в клубных, вечерних и праздничных костюмах имеют больше шансов попасть в клуб';
var clubcards_hint='Владельцам клубных карт свободный вход';
var flyer_hint='Распечатанный флаер дает скидку при покупке билета в кассе клуба';
var costume_hint='Посетители в костюмах имеют скидки при входе или пропускаются совершенно бесплатно на заранее оговоренных клубом условиях';
var tooltip_options={
	delay: 50,
	track: true,
	left:5,
	top:5
};
$j(document).ready(function(){
	$j('.hint_facecontrol').tooltip($j.extend(tooltip_options, {bodyHandler: function(){return facecontrol_hint;}}));
	$j('.hint_dresscode').tooltip($j.extend(tooltip_options, {bodyHandler: function(){return dresscode_hint;}}));
	$j('.hint_clubcards').tooltip($j.extend(tooltip_options, {bodyHandler: function(){return clubcards_hint;}}));
	$j('.hint_flyer').tooltip($j.extend(tooltip_options, {bodyHandler: function(){return flyer_hint;}}));
	$j('.hint_costume').tooltip($j.extend(tooltip_options, {bodyHandler: function(){return costume_hint;}}));
});//}}}

// выбор города в регистрации
var cities={};
$j(document).ready(function() {//{{{
	$j('#inp_oblast').bind('change', function(){
		oblast_id=$j('#inp_oblast').val();
		if (!cities[oblast_id]) {
			//$j('#b_'+book_id).css('background-image', 'url("images/loading.gif")');
			//$j('#b_'+book_id).css('background-position', '100% 5px');
			//$j('#b_'+book_id).css('background-repeat', 'no-repeat');
			$j.ajax({
				url:'/get_cities.php',
				data:{'oid':oblast_id},
				type:'GET',
				dataType:'json',
				timeout:20000,
				complete:function(){
					//$j('#b_'+book_id).css('background-image', '');
				},
				error:function(request, errmsg, exception){
					//$j('#report_26_1_result').find('DIV.analogs').prepend('<div class="warn ajax-error">Ошибка запроса</div>');
				},
				success:function(oblast_cities){
					cities[oblast_id]=oblast_cities;
					showCities(oblast_id);
				}
			});
		} else {
			showCities(oblast_id);
		}
	});
});//}}}
function showCities(oblast_id) {//{{{
	$j("#inp_city").removeOption(/./);
	var options={0:'- Другой -'};
	if (cities[oblast_id]) {
		$j.each(cities[oblast_id], function(city_id, city){
			options[city_id]=city;
		});
	}
	$j("#inp_city").addOption(options);
	$j("#inp_city").sortOptions();
	$j("#inp_city").selectOptions('0');
}//}}}

// фотографии пользователя
$j(document).ready(function() {//{{{
	if ($j.browser.msie) {
		$j("TABLE.user_photos").find("TD.thumb").hover(function(){
			$j(this).addClass("over");
		}, function(){
			$j(this).removeClass("over");
		});
	}
	$j("TABLE.user_photos").find("TD.thumb").bind('click', function(){
		if ($j(this).find("A").length) {
			//window.location=$j(this).find("A")[0].href;
			window.open($j(this).find("A")[0].href);
		}
	}).find('A').bind('click', function(ev){
		ev.stopPropagation();
		return true;
	});
});//}}}

// vim:fdm=marker
