var m_html = '<br/><br/><div align="center"><img src="/gfx/loading.gif" alt="" /></div><br/><br/>';	
var m_browser=0;
var m_browser2=0;
var m_browser3=0;
var selected_tab = 0;

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

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

function expw(listID) 
{
   if (document.getElementById(listID).style.display=="none") 
    {
    	document.getElementById(listID).style.display="";
    	document.getElementById(listID).style.visibility="visible";
    }
    else 
    {
    	document.getElementById(listID).style.display="none";
    	document.getElementById(listID).style.visibility="hidden";
    }

}

function contw(listID) 
{
 if (listID.style.display=="show") {listID.style.display="";}
 else {listID.style.display="none";}
 window.event.cancelBubble=true;
}




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

function Draw()
{
 $("#dl_box").load("/cron/show_dls.php");
}

function DrawOnline()
{
 $("#chat_box").html(m_html);
 $("#chat_box").load("/cron/show_online.php");
}

function ShowGroups(id)
{
 $("#skin_groups").load("/display_groups.php?id="+id);
}

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

function UpdateCategoriesBox()
{
 var id = document.forma.section_filter.options[document.forma.section_filter.selectedIndex].value;
 $("#mySectionList").html(m_html);
 $("#mySectionList").load("/uploads.php?ajax=true&action=updateCats&id="+id);
}

function updateSubgroups()
{
 var id = document.browser.groups.options[document.browser.groups.selectedIndex].value;
 $("#skinGroups").load("/include/get_groups.php?id="+id);
}

/***********************************************/
/**                                           **/
/** UPLOADS MANAGER                           **/
/**                                           **/
/**                                           **/
/***********************************************/
function ShowSkin(id)
{
 $("#msgShow").html(m_html);
 $("#msgShow").load("/manul.php?ajax=true&action=ShowSkin&id="+id);
}

/***********************************************/
/**                                           **/
/** LATEST UPLOADS VIEWES                     **/
/**                                           **/
/**                                           **/
/***********************************************/
function ShowLatest(uname,field)
{
 $("#"+field).html(m_html)
 $("#"+field).load("/include/latestUpload.php?uname="+uname+"&field="+field);
}

function clearField(field)
{
 m_html = '';
 document.getElementById(field).innerHTML = m_html;
}

/***********************************************/
/**                                           **/
/** PRIVATE MESSAGES                          **/
/**                                           **/
/**                                           **/
/***********************************************/

function updatePrivMsgBox()
{
 $.get("include/updatePrivMsgBox.php");
 $("#msgBox").hide();
 $("#msgBoxTxt").hide();
 $("#msgBoxX").hide();
}

function ShowPrivateMessage(id)
{
 $("#msgShow").html(m_html);
 //$("#news-"+id).css('font-weight','bold');
 $("#msgShow").load("/privmsg.php?ajax=true&action=ShowMsg&id="+id);
}

function ShowPrivateMessageList(box,id)
{
 if(box !== 'new')
 {
  $("#msgList").html(m_html);
  $("#msgShow").html('');
 }
 if(box == 'new')
  $("#msgShow").load("/privmsg.php?ajax=true&action=msgList&box="+box+"&id="+id);
 else
  $("#msgList").load("/privmsg.php?ajax=true&action=msgList&box="+box+"&id="+id);
}

function SaveMessage(id)
{
 $("#msgList").html(m_html);
 $("#msgShow").html('');
 $("#msgList").load("/privmsg.php?ajax=true&action=SaveMsg&id="+id);
}

function DeleteMessage(id,box)
{
 $("#msgList").html(m_html);
 $("#msgShow").html('');
 $("msgList").load("/privmsg.php?ajax=true&action=DelMsg&box="+box+"&id="+id);
}

/***********************************************/
/**                                           **/
/**                                           **/
/***********************************************/
function checkMovement()
{
 width =  $(window).width();

 if(width>1036)
 {
  $("#mainContent").css('margin-left','150px');
  //$("#mainNav").show();
  $("#leftMain").css('width','140px');
  //style.marginLeft = '150px';
  document.getElementById("mainNav").style.visibility = "visible";
  //document.getElementById("leftMain").style.width = 140+'px';
 }
 else
 {
  //$("#mainNav").hide();
 	$("#mainContent").css('margin-left','20px');
 	$("#leftMain").css('width','10px').show();
  //document.getElementById("mainContent").style.marginLeft = '20px';
  //document.getElementById("leftMain").style.width = 10+'px';
  document.getElementById("mainNav").style.visibility = "hidden";
 }

 if(width<894)
 {

  //$("#rightNav").hide();
 	$("#mainContent").css('margin-right','20px');
 	$("#rightMain").css('width','10px').show();

  //document.getElementById("mainContent").style.marginRight = '20px';
  //document.getElementById("rightMain").style.width = 10+'px';
  document.getElementById("rightNav").style.visibility = "hidden";
 }
 else
 {

  //$("#rightNar").show();
 	$("#mainContent").css('margin-right','150px');
 	$("#rightNav").css('width','140px');
  //document.getElementById("mainContent").style.marginRight = '150px';
  document.getElementById("rightNav").style.visibility = "visible";
  //document.getElementById("rightMain").style.width = 140+'px';
 }
}

function fixLeftNav(pos)
{
 width =  $(window).width();
 if(width>1036)
 {
  document.getElementById("mainContent").style.marginLeft = '150px';
  document.getElementById("mainNav").style.visibility = "visible";
  document.getElementById("leftMain").style.width = 140+'px';
  return;
 } 
 if(pos == 1)
 {
  document.getElementById("mainNav").style.visibility = "visible";
  document.getElementById("leftMain").style.width = 140+'px';
 }
 else if(pos == 0)
 {
  document.getElementById("mainContent").style.marginLeft = '20px';
  document.getElementById("leftMain").style.width = 10+'px';
  document.getElementById("mainNav").style.visibility = "hidden";
  //$("#mainNav").hide();
 } 	
}


function fixRightNav(pos)
{
 width =  $(window).width();
 if(width>880)
 {
  document.getElementById("mainContent").style.marginRight = '150px';
  document.getElementById("rightNav").style.visibility = "visible";
  document.getElementById("rightMain").style.width = 140+'px';
  return;
 } 
 if(pos == 1)
 {
  document.getElementById("rightNav").style.visibility = "visible";
  document.getElementById("rightMain").style.width = 140+'px';
 }
 else if(pos == 0)
 {
  document.getElementById("mainContent").style.marginRight = '20px';
  document.getElementById("rightMain").style.width = 10+'px';
  document.getElementById("rightNav").style.visibility = "hidden";
 }	
}

/***********************************************/
/**                                           **/
/** PROFILE                                   **/
/**                                           **/
/**                                           **/
/***********************************************/
function ShowProfile(id,uname)
{
 $("#profileContent").html(m_html);
 $("#profileContent").load("/profile.php?show="+id+'&uname='+uname);
}

function showDailySkins(datums,x)
{
 $("#myContent").html(m_html);
 if(selected_tab>0)
 {
  document.getElementById('tab-'+selected_tab).style.fontWeight = 'normal';
  document.getElementById('tab-'+selected_tab).style.backgroundColor = '#eee';
 }

 document.getElementById('tab-'+x).style.fontWeight = 'bold';
 document.getElementById('tab-'+x).style.backgroundColor = '#ccc';
 selected_tab = x;
 $("#myContent").load("/recent.php?ajax=true&datum="+datums);
}


function showCategories()
{
 m_browser2 = m_browser2+1;
 if(m_browser2==2)
  {
   document.getElementById("mainDisplay").style.visibility = "hidden";
   m_browser2 = 0;
  }
  else
  {
   document.getElementById("mainDisplay").style.visibility = "visible";
   updateSkinBrowser("displayCategories",0,0);
  } 
}

function showCategories2(namek)
{
 if(namek == 0)
 {
  visina = 430;
  levo = 160;
 }
 else if(namek == 1)
 {
  visina = 140;
  levo = 52;
 }
 else
 {
  visina = findPosY(namek) + 23;
  levo = findPosY(namek) + 30;
 }
 document.getElementById('mainDisplay2').style.top = visina+"px";
 document.getElementById('mainDisplay2').style.left = levo+"px";
 //alert(visina);
 m_browser2 = m_browser2+1;
 //alert();
 if(m_browser2==2)
  {
 	 //new Effect.Puff(document.getElementById("displayCategories"));
   document.getElementById("mainDisplay2").style.visibility = "hidden";
   m_browser2 = 0;
  }
  else
  {
   //new Effect.Appear(document.getElementById("displayCategories"));
   document.getElementById("mainDisplay2").style.visibility = "visible";
   updateSkinBrowser("displayCategories2",0,0);
  } 
}

function updateSkinBrowser(divID,id,subid)
{
 $("#"+divID).html(m_html);
 $("#"+divID).load("/include/skinBrowser.php?id="+id+"&subid="+subid+"&divID="+divID);
}

function findPosX(obj)
{
 var curleft = 0;
 if(obj.offsetParent)
   while(1) 
   {
    curleft += obj.offsetLeft;
    if(!obj.offsetParent)
      break;
    obj = obj.offsetParent;
   }
   else if(obj.x)
      curleft += obj.x;
  return curleft;
}

 function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function ShowBrowserWin()
{
	m_browser = m_browser+1;
  if(m_browser==2)
  {
 	 //new Effect.Puff(document.getElementById("showBrowser"));
   document.getElementById("showBrowser").style.visibility = "hidden";
   m_browser = 0;
  }
  else
  {
   //new Effect.Appear(document.getElementById("showBrowser"));
   document.getElementById("showBrowser").style.visibility = "visible";
   updateSkinBrowser("showBrowser",0);
  }
}

function ShowOnlineList()
{
 $("#onlineList").load("/include/showOnline.php");
}


function removeNotice(id,type)
{
 $.get("/include/removeNotice.php?id="+id+"&type="+type);
 $("#wu-"+id).hide(1000);
}

