// My simple javascript for ehftv

function prevMatch()
{
	var pOpt={url:"player.php",
		type: "POST",
  data: "req=prev&current=" + $('#current').text(),
  success: function(data)
  {
	  $('#player').replaceWith(data);
  }};
  
   var cOpt={url:"reqlist.php",
	   type: "POST",
    data: "req=prev&current=" + $('#current').text(),
    success: function(data)
    {
	    $('#nav').replaceWith(data);
    }};
  
  $.ajax(pOpt);
  $.ajax(cOpt);
  return false;
}

function nextMatch()
{
	var pOpt={url:"player.php",
		type: "POST",
  data: "req=next&current=" + $('#current').text(),
  success: function(data)
  {
	  $('#player').replaceWith(data);
  }};
  
   var cOpt={url:"reqlist.php",
	   type: "POST",
    data: "req=next&current=" + $('#current').text(),
    success: function(data)
    {
	    $('#nav').replaceWith(data);
    }};
  
   $.ajax(pOpt);
   $.ajax(cOpt);
   return false;
}


function changePage(mId)
{
   var cOpt={url:"reqlist.php",
	   type: "POST",
    data:  "req=view&flv=" + mId,
    success: function(data)
    {
	    $('#nav').replaceWith(data);
    }};
    $.ajax(cOpt);
    return false;
}

function directTo(mId)
{
	var pOpt={url:"player.php",
		type: "POST",
  data: "req=view&flv=" + mId,
  success: function(data)
  {
	  $('#player').replaceWith(data);
  }};
  
  var cOpt={url:"reqlist.php",
	  type: "POST",
   data:  "req=desc&flv=" + mId,
   success: function(data)
   {
	   $('#description').replaceWith(data);
   }};
  

   $.ajax(pOpt);
   $.ajax(cOpt);
   return false;
}

function toLatest()
{
	var pOpt={url:"player.php",
		type: "POST",
  data: "req=last",
  success: function(data)
  {
	  $('#player').replaceWith(data);
  }};
   
  var cOpt={url:"reqlist.php",
	  type: "POST",
   data: "req=view",
   success: function(data)
   {
	   $('#nav').replaceWith(data);
   }};
   
   var dOpt={url:"reqlist.php",
	   type: "POST",
    data:  "req=desc",
    success: function(data)
    {
	    $('#description').replaceWith(data);
    }};
  
   $.ajax(pOpt);
   $.ajax(cOpt);
   $.ajax(dOpt);
   return false;
}

function initAjaxSelect()
{
	$('#prev').click(prevMatch);
	$('#next').click(nextMatch);
}

function allInit()
{
	toLatest();
}

$(document).ready(allInit); 
