/* javascript function to get got doks  in index page*/
function getTopDoks()
{
	
document.getElementById('tabformat').style.display = 'block';
	document.getElementById('tabformat2').style.display = 'none';
	document.getElementById('tabformat1').style.display = 'none';
	document.getElementById('t1').className = 'active';
	document.getElementById('t2').className = '';
	document.getElementById('t3').className = '';
}

/* javascript function to get top users in index page */
function getTopUsers()
{
	document.getElementById('tabformat').style.display = 'none';
	document.getElementById('tabformat2').style.display = 'none';
	document.getElementById('tabformat1').style.display = 'block';
	document.getElementById('t2').className = 'active';
	document.getElementById('t1').className = '';
	document.getElementById('t3').className = '';
}

/* javascript function to get hot topics  in index page */
function getTopTopics()
{
	document.getElementById('tabformat').style.display = 'none';
	document.getElementById('tabformat1').style.display = 'none';
	document.getElementById('tabformat2').style.display = 'block';
	document.getElementById('t3').className = 'active';
	document.getElementById('t1').className = '';
	document.getElementById('t2').className = '';
}

// function to refresh the incoming requests section of request_details.php

function showIncomingRequests()
   {
	    
   		$.post("incoming_requests.php",
   						function(data) {
						if(data!=''){
						document.getElementById('incomerequests').innerHTML = data;
						
						}
									
									});
   		
 }
 
 function showSendRequests()
   {
	    
   		$.post("show_send_requests.php",
   						function(data) {
						if(data!=''){
						document.getElementById('incomerequests').innerHTML = data;
						
						}
									
									});
   		
 }
 
 // function to refresh the accepted requests section of request_details.php
 
  function showAcceptedRequests()
   {
	    
   		$.post("accepted_requests.php",
   						function(data) {
						if(data!=''){
						document.getElementById('acceptedrequests').innerHTML = data;
						
						}
									
									});
   		
 }
 
  // function to show the holded sessions section of holded_sessions.php
 
  function showHoldIncomingRequests()
   {
	    
   		$.post("show_hold_incoming_requests.php",
   						function(data) {
						if(data!=''){
						document.getElementById('incomerequests').innerHTML = data;
						
						}
									
									});
   		
 }
 
  function showHoldedSessions()
   {
	    
   		$.post("show_holded_sessions.php",
   						function(data) {
						if(data!=''){
						document.getElementById('holdedsessions').innerHTML = data;
						
						}
									
									});
   		
 }


/* javascript function to accept the session request and redirect to the one-to-one session page*/
function acceptSession(request_user_id,owner_user_id,dok_id,request_id)
{
$.ajax({
  type: 'POST',
  url: 'acceptSession.php',
  data: 'request_user_id='+request_user_id+'&owner_user_id='+owner_user_id+'&dok_id='+dok_id+'&request_id='+request_id,
  success: function(data) {
    window.location.href='session.php';
    
  }

 });

}

function switchSession(request_user_id,owner_user_id,dok_id,request_id,sess_id)
{
$.ajax({
  type: 'POST',
  url: 'switchSession.php',
  data: 'request_user_id='+request_user_id+'&owner_user_id='+owner_user_id+'&dok_id='+dok_id+'&request_id='+request_id+'&sess_id='+sess_id,
  success: function(data) { 
  window.location.href='session.php';
    
  }

 });

}


function switchSessionWaitingList(request_user_id,owner_user_id,dok_id,request_id,sess_id)
{
$.ajax({
  type: 'POST',
  url: 'switchSessionWaitingList.php',
  data: 'request_user_id='+request_user_id+'&owner_user_id='+owner_user_id+'&dok_id='+dok_id+'&request_id='+request_id+'&sess_id='+sess_id,
  success: function(data) {
    window.location.href='session.php';
    
  }

 });

}

function continueHoldedSession(request_user_id,owner_user_id,dok_id,request_id,sess_id)
{
$.ajax({
  type: 'POST',
  url: 'continueHoldedSession.php',
  data: 'request_user_id='+request_user_id+'&owner_user_id='+owner_user_id+'&dok_id='+dok_id+'&request_id='+request_id+'&sess_id='+sess_id,
  success: function(data) { 
  window.location.href='session.php';
    
  }

 });

}


/* javascript function to accept the session request and redirect to the one-to-one session page*/
function startSession(request_user_id,owner_user_id,dok_id,request_id)
{
	
$.ajax({
  type: 'POST',
  url: 'startSession.php',
  data: 'request_user_id='+request_user_id+'&owner_user_id='+owner_user_id+'&dok_id='+dok_id+'&request_id='+request_id,
  success: function(data) {
    window.location.href='session.php';
    
  }

 });

}

/* javascript function to accept the session request and redirect to the one-to-one session page*/



/* javascript function to display inbox messages using ajax  */
function displayInboxMessages(url, qStr)
{
  if (url.length==0)
  {
      document.getElementById("txtResult").innerHTML = "";
      return;
  }
  
	$.ajax({
  type: 'GET',
  data:qStr+"&sid="+Math.random(),
  url: 'inbox_messages.php',
  success: function(data) {
 document.getElementById('txtResult').innerHTML =data;
  }
 });
 //setTimeout("displayInboxMessages()",10000);

}

/* javascript function to display outbox messages using ajax  */
function displayOutboxMessages(url, qStr)
{
  if (url.length==0)
  {
      document.getElementById("txtResult").innerHTML = "";
      return;
  }
  
	$.ajax({
  type: 'GET',
  data:qStr+"&sid="+Math.random(),
  url: 'outbox_messages.php',
  success: function(data) {
 document.getElementById('txtResult').innerHTML =data;
  }
 });
 //setTimeout("displayInboxMessages()",10000);

}


function checkAll()
{
	var tot = document.inboxform.totalOnPage.value;	
	
	if(document.inboxform.checkallbox.checked==true)
		{
			if(tot>1)
				{
					for(var i=0;i<document.inboxform.totalOnPage.value;++i)
						{	document.inboxform.cid[i].checked=true; 	}
				}
			else
				{ 	document.inboxform.cid.checked=true;	}
	}
	else
	{
		if(tot>1)
		{	
		 for(var i=0;i<document.inboxform.totalOnPage.value;++i)
			document.inboxform.cid[i].checked=false;
		}
		else
		{
			document.inboxform.cid.checked=false;
		}
	}
	
}


