// AJAX бля!
var oldId = 0;

function callback_TestMetod(res)
{
	document.getElementById("display1").innerHTML = res.value;
}

function TestMetod()
{
	AjaxMethods.TestMethods(1,2,callback_TestMetod);
}

function callback_GetAuthor(res)
{
	document.getElementById("imgAuthor").style.display = "none";
	
	var html = [];
	
	document.getElementById("displayAuthorName").innerHTML = res.value[0].Name;
	document.getElementById("displayAuthorJobTitle").innerHTML = res.value[0].JobTitle;
	document.getElementById("displayAuthorAbout").innerHTML = res.value[0].About;
	document.getElementById("displayAuthorEmail").innerHTML = res.value[0].Email;
	
	document.getElementById("LinkAuthorArticle").href = "/author/"+res.value[0].AuthorId+"/all";
	
	if(res.value[0].Photo != null)
	{
	document.getElementById("imgAuthor").style.display = "inline";
	document.getElementById("imgAuthor").src = "/images/author/"+res.value[0].Photo;
	
	}
		
	if(res.value[4] != 0)
	{
	document.getElementById("tdRight").width = res.value[4];
	}
	
	if(res.value[3] != 0)
	{
	document.getElementById("tdLeft").width = res.value[3];
	}
	else
	{
	document.getElementById("tdRight").width = 100;
	
	}
	
	document.getElementById("displayMubleVote").innerHTML = res.value[2];
	document.getElementById("displayCountArticle").innerHTML = res.value[1];
	
	var html;

	for(var i=0; i<res.value[5].Rows.length; i++)
	{
      
      html += '<div class=numberlist>'+res.value[5].Rows[i]["NameRubric"]+' / <a href=/'+res.value[5].Rows[i]["Link"]+'>'+res.value[5].Rows[i]["Name"]+'</a><span class=number> ('+res.value[5].Rows[i]["Date"]+')</span></div><hr size=1 color=#efefef>';

    }
  
	document.getElementById("displayAuthorArticle").innerHTML = html;
	document.getElementById("displayLoading").style.display = "none";
	if(document.getElementById("displayAuthorForm").style.display == "none")
	{
	document.getElementById("displayAuthorForm").style.display = "inline";
	document.getElementById("displayTextForm").style.display = "none";
	}
	
	


	
}



function getAuthor(id)
{
	
	document.getElementById("displayAuthorForm").style.display = "none";
	document.getElementById("displayLoading").style.display = "inline";
	document.getElementById("imgAuthor").src = "/images/null.gif";
	document.getElementById("imgAuthor").style.display = "none";
		//alert(id);
		document.getElementById("Ahref"+id).className = "polosa";
		if(oldId != 0)
		{
			document.getElementById("Ahref"+oldId).className = "";
		}
	
	oldId = id;
	//document.getElementById("Ahref21").style.FONT.SIZE = "x-small";
	
	scroll(0,0);
	AjaxMethods.GetAuthor(id,callback_GetAuthor);
}

function getAuthorFirst(id)
{
	document.getElementById("displayAuthorForm").style.display = "none";
	document.getElementById("imgAuthor").src = "/images/null.gif";
	document.getElementById("imgAuthor").style.display = "none";
	oldId = id;
	scroll(0,0);
	AjaxMethods.GetAuthor(id,callback_GetAuthor);
}

function callback_GetAuthorList(res)
{
	oldId = 0;
	var html="<table cellspacing='0' cellpadding='0' border='0' width='100%' class=lmenu>";
	
	for(var i=0; i<res.value.Tables[0].Rows.length; i++)
	{
		html += "<tr><td ID=Ahref"+res.value.Tables[0].Rows[i]["AuthorId"]+"><a  href='javascript:getAuthor("+res.value.Tables[0].Rows[i]["AuthorId"]+");void(0);'>"+res.value.Tables[0].Rows[i]["Name"]+"</a></td></tr>";
    }
    html += "</td></tr></table>";
    
	document.getElementById("displayAuthorList").innerHTML = html;
	document.getElementById("displayAuthorForm").style.display = "inline";
	document.getElementById("displayLoading").style.display = "none";
}

function getAuthorList(Staff)
{
	document.getElementById("displayAuthorForm").style.display = "none";
	document.getElementById("displayLoading").style.display = "inline";
	
	if(Staff)
	{
	document.getElementById("displayTitleAuthorListStaff").style.display = "inline";
	document.getElementById("displayTitleAuthorListNoStaff").style.display = "none";
	document.getElementById("displayLinkAuthorListStaff").style.display = "none";
	document.getElementById("displayLinkAuthorListNoStaff").style.display = "inline";
	}
	else
	{
	document.getElementById("displayTitleAuthorListStaff").style.display = "none";
	document.getElementById("displayTitleAuthorListNoStaff").style.display = "inline";
	document.getElementById("displayLinkAuthorListStaff").style.display = "inline";
	document.getElementById("displayLinkAuthorListNoStaff").style.display = "none";
	
	}
	scroll(0,0);
	AjaxMethods.GetAuthorList(Staff,callback_GetAuthorList);
	
}

function callback_GetAuthorListFirst(res)
{
	oldId = 0;
	var html="<table cellspacing='0' cellpadding='0' border='0' width='100%' class=lmenu>";
	
	for(var i=0; i<res.value.Tables[0].Rows.length; i++)
	{
		html += "<tr><td ID=Ahref"+res.value.Tables[0].Rows[i]["AuthorId"]+"><a  href='javascript:getAuthor("+res.value.Tables[0].Rows[i]["AuthorId"]+");void(0);'>"+res.value.Tables[0].Rows[i]["Name"]+"</a></td></tr>";
    }
    html += "</td></tr></table>";
    
	document.getElementById("displayAuthorList").innerHTML = html;
	document.getElementById("displayLoading").style.display = "none";
}

function getAuthorListFirst(Staff)
{
	document.getElementById("displayAuthorForm").style.display = "none";
	document.getElementById("displayLoading").style.display = "inline";
	
	if(Staff)
	{
	document.getElementById("displayTitleAuthorListStaff").style.display = "inline";
	document.getElementById("displayTitleAuthorListNoStaff").style.display = "none";
	document.getElementById("displayLinkAuthorListStaff").style.display = "none";
	document.getElementById("displayLinkAuthorListNoStaff").style.display = "inline";
	}
	else
	{
	document.getElementById("displayTitleAuthorListStaff").style.display = "none";
	document.getElementById("displayTitleAuthorListNoStaff").style.display = "inline";
	document.getElementById("displayLinkAuthorListStaff").style.display = "inline";
	document.getElementById("displayLinkAuthorListNoStaff").style.display = "none";
	
	}
	scroll(0,0);
	
	AjaxMethods.GetAuthorList(Staff,callback_GetAuthorListFirst);
	
}
