//Generic Window Opener function
function openWinFsi(winURL, winName, winWidth, winHeight) {
  var winTop  = 25;
  var winLeft = 25;
  if (screen.availWidth <= 800) {
    var winLeft = screen.availWidth - winWidth;
  }
  if (arguments.length == 2) {  //open generic window
    var theWin = window.open(winURL, winName);
  }
  else { // open standard pop-up window with tool bars disabled  
    var theWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + ",top=" + winTop + ",left=" + winLeft + ",screenY=" + winTop + ",screenY=" + winLeft + ",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=1,scrollbars=1");
  }
}

/*not currently in used!*/
function LgTmFrntOpenTeamFrntPage(site,league,description,id) {
    var tempURL = site+'/'+league+'/team/'+description+'?categoryId='+id;
    var url = window.location.href;
    var contextPath = url.split('/')[2];

    //It is advisable to take always the url directly from the application. If there is an error use a static redirect instead
    if(url=="" || contextPath==""){
      window.parent.location='http://msn.foxsports.com/'+tempURL;
    }
    else{//url is taken from the application
      window.parent.location='http://'+contextPath+'/'+tempURL;
    }  
}

/*These functions are used on the league team front selection module.*/
function showLgTmSelectionModule(elmnt){ //when mousing over a logo
  if(document.getElementById(elmnt)){
     document.getElementById(elmnt).style.visibility="visible";
  }
}

function hideLgTmSelectionModule(elmnt){ //When mousing out a logo
  if(document.getElementById(elmnt)){
    document.getElementById(elmnt).style.visibility="hidden";
  }
}

/*Display key color info when mousing over*/
function FSIKeyColorInfoTip(colorDescription,colorCode){
  //Begin content and layout of info when mousing over
  var tableBegin          = "<table border=\'0\'>";
  var colorKeyDescription = "<tr><td width=\'10px\' style=\'background-color:"+colorCode+"\'>&nbsp;</td><td align=\'left\' style=\'font-weight:bold;font-family:Verdana;font-size:10px\'>"+colorDescription+"</td></tr>";
  var tableEnd            = "</table>";
  
  contentType = tableBegin + colorKeyDescription + tableEnd;
  return Tip(contentType, ABOVE, true, JUMPHORZ, true, FADEIN, 300, FADEOUT, 400, BORDERCOLOR, '#cccccc', TITLEFONTCOLOR, '#ffffff', TITLEFONTFACE, 'Verdana, Arial, Helvetica, sans-serif', FOLLOWMOUSE, false, OPACITY, 95, DELAY, 1, ABOVE, true, OFFSETY, -15);
}

//needs to be moved into another js file
function openMatchTraxFSI(winURL) {
  var winWidth = 740; 
  var winHeight = 610;
  var winName = 'MatchTrax';
  var winTop  = 25;
  var winLeft = 25;
  if (screen.availWidth <= 800) {
    var winLeft = screen.availWidth - winWidth;
  }
  if (arguments.length == 2) {  //open generic window
    var theWin = window.open(winURL, winName);
  }
  else { // open standard pop-up window with tool bars disabled  
    var theWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + ",top=" + winTop + ",left=" + winLeft + ",screenY=" + winTop + ",screenY=" + winLeft + ",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no");
  }
}

//---------------------------------------------------------------------------
// NAME:    fsiImgError(source,sport,imgSize)
// PURPOSE: replace broken images with default images on all FSI/FPAS pages
// PARAM:   source:  self image 
//          sport:   based on this, present a soccer ball, baseball, basketball etc
//          imgSize: image size (xsmall, small, medium, large)  
// RESULT:  substituted image (if any)  
//----------------------------------------------------------------------------
function fsiImgError(source,sport,imgSize) {
 var imgPath = null;
 //default images for soccer
 if(sport=='soccer'){
   if (imgSize=='xsmall')      {imgPath = '/fe/fsi/img/futbol/teamLogo/statsInc/xsmall/nologo.gif'}
   else if (imgSize=='medium') {imgPath = '/fe/fsi/img/futbol/teamLogo/statsInc/medium/nologo.gif'}
   else                        {imgPath = '/fe/fsi/img/futbol/teamLogo/statsInc/small/nologo.gif' }
 }
 //add other sports here
  source.src = imgPath;
  source.onerror = ""; // disable onerror to prevent endless loop
  return true;
}
