function netcatru_init_reg_auth ( doinit ) {
     // авторизация
    $('#auth_forms').submit(function() {
        $('#img_loader').css( 'display', 'block');
        $.post("/netcat/modules/auth_ad/", $(this).serialize()+"&isNaked=1 " , auth_response);     
        $('input').each ( function() { 
            //$(this).attr('disabled', 'disabled');  
        } );  
        return false;
    });

}

// пришел ответ по авторизации
function auth_response ( resp ) {
   $('input').each ( function() { $(this).removeAttr('disabled')  } );
   if ( resp == 0 ) { 
    $('#auth_status').html('Не угадали, попробуйте еще раз.'); 
	$('#auth_status').css( 'color', 'red');
    $('#auth_status').css( 'display', 'block');
    return 0;
  }else{
    $('#auth_forms').html(resp);
    return 0;
  }

}


// иммитация select
function netcatru_sel ( value_id, value, hidden_id, cur_id ) {
  $( '#' + cur_id ).html( netcatru_htmlspecialchars(value) );
  $( '#' + hidden_id ).attr( 'value', netcatru_htmlspecialchars(value_id) );
  
  if ( add_edit_copy ) {
    netcatru_modules(value_id);
  }
}

function blinkLink()
{
	old_color = $(".blinkLink")[0].style.color;
	color = (old_color == "" ? "#FF0000" : "");
	$(".blinkLink").css("color",color);
	setTimeout(blinkLink, 1000);
}



function target_live_edu(id){
	val = $(id).attr("checked");
	loading = $(id).parent().parent().find('.loading');
	val_edulive = $("#edulive").html();
	if(val==false){
		if(val_edulive!=''){
			val=1;
			$('#live-edu').slideUp('slow');
		}
	}else if(val==true){
		val=2;
		if(val_edulive=='') get_list(id, loading);
		else{
			$('#live-edu').slideDown('slow');
		}

	}
	$.post("/lk/edu-live/", { target_live_edu: val});
}

function get_list(id, loading){
	$.ajax({
		type: "POST",
		url: "/lk/edu-live/",
		data: "view=list",
		beforeSend: function(){
			$(id).attr("disabled", true);
			$(id).css("display", "none");
			loading.css("display", "block");
		},
		success: function(date){
			$('#edulive').html(date);
			$('#edulive').slideDown('slow');
			$('#live-edu').slideDown('slow');
			loading.css("display", "none");
			$(id).css("display", "block");
			$(id).attr("disabled", false);
		}
	});
}

function search_checkbox_edu(e){
    if(e==null) e=false;
    $("input[type='checkbox']").each(function() {
		if($(this).attr("OnClick")=='target_live_edu(this);')
        {
            target_live_edu(this);
			if(e==true){
				 val = $(this).attr("checked");
				 if(val==false){
					$(this).attr("checked", "checked");
				 }else if(val==true){
					$(this).removeAttr("checked")
				 }
				 target_live_edu(this);
			}
        }
    });  
}

$(document).ready(function() {
	search_checkbox_edu();
	setTimeout(blinkLink,1000);
	scroll_fix();
	$(window).bind('resize', function() {
		scroll_fix();
	});		
});


function scroll_fix(){
	var width = $(window).width();
	$('.scroll_fix').css('width', width-1);
}


function reload_sub(obj){
	$.ajax({
	   type: "POST",
	   url: "/lk/helpdesk/?isNaked=1",
	   data: "action=reload_sub",
	   success: function(msg){
			if(msg){
				openWin2(msg);
			}else{
				href = $(obj).attr('href');
				document.location.href = href;
			}
	   }
	});
}

function openWin2(url) {
  myWin= open(url, "displayWindow", "width=800,height=600,status=no,toolbar=no,menubar=no");
}



