﻿// JScript File
var is_ei = 0;
var is_sr = 0;
var is_ns = 0;

if( String(navigator.appName).indexOf("Microsoft") >= 0)  is_ei = 1;
if( String(navigator.appName).indexOf("Netscape") >= 0)   is_ns = 1;

function  elemPos(elemID) 
{
    if(document.getElementById(elemID ) )
    {
        var offsetTrail = document.getElementById(elemID);
        var offsetLeft = 0;
        var offsetTop = 0;
        while (offsetTrail) 
        {
            offsetLeft += offsetTrail.offsetLeft;
            offsetTop += offsetTrail.offsetTop;
            offsetTrail = offsetTrail.offsetParent;
        }
        if(is_ei == 0 && is_ns == 0)
        {
            offsetLeft += document.body.leftMargin;
            offsetTop += document.body.topMargin;
        }
     return [offsetLeft, offsetTop,getComputedWidth(elemID),getComputedHeight(elemID)];
    }
    else return [0,0,0,0];
}

function getComputedHeight(theElt)
{
   var tmphght = 0;
    if(is_ei == 1 || is_ns == 1)
    {
            tmphght = document.getElementById(theElt).offsetHeight;
    }
    else
    {
            docObj = document.getElementById(theElt);
            var tmphght1 = document.defaultView.getComputedStyle(docObj, "").getPropertyValue("height");
            tmphght = tmphght1.split('px');
            tmphght = tmphght[0];
    }
    return tmphght;
}


function getComputedWidth(theElt)
{
   var tmphght = 0;
    if( is_ei == 1 || is_ns == 1)
    {
            tmpWidth = document.getElementById(theElt).offsetWidth;
    }
    else
    {
        tmpWidth = document.getElementById(theElt).offsetWidth;
            docObj = document.getElementById(theElt);
            var tmpWidth1 = document.defaultView.getComputedStyle(docObj, "").getPropertyValue("width");
            tmpWidth = tmpWidth.split('px');
            tmpWidth = tmpWidth[0];
    }
    return tmpWidth;
}

function toggleDisplay(id)
{
   if( document.getElementById(id) )
   {
        if( document.getElementById(id).style.display == 'none')
          document.getElementById(id).style.display = '';
        else document.getElementById(id).style.display = 'none';
   }
}


function display(id,mode)
{

   
   if( document.getElementById(id))
   {
       if(mode == 'y' || mode == 'Y')
       {
          document.getElementById(id).style.display = '';
       }
       else
       {
           document.getElementById(id).style.display = 'none';
       }
   }
   
   
   if( document.getElementById('city') && document.getElementById('divHome'))
    {
     
                 if( document.getElementById('divHome').style.display == 'none')
                    document.getElementById('city').style.display = '';
                  else document.getElementById('city').style.display = 'none';
    }
   
 
   
}

var menuId = "";
var focusMenuId = "";
function menuDropDown(name)
{

   
   if( String(menuId).length > 0 && menuId != focusMenuId) display(menuId,'n');
   lbId  = 'lb' + name
   tdId  = 'td' + name;
   tblId = 'tbl' + name;
   divId = 'div' + name;
   if(document.getElementById(lbId) )
      document.getElementById(lbId).style.fontWeight = 'bold';
   if(document.getElementById(tdId) && document.getElementById(divId) && document.getElementById(divId) && document.getElementById(tblId) )
   {
       pos = elemPos(tdId)
       document.getElementById(divId).style.left = '' + (pos[0]-1) + 'px';
       document.getElementById(divId).style.top = '' + (pos[1] + pos[3]) + 'px';
       document.getElementById(tblId).width = '' + (pos[2] + 2) + 'px';
       display(divId,'y');
       menuId = divId;
       focusMenuId = "";
       
   }
}


function viewCart()
{
 
  window.location= "" + httpPrefix + "ticketCart.aspx";
}


function menuOut(id)
{
   
   display(id,'n');
 }

function delayMenuHideDisplay()
{
    setTimeout("hideDelayedMenu()",2000);
}

function hideDelayedMenu()
{
   
   if( focusMenuId != menuId ) 
   {
      
      display(menuId,'n');
   }
}

function keepDropDown(id)
{
    focusMenuId = id;
}

function changeBg(id,color)
{
   document.getElementById(id).style.backgroundColor = color;
}

function changeIm(id,src)
{
   document.getElementById(id).src = src;
}


function divisionResults(name)
{
 var lcg = "tdHome";
 if(lastChangeOfGenre) lcg = lastChangeOfGenre;
 
 var url =  "" + httpPrefix  + "divisionResults.aspx?st=" + lcg + "&name=" + name;
 window.location = url;
}



function selectTickets(sk,vk,dt)
{

 var lcg = "tdHome";
 if(lastChangeOfGenre) lcg = lastChangeOfGenre;

  sk =  String(sk).toLowerCase();
  vk =  String(vk).toLowerCase();
  
  if(sk == "ac/dc") sk = "acdc";
  if(vk == "none") vk = "";
  //2.
  
  var url =  httpPrefix + "selectTickets.aspx?st=" + lcg + "&sk=" + sk + "&vk=" + vk + "&dt=" + dt;
  
  url=url.toLowerCase().replace('char',':c:');
  url = url.replace('char',":c:");
  window.location = url;
  //alert(url);
} 




function sportRresultDetails(sk,vk,ck,rk)
{

 var lcg = "tdHome";
 if(lastChangeOfGenre) lcg = lastChangeOfGenre;


  sk =  String(sk).toLowerCase();
  vk =  String(vk).toLowerCase();
  ck =  String(ck).toLowerCase();
  rk =  String(rk).toLowerCase();
 
  
  if(ck == "new york" || rk == "new york")
  { 
     ck = "";
     if(sk == "new york giants") rk = "NJ";
     if(sk == "new york jets")  rk = "NJ";
  }
  
  if(vk == "none") vk = "";
  if(ck == "none") ck = "";
  var url =  "" + httpPrefix +  "resultDetails.aspx?st=" + lcg + "&sk=" + sk + "&vk=" + vk + "&ck=" + ck + "&rk=" + rk;
  
 ////
  url = "resultDetails" + lcg + "," + sk + "," + vk + "," + ck + "," + rk;
 callbackAjax(url);
 
 

 /*  if(document.getElementById('sportTeamsState'))
   {
      url = url + "&sp=" + document.getElementById('sportTeamsState').value;
   }
  window.location = url; */
 
}     

function resultDetails(sk,vk,ck,rk)
{

  var lcg = "tdHome";
 if(lastChangeOfGenre) lcg = lastChangeOfGenre;

   sk = String(sk).replace("&",":and:");
   vk = String(vk).replace("&",":and:");
  
   if(document.getElementById('sportTeamsState'))
   {
     if(String(document.getElementById('sportTeamsState').value).length > 0)
         document.getElementById('sportTeamsState').value = '';
   }

   //setLoadingGif('divPageControlTable');
  sk =  String(sk).toLowerCase();
  vk =  String(vk).toLowerCase();
  ck =  String(ck).toLowerCase();
  rk =  String(rk).toLowerCase();
  if(sk == "ac/dc") sk = "acdc";
  
 
  
  if(ck == "new york" || rk == "new york")
  { 
     ck = "";
     if(sk == "new york giants") rk = "NJ";
     if(sk == "new york jets")  rk = "NJ";
  }
  
  if(vk == "none") vk = "";
  if(ck == "none") ck = "";
  
  var url =  "" + httpPrefix +  "resultDetails.aspx?st=" + lcg + "&sk=" + sk + "&vk=" + vk + "&ck=" + ck + "&rk=" + rk;
  
 url = "resultDetails" + lcg + "," + sk + "," + vk + "," + ck + "," + rk;
 callbackAjax(url);
  
 //window.location = url;
  //alert(url);
  
  
  
} 

//http://localhost:3066/WebTravelocity/nascar_camping_world_truck_series%3A_nextera_energy_resources_250/Daytona_International_Speedway/daytona_beach/State_tickets
 function showWin(url,name)
   {
      if(url.indexOf(url) < 0) url = "" + httpPrefix + url;
       
      window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=580,height=480,left=100,top=50');
   }
   
   


 function showfaq()
   {
      window.open("" + httpPrefix + "faq.aspx","faq",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=600,height=580,left=100,top=50');
   } 
   
   //was in navigation.js
function quickCity()
{
    if( document.getElementById('city') )
    {
        var city = String( document.getElementById('city').value);
        document.getElementById('cityGuideCity').value = city;
       
        //navigationDisplay('cityGuide' + city + ';' +  document.getElementById('cityGuideSort').value + ";" + document.getElementById('cityGuideSortDir').value);
        //window.location=  httpPrefix + "default.aspx?st=searchcity&sk=" + city;
        window.location=  httpPrefix + "SearchCity_" + city.replace(/ /g,"_") + "_Tickets";
    }
} 