﻿tvgReferrer='Arena';
tvgBroadcaster='Arena-Family-XXL';
tvgListingsDiv = 'tvgListingComp';
tvgListingsViewStyle='Magazine';
tvgNumberChannels=5;
tvgNumberHours=6;
tvgListingsShowFullWeek='Yes';
tvgListingShow24hDropDown='Yes';
tvgListingsHeaderText='%cardinal%. %month%%';
tvgShowDetailsDiv='tvgShowDetails';
tvgThumbnailUrl='http://static.tvgenius.co.uk/thumbs/160x90/';
tvgTVSearchDiv='tvgSearchDiv';
tvgFoundText='%number% %shows% %phrase%%';
tvgSearchSummaryLength=110;
tvgListingsShowPicks='Yes';
tvgMagazineChannelLogoURL='http://demos.tvgenius.net/arena/img/ChannelLogos/';
tvgListingsLoadWholeDay='Yes';
tvgFirstChannelNumber=0;
tvgListingsDiv='tvgListingCompHidden';
tvgScrollStep=25;
tvgScrollTimer=10;
tvgShowListingsPrefs='WithChannels';
tvgRepeatSearchNav='Yes';
tvgShowChannelNumbers='Yes';
tvgMouseOverNumberCharacters=40;

function tvgAjaxPreback(id)
{
switch (id)
    {
    case 'tvgListingCompHidden':
    
    tvgPrepareScrolling('tvgListingComp')
    
    break;
    default:
    break;
    }
}
function tvgAjaxCallback(id)
    {
    switch (id)
        {
        case 'tvgListingCompHidden':
        tvgImplementScrolling('tvgListingComp');
        
        case 'tvgListingComp':
        tvgClose('tvgShowDetailsWrapper');
        tvgClose('tvgSearchWrapper');

        break;
        
        case 'tvgShowDetails':
        var wrapper = document.getElementById('tvgShowDetailsWrapper');
        var box = document.getElementById('tvgDescription');
        wrapper.style.display='none';
        wrapper.style.display='block';
        if (box.style.visibility == 'visible')
        {
            wrapper.style.left = "300px";
            wrapper.style.top = "320px";
            box.style.zIndex=-1;
            }
        else
        {
          
            //position the details box...
            var listingID = tvg_qs.match(/tvgListingID=\d*/);

            var els= document.getElementsByTagName('div');
            for (var i  = els.length -1; i >= 0; i--)
            {
                if (els[i].className.indexOf('tvg_search_result') == 0 | els[i].className.indexOf('tvg_listings_channel_bit') >=0)
                {
                    if (els[i].innerHTML.indexOf(listingID) > 0)
                        {
                        var chann_offset = tvgGetOffset(els[i]);
                        var chan_top = (els[i].offsetTop != undefined) ? parseInt(els[i].offsetTop,10):0;
                
                        //Calculate the offset of the pop-up...
                        var popup_offset = tvgGetOffset(wrapper); 
                        var idealPosition = chann_offset[1] - popup_offset[1] + chan_top - 100;

                        wrapper.style.top = idealPosition + 'px';

                        break;
                        }
                }
            
            }
        }
        break;

        case 'tvgSearchDiv':
        document.getElementById('tvgSearchWrapper').style.display='block';
        tvgClose('tvgShowDetailsWrapper');
        break;
        }
    }
    
function tvgClose(div)
{
    document.getElementById(div).style.display='none';
    if (div = 'tvgSearchWrapper')
        {
        tvg_qs = tvg_qs.replace('tvgPageNumber=','ignore=');
        }
    if (div = 'tvgShowDetails')
        {      
        try {
        document.getElementById('tvgDescription').style.zIndex=1;
        }catch(e) {}
        tvgClearParameter("tvgShowID");
        tvgClearParameter("tvgEpisodeID");
        }
}


function tvgSearchKeyDown(e)
{
if (e.keyCode == 13)
            {
            tvgDoSearch();
            }
 }
  

function tvgDoSearch()
{

if (tvgVerifySearch('tvgSearchBox'))
    {
    tvgLinkTo('search', 'tvgSearchDiv', '', '?tvgEpisodeID=&tvgShowID=&tvgSearchPhrase=' + encodeURIComponent (document.getElementById('tvgSearchBox').value) );
    }
 }  

