// showing red TR when 'delete' check pressed
 function _if_tr_color(_p_id)
 {
  _v_tr=document.getElementById(_p_id);
  if(_v_tr.old_class==null)
  {
   if(_v_tr.className==null) _v_tr.old_class='';
   else _v_tr.old_class=_v_tr.className;
  }
  if(_v_tr.className=='dict_trd')
   _v_tr.className=_v_tr.old_class;
  else _v_tr.className='dict_trd';
 }
// Highlighting menu item
 function _if_menu_over(_p_id,_p_src)
 {
  _v_img=document.getElementById(_p_id);
  if(_v_img.old_src==null)
   _v_img.old_src=_v_img.src;
  _v_img.src=_p_src;
 }
 function _if_menu_out(_p_id)
 {
  _v_img=document.getElementById(_p_id);
  if(_v_img.old_src!=null) _v_img.src=_v_img.old_src;
 }
// Calculate total team value
 function _if_check_total(_p_max_value)
 {
  var _v_bat0=document.getElementById('_fv_batsmen_id[0]');
  var _v_bat1=document.getElementById('_fv_batsmen_id[1]');
  var _v_bat2=document.getElementById('_fv_batsmen_id[2]');
  var _v_bat3=document.getElementById('_fv_batsmen_id[3]');
  var _v_bat4=document.getElementById('_fv_batsmen_id[4]');
  var _v_bowl0=document.getElementById('_fv_bowler_id[0]');
  var _v_bowl1=document.getElementById('_fv_bowler_id[1]');
  var _v_bowl2=document.getElementById('_fv_bowler_id[2]');
  var _v_bowl3=document.getElementById('_fv_bowler_id[3]');
  var _v_allr=document.getElementById('_fv_allrounder_id');
  var _v_wkpr=document.getElementById('_fv_wicketkeeper_id');

  var _v_total=
   _if_extract_value(_v_bat0[_v_bat0.selectedIndex].text)+
   _if_extract_value(_v_bat1[_v_bat1.selectedIndex].text)+
   _if_extract_value(_v_bat2[_v_bat2.selectedIndex].text)+
   _if_extract_value(_v_bat3[_v_bat3.selectedIndex].text)+
   _if_extract_value(_v_bat4[_v_bat4.selectedIndex].text)+
   _if_extract_value(_v_bowl0[_v_bowl0.selectedIndex].text)+
   _if_extract_value(_v_bowl1[_v_bowl1.selectedIndex].text)+
   _if_extract_value(_v_bowl2[_v_bowl2.selectedIndex].text)+
   _if_extract_value(_v_bowl3[_v_bowl3.selectedIndex].text)+
   _if_extract_value(_v_allr[_v_allr.selectedIndex].text)+
   _if_extract_value(_v_wkpr[_v_wkpr.selectedIndex].text);
  _v_total=Math.round(_v_total*10)/10;

  var _v_max_value=0;
  if(_p_max_value==-1)
  {
   var _v_season=document.getElementById("_fv_season_id");
   _v_max_value=_if_extract_value(_v_season[_v_season.selectedIndex].text);
  }
  else _v_max_value=_p_max_value;
  var _v_object=document.getElementById("total_value");
  var _v_text="";
  if(_v_total>_v_max_value)
   _v_text="<font color='red'>"+_v_total+"</font>";
  else _v_text=_v_total+"";
  _v_text+=" ( max="+_v_max_value+" )";
  _v_object.innerHTML=_v_text;
// Check for the other errors
  var _v_text_error="";
  if(_v_total>_v_max_value)
    _v_text_error+="Team is worth more than allowed in this season<br>";
  if(_p_max_value==-1)
  {
   var _v_team_name=document.getElementById('fan_team_name');
   if(_v_team_name.value=="")
      _v_text_error+="Empty team name is not valid<br>";
   var _v_owner=document.getElementById('fan_owner_name');
   if(_v_owner.value=="")
      _v_text_error+="Empty owner is not valid<br>";
  }

  if((_v_bat0[_v_bat0.selectedIndex].value==_v_bat1[_v_bat1.selectedIndex].value ||
  _v_bat0[_v_bat0.selectedIndex].value==_v_bat2[_v_bat2.selectedIndex].value ||
  _v_bat0[_v_bat0.selectedIndex].value==_v_bat3[_v_bat3.selectedIndex].value ||
  _v_bat0[_v_bat0.selectedIndex].value==_v_bat4[_v_bat4.selectedIndex].value) ||
  (_v_bat1[_v_bat1.selectedIndex].value==_v_bat2[_v_bat2.selectedIndex].value ||
  _v_bat1[_v_bat1.selectedIndex].value==_v_bat3[_v_bat3.selectedIndex].value ||
  _v_bat1[_v_bat1.selectedIndex].value==_v_bat4[_v_bat4.selectedIndex].value) ||
  (_v_bat2[_v_bat2.selectedIndex].value==_v_bat3[_v_bat3.selectedIndex].value ||
  _v_bat2[_v_bat2.selectedIndex].value==_v_bat4[_v_bat4.selectedIndex].value) ||
  (_v_bat3[_v_bat3.selectedIndex].value==_v_bat4[_v_bat4.selectedIndex].value))
    _v_text_error+="Some batsmen was found in 2 or more places!<br>";
  if((_v_bowl0[_v_bowl0.selectedIndex].value==_v_bowl1[_v_bowl1.selectedIndex].value ||
  _v_bowl0[_v_bowl0.selectedIndex].value==_v_bowl2[_v_bowl2.selectedIndex].value ||
  _v_bowl0[_v_bowl0.selectedIndex].value==_v_bowl3[_v_bowl3.selectedIndex].value) ||
  (_v_bowl1[_v_bowl1.selectedIndex].value==_v_bowl2[_v_bowl2.selectedIndex].value ||
  _v_bowl1[_v_bowl1.selectedIndex].value==_v_bowl3[_v_bowl3.selectedIndex].value) ||
  (_v_bowl2[_v_bowl2.selectedIndex].value==_v_bowl3[_v_bowl3.selectedIndex].value))
    _v_text_error+="Some bowler was found in 2 or more places!<br>";

  _v_object=document.getElementById("text_error");
  if(_v_text_error=="")
  {
   _v_object.innerHTML="&nbsp;";
   return true;
  }
  _v_object.innerHTML=
   "<table width='500' border='0' align='center' class='fan_table' cellpadding='5' cellspacing='1'>"+
   "<tr><td class='fan_name' width='120'>Errors:</td><td class='fan_value'><font color='red'>"+
   _v_text_error+"</font></td></tr></table>";
  return false;
 }
 // aux. - extract value from player name
 function _if_extract_value(_p_text)
 {
  var _v_reg=/.*\((.+)\).*/;
  var _v_array=_v_reg.exec(_p_text);
  return parseFloat(_v_array[1]);
 }
