 $(document).ready(function() {
 	 $("#load_servers").load("/includes/monitor.inc.php");
 	 $("#load_posts").load("/includes/posts.inc.php");
 	 $("#load_online").load("/includes/online.inc.php");
   var modules_refresh = setInterval(function() {
      $('#load_servers').fadeOut('slow').load('/includes/monitor.inc.php').fadeIn("slow");
      $("#load_posts").fadeOut('slow').load('/includes/posts.inc.php').fadeIn("slow");
      $("#load_online").fadeOut('slow').load('/includes/online.inc.php').fadeIn("slow");
   }, 10000);
   $.ajaxSetup({ cache: false });
});

function show_pl_list(zone) {
	var el = document.getElementById("pl_list_" + zone);
	var link = document.getElementById("show_pl_" + zone);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		link.innerHTML = "<a class='show' onclick='show_pl_list(" + zone +")' href='javascript:;'><img src='http://www.nyd.lv/style/img/speletaji.png' border='0'></a></a>";
	}
	else {
		el.style.display = '';
		link.innerHTML = "<a class='hide' onclick='show_pl_list(" + zone +")' href='javascript:;'><img src='http://www.nyd.lv/style/img/speletaji.png' border='0'></a></a>";

	}
}

function loadComments(type, parentid) {
$("#page_comments").mask("Ielādēju..");
$.get("http://www.nyd.lv/includes/loadComments.php",
{ type: type,
  parentid: parentid
 },
function(response){
$("#page_comments").html(response);
$("#page_comments").unmask();
});
}

function comment(type, parentid) {
if ($("#message").val() != 0) {
$.post("http://www.nyd.lv/includes/loadComments.php",
{ submit: $("#submit").val(),
  komentaars: $("#message").val(),
  type: type,
  parentid: parentid
 },
function(response){
return loadComments(type, parentid);
});
} else {
$("#message").addClass("src_empty");
$("#message").focus();
}
}

function delete_comment(id, act, type, parentid) {
$.get("http://www.nyd.lv/com.php",
{ id: id ,
  'do': act
},
function(response){
return loadComments(type, parentid);
});
}

function edit_comment(id, act, type, parentid, comment) {
if (comment != 1) {
$.get("http://www.nyd.lv/com.php",
{ id: id ,
  'do': act
},
function(response){
$("#comment_" + id).mask("Ielādēju..");
$("#comment_" + id).html(response);
$("#comment_" + id).unmask();
});
} else {
if ($("#message2").val() != 0) {
$.post("http://www.nyd.lv/com.php",
{ submit: $("#submit").val(),
  komentaars: $("#message2").val(),
  'do': act,
  id: id
 },
function(response){
return loadComments(type, parentid);
});
} else {
$("#message2").addClass("src_empty");
$("#message2").focus();
}
}
}

$(document).ready(function(){
	$('#search').keyup(function(e) {
      if(e.keyCode == 13) {
		$('#sub_cont').fadeIn(1500);
		$("#content #sub_cont").load("/users/search/" + $("#search").val());
      }
      });
	$('#start').click(function(e) {
		$('#sub_cont').fadeIn(1500);
		$("#content #sub_cont").load("/users/search/" + $("#search").val());
      });
});

// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

$(document).ready(function() {
	$("#stats").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#stats2").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#stats3").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#bans").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#kz").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#vs").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	$("#vip_show").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade'
			});

});
