function confirm_yes_no(text_post)
{
	return confirm(text_post);
}

$(document).ready(function(){
	$("table.odd_table tr:nth-child(even)").addClass("odd");
});
// обработка клавиши ESC
document.onkeydown = function() {
	if (window.event.keyCode == 27) {
		if( $('#popup_my_box').css('display')!='none' ){
			$('#popup_my_box').fadeOut('slow');
		}
	}
}
function my_popup(n_url)
{
	var url_path = $('#popup_my_link'+'_'+n_url).attr('rel');
	if( $('#popup_my_box').css('display')=='none' )
	{
		$('#popup_my_box').load(url_path,{},function(){
		$('#popup_my_box').prepend('<a href="#" title="Закрыть" id="popup_my_box_close" onClick="my_popup_close(); return false;" style="position:absolute;margin-top:-28px;margin-left:-28px;"><img src="/modules/script/form/images/closebox.png" alt="Закрыть" /></a>');
		});
		$('#popup_my_box').html($('#popup_my_box').css('width'));
		$('#popup_my_box').html($('#popup_my_box').css('height'));
		var w = $(window);
		$('#popup_my_box').css('top',($('#popup_my_box').height())/2+w.scrollTop() + 'px');
		$('#popup_my_box').css('left',($('#popup_my_box').width())/2+w.scrollLeft() + 'px');
		$('#popup_my_box').fadeIn('slow');
	}
	else
	{
		$('#popup_my_box').fadeOut('slow');
	}
}
// закрываем форму
function my_popup_close(){
	if( $('#popup_my_box').css('display')!='none' )
	{
		$('#popup_my_box').fadeOut('slow');
	}
}

//Tooltips
$(document).ready(function() {
	$(".tip_trigger").hover(function(){
		tip = $(this).find('.tip');
		tip.show();
	}, function() {
		tip.hide();
	}).mousemove(function(e) {
		var mousex = e.pageX + 20;
		var mousey = e.pageY + 20;
		var tipWidth = tip.width();
		var tipHeight = tip.height();
		var tipVisX = $(window).width() - (mousex + tipWidth);
		var tipVisY = $(window).height() - (mousey + tipHeight);
		if ( tipVisX < 20 ) {
			mousex = e.pageX - tipWidth - 20;
		} if ( tipVisY < 20 ) {
			mousey = e.pageY - tipHeight - 20;
		}
		tip.css({  top: mousey, left: mousex });
	});
});

// Смена аварда
var frame=0;
var tim;
function timers(){
	$(".link_award a").eq(frame).trigger("click");
}
$(document).ready(function(){
$("table.odd_table tr:nth-child(even)").addClass("odd");
	$(".link_award a").click(function(){
		clearTimeout(tim);
		tim=setTimeout("timers()", 5000);
		var largePath = $(this).attr("href");
		var linkbig = $(this).attr("rel");
		$(".link_award a").removeClass("active");
		$(this).toggleClass("active");
		frame=$(this).index()+1;
		if (frame>=5){
			frame=0;
		}
		$("#random_award img").fadeOut('slow', function(){
			$("#random_award img").attr({ src: largePath });
			$("#random_award a").attr("href", linkbig);
			$("#random_award img").fadeIn('slow');
		});
	});
timers();
});
