$(document).ready(function() 
{
 initPage();
 $("#pplIcon").click(function(){$("#onUsers").toggle();});
 
 $("a[rel^='prettyPhoto']").prettyPhoto();
 
/*
 $("#myNavigator").load("/includes/showNavigatorForm.php");
 $('#userToolbar ul li').click
 {
  $(this.id).hide();
 }
*/
});

function openMe()
{
 $("#navCategory").slideToggle(1000);
 $("#navBrowser").toggleClass("openCategory");

}
function Confirm(link,text) 
{
 if(confirm(text))
   window.location=link;
}

function nextPage()
{
 var p = $(".submenu2").scrollTop();
 p += 100;
 $(".submenu2").animate({ scrollTop: p }, "slow");
}

function prevPage()
{
 var p = $(".submenu2").scrollTop();
 p -= 100;
 if(p<0)
   p = 0;
 $(".submenu2").animate({ scrollTop: p }, "slow");
}

function showSubgroup(id)
{
 $(".submenu2").load("/includes/showSubCategories.php?type=sub&id="+id);
}

function showGroups(id)
{
 $(".submenu1").load("/includes/showSubCategories.php?id="+id);
 $(".submenu2").empty();
}

function initPage()
{
 $('#latestDownload').fadeIn("slow");
/*
 $('#browserBox').click(function()
 {
 	if($('#dropDown').css("display") == "none")
 	  $('#dropDown').fadeIn("slow");
  else
 	  $('#dropDown').fadeOut("slow");
 });
 
 $('#myDrop').clickMenu(); 

 var pos = $('#browserBox').offset();
 $('#dropDown').css("left",pos.left);
 $('#dropDown').css("top",pos.top+25);
*/
}

// Private Message
function ShowPrivateMessage(id)
{
 $('#msgShow').hide(0);	
 $('#msgShow').load("/privmsg.php?ajax=true&action=ShowMsg&id="+id);
 $('#msgShow').animate({opacity: 'show'}, 1000);
}

function ShowPrivateMessageList(box,id)
{
 if(box !== 'new')
 {
  prepeareBox("#msgList");
  $('#msgShow').empty();
 }
 if(box == 'new')
 {
  $('#msgShow').hide();
  $('#msgShow').load("/privmsg.php?ajax=true&action=msgList&box="+box+"&id="+id);
  $('#msgShow').animate({opacity: 'show'}, 1000);
 }
 else
 {
  $('#msgList').hide();
  $('#msgList').load("/privmsg.php?ajax=true&action=msgList&box="+box+"&id="+id);
  $('#msgList').animate({opacity: 'show'}, 1000);
 }

}

function SaveMessage(id)
{
 $('#msgShow').empty();
 $('#msgList').load("/privmsg.php?ajax=true&action=SaveMsg&id="+id);
 $('#msgList').animate({opacity: 'show'}, 1000);
}

function DeleteMessage(id,box)
{
 $('#msgShow').empty();
 $('#msgList').load("/privmsg.php?ajax=true&action=DelMsg&box="+box+"&id="+id);
 $('#msgList').animate({opacity: 'show'}, 1000);
}

function prepeareBox(m_box)
{
 var m_html = '<br/><br/><div align="center"><img src="/gfx/loading.gif" alt="" /></div><br/><br/>';	
 $(m_box).empty();
 $(m_box).append(m_html);
}

function showWallz(link)
{
 alert(link);
}

function InitChat()
{
 $('#boks').load("/includes/show_chat.php");
 setTimeout("InitChat()", 2000);
}

function put_smiley(smiley,outp)
{
 if(outp == 'comment')
 {
  document.forms['newMsg'].comment.value += ' ' + smiley + ' ';
  document.forms['newMsg'].comment.focus();
 }
}

function loadPage(pagek)
{
 window.location = pagek;
}

function updateSubRootCats()
{
 var rootid;
 rootid = $("#listRootGroup").val();
 $.getScript('/includes/showCategories.php?name=myOptions1&rootid='+rootid,function(data){
 	 $("#listSubGroup1").empty();
   $("#listSubGroup2").empty();
   $("#listSubGroup2").css("opacity",".2");
   $("#listSubGroup1").addOption(myOptions1, false); 	
 });
}

function updateSubCats()
{
 var rootid;
 rootid = $("#listSubGroup1").val();
 $.getScript('/includes/showCategories.php?name=myOptions2&rootid='+rootid,function(){
   $("#listSubGroup2").empty();
   $("#listSubGroup2").css("opacity","1");
   $("#listSubGroup2").addOption(myOptions2, false); 	
 });
}