var ScreensTimeout = false;
var ScreensVisible = false;

/*var FirstSrc="";


  $(document).ready(function(){
 	
 	$(".hover_image").hover(
 	
 	function()
 	{
		var path=$(this).attr("src");
		FirstSrc=path;
		path=path.split(".");
		var src=path[0];
		$(this).attr("src",src+"_hov"+".png");
	},
	
	function()
	{
		$(this).attr("src",FirstSrc);
		FirstSrc="";
	});
  });*/	

  $(document).ready(function(){
    
    if (document.getElementById("ind_newsblock_2"))
    {
	    $("div#ind_newsblock_2").mouseenter(function () {
	       if ( !ScreensVisible ) {
			   $("div#tex").fadeIn(500)//show(5000);
			   ScreensVisible = true;
		   }
	    });
	
		$("div#ind_newsblock_2").mousemove( function(){
			if ( ScreensTimeout !== false ){ 
				clearTimeout( ScreensTimeout );
			    ScreensTimeout = false;
			}
		});
	
	    $("div#ind_newsblock_2").mouseleave(function () {
			ScreensTimeout = setTimeout( " $(\"div#tex\").fadeOut(500); ScreensVisible = false; ScreensTimeout = false; ", 700 );
	    });
		
	}
	
	// Doubleclick event on main img
	if (document.getElementById("c_image"))
	{
		$("img#c_image").bind("click",function () {
				if (currentshown >= (gallery_nextlist.length - 1))return;
				changeGalleryAjax(gallery_nextlist[currentshown+1],'',currentshown+1)
				slideGalNext();
			}
    	);
    }
    
 });

function screen_next(type)
{
	if (currentshown >= (gallery_nextlist.length - 1))return;
	if(type=='trailer')document.location="/"+GLOBAL_LANGUAGE+"/media"+"/trailers/"+gallery_nextlist[currentshown+1];
	slideGalNext();
	changeGalleryAjax(gallery_nextlist[currentshown+1],'',currentshown+1)
}

function screen_prev(type)
{
	if (currentshown < 1)return;
	if(type=='trailer')document.location="/"+GLOBAL_LANGUAGE+"/media"+"/trailers/"+gallery_nextlist[currentshown-1];
	slideGalPrev();
	changeGalleryAjax(gallery_nextlist[currentshown-1],'',currentshown-1)
}
  
function news_tabs( arg ) {
	
		for(i=1;i<=3;i++) {
			$("#ind_newsblock_"+i).hide();
			$("#but"+i).attr("src",STATIC_BASE_PATH + "/images/news_"+i+".png");
		}
		
      $("#ind_newsblock_"+arg).show();
	  
	  $("#but"+arg).attr("src",STATIC_BASE_PATH + "/images/news_op_"+arg+".png");
}

function check( arg ) {
	
	for(i=1;i<=2;i++) {
			$("#check_img_"+i).hide();
		}
		
      $("#check_img_"+arg).show();
      
      if (arg == 1)
      {
      	$("#newmedia_bde_begin").attr("src",STATIC_BASE_PATH + "/images/korn_m1_new.png");
      	$("#newmedia_tte_1").attr("class","hi_01");
      	$("#newmedia_bde_1").attr("src",STATIC_BASE_PATH + "/images/korn_op_m1_new.png");
      	$("#newmedia_tte_2").attr("class","hi_07");
     	$("#newmedia_bde_end").attr("width","25");
      	$("#newmedia_bde_end").attr("src",STATIC_BASE_PATH + "/images/korn_m2_colse_1.png");
      }
      else
      {
		$("#newmedia_bde_begin").attr("src",STATIC_BASE_PATH + "/images/korn_left_m1_close_new_2.png");
      	$("#newmedia_tte_1").attr("class","hi_07");
      	$("#newmedia_bde_1").attr("src",STATIC_BASE_PATH + "/images/korn_op_m1_1_new.png");
      	$("#newmedia_tte_2").attr("class","hi_01");
      	$("#newmedia_bde_end").attr("width","26");
      	$("#newmedia_bde_end").attr("src",STATIC_BASE_PATH + "/images/korn_m2-29_new.png");
      	$('#check_scroll_'+arg).jScrollPane({scrollbarWidth:15, dragMaxHeight:200, dragMinHeight:24});
      }
}

var current_thumb = 0;

function change_rotator_image (id)
{
	if (id==current_thumb) return;

	$('#scr').attr("src","/content/screenshots/rotator/"+id+".png");
	
	$('#rotator_thumb_'+id).attr("src","/content/screenshots/rot_thumb_s/"+id+".png");
	
	$('#rotator_thumb_'+current_thumb).attr("src","/content/screenshots/rot_thumb/"+current_thumb+".png");
	
	current_thumb = id;
}

function replytocomment (person,id)
{
	$('#wind').css("display","block");
	
	$('#tar1').val($('#tar1').val()+($('#tar1').val()?"\n":"")+"To "+person+": ");
}

/*function _ccgi (id,char){
	//alert ("/content/characters/arts/"+char+"/"+id+".png");
	$("#char_art_current").attr("src", "/content/characters/arts/"+char+"/"+id+".png").animate(
			{opacity: 100},
			3000
		);
}*/

function changeGallery(id,folder)
{
	//$("#char_art_current").fadeOut(500).attr("src", "/content/characters/arts/"+char+"/"+id+".png").fadeIn(500);
	$("#char_art_current").attr("src", "/content/"+folder+"/sized/"+id+".png");
}

var currnet_gallery_img = 1;

function slideGalPrev()
{
//alert (currnet_gallery_img +"\n"+ gallery_imgs);
	//gallery_imgs
	if (currnet_gallery_img > 1)
	{
		currnet_gallery_img --;
		$("#dim13").animate ({marginLeft:-((currnet_gallery_img-1)*108)+4});
	}
}

function slideGalNext()
{
//alert (currnet_gallery_img +"\n"+ gallery_imgs);
	if (currnet_gallery_img < gallery_imgs)
	{
		currnet_gallery_img ++;
		$("#dim13").animate ({marginLeft:-((currnet_gallery_img-1)*108)+4});
	}
}

function trySubscribe()
{
	var e = $('#subscribe_email_fld').val();
	
	$.post("/ajax/", { func: "subscribe", mail:e },
	  function(data){
		if (data != "ok" && data != "invalid" && data != "taken")return;
		// Getting viewport width
		var viewportwidth;
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		if (typeof window.innerWidth != 'undefined')
		{
			viewportwidth = window.innerWidth;
		}
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		else if (
			typeof document.documentElement != 'undefined'
			&& typeof document.documentElement.clientWidth !=
			'undefined' && document.documentElement.clientWidth != 0
		)
		{
			viewportwidth = document.documentElement.clientWidth;
		}// older versions of IE
		else
		{
			viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		}
	    $('body').prepend(
	    	//$('<div></div>').attr({"class":"subscribe_floater","id":"subscribe_floater"}).append(
	    		$('<img />').attr({
	    			"src":STATIC_BASE_PATH + "/images/"+(data=="ok"?"podpiska":(data=="invalid"?"incorrect_mail":"submail_alr"))+"_"+GLOBAL_LANGUAGE+".png",
	    			"width":651,
	    			"height":65,
	    			"class":"subscribe_floater",
	    			"id":"subscribe_floater"
	    		}).css("left",((viewportwidth-651)/2)+"px")
	    	//)
	    );
	    $('#subscribe_floater').fadeIn(1000,function(){setTimeout("$('#subscribe_floater').fadeOut(1000,function(){$('#subscribe_floater').remove()})",1000)});
	  }, "text");
	
}

function openMenuBlock(id)
{
	//$("#mcont_"+id).css('display',"block");
	document.getElementById("mcont_"+id).style.display = "block";
}
function closeMenuBlock(id)
{
	//$("#mcont_"+id).css('display',"none");
	document.getElementById("mcont_"+id).style.display = "none";
}

function changeGalleryChar(id)
{
	$("img.arttss").removeClass('arttss').addClass('artts');
	$("img#gallery_item_"+id).addClass('arttss');
	
	var src = $('#c_image').attr("src");
	src = src.split("/");
	
	src[4] = id+".png";
	
	src = src.join("/");
	
	$('#c_image').attr("src",src);
}

function loadCommentPage(page,id,type)
{
	$.post("/ajax/", { func: "getcommentpage", id:id, page:page, type:type },
	function(data){
		if (data.status=="ok")
		{
			_draw_comments_page(id,type,data);
		}
	},'json');
}

function changeGalleryAjax(id,showopt,curr)
{
	if(showopt=='trailers')document.location="/"+GLOBAL_LANGUAGE+"/media"+"/trailers/"+id;
	
	jQuery.ajax({
		cache: false,
		//beforeSend: function (request) { alert('!'); },
		data: 'func=getgalleryitem&id='+id,
		dataType: 'json',
		url: '/ajax/',
//		error: function (XMLHttpRequest, textStatus, errorThrown){
//			alert(' -> '+textStatus);
//		},
		success: function(data,a,b) {
		
		if (data.status=="ok")
	  	{
	  		currentshown = curr;
	  		// Changing download link
	  		var src = $('#download_link').attr("href");
	  		
	  		src = src.split("/");
		  		
	  		src[3] = data.id+".png";
		  		
	  		src = src.join("/");
	  		
	  		var src = $('#download_link').attr("href",src);
	  		
	        changeGalleryChar(data.id);
	        
	  		$('#titleholder').empty().append(data.title);
	  		$('#pathlink0').empty().append(data.title);
	  		
	  		if (data.desc)
	  		{
	  			$('#descriholder').css("display","block");
		  		$('#scroll_1').empty().append(data.desc).show();
		  		
		  		$('#scroll_1').jScrollPane({scrollbarWidth:15, dragMaxHeight:200, dragMinHeight:24});
	  		}
	  		else
	  		{
	  			$('#descriholder').css("display","none");
	  			$('#scroll_1').empty().hide();
	  		}
	  		
	  		// Comments
	  		$("#comment_to_item").val(data.id);
	  		
	  		_draw_comments_page(id,showopt,data);
	  	}},
	  	type: 'POST'
	});
	
//	jQuery.post("/ajax/", { func: "getgalleryitem", id:id },
//		function (data){
//			if (data.status=="ok")
//		  	{
//		  		currentshown = curr;
//		  		// Changing download link
//		  		var src = $('#download_link').attr("href");
//		  		
//		  		src = src.split("/");
//			  		
//		  		src[3] = data.id+".png";
//			  		
//		  		src = src.join("/");
//		  		
//		  		var src = $('#download_link').attr("href",src);
//		  		
//		        changeGalleryChar(data.id);
//		        
//		  		$('#titleholder').empty().append(data.title);
//		  		$('#pathlink0').empty().append(data.title);
//		  		
//		  		if (data.desc)
//		  		{
//		  			$('#descriholder').css("display","block");
//			  		$('#scroll_1').empty().append(data.desc).show();
//			  		
//			  		$('#scroll_1').jScrollPane({scrollbarWidth:15, dragMaxHeight:200, dragMinHeight:24});
//		  		}
//		  		else
//		  		{
//		  			$('#descriholder').css("display","none");
//		  			$('#scroll_1').empty().hide();
//		  		}
//		  		
//		  		// Comments
//		  		$("#comment_to_item").val(data.id);
//		  		
//		  		_draw_comments_page(id,showopt,data);
//		  	}
//		}
//	,"json");
}

function _draw_comments_page(id,showopt,data)
{
	// Comment count
	$("#commentcount_cnt").html(data.commentcount);
	
	if (isNaN(parseInt(data.commentcount)))
	{
		$("#commentcount_doubledot").hide();
	}
	else
	{
		$("#commentcount_doubledot").show();
	}
	
	// DRAWING COMMENTS
	
	$("#comment_container").empty();
	
	for (var i in data.comments)
	{
		$("#comment_container").append(
		$('<table border="0" cellspacing="0" cellpadding="2" class="coment">'+

'<tr valign="top" height="16px">'+
' <td width="165px" align="center" rowspan="2"><img src="'+(data.comments[i]['avatar']=="y"?'/content/avatars/'+data.comments[i]['id_author']+'.png':STATIC_BASE_PATH + '/images/no_avatar.gif')+'" width="91px" height="76px" border="0" class="png" /><br />'+
' <span class="lol">'+data.comments[i]['display_name']+'</span>'+
' </td>'+
' <td>'+
'  <span class="bmenu">'+data.comments[i]['date']+'</span><a href="#wind" class="ant" onclick="replytocomment (\''+data.comments[i]['display_name']+'\','+data.comments[i]['id']+');"><strong>'+data.reto+'</strong></a>'+
'  </td>'+
'  <td style="text-align: right;">'+
 
  	
' 	<span style="float: right;'+(parseInt(data.comments[i]['votes'])==0?"display:none;":"")+'" id="votesttl_'+data.comments[i]['id']+'">'+
'  	&nbsp;&nbsp;&#8212&nbsp;'+data.vtext+' <span id="votesttl_cnt_'+data.comments[i]['id']+'">'+data.comments[i]['votes']+'</span>'+
'  	</span>'+ 
  	
'  	'+((!data.votedlist[data.comments[i]['id']]&&data.comments[i]['id_author']!=data.current_user)?
'  	<a class="vote_p_btn" href="#" onclick="voteComment(1,'+data.comments[i]['id']+');return false;" id="votelink_comm_'+data.comments[i]['id']+'_u"></a>'
		:"")+
		
'  	<span class="ratecom_'+(parseInt(data.comments[i]['rate'])>0?"g":(data.comments[i]['rate']<0?"b":"n"))+'c" id="ratecom_cnt_'+data.comments[i]['id']+'">'+(parseInt(data.comments[i]['rate'])>0?"+":"")+data.comments[i]['rate']+'</span>'+

'	'+((!data.votedlist[data.comments[i]['id']]&&data.comments[i]['id_author']!=data.current_user)?
'  	<a class="vote_m_btn" href="#" onclick="voteComment(-1,'+data.comments[i]['id']+');return false;" id="votelink_comm_'+data.comments[i]['id']+'_d"></a>'
		:"")+
		
'  </td>'+
'  </tr>'+
'  <tr>'+
'  <td colspan="2" valign="top">'+
'  <img src="'+STATIC_BASE_PATH + '/images/newsline.png" width="344px" height="1px" vspace="6" class="png" /><br />'+
data.comments[i]['text']+
'  </tr>'+
' </table>')
		);
	}
	
	// DRAWING PAGES
	$("#comment_pages_container").empty();
	if (data.pages > 1)
	{
		if(data.page_active > 1)
		{
			$("#comment_pages_container").append($(
				'<div class=rec>'+
					'<a href="#" title="Перейти на предыдущую страницу" onclick="loadCommentPage('+(data.page_active-1)+',\''+id+'\',\''+showopt+'\');return false;"><< Назад</a>'+
				'</div>'));
		}
		
		var j=0; var k=0;
		
		if(data.page_active-2 > 0) j=data.page_active-2;
		else if(data.page_active-1 > 0) j=data.page_active-1;
		else j=data.page_active;
		 			
		if(data.page_active+2 < data.pages) k=data.page_active+2;
		else k=data.pages;
		
		for (var i = j; i <= k; i++)
		{
			$("#comment_pages_container").append($(
				'<div class="rec'+(i==data.page_active?"1":"")+'">'+
  					'<a href="#" onclick="loadCommentPage('+i+',\''+id+'\',\''+showopt+'\');return false;">'+i+'</a>'+
  				'</div>'
			));
		}
		
		if(data.page_active < data.pages)
		{
			$("#comment_pages_container").append($(
				'<div class=rec>'+
					'<a href="#" title="Перейти на следующую страницу" onclick="loadCommentPage('+(data.page_active+1)+',\''+id+'\',\''+showopt+'\');return false;">Далее >></a>'+
				'</div>'));
		}
		
	}
}

//Scrolling screenshots on main page
//----------------------------------------

var current_ss_img=1;

function slideIndexSSPrev()
{
	if (current_ss_img > 1)
	{
		current_ss_img --;
		$("#gal2").animate ({marginLeft:-((current_ss_img-1)*49)});
	}
}

function slideIndexSSNext()
{
	if (current_ss_img < gallery_imgs)
	{
		current_ss_img ++;
		$("#gal2").animate ({marginLeft:-((current_ss_img-1)*49)});
	}
}
//--------------------------------------------
//Voting for comments
//--------------------------------------------
function voteComment(amount,id)
{
	var a = "";
	if (amount>0)
	{
		a = "+";
	}
	else if (amount<0)
	{
		a = "-"
	}
	else return;
	
	$.post("/ajax/", { func: "voteforcomment", id:id, action:a },
	  function(data){
	  	if (data.status=="ok")
	  	{
	  		// Removing hands
	  		$("#votelink_comm_"+data.id+"_u").remove();
	  		$("#votelink_comm_"+data.id+"_d").remove();
	  		
	  		// Updating total voted counters
	  		$("#votesttl_"+data.id).show();
	  		$("#votesttl_cnt_"+data.id).html(data.voted);
	  		
	  		// Updating rating
	  		$("#ratecom_cnt_"+data.id)
	  			.attr("class","ratecom_"+(data.rating>0?"g":(data.rating<0?"b":"n"))+"c")
	  			.html((data.rating>0?"+":"")+data.rating);
	  	}
	  	else if (data.status=="selfvote")
	  	{
	  		if(GLOBAL_LANGUAGE=='ru')alert("Извините, но вы не можете голосовать за свой комментарий.");
  			else alert("Error! You cant voted for himself.");
	  	}
	  	else if (data.status=="alreadyvote")
	  	{
	  		if(GLOBAL_LANGUAGE=='ru')alert("Извините, но вы уже голосовали за этот комментарий.");
	  		else alert("Sorry, but you already voted for this comment");
	  	}
	  	else if (data.status=="notlogged")
	  	{
	  		eleOffset = $("#votelink_comm_"+id+"_u").offset();
	  		
	  		// Getting viewport width
			var viewportwidth;
			// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
			if (typeof window.innerWidth != 'undefined')
			{
				viewportwidth = window.innerWidth;
			}
			// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
			else if (
				typeof document.documentElement != 'undefined'
				&& typeof document.documentElement.clientWidth !=
				'undefined' && document.documentElement.clientWidth != 0
			)
			{
				viewportwidth = document.documentElement.clientWidth;
			}// older versions of IE
			else
			{
				viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
			}
	  	
	  		$('body').prepend(
	    	//$('<div></div>').attr({"class":"subscribe_floater","id":"subscribe_floater"}).append(
	    		$('<img />').attr({
	    			"src":STATIC_BASE_PATH + "/images/ew_banner2_"+GLOBAL_LANGUAGE+".png",
	    			"width":652,
	    			"height":66,
	    			"class":"subscribe_floater",
	    			"id":"subscribe_floater"
	    		}).css({
	    				"left":((viewportwidth-651)/2)+"px",
	    				"top":eleOffset.top
	    			})
	    	//)
	    );
	    $('#subscribe_floater').fadeIn(1000,function(){setTimeout("$('#subscribe_floater').fadeOut(1000,function(){$('#subscribe_floater').remove()"+(typeof (data.banned) != 'undefined'?';document.location = document.location;':'')+"})",2000)});
	  	}
	  },
	"json");
}
//--------------------------------------------
var commformopened = false;
function opencloseCommForm()
{
	if (commformopened)
	{
		$("#wind").slideUp(1000,function(){commformopened = !commformopened;});
		$("#comment_open_btn").slideDown(1000);
	}
	else
	{
		$("#wind").slideDown(1000,function(){commformopened = !commformopened;});
		$("#comment_open_btn").slideUp(1000);
	}
}
var bannfull = true;
var bannintl = 1000;
function banflash ()
{//return;
	bannfull = !bannfull;
	
	if (bannfull)
	{
		$("#bottombanner_timg").attr("src",STATIC_BASE_PATH + "/images/ew_banner_"+GLOBAL_LANGUAGE+".png");
	}
	else
	{
		$("#bottombanner_timg").attr("src",STATIC_BASE_PATH + "/images/ew_banner_2_"+GLOBAL_LANGUAGE+".png");
	}
	
	setTimeout ("banflash ();",bannintl);
}

//Funny icons on view_index
(function($){
	
	if(!document.defaultView || !document.defaultView.getComputedStyle){
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
})(jQuery);

(function($) {
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			
			var start = $.curCSS(fx.elem,'backgroundPosition');
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);

function showIcon(id)
{
	var position=$('#ico'+id).css('backgroundPosition');
	//console.debug('hehe');
	position=position.split(" ");
	var positionX=position[0];
	var positionY=position[1];
	$('#ico'+id).animate({backgroundPosition: '('+ positionX + ' 0)'},50);
	$('#ico_shadow'+id).css('backgroundPosition','0 100px');
}
function hideIcon(id)
{
	var position=$('#ico'+id).css('backgroundPosition');
	position=position.split(" ");
	var positionX=position[0];
	var positionY=position[1];
	$('#ico'+id).animate({backgroundPosition: '('+ positionX + ' 10px)'},50);
	$('#ico_shadow'+id).css('backgroundPosition','0 10px');
}

function openregform ()
{
	if("block" == $("#openregform_cnt").css("display"))
	{
		$("#openregform_cnt").slideUp("slow");
	}
	else
	{
		$("#openregform_cnt").slideDown("slow");
		$('#scroll_1').jScrollPane({scrollbarWidth:15, dragMaxHeight:200, dragMinHeight:24});
	}
}

function chTOPBlock(block)
{
	var blox = ['players','pvp','syndicates'];
	
	var c = blox.length;
	
	for (var i = 0; i < c; i++)
	{
		$('#sidetop50_'+blox[i]).hide();
		$('#toplink_'+blox[i]).css('text-decoration','underline');
	}
	
	if (block == 'players')
	{
		hide = 'syndicates';
	}
	
	$('#sidetop50_'+block).show();
	
	$('#toplink_'+block).css('text-decoration','none');
}

function chTOPBlockAjax(block,server)
{
	side_top50_active = block;
	side_top50_server = server;
	var cnt = $('#sidetop50');
	cnt.empty();
	cnt.append($('<center><img src="'+STATIC_BASE_PATH+'/images/loader_syn.gif"/></center>'));
	
	$('.side_top50_section').css('border-bottom','1px dashed');
	$('.side_top50_server').css('border-bottom','1px dashed');
	$('#toplink_'+block).css('border-bottom','none');
	$('#toplink_s_'+server).css('border-bottom','none');
	
	
	var blox = ['pvp','syndicates'];
	$.post('/ajax/',{func:'getTop50',type:side_top50_active,count:3,server:server},function(data){
		if (typeof data.status != 'undefined' && data.status == 'ok') {
			var adds = [
			            ' width="115px"',
			            ' align="right" width="40px"',
			            ' width="30px"'
			            ];
			var linx = {
					ptl:'players/level',
					stm:'syndicates/members',
					pvp:'pvp/pvprating'
				}
			// Building table
			cnt.empty();
			var tmp = '<table cellspacing="0" width="100%" cellpadding="2" border="0" '+
				'class="bmenu" id="log">'+
			'<tr>'+
				'<td height="10" colspan="4"><!-- empty spacer--></td>'+
			'</tr>'+
			'<tr>'+
				'<td width="15px"><b>#</b></td>';
			for (var i = 0; i < data.fields.length; i++) {
				tmp += '<td'+adds[i]+'><b>'+data.fields[i]+'</b></td>';
			}
			tmp += '</tr>';
			
			// Populating
			for (var i = 0; i < data.data.length; i++) {
				tmp += '<tr>'+
					'<td><small><?=$i;?></small></td>'+
					'<td align="left"><small>'+data.data[i].name+'</small></td>'+
					'<td align="right"><small>'+data.data[i].value+'</small></td>'+
					'<td><img src="'+STATIC_BASE_PATH+'/images/'+(data.data[i].race == 'imp'?'imp_8_16':'neov_15x16_near')+'.png" /></td>'+
				'</tr>';
			}
			tmp += '<tr valign="top">'+
				'<td colspan="4" align="right"><b><a href="/'+GLOBAL_LANGUAGE+'/top/'+linx[side_top50_active]+'/'+server+'"'+
					'style="margin-top: 15px">'+data.linktext+'</a></b></td>'+
			'</tr>'+
	'</table>';
			
			cnt.append($(tmp));
		}
	},'json');
}

var chrgd_timers = {};
var chrgd_values = {};
var chrgd_timout = 2000;

function CheckRegData (fld)
{
	var chkdata = $('#chkr_'+fld+'_fld').val();
	
	if (chkdata != chrgd_values[fld] && chkdata.length >= 3)
	{
		clearTimeout(chrgd_timers[fld]);
		
		chrgd_timers[fld] = setTimeout('_CheckRegData("'+fld+'")',chrgd_timout);
		chrgd_values[fld] = chkdata;
	}
}

function _CheckRegData(fld)
{
	var chkdata = $('#chkr_'+fld+'_fld').val();
	
	if (chkdata.length < 3) return;
	
	// Checking for login and displayname
	if (fld == 'login' || fld == 'dname')
	{
		/*if ($('#chkr_login_fld').val() == $('#chkr_dname_fld').val())
		{
			$('#chkr_dname_ok').hide();
			$('#chkr_dname_fail').show();
			$('#chkr_dname_msg_2').show();
			return;
		}
		else*/
		{
			$('#chkr_dname_msg_2').hide();
			$('#chkr_dname_fail').hide();
		}
	}
	
	_chred_hide_all (fld);
	$('#chkr_'+fld+'_loader').show();
	
	$.post(
		'/ajax/',
		{
			func: "chkregdata",
			fld: fld,
			data: chkdata
		},
		function (data){
			_chred_hide_all (fld);
			if (data.status == 'ok')
			{
				if (data.data == 'ok')
				{
					$('#chkr_'+fld+'_ok').show();
				}
				else
				{
					$('#chkr_'+fld+'_fail').show();
					$('#chkr_'+fld+'_msg').show();
				}
			}
		},
		'json'
	);
}

function _chred_hide_all (fld)
{
	$('#chkr_'+fld+'_loader').hide();
	$('#chkr_'+fld+'_fail').hide();
	$('#chkr_'+fld+'_msg_2').hide();
	$('#chkr_'+fld+'_msg').hide();
	$('#chkr_'+fld+'_ok').hide();
}
