//*EXTRAS*//
function hideScrolls(){
  $$('#boxesNotebook .boxes .content').each(function(c){
    c.style.overflow = 'hidden';
  })
}

function showScrolls(){
  $$('#boxesNotebook .boxes .content').each(function(c){
    c.style.overflow = 'auto';
  })
}

/* TOURNAMENTS */
function revertTo(type,id){
  switch(type){
    case 'timezone':
      $('time_local'+id).hide();
      $('time_timezone'+id).show();
      $ES('.timeTimeZone','matchTable'+id).each(
      function(e){
          e.show();
      });
      $ES('.timeLocal','matchTable'+id).each(
      function(e){
          e.hide();
      });

    break;
    case 'local':
      $('time_timezone'+id).hide();
      $('time_local'+id).show();
      $ES('.timeTimeZone','matchTable'+id).each(
      function(e){
          e.hide();
      });
      $ES('.timeLocal','matchTable'+id).each(
      function(e){
          e.show();
      });
    break;
  }
}

function viewTournament(nameTournament){
  window.location.href="/tournaments/stats/"+nameTournament;
}

function addTableGroupTab(tournamentId){
 new Ajax(
   '/admin/tournaments/ajax_the_tournament_have_groups_stage/'+tournamentId,
   {
     onComplete:function(e){
       if(e=="true\n"){
         document.statsNotebook.injectAfter(
           'general_table',
           {id:'table_for_groups',title:'Table for groups'},
           {'url':'/tournaments/ajax_get_general_table_by_groups/'+tournamentId}
         );
         
       }
     }
   }
 ).request();
}

function setNewTournamentNoteBook(e){
  if(e.value){
    document.statsNotebook.closePage('general_table');
    document.statsNotebook.closePage('matches');
    document.statsNotebook.closePage('table_for_groups');
    
    document.statsNotebook.addPage(
      {id: 'general_table',title : 'General Table'},
      {'url':'/tournaments/ajax_get_general_table/'+e.value}
    );
    
    document.statsNotebook.addPage(
      {id: 'matches',title : 'Matches'},
      {'url':'/matches/ajax_get_of_tournament/'+e.value}
    );
    addTableGroupTab(e.value);
    document.statsNotebook.selectPage('general_table');
  }
}

function loadClickInfoMatch(idKey, stageKey, tournamentId, matchDay, obj){
  $ES('span','rounds_'+idKey).each(function(e){
    e.className = 'squarelink'
  });
  obj.className = 'squarelinkselected';
  loadInfoMatch(idKey,stageKey, tournamentId, matchDay);
}

function loadClickGroupMatch(idKey,newvalue,obj){
  $ES('span','groupss_'+idKey).each(function(e){
    e.className = 'squarelink'
  });
  $ES('span','rounds_'+idKey).each(function(e){
    e.className = 'squarelink'
  });
  
  
  obj.className = 'squarelinkselected';
  $('span'+idKey+'_1').className = 'squarelinkselected';
  $('hiddengroup_'+idKey).value = newvalue;
  loadInfoMatch(idKey, $('hiddenstagekey_'+idKey).value, $('hiddentournament_'+idKey).value, 1);
}

function loadInfoMatch(idKey, stageKey, tournamentId,matchDay){
  extra_condition = 0;
  if (typeof $('hiddengroup_'+idKey).value != "undefined"){
    extra_condition = $('hiddengroup_'+idKey).value;
    $('hiddentournament_'+idKey).value = tournamentId;
    $('hiddenstagekey_'+idKey).value = stageKey;
  }
  $('match_'+idKey).setContent({'url':'/matches/ajax_get_block_content/'+stageKey+'/'+tournamentId+'/'+matchDay+'/'+extra_condition});  
} 

function autoredirect(type,response){
  var url;
  var reg = /\s+/g;
  var str = response.content;
  if(str == ''){
    return false;
  }
  str = str.replace(reg,'_')
  switch(type){
    case 'player':
      url = '/players/v/'+str+'/'+response.index;
    break;
    case 'tournament':
      url = '/tournaments/v/'+str+'/'+response.index;
    break;
    case 'team':
      url = '/teams/v/'+str+'/'+response.index;
    break;  
    case 'friendgroup':
      url = '/group/'+response.content;
    break;
  }
  location.href = url;
}


function showSegment(type,key,obj){
  $ES('td','contTable'+key).each(
    function(e){
        if(e.className == 'dark hidden '+type+' '+key){
            e.className = 'dark '+type+' '+key;
        }
        if(e.className == 'hidden '+type+' '+key){
            e.className = type+' '+key;
        }
        if(e.className == 'hidden '+type+'separation '+key){
            e.className = type+'separation '+key;
        }
        if(e.className == 'num hidden '+type+' '+key){
            e.className = 'num '+type+' '+key;
        }
        if(e.className == 'num hidden '+type+'separation '+key){
            e.className = 'num '+type+'separation '+key;
        }
        if(e.className == 'num hidden '+type+' '+key+' negative'){
            e.className = 'num '+type+' '+key+' negative';
        }
        if(e.className == 'num hidden '+type+' '+key+' positive'){
            e.className = 'num '+type+' '+key+' positive';
        }
    }
  );
  $('hidelink'+type+key).show();
  $(obj.id).hide();
}

function hideSegment(type,key,obj){
  $ES('td','contTable'+key).each(
    function(e){
        if(e.className == 'dark '+type+' '+key){
            e.className = 'dark hidden '+type+' '+key;
        }
        if(e.className == type+' '+key){
            e.className = 'hidden '+type+' '+key;
        }
        if(e.className == type+'separation '+key){
            e.className = 'hidden '+type+'separation '+key;
        }
        if(e.className ==  'num '+type+' '+key){
            e.className = 'num hidden '+type+' '+key;
        }
        if(e.className ==  'num '+type+'separation '+key){
            e.className = 'num hidden '+type+'separation '+key;
        }

        if(e.className ==  'num '+type+' '+key+' negative'){
            e.className = 'num hidden '+type+' '+key+' negative';
        }
        if(e.className == 'num '+type+' '+key+' positive'){
            e.className = 'num hidden '+type+' '+key+' positive';
        }
    }
  );
  $('showlink'+type+key).show();
  $(obj.id).hide();
}

function GoalsDetails(tournamentId,playerId){
  Meteora.overlay();
  dialog = new Dialog(
    {url:'/players/ajax_get_details_goals/'+tournamentId+'/'+playerId},
    {
      height:300,
      width:240,
      onClose: function() { Meteora.removeOverlay();}
    }
  );
  dialog.center();
}
function loadPlayerInfo(playerId,tournamentId){
  if(tournamentId){
    $('infoCurrentTournament'+tournamentId).setContent({url:'/players/ajax_get_tournament_match_stats/'+playerId+'/'+tournamentId});
  }
}

function loadNewTournamentTab(playerId,tournamentId, select){
  if(tournamentId){
    var titleName = select[select.selectedIndex].text;
    document.playerNotebook.addPage(
      {id:'player_tournament_'+tournamentId+':'+playerId,'title': titleName,'allowClose' : true},
      {url:'/players/ajax_get_tournament_match_stats/'+playerId+'/'+tournamentId},
      {allowClose:true}
    );
    document.playerNotebook.selectPage('player_tournament_'+tournamentId+':'+playerId);
    select[0].selected = true;
  }
}

function loadNewTeamTab(teamId,tournamentId,select, type){
  
  if(tournamentId){

    var titleName = select[select.selectedIndex].text;
    var myId;
    var myUrl;
    switch(type){
    case 'stats':
      myId = 'team_tournament_'+teamId+':'+tournamentId;
      myUrl = '/teams/ajax_get_stats/'+teamId+'/'+tournamentId;
      break;
    case 'fixtures':
      myId = 'team_fixtures_'+teamId+':'+tournamentId
      myUrl = '/teams/ajax_get_fixtures_results/'+teamId+'/'+tournamentId;
      break;
    case 'squad':
      myId = 'team_squad_'+teamId+':'+tournamentId
      myUrl = '/teams/ajax_get_squad/'+teamId+'/'+tournamentId;
      break;
    }
    document.teamNotebook.addPage(
      {id:myId, 'title': titleName,'allowClose' : true},
      {url:myUrl},
      {allowClose:true}
    );
    document.teamNotebook.selectPage(myId);
    select[0].selected = true;
  }
}

function createGroup(){
  Meteora.overlay();
  dialog = new Dialog(
    {url:'/users/ajax_create_group/'},
    {
      height:350,
      width:680,
      onClose: function() { Meteora.removeOverlay();}
    }
  );
  dialog.center();
  document.userGroupDialog = dialog;
}

function editGroup(id){
  Meteora.overlay();
  dialog = new Dialog(
    {url:'/users/ajax_create_group/'+id},
    {
      height:350,
      width:680,
      onClose: function() { Meteora.removeOverlay();}
    }
  );
  dialog.center();
  document.userGroupDialog = dialog;
}

function deleteGroup(id){
 var dialog = new Dialog(
    __('Are you sure you want to delete this group and unsuscribe all the members ?'),
    {
      'title':  __('Delete group'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
                dialog.close();
                Meteora.removeOverlay();
                new Ajax("/users/ajax_delete_group/"+id).rpc();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.NotFanDialog = dialog;

}


function userPrefs(){
  hideScrolls();
  Meteora.overlay();
  dialog = new Dialog(
    {url:'/users/ajax_user_prefs/'},
    {
      height:420,
      width:670,
      onClose: function() { Meteora.removeOverlay();  showScrolls();}
    }
  );
  dialog.center();
  document.userPrefsDialog = dialog;
}

function showRequests(){
  window.location = '/users/my_profile/requests';
}

function showUnreadMessages(userId){
  window.location = '/users/my_profile/wall';
}

function readMessage(msgId){
  new Ajax('/users/ajax_read_message/'+msgId).request();
}

function showMessage(msgId){
  $('messageDetails').setContent({'url':'/users/ajax_get_message/'+msgId});
}

function showLanguages(){

  var el = $('langlist');
  
  if (el.style.display== 'none' || el.style.visibility == 'hidden'){
    
    Effect.appear(el, {duration:900});

    $(document.body).addEvent(
      'mousedown',
      el.$tmp.close = function(e) {
        var e = new Event(e);
        var parent = e.target;
        while (parent) {
          if (parent.id == 'langlist') {
            return;
          }
          parent = parent.parentNode;
        }
        $(document.body).removeEvent('mousedown', this.$tmp.close);
        Effect.fade(this, {'duration': 600});
      }.bindAsEventListener(el)
    );

  } else {

    if (el.$tmp.close) {
      $(document.body).removeEvent('mousedown', el.$tmp.close);
    }

    Effect.fade(el, {duration:900});
  }
}

function cleanText(obj){
  if($(obj.id).value == $(obj.id).defaultValue){
    $(obj.id).value = '';
  }
}

function resetText(obj){
  if($(obj.id).value == '' ) {
      $(obj.id).value = $(obj.id).defaultValue;
  }
}
function changeTournament(select, value){
  if(value != 0){
    document.location.href='/tournaments/v/'+select[select.selectedIndex].text+'/'+value;
  }
}
function launchHomeLanguage(){
  hideScrolls();
  var d = new Dialog(
    {'url': '/users/ajax_get_langs'},
    {  'title' : ' ',
      'onClose': function(){Meteora.removeOverlay();showScrolls();}, 'width':'430', 'height':'200'}
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.userLang = d;

}

function launchHomeUserLogin(){
  hideScrolls();
  var d = new Dialog(
    {'url': '/users/ajax_login'},
    {  'title' : __('User login'),
      'onClose': function(){Meteora.removeOverlay();showScrolls();}, 'width':'430', 'height':'200'}
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.userLogin = d;
}

function launchUserRegistration(msg) {
  hideScrolls();
  if(msg == undefined){
    msg = '';
  }
  var d = new Dialog(
    {'url': '/users/ajax_register/0/'+msg},
    {'onClose': function(){Meteora.removeOverlay();showScrolls();}, 'width':'430', 'height':'320'}
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.userRegistration = d;
} 
function launchGroupUserRegistration(hash){
  var d = new Dialog(
    {'url': '/users/ajax_register/' +hash},
    {'onClose': function(){Meteora.removeOverlay();showScrolls();}, 'width':'430', 'height':'290'}
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.userRegistration = d;
}


function addFriend(userId, userName) {
  hideScrolls();
  var d = new Dialog(
    {'url': '/users/ajax_add_friend_dialog/'+userId},
    {
      'onClose': function(){Meteora.removeOverlay();showScrolls();}, 
      'width'  :'430', 
      'height' :'170',
      'title'  : __('Add ')+userName+__(' as friend?')
    }
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.addFriendDialog = d;
} 

function confirmFriend(userId, userName){
  var dialog = new Dialog(
    __('Are you friends with ')+userName + '?',
    {
      'height':'60px',
      'title':  __('Confirm friend'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) { 
                dialog.close();
                Meteora.removeOverlay();
                new Ajax("/users/ajax_confirm_friend/"+userId).rpc();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.ConfirmFriendDialog = dialog;
}

function acceptFriend(friendId){
  new Ajax("/users/ajax_accept_friend/"+friendId).rpc();
  $('friendRequestDiv_'+friendId).hide();
}

function denyFriend(friendId){
  new Ajax("/users/ajax_deny_friend/"+friendId).rpc();
  $('friendRequestDiv_'+friendId).hide();
}

function joinGroup(groupId, reload){
  if(reload != 1){
    reload = 0;
  }
  new Ajax("/users/ajax_accept_group/"+groupId+'/'+reload).rpc();
}

function acceptGroup(groupId){
  new Ajax("/users/ajax_accept_group/"+groupId+'/0').rpc();
  $('groupRequestDiv_'+groupId).hide();
}

function denyGroup(groupId){
  new Ajax("/users/ajax_deny_group/"+groupId).rpc();
  $('groupRequestDiv_'+groupId).hide();
}

function leaveGroup(groupId){
  var dialog = new Dialog(
    __('Are you sure to leave this group')+ '?',
    {
      'title':  __('Leave group'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
            dialog.close();
            Meteora.removeOverlay();
            new Ajax("/users/ajax_leave_group/"+groupId).rpc();
            $('groupDiv_'+groupId).hide();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.leaveGroupDialog = dialog;
}

function unsuscribeUser(groupId,userId){
  var dialog = new Dialog(
    __('Are you sure to unsuscribe this user from the group')+ '?',
    {
      'title':  __('Unsuscribe user'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
                dialog.close();
                Meteora.removeOverlay();
                new Ajax("/users/ajax_leave_group/"+groupId+"/"+userId).rpc();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.unsuscribeUserDialog = dialog;
}




function launchUserLogin() {

  var myFx = new Fx.Scroll(window).toTop();
  var el = $('signInDiv');

  if (el.style.display== 'none' || el.style.visibility == 'hidden') {

    Effect.appear(el, {duration:800});

    $(document.body).addEvent(
      'mousedown',
      el.$tmp.close = function(e) {
        var e = new Event(e);
        var parent = e.target;
        while (parent) {
          if (parent.id == 'signInDiv') {
            return;
          }
          parent = parent.parentNode;
        }
        $(document.body).removeEvent('mousedown', this.$tmp.close);
        Effect.fade(this, {'duration': 600});
      }.bindAsEventListener(el)
    );

  } else {
    if (el.$tmp.close) {
      $(document.body).removeEvent('mousedown', el.$tmp.close);
    }
    Effect.fade(el, {'duration': 600});
  }
}


function launchHomeLostPassword(){
  hideScrolls();
  var d = new Dialog(
    {'url': '/users/forgot_password'},
    {'onClose': function(){document.userLogin.show()}, 'width': '300', 'height':'200'}
  );
  d.center();
  d.show();
  document.userLostPassword = d;
  document.userLogin.hide();
}


function launchLostPassword(){
  hideScrolls();
  var d = new Dialog(
    {'url': '/users/forgot_password'},
    {'onClose': function(){Meteora.removeOverlay();showScrolls();}, 'width': '300', 'height':'200'}
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.userLostPassword = d;
  document.userLogin.show()
}



function userRegister(form){
	return formSubmit(form);
}

function showSquads(value){
  if(value){
    $('squadteam').setContent({'url':'/teams/ajax_get_squad/'+value+'/'+$('TournamentId').value});
  }
}



var launchAddBox = function(url) {
  var d = new Dialog(
    {'url': '/homepage/ajax_add_box/'+url },
    {
      'title': __('Choose a tab'),
      'onClose': Meteora.removeOverlay, 
      'width':'300',
      'height':'300'
    }
  );
  Meteora.overlay();
  d.center();
  d.show();
  document.addBoxDialog = d;
}

function beFanOf(id,name,type){
  var dialog = new Dialog(
    __('Are you sure to become fan of ')+name + '?',
    {
      'title':  __('Become fan'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) { 
                dialog.close();
                Meteora.removeOverlay();
                new Ajax("/users/ajax_convert_fan/"+type+"/"+id).rpc();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.FanDialog = dialog;
}

function deleteFan(type,id){
  var dialog = new Dialog(
    __('Are you sure you want to delete this ')+__(type) + '?',
    {
      'title':  __('Become fan'),
      'onClose' :  function(){Meteora.removeOverlay()},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay() }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
                dialog.close();
                Meteora.removeOverlay();
                new Ajax("/users/ajax_delete_fan/"+type+"/"+id).rpc();
          }
        }
      }
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.NotFanDialog = dialog;
}

function deleteFriend(friendId){
  var dialog = new Dialog(
    __('Are you sure?'),
    {
      'title':  __('Remove friend'),
      'onClose' :  function(){Meteora.removeOverlay();},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay(); }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
            dialog.close();
            Meteora.removeOverlay();
            new Ajax("/users/ajax_remove_friend/"+friendId).rpc();
          }
        }
      }
    }
  );
  dialog.center();
  dialog.show();
}

function inviteUser(e){
  $('sectionAddUsers').show();
  var tr = Widget.tr();
  tr.appendChild(
        Widget.td(
          null,
          Widget.fromHTML('<input type="checkbox" name="data[friendInvite][]" checked="checked" value="'+e.index+'">')
        )
  );
  tr.appendChild(
        Widget.td(
          null,
          Widget.a(
            {
              'href': "/profile/"+e.index
            },
            Widget.fromHTML(e.content)
          )
        )
  );
  $('invitableUsers').appendChild(tr);
  $('UserName').value = "";
}

var addAndRefreshBox = function(id, url) {
  var nb = document.boxesNotebook;
  if (nb) {
    var i = 0;
    for (var name in nb.__contents) {
      nb.cleanPage(name); 
      if (id == i && nb.__isSelected(name)) {
        addBox(url);
      }
      i++;
    }
  }
}

var addVirtualBox = function(i, url) {
  document.addBoxDialog.close();
  new Ajax(
    '/homepage/ajax_add_box/'+url+'/'+i,
    {
      'method': 'get'
    }
  ).rpc();
}

function addDialogContent(tab, title) {

  if (!tab) {
    tab = null;
  }

  hideScrolls();
  var dialog = new Dialog(
    {
      'url': '/homepage/ajax_add_icontent'
    },
    {
      'title': __('Add content'),
      'onClose': function() {
        var dialog = document.addContent;
        if (dialog.tab) {
          dialog.tab.__renamePage(dialog.tabTitle);
        }
        Meteora.removeOverlay();
        showScrolls();
      },
      'width':'330',
      'height':'220' 
    }
  );

  Meteora.overlay();
  dialog.center();
  dialog.show();
  if (tab) {
    dialog.tab = tab;
    dialog.tabTitle = title;
  }
  document.addContent = dialog;
}


function OpenVideo(videoName){
  var posx = (screen.width - 645) / 2;
  var posy = (screen.height - 500) / 2;
  window.open('/homepage/video/'+videoName,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=510,left ='+posx+',top ='+posy);
}

function lastPhoto(current_id){
  var orderPhotos = new Array;
  c = $ES('span','photobar');
  c.each(function(e){ orderPhotos.include(parseInt(e.id))})
  c = orderPhotos.indexOf(current_id);
  newId = orderPhotos[c-1];
  if(typeof(newId) == "undefined"){
      if($('lastPhotoPage')){
        $('photoSelected').innerHTML = '';
        $('sectionNav').setContent({'url':$('lastPhotoPage').value+'/1'});
      }
  }else{
      $('currentPhoto').value = newId;
      updateURL(newId);
      $('photoSelected').setContent({'url':'/photos/ajax_individual_photo/'+newId});
  }
}

function nextPhoto(current_id){
  var orderPhotos = new Array;
  var ph = $ES('span','photobar');
  ph.each(function(e){ orderPhotos.include(parseInt(e.id))})
  var c = orderPhotos.indexOf(current_id);
  newId = orderPhotos[c+1];
  if(typeof(newId) == "undefined"){
      if($('nextPhotoPage')){
        $('photoSelected').innerHTML = '';
        $('sectionNav').setContent({'url':$('nextPhotoPage').value});
      }else{  
        if($('photoIndex')){
          $('photoSelected').innerHTML = '';
          $('sectionNav').setContent({'url':$('photoIndex').value});
        }else{
          $('currentPhoto').value = ph[0].id;
          updateURL(ph[0].id);
          $('photoSelected').setContent({'url':'/photos/ajax_individual_photo/'+ph[0].id})   
        }
      }
  }else{
      $('currentPhoto').value = newId;
      updateURL(newId);
      $('photoSelected').setContent({'url':'/photos/ajax_individual_photo/'+newId});
  }   
}
function deleteUserMessage(messageid){
  Meteora.overlay();
 var dialog = new Dialog(
    __('Are you sure?'),
    {
      'title':  __('Remove message'),
      'onClose' :  function(){Meteora.removeOverlay();},
      'buttons': {
        'buttonNo': {
          'caption': __('No'),
          'onClick':  function(dialog) { dialog.close();Meteora.removeOverlay(); }
        },
        'buttonYes': {
          'caption': __('Yes'),
          'default': true,
          'onClick': function(dialog) {
            dialog.close();
            Meteora.removeOverlay();
            new Ajax("/users/ajax_remove_user_comment/"+messageid).rpc();
          }
        }
      }
    }
  );

  dialog.center();


}

function addLiveMatchHomePage(matchId){
  eval("document.timer_"+matchId+" =  document.timer = window.setInterval('updateLiveHomePage("+matchId+")', 60000);");
}
function updateLiveHomePage(matchId){
  new Ajax("/matches/ajax_update_live_homepage/"+matchId).rpc();    
}
function show_or_hide(classes,obj){

  $ES('.'+classes,'fieldMatch').each(function(e){
    if(obj.checked){
      e.show();
    }else{
      e.hide();
    }
  });
}
function takePhoto(obj){
  dialog = new Dialog(
     Widget.embed({'src':'camera.swf','height':'300','width':'300','play':'true','loop':'false','quality':'high','allowscriptaccess':'all','type':'application/x-shockwave-flash'}),
     {
      height:350,
      width:320
     }
  );
  dialog.center();
  document.dialogo = dialog;
}
function getCalendar(teamId){
  hideScrolls();
  var dialog = new Dialog(
    {'url': '/teams/ajax_get_calendar/'+teamId},
    {  'title' : __('Calendar'),
      'onClose': function(){Meteora.removeOverlay();showScrolls();}, 
      'width':'430', 
      'height':'150'
    }
  );
  Meteora.overlay();
  dialog.center();
  dialog.show();
  document.calendarDialog = dialog;
}
