var current=1;

function initGamesBar(c){
  current=c;
  if(current==1)
    jQuery('.slide-win-prev').css('visibility', 'hidden');
  if(current+11>jQuery('.match-wrapper').length)
    jQuery('.slide-win-next').css('visibility', 'hidden');
}

function nextMatch(){
  if(current>0)
    jQuery('.slide-win-prev').css('visibility', 'visible');
  if(current<(jQuery('.match-wrapper').length-11))
    jQuery('.slide-win-next').css('visibility', 'visible');
  else
    jQuery('.slide-win-next').css('visibility', 'hidden');
  if(current<(jQuery('.match-wrapper').length-10)){ 
    var el=jQuery('.match-wrapper').get(current-1);
    jQuery(el).stop(true,true).animate({marginLeft: -92}, 500);
    current++;
  }
}

function prevMatch(){
  if(current<(jQuery('.match-wrapper').length-9))
    jQuery('.slide-win-next').css('visibility', 'visible');
  if(current>2)
    jQuery('.slide-win-prev').css('visibility', 'visible');
  else
    jQuery('.slide-win-prev').css('visibility', 'hidden');
  if(current>1){
    current--;
    var el=jQuery('.match-wrapper').get(current-1);
    jQuery(el).stop(true,true).animate({marginLeft: 0}, 500);
  }
}

function getGameInfo(path,m_id){
  jQuery('#gameInfoBox').html("").dialog("destroy");
  jQuery('#gameInfoBox').load(path+'/matches_page.php?m_id='+m_id, function() {
    jQuery('#gameInfoBox').dialog({
      modal: true,
      open: initialize,
      width: 970,
      height: 500,
      show: "fade",
      hide: "fade",
      buttons: {
        "OK":function() {
					jQuery(this).dialog( "close" );
				}
      }
    });
  })
}
