var registration_links="#reg_link, #login_link, #online_link";
function hide_registration_links()
{
$(registration_links).hide();
}
var delay_for_animation_auth = 200;
var in_delay_for_animation_auth = 330;
$(document).ready(function(){
$("#text").attr('value', 'Поиск по сайту' );

	$(".in").click(function(){
	//alert(registration_links);
		$("#auth").slideToggle(in_delay_for_animation_auth);
		$(registration_links).fadeOut(delay_for_animation_auth);
		//$(this).toggleClass("active"); 
		return false;
	});
	$("#close_login_link").click(function(){
		//$("#auth").hide();
		$("#auth").slideToggle(in_delay_for_animation_auth);
		$(registration_links).fadeIn(delay_for_animation_auth);
		
		return false;
	});

	 
});

function inreg()
{

$(registration_links).fadeOut(delay_for_animation_auth);
$("#auth").slideDown(in_delay_for_animation_auth);
$(".need_auth_msg").html("Для использования всех функций сайта нужна авторизация.").show();
$("#auth").focus();
return false;
}
function inregmusic()
{

$(registration_links).fadeOut(delay_for_animation_auth);
$("#auth").slideDown(in_delay_for_animation_auth);
$(".need_auth_msg").html("Чтобы <b>загрузить музыку</b> авторизуйся или зарегистрируйся на сайте. Регистрация займет не больше 1 минуты.").show();
$("#i_new_user").attr("href", "http://www.realmusic.ru/profile/register.php?master=1");
$("#master").val(1);
$("#auth").focus();
return false;
}
function inregvideo()
{

$(registration_links).fadeOut(delay_for_animation_auth);
$("#auth").slideDown(in_delay_for_animation_auth);
$(".need_auth_msg").html("Чтобы <b>загрузить видео</b> авторизуйся или зарегистрируйся на сайте. Регистрация займет не больше 1 минуты.").show();
$("#i_new_user").attr("href", "http://www.realmusic.ru/profile/register.php?videomaster=1");
$("#videomaster").val(1);
$("#auth").focus();
return false;
}
function inregcontest(set_contestsename)
{

$(registration_links).fadeOut(delay_for_animation_auth);
$("#auth").slideDown(in_delay_for_animation_auth);
$(".need_auth_msg").html("Чтобы <b>выставить трек на конкурс</b> авторизуйся или зарегистрируйся на сайте. Регистрация займет не больше 1 минуты.").show();
$("#i_new_user").attr("href", "http://www.realmusic.ru/profile/register.php?contestmaster=1");
$("#contestmaster").val(1);
$.cookie('set_contestsename', set_contestsename, { path: '/' });
$("#auth").focus();
return false;
}
function inregcontestvideo(set_contestvideosename)
{

$(registration_links).fadeOut(delay_for_animation_auth);
$("#auth").slideDown(in_delay_for_animation_auth);
$(".need_auth_msg").html("Чтобы <b>выставить видео на конкурс</b> авторизуйся или зарегистрируйся на сайте. Регистрация займет не больше 1 минуты.").show();
$("#i_new_user").attr("href", "http://www.realmusic.ru/profile/register.php?contestvideomaster=1");
$("#contestvideomaster").val(1);
$.cookie('set_contestvideosename', set_contestvideosename, { path: '/' });
$("#auth").focus();
return false;
}
$(document).ready(function() {

$('#view_nastr').show();
$('#nastr').hide();
$('#view_nastr').css("background", "none");

$('#view_nastr').mouseover(function(){
$('#nastr').show();
$('#view_nastr').css("background", "url(/i/bg_account.png) no-repeat scroll");
return false;
});
$('#vsegda_view_nastr').mouseover(function(){
$('#nastr').show();
$('#view_nastr').css("background", "url(/i/bg_account.png) no-repeat scroll");

});

$('#vsegda_view_nastr').mouseout(function(){
$('#nastr').hide();
$('#view_nastr').css("background", "none");

});

var def_main_txt = "Поиск по сайту";
$("#text").attr('value', def_main_txt);
$("#text").blur(function()
{
//alert($('#msg').val().length);
if($('#text').val().length == 0 || $('#text').val() == def_main_txt)
{
//alert(def_txt);
$("#text").css("color", "gray"); 
$("#text").attr('value', def_main_txt);
}
return false;
}).focus(function(){
$("#text").css("color", "#000000"); 
if($("#text").val() == def_main_txt)
{
//alert(9999);
$("#text").attr('value', '');
}
return false;
}); 


$('#main_search #main_search_button').click(function(){

//alert($('#main_search #text').val());
if($('#text').val().length == 0 || $('#main_search #text').val() == def_main_txt)
{
return false;
}
else
{
$('#main_search').submit();
}
return false;
});

$('#popup_share_close').click(function(){
$('#popup').hide();
var date = new Date();
date.setTime(date.getTime() + (200 * 24 * 60 * 60 * 1000));
//alert(date);
$.cookie('close_main_popup', null);
$.cookie('close_main_popup', '1', { path: '/', expires: date });

return false;
});

$('#sendbutton_approve_video').click(function(){
$.ajax({
url: '/ajax/sharevideo.php',
data: "act=share&set_user_id=" + $('#video_share_save #set_user_id').val() + "&csid=" + $('#video_share_save #csid').val(),
dataType: 'json',
type: 'post',
beforeSend: function() { 
//$('#genres_loading').show();
},
success: function (json) {
$('#popup_text_main').hide();
$('#popup_text_result').show();
}
});
return false;

});

});


$(function(){




$("#main_search #text").autocomplete("/ajax/ac.php",{
minChars:1,
cacheLength:1,
delay: 200,
cacheLength: 1,
maxItemsToShow: 10,
matchSubset: 0,
highlight: function(value, term) {
return value;
},
   
formatItem:function formatItem(row) {
	return row[0];
},
autoFill:false
});








});



