function detectKey()
{
    if (event.keyCode==13) { location.href='/Search.aspx?searchStr=' + document.getElementById('searchInput').value; return false;}else return true;
}

function showSubNav(name) {
  links = document.getElementsByTagName('a');
  for (i = 0; i < links.length; i++)
  {
    var inner = links[i].innerHTML;
    if (inner.indexOf(name) != -1)
    {
        links[i].style.color = '#2FB329';
    }
  }
}

function imageOver(object,imgNum) {
 if (document.images) {
  if (imgNum) img2Change = object + imgNum; else img2Change = object;
  document.getElementById(img2Change).src = eval(object + "On.src");
 }
}
/*function imageOver(object) {
 if (document.images) {
  document.getElementById(object).src = eval(object + "On.src");
 }
}*/

function imageOut(object,imgNum) {
 if (document.images) {
  if (imgNum) img2Change = object + imgNum; else img2Change = object;
  document.getElementById(img2Change).src = eval(object + "Off.src");
 }
}

/*function imageOut(object) {
 if (document.images) {
  document.getElementById(object).src = eval(object + "Off.src");
 }
}*/

function ticketOver(object) {
 var j = document.getElementById('hdnNumTicketTabs').value;
 for (i=1;i<j;i++) {
  document.getElementById("t"+i+"Content").style.visibility='hidden';
  imageOut("t"+i);
 }
 imageOver(object);
 document.getElementById(object+"Content").style.visibility='visible';
}

// tabs
function tabOver(object) {
 imageOver("tab_"+object);
}

function tabOut(object) {
 if (currentSubTab != object) {
  imageOut("tab_"+object);
 }
}

function tabOn(object) {
 if (navigator.appName=="Microsoft Internet Explorer" && document.getElementById("MediaPlayer")) stopMedia();
 document.getElementById("tab_startup_content").style.visibility='hidden';
 document.getElementById("tab_multimedia_content").style.visibility='hidden';
 document.getElementById("tab_news_content").style.visibility='hidden';
 document.getElementById("tab_columns_content").style.visibility='hidden';
 document.getElementById("tab_photos_content").style.visibility='hidden';
 document.getElementById("tab_startup_content").style.display='none';
 document.getElementById("tab_multimedia_content").style.display='none';
 document.getElementById("tab_news_content").style.display='none';
 document.getElementById("tab_columns_content").style.display='none';
 document.getElementById("tab_photos_content").style.display='none';
 currentSubTab=object;
 imageOut("tab_multimedia");
 imageOut("tab_news");
 imageOut("tab_columns");
 imageOut("tab_photos");
 imageOver("tab_"+object);
 document.getElementById("tab_"+object+"_content").style.visibility='visible';
 document.getElementById("tab_"+object+"_content").style.display='block';
 
 document.getElementById('multimediaFrame').style.width = 0; document.getElementById('multimediaFrame').style.height = 0;
 document.getElementById('newsFrame').style.width = 0; document.getElementById('newsFrame').style.height = 0;
 document.getElementById('columnsFrame').style.width = 0; document.getElementById('columnsFrame').style.height = 0;
 document.getElementById('photosFrame').style.width = 0; document.getElementById('photosFrame').style.height = 0;
 if (object == 'multimedia' && document.getElementById('multimediaFrame'))
 { document.getElementById('multimediaFrame').style.width = 460; document.getElementById('multimediaFrame').style.height = 316; }
 if (object == 'news' && document.getElementById('newsFrame'))
 { document.getElementById('newsFrame').style.width = 460; document.getElementById('newsFrame').style.height = 316; }
 if (object == 'columns' && document.getElementById('columnsFrame'))
 { document.getElementById('columnsFrame').style.width = 460; document.getElementById('columnsFrame').style.height = 316; }
 if (object == 'photos' && document.getElementById('photosFrame'))
 { document.getElementById('photosFrame').style.width = 460; document.getElementById('photosFrame').style.height = 316; }
}



// stories
var overStory="";
function storyOver(object) {
 if (prevStoryId!=object) {
  document.getElementById(object+"_txt").style.color="#2FB329";
  overStory=object;
  if(document.getElementById(object+"_img"))
  {
    document.getElementById(object+"_img").style.border="1px solid #2FB329";
    setTimeout("storyExpand('"+object+"')",10);
  }
 }
}

function storyOut(object) {
 document.getElementById(object+"_txt").style.color="#FFFFFF";
 overStory="";
  if(document.getElementById(object+"_img"))
  {
     document.getElementById(object+"_img").style.border="1px solid #A5A5A5";
     setTimeout("storyShrink('"+object+"')",240);
  }
}

function storyExpand(object) {
 if (overStory==object) {
  currentWidth = document.getElementById(object+"_img").width;
  currentHeight = document.getElementById(object+"_img").height;
  if (currentWidth<91) {
   document.getElementById(object+"_img").style.width = currentWidth + 10;
   document.getElementById(object+"_img").style.height=Math.round(currentHeight+(currentHeight/currentWidth)*10);
   setTimeout("storyExpand('"+object+"')",50);
  }
 }
}

function storyShrink(object) {
 if (overStory!=object) {
  currentWidth = document.getElementById(object+"_img").width;
  currentHeight = document.getElementById(object+"_img").height;
  if (currentWidth>51) {
   document.getElementById(object+"_img").style.width = currentWidth - 10;
   document.getElementById(object+"_img").style.height=Math.round(currentHeight-(currentHeight/currentWidth)*10);
   setTimeout("storyShrink('"+object+"')",50);
  }
 }
}

function loadVideo(vidFile,title,description,podcast) {
 document.getElementById('multimediaFrame').src=vidFile;
 document.getElementById('vid_title').innerHTML=title;
 document.getElementById('vid_description').innerHTML=description;
}

var prevStoryId="";
var prevStoryPicBg="";
var prevStoryTxtBg="";

function storyClick(object) {
 if (prevStoryId!="") {
   if(document.getElementById('storyPic_'+prevStoryId))
        document.getElementById('storyPic_'+prevStoryId).style.backgroundColor=prevStoryPicBg;
  document.getElementById('storyTxt_'+prevStoryId).style.backgroundColor=prevStoryTxtBg;
 }

 prevStoryId=object;
 if(document.getElementById('storyPic_'+object))
    prevStoryPicBg=document.getElementById('storyPic_'+object).style.backgroundColor;
 prevStoryTxtBg=document.getElementById('storyTxt_'+object).style.backgroundColor;

 if(document.getElementById('storyPic_'+object))
    document.getElementById('storyPic_'+object).style.backgroundColor="#2FB329";
 document.getElementById('storyTxt_'+object).style.backgroundColor="#2FB329";
 document.getElementById('storyTxt_'+object).style.color="#FFFFFF";

 storyOut(object);
}

// multimedia tabs
function mmOver(object) {
 imageOver("vnav_"+object);
}

function mmOut(object) {
 if (currentSubTab != object) {
  imageOut("vnav_"+object);
 }
}

// MAIN MENU FUNCTIONS
function menuOver(object) {
 showMenu(object);
 imageOut(currentTab);
 imageOver(object);
}

function menuOut(object) {
 show[object]=0;
 setTimeout("hideMenu('"+object+"')",3000);
}

function hideMenu(object) {
 if (document.getElementById(object+'Menu') && document.getElementById(object+'Menu').style.visibility=='visible' && show[object]==0) {
  imageOut(object);
  document.getElementById(object+'Menu').style.visibility='hidden';
  imageOver(currentTab);
  document.getElementById(currentTab+'Menu').style.visibility='visible';
 }
}

function showMenu(object) {
 hideAll();
 show[object]=1;
 if (document.getElementById(object+'Menu')) {
  document.getElementById(currentTab+'Menu').style.visibility='hidden';
  document.getElementById(object+'Menu').style.visibility='visible';
 }
}

function positionSubMenu(object)
{
  frameLeft = document.getElementById('mainMenuFrame').offsetLeft;
  menuWidth = document.getElementById(object+'Menu').offsetWidth;
  buttonCenter = frameLeft + document.getElementById(object).offsetLeft + document.getElementById(object).offsetWidth/2;
  dif = buttonCenter - menuWidth/2;
  if (dif + menuWidth > 995 + frameLeft)
  { 
    dif = 995 - menuWidth + frameLeft; 
  }
  if (dif < frameLeft)
  { 
    dif = frameLeft; 
  }
  document.getElementById(object+'Menu').style.left = dif;
}

var show = new Array();
show['iHome']=0;
show['iTeam']=0;
show['iGameDay']=0;
show['iTickets']=0;
show['i12Zone']=0;
show['iNews']=0;
show['iMultimedia']=0;
show['iQwestField']=0;
show['iCommunity']=0;
show['iSeaGals']=0;
show['iProShop']=0;
show['iKids']=0;
show['iEspanol']=0;

function loadImages(imgFolderPath, gameDayOnImg, gameDayoffImg)
{
if (document.images) {
 iHomeOn = new Image();iHomeOn.src = imgFolderPath + "nav-home-on.gif";
 iTeamOn = new Image();iTeamOn.src = imgFolderPath + "nav-team-on.gif";
 iGameDayOn = new Image();iGameDayOn.src = gameDayOnImg;//imgFolderPath + "nav-combine-on.gif";
 iTicketsOn = new Image();iTicketsOn.src = imgFolderPath + "nav-tickets-on.gif";
 i12ZoneOn = new Image();i12ZoneOn.src = imgFolderPath + "nav-12zone-on.gif";
 iNewsOn = new Image();iNewsOn.src = imgFolderPath + "nav-news-on.gif";
 iMultimediaOn = new Image();iMultimediaOn.src = imgFolderPath + "nav-multimedia-on.gif";
 iQwestFieldOn = new Image();iQwestFieldOn.src = imgFolderPath + "nav-qwest_field-on.gif";
 iCommunityOn = new Image();iCommunityOn.src = imgFolderPath + "nav-community-on.gif";
 iSeaGalsOn = new Image();iSeaGalsOn.src = imgFolderPath + "nav-seagals-on.gif";
 iProShopOn = new Image();iProShopOn.src = imgFolderPath + "nav-pro_shop-on.gif";
 iKidsOn = new Image();iKidsOn.src = imgFolderPath + "nav-kids-on.gif";
 iEspanolOn = new Image();iEspanolOn.src = imgFolderPath + "nav-espanol-on.gif";

 iHomeOff = new Image();iHomeOff.src = imgFolderPath + "nav-home.gif";
 iTeamOff = new Image();iTeamOff.src = imgFolderPath + "nav-team.gif";
 iGameDayOff = new Image();iGameDayOff.src = gameDayoffImg;//imgFolderPath + "nav-combine.gif";
 iTicketsOff = new Image();iTicketsOff.src = imgFolderPath + "nav-tickets.gif";
 i12ZoneOff = new Image();i12ZoneOff.src = imgFolderPath + "nav-12zone.gif";
 iNewsOff = new Image();iNewsOff.src = imgFolderPath + "nav-news.gif";
 iMultimediaOff = new Image();iMultimediaOff.src = imgFolderPath + "nav-multimedia.gif";
 iQwestFieldOff = new Image();iQwestFieldOff.src = imgFolderPath + "nav-qwest_field.gif";
 iCommunityOff = new Image();iCommunityOff.src = imgFolderPath + "nav-community.gif";
 iSeaGalsOff = new Image();iSeaGalsOff.src = imgFolderPath + "nav-seagals.gif";
 iProShopOff = new Image();iProShopOff.src = imgFolderPath + "nav-pro_shop.gif";
 iKidsOff = new Image();iKidsOff.src = imgFolderPath + "nav-kids.gif";
 iEspanolOff = new Image();iEspanolOff.src = imgFolderPath + "nav-espanol.gif"; 
}
}

function hideAll() {
 show['iHome']=0;
 show['iTeam']=0;
 show['iGameDay']=0;
 show['iTickets']=0;
 show['i12Zone']=0;
 show['iNews']=0;
 show['iMultimedia']=0;
 show['iQwestField']=0;
 show['iCommunity']=0;
 show['iSeaGals']=0;
 show['iProShop']=0;
 show['iKids']=0;
 show['iEspanol']=0;

 hideMenu('iHome');
 hideMenu('iTeam');
 hideMenu('iGameDay');
 hideMenu('iTickets');
 hideMenu('i12Zone');
 hideMenu('iNews');
 hideMenu('iMultimedia');
 hideMenu('iQwestField');
 hideMenu('iCommunity');
 hideMenu('iSeaGals');
 hideMenu('iProShop');
 hideMenu('iKids');
 hideMenu('iEspanol');
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
