﻿// JScript File
var xmlHttp;
var sport
var type;
var lang;
var sort;
var subcontestID;
var contestName;
var intval = "";
var refreshInterval; 
var date;
var intvalTicker = "";
var resizeIDArrayLive = "";
var resizeIDArrayFixtures = "";
var resizeIDArrayResults = "";
var resizeIDArrayUpcoming = "";
var closedIDArray = "";
var pageType = "";
var typeStats;
var statsOrResults = "results";
var dateNew;
var country;
var eventID;
var dateForTv = "";
var firstCheckedTeam;
var secondCheckedTeam;
var uper;
var weekCount = 0;
var season = "";

function refreshPage(typeIN) {
    closedIDArray = "";
    resizeIDArrayLive = "";
    resizeIDArrayFixtures = "";
    resizeIDArrayResults = "";
    dateForTv = "";
    if (typeIN != "") {
        type = typeIN;
    } else {
        if (sport == "football") {
            arrayMyMatchesSoccer = new Array();
        } else if (sport == "basketball") {
            arrayMyMatchesBasketball = new Array();
        }        
    }
    if (type == 'left_menu') {
        refreshInterval = 600000;
    }
    else if (type == 'live') {
        refreshInterval = 5000;
    }
    else if (type == 'liveOnTv') {
        pageType = "tv";
        refreshInterval = 3600000;
        $.post("page_type_menu.aspx?page=" + pageType + "&sport=" + sport,
            function(data) {
                $("#page_type_menu").html(data);
            });
    } else if (type == "fixtures") {
        refreshInterval = 60000;
    } else if (type == "mymatches") {
        refreshInterval = 30000;
    } else if (type == 'aboutUs') {
        refreshInterval = 3600000;
    }
    else if (type == 'liveOnTv') {
        refreshInterval = 3600000;
    }
    else {
        refreshInterval = 120000;
    }
    if (type == "mymatches") {
        $("#reset").hide();
    } else {
        $("#reset").show();
    }
    if (intval == "") {
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    else {
        stop_Int();
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    checkselect();    
}
function refreshTV(sportIN) {
    if (sportIN != "") {
        sport = sportIN;
    }
    if (intval == "") {
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    else {
        stop_Int();
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    checkselect();
}

function refreshPageTV(typeIN, eventIDIN, sportIN) {
    if (statsOrResults == "stats") {
        prepareForResults();
        statsOrResults = "results";
    }
    dateForTv = "";
    closedIDArray = "";
    resizeIDArrayFixtures = "";
    resizeIDArrayLive = "";
    resizeIDArrayResults = "";
    eventID = eventIDIN;
    if (typeIN != "") {
        type = typeIN;
    }
    if (sportIN != "") {
        sport = sportIN;
    }   
    if (intvalTicker == "") {
        showDataTicker();
        intvalTicker = setInterval("showDataTicker()", 5000);
    }
    else {
        stop_IntTicker();
        showDataTicker();
        intvalTicker = setInterval("showDataTicker()", 5000);
    }
    if (type == 'liveOnTv') {
        pageType = "tv";
        refreshInterval = 3600000;
        $.post("page_type_menu.aspx?page=" + pageType + "&sport=" + sport,
            function(data) {
                $("#page_type_menu").html(data);
            });
    }
    if (intval == "") {
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    else {
        stop_Int();
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    checkselect();
    $("#left_menu").empty();
}

function refreshPageSport(sportIN, typeIN, langIN, sortIN, pageTypeIN) {
    if (statsOrResults == "stats") {
        prepareForResults();
        statsOrResults = "results";
    }
    dateForTv = "";
    sport = sportIN;
    type = typeIN;
    lang = langIN;
    pageType = pageTypeIN;
    if (type == "fixtures") {
        refreshInterval = 60000;
    } else {
        refreshInterval = 120000;
    }
    $.post("page_type_menu.aspx?page=" + pageType + "&sport=" + sport,
            function(data) {
                $("#page_type_menu").html(data);
                checkselect();
            });
    if (intvalTicker == "") {
        showDataTicker();
        intvalTicker = setInterval("showDataTicker()", 5000);
    }
    else {
        stop_IntTicker();
        showDataTicker();
        intvalTicker = setInterval("showDataTicker()", 5000);
    }

    if (sortIN != "0") {
        sort = sortIN;
    }
    if (intval == "") {
        showData();
        intval = setInterval("showData()", refreshInterval);
    }
    else {
        stop_Int();
        showData();
        intval = setInterval("showData()", refreshInterval);
    }

    $("#left_menu").empty();
    //checkHeaderBanners();
}

function stop_Int() {
    if (intval != "") {
        window.clearInterval(intval)
        intval = ""
    }
}
function stop_IntTicker() {
    if (intvalTicker != "") {
        window.clearInterval(intvalTicker)
        intvalTicker = ""
    }
}

function refreshDateMinus() {
    date = document.getElementById("ddd").innerHTML;
    var dateArray = date.split("-");
    dateNew = new Date(dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]);
    dateNew.setDate(dateNew.getDate() - 1);
    var dayStr = dateNew.getDate().toString();
    if(dayStr.length == 1)
    {
        dayStr = 0 + dayStr;
    }
    var monthStr = (dateNew.getMonth() + 1).toString();
    if(monthStr.length == 1)
    {
        monthStr = 0 + monthStr;
    }
    document.getElementById("ddd").innerHTML = dayStr + "-" + monthStr + "-" + dateNew.getFullYear();
    date = (dateNew.getMonth() + 1) + "-" + dateNew.getDate() + "-" + dateNew.getFullYear();
    if (type != "liveOnTv") {
        type = "forDay";
    } else {
        dateForTv = date;
    }
    checkDate();
    if (intval == "") {
        showData();
    }
    else {
        stop_Int();
        showData();
    }
}

function refreshDatePlus() {
    date = document.getElementById("ddd").innerHTML;
    var dateArray = date.split("-");
    dateNew = new Date(dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]); 
    dateNew.setDate(dateNew.getDate() + 1);  
    var dayStr = dateNew.getDate().toString();
    if(dayStr.length == 1)
    {
        dayStr = 0 + dayStr;
    }
    var monthStr = (dateNew.getMonth() + 1).toString();
    if(monthStr.length == 1)
    {
        monthStr = 0 + monthStr;
    }
    document.getElementById("ddd").innerHTML = dayStr + "-" + monthStr + "-" + dateNew.getFullYear();
    date = (dateNew.getMonth() + 1) + "-" + dateNew.getDate() + "-" + dateNew.getFullYear();
    if (type != "liveOnTv") {
        type = "forDay";
    } else {
        dateForTv = date;
    }
    checkDate();
    if (intval == "") {
        showData();
    }
    else {
        stop_Int();
        showData();
    }
}

function showData() {
    if (type == 'live') {
        $.post("refresh_live.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort=" + sort + "&resize="
                   + resizeIDArrayLive + "&close=" + closedIDArray,
            function(data) {
                $("#accordians").html(data);
                checkMyMatches();
                removeClosedElements();
                resizeResizedElements();
                checkMainHeight();
                checkDoubleImages();
            });
    } else if (type == 'results') {
        $.post("refresh_results.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort="
                    + sort + "&resize=" + resizeIDArrayResults + "&close=" + closedIDArray,
            function(data) {
                $("#accordians").html(data);
                checkMyMatches();
                removeClosedElements();
                resizeResizedElements();
                checkMainHeight();
                checkDoubleImages();
            });
    } else if (type == 'fixtures') {
        $.post("refresh_fixtures.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort="
                    + sort + "&resize=" + resizeIDArrayFixtures + "&close=" + closedIDArray,
            function(data) {
                $("#accordians").html(data);
                checkMyMatches();
                removeClosedElements();
                resizeResizedElements();
                checkMainHeight();
                checkDoubleImages();
            });
    } else if (type == 'upcoming') {
        $.post("refresh_upcoming.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort="
                    + sort + "&resize=" + resizeIDArrayFixtures + "&close=" + closedIDArray,
            function(data) {
                $("#accordians").html(data);
                checkMyMatches();
                removeClosedElements();
                resizeResizedElements();
                checkMainHeight();
                checkDoubleImages();
            });
    }else if (type == "mymatches") {
        $.post("refresh_mymatches.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort="
                    + sort,
            function(data) {
                if (sport == "football") {
                    showMyMatchesSoccer(data, true);
                } else if (sport == "basketball") {
                    showMyMatchesBasketball(data, true);
                }
                checkMainHeight();
                checkDoubleImages();
            });
    } else if (type == 'liveOnTv') {
        $.post("liveOnTv.aspx?sport=" + sport + "&lang=" + lang + "&sort=" + sort + "&event=" + eventID + "&date=" + dateForTv,
            function(data) {
                $("#accordians").html(data);
                checkMainHeight();
                try{
                    var p = $("#t_" + eventID).position();
                    $.scrollTo(p.top - 10);
                } catch(err){}
            });
    } else if (type == 'forDay') {
        $.post("refresh_forday.aspx?type=naslovna&sport=" + sport + "&lang=" + lang + "&cont=-1&bookie=&iframe=0&sort="
        + sort + "&date=" + date,
            function(data) {
                $("#accordians").html(data);
                checkMainHeight();
                checkDoubleImages();
            });
    }
}

function showRightColumnDataStats() {
    $.post("refresh_stats_right_column.aspx?sport=" + sport + "&lang=" + lang + "&country=" + country + "&id=" + subcontestID,
            function(data) {
                $("#leagues_right").html(data);
                if ($("#hidSeason").length > 0) {
                    season = $("#hidSeason")[0].value;
                    $("#season").html(season);
                }
            });
}

function showDataTicker() {
    $.post("refresh_livescore_changes.aspx?type=naslovna&sport=football&lang=2&cont=-1&bookie=&iframe=0&sort=1",
            function(data) {
                $("#col-right").html(data);
            });
}

function removeClosedElements() {
    if (closedIDArray != "") {
        var niz = new Array();
        niz = closedIDArray.split(',');
        $.each(niz, function() {
            var elemDiv = $("#td_" + this);
            if (elemDiv) {
                elemDiv.remove();
            }
            elemDiv = $("#t_" + this);
            if (elemDiv) {
                elemDiv.remove();
            }
            elemDiv = $("#acc_" + this);
            if (elemDiv) {
                elemDiv.remove();
            }
        });
    }
}

function resizeResizedElements() {
    if (type == "fixtures") {
        if (resizeIDArrayFixtures != "") {
            var niz = new Array();
            niz = resizeIDArrayFixtures.split(',');
            $.each(niz, function() {
                var elem = $("#acc_" + this);
                elem.hide();
                var elem_pic = $("#" + this)
                elem_pic.attr("src", "media/images/plus.gif");
            });
        }
    } else if (type == "live") {
        if (resizeIDArrayLive != "") {
            var niz = new Array();
            niz = resizeIDArrayLive.split(',');
            $.each(niz, function() {
                var elem = $("#acc_" + this);
                elem.hide();
                var elem_pic = $("#" + this)
                elem_pic.attr("src", "media/images/plus.gif");
            });
        }
    } else if (type == "results") {
        if (resizeIDArrayResults != "") {
            var niz = new Array();
            niz = resizeIDArrayResults.split(',');
            $.each(niz, function() {
                var elem = $("#acc_" + this);
                elem.hide();
                var elem_pic = $("#" + this)
                elem_pic.attr("src", "media/images/plus.gif");
            });
        }
    } else if (type == "upcoming") {
        if (resizeIDArrayUpcoming != "") {
            var niz = new Array();
            niz = resizeIDArrayUpcoming.split(',');
            $.each(niz, function() {
                var elem = $("#acc_" + this);
                elem.hide();
                var elem_pic = $("#" + this)
                elem_pic.attr("src", "media/images/plus.gif");
            });
        }
    }
}

function checkselect() {
    try {
        var elem;
        elem = document.getElementById("fixtures");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("live");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("results");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("upcoming");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("mymatches");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("liveOnTv");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("football");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("basketball");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("hockey");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("nfl");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("tennis");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("cricket");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("handball");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("volleyball");
        if (elem != null) {
            elem.className = "match";
        }
        elem = document.getElementById("rugby");
        if (elem != null) {
            elem.className = "match";
        }

        if (type != "liveOnTv") {            
            if (sport == "football") {
                elem = document.getElementById("football");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "basketball") {
                elem = document.getElementById("basketball");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "hockey") {
                elem = document.getElementById("hockey");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "nfl") {
                elem = document.getElementById("nfl");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "tennis") {
                elem = document.getElementById("tennis");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "cricket") {
                elem = document.getElementById("cricket");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "handball") {
                elem = document.getElementById("handball");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "volleyball") {
                elem = document.getElementById("volleyball");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "rugby") {
                elem = document.getElementById("rugby");
                if (elem != null) {
                    elem.className = "active";
                }
            }
        }
        else {
            elem = document.getElementById("footballTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("basketballTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("hockeyTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("nflTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("tennisTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("cricketTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("handballTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("volleyballTV");
            if (elem != null) {
                elem.className = "match";
            }
            elem = document.getElementById("rugbyTV");
            if (elem != null) {
                elem.className = "match";
            }
            if (sport == "football") {
                elem = document.getElementById("footballTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "basketball") {
                elem = document.getElementById("basketballTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "hockey") {
                elem = document.getElementById("hockeyTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "nfl") {
                elem = document.getElementById("nflTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "tennis") {
                elem = document.getElementById("tennisTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "cricket") {
                elem = document.getElementById("cricketTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "handball") {
                elem = document.getElementById("handballTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "volleyball") {
                elem = document.getElementById("volleyballTV");
                if (elem != null) {
                    elem.className = "active";
                }
            } else if (sport == "rugby") {
                elem = document.getElementById("rugbyTV");
                if (elem != null) {
                    elem.className = "active";
                }
            }
        }
        if (type == "fixtures") {
            elem = document.getElementById("fixtures");
            if (elem != null) {
                elem.className = "active";
            }
        } else if (type == "live") {
            elem = document.getElementById("live");
            if (elem != null) {
                elem.className = "active";
            }
        } else if (type == "results") {
            elem = document.getElementById("results");
            if (elem != null) {
                elem.className = "active";
            }
        } else if (type == "upcoming") {
            elem = document.getElementById("upcoming");
            if (elem != null) {
                elem.className = "active";
            }
        } else if (type == "mymatches") {
            elem = document.getElementById("mymatches");
            if (elem != null) {
                elem.className = "active";
            }
        } else if (type == "liveOnTv") {
            elem = document.getElementById("liveOnTv");
            if (elem != null) {
                elem.className = "active";
            }
        }
    }
    catch (err) { }
}

function resize(id) {
    var elem = $("#acc_" + id);
    var elem_pic = $("#" + id);
    var elem_tab = $("#tab_" + id);
    if (elem_pic.attr("src").search("plus.gif") > -1) {
        elem_pic.attr("src", "media/images/neg.gif");
        elem.show("fast");
        if (type == "live") {
            resizeIDArrayLive = resizeIDArrayLive.replace(id, "");
        }
        if (type == "fixtures") {
            resizeIDArrayFixtures = resizeIDArrayFixtures.replace(id, "");
        }
        if (type == "results") {
            resizeIDArrayResults = resizeIDArrayResults.replace(id, "");
        }
        if (type == "upcoming") {
            resizeIDArrayUpcoming = resizeIDArrayUpcoming.replace(id, "");
        }
    } else {
        elem_pic.attr("src", "media/images/plus.gif");
        elem.hide("fast");
        if (type == "live") {
            if (resizeIDArrayLive != "") {
                resizeIDArrayLive = resizeIDArrayLive + ",";
            }
            resizeIDArrayLive = resizeIDArrayLive + id;
        }
        if (type == "fixtures") {
            if (resizeIDArrayFixtures != "") {
                resizeIDArrayFixtures = resizeIDArrayFixtures + ",";
            }
            resizeIDArrayFixtures = resizeIDArrayFixtures + id;
        }
        if (type == "results") {
            if (resizeIDArrayResults != "") {
                resizeIDArrayResults = resizeIDArrayResults + ",";
            }
            resizeIDArrayResults = resizeIDArrayResults + id;
        }
        if (type == "upcoming") {
            if (resizeIDArrayUpcoming != "") {
                resizeIDArrayUpcoming = resizeIDArrayUpcoming + ",";
            }
            resizeIDArrayUpcoming = resizeIDArrayUpcoming + id;
        }
    }
}

function remove(id) {
    if (closedIDArray != "") {
        closedIDArray = closedIDArray + ",";
    }
    closedIDArray = closedIDArray + id;
    var elemDiv = $("#td_" + id);
    if (elemDiv) {
        elemDiv.remove();
    }
    elemDiv = $("#t_" + id);
    if (elemDiv) {
        elemDiv.remove();
    }
    elemDiv = $("#acc_" + id);
    if (elemDiv) {
        elemDiv.remove();
    }
}

function removeTV(id) {
    var elemDiv = document.getElementById("td_" + id);
    if (elemDiv != null) {
        elemDiv.outerHTML = "";
    }
    elemDiv = document.getElementById("t_" + id);
    if (elemDiv != null) {
        elemDiv.outerHTML = "";
    }
    elemDiv = document.getElementById("acc_" + id);
    if (elemDiv != null) {
        elemDiv.outerHTML = "";
    }
}

function prepareForResults() {
    home = "";
    away = "";
    var elem = document.getElementById('container');
    try{
        elem.removeChild(document.getElementById('col-big'));
    } catch (e) {
        try {
            elem.removeChild(document.getElementById('col-big1'));
        } catch (ee) {
            elem.removeChild(document.getElementById('col-left'));
        }
    }
    try {
        elem.removeChild(document.getElementById('col-right-big'));
    }
    catch (eee) {
    }

    var newLeftDiv = document.createElement('div');
    newLeftDiv.setAttribute('id', 'col-left');
    newLeftDiv.innerHTML = "<span class='col-heading'>League Browser</span>" +
            "<br /><br />" +
            "<table width='190' cellspacing='0' cellpadding='0' border='0' style='margin: 0pt auto;'>" +
                "<tr>" +
                    "<td width='4px' valign='top' align='right'>" +
                        "<img src='media/images/txt_left_crn.gif' alt=''/>" +
                    "</td>" +
                    "<td background='media/images/txt_bg.gif'>" +
                        "<label>" +
                            "<input id='123' type='text' onfocus='this.value=\"\"' onclick='value=\"\"'" +
                                "value='search...' onkeydown='search(event);' onKeyPress='return disableEnterKey(event)' style='border: 0pt none ; " 
                                + "padding:4px 0px 0px 0px; background-color:" +
                                "transparent; color: rgb(153, 153, 153); text-transform: none; background-repeat: repeat-x;' name='123'/>" +
                        "</label>" +
                    "</td>" +
                    "<td width='33' valign='top' align='left'>" +
                    "<img height='26' width='33' src='media/images/txt_search.gif' alt=''/>" +
                    "</td>" +
                "</tr>" +
            "</table>" +
            "<ul id='left_menu' class='leagues'></ul>" + 
            "<a id='imgAdvertisiment1' href='http://www.bet365.com/?affiliate=365_034112' target='_blank'>" + 
                "<img src='media/images/200x140_bet365.gif' alt='Advertisement' id='imgAdvertisiment'/></a>";
    
    var newMidDiv = document.createElement('div');
    newMidDiv.setAttribute('id', 'col-mid');
    newMidDiv.innerHTML = "<div id='page_type_menu'></div><div id='accordians'>Loading ...</div>";

    var newRightDiv = document.createElement('div');
    newRightDiv.setAttribute('id', 'col-right');

    elem.appendChild(newLeftDiv);
    elem.appendChild(newMidDiv);
    elem.appendChild(newRightDiv);
}

function checkDate() {
    if (type != "liveOnTv") {
        if (dateNew.toDateString() == new Date().toDateString()) {
            document.getElementById("ulPageType").innerHTML = "<li id='fixtures' class='active' onclick='refreshPage(\"fixtures\");'>"
                        + "<a href='#'><span>All</span></a></li><li id='live' class='match' onclick='refreshPage(\"live\");'>"
                        + "<a href='#'><span>Live</span></a></li><li id='results' class='match' onclick='refreshPage(\"results\");'>"
                        + "<a href='#'><span>Finished</span></a></li><li id='upcoming' class='match' onclick='refreshPage(\"upcoming\");'>"
                        + "<a href='#'><span>Upcoming</span></a></li><li id='mymatches' class='match' onclick='refreshPage(\"mymatches\");'>" 
                        + "<a href='#'><span>My Matches</span></a></li><li id='reset' class='match' style='float:right' onclick='refreshPage(\"\");'>"
                        + "<a href='#'><span>Reset</span></a></li>";
            refreshPage('fixtures');

        }
        else if (dateNew > new Date()) {
            document.getElementById("ulPageType").innerHTML = "<li>Show:</li><li class='active' ><a href='#'><span>All</span></a></li>";
        }
        else {
            document.getElementById("ulPageType").innerHTML = "<li>Show:</li><li class='active' ><a href='#'><span>Finished</span></a></li>";            
        }
    }
}

function back() {
    if (type == "leguelive" || type == "leaguefinished" || type == "leagueupcoming") {
        statsOrResults = "results";
        beckToLeague();
    } else {
        refreshPageSport(sport, type, lang, sort, 'results');
    }
}

function backFromTV() {
    refreshPageSport(sport, 'fixtures', lang, sort, 'results');
}

function openContacts() {
    stop_Int();
    stop_IntTicker();
    statsOrResults = "stats";
    $("#container").empty();
    
    var newBigDiv = "<div id='col-left' style='width:100%'><span class='col-heading'>Advertisment &amp; contact</span><br /><br />" +
        "<table width='490' border='0' cellspacing='0' cellpadding='0'><tr><td width='20px;'></td>" +
        "<td width='150px;' align='right'><strong>Subject:</strong></td><td width='20'>&nbsp;</td>" +
        "<td background='media/images/txt_bg1.gif' style='border:solid 1px #d6d6d6; background-repeat:repeat-x;'>" +
            "<label>" +
                "<select id='txtSubject' name='txtSubject' style='border:0; background-color:transparent;" +
                    "color:#999999; text-transform:none; background-repeat:repeat-x; padding:4px; width:100%;'>" +
                    "<option value='General enquire'>General enquire</option>" +
                    "<option value='Advertising enquire'>Advertising enquire</option>" +
                    "<option value='Error in live score data'>Error in live score data</option>" +
                    "<option value='Feed purchase enquire'>Feed purchase enquire</option>" +  
                "</select>" + 
            "</label>" +
        "</td><td width='15' align='right' valign='top'>*</td><td width='33' align='left' valign='top'>&nbsp;</td>" +
        "<td width='33' align='left' valign='top'>&nbsp;</td></tr><tr>" +
        "<td></td><td align='right'></td><td>&nbsp;</td><td>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td></tr><tr>" +
        "<td></td><td align='right'><strong>Your Email:</strong></td><td>&nbsp;</td>" +
        "<td background='media/images/txt_bg1.gif' style='border:solid 1px #d6d6d6; background-repeat:repeat-x;'>" +
            "<label>" +
                "<input type='text' name='txtEmail' id='txtEmail' style='border:0; background-color:transparent; padding:4px 0; " +
                "color:#999999; text-transform:none; background-repeat:repeat-x; padding:4px; width:100%;'  />" +
            "</label>" +
        "</td><td align='right' valign='top'>*</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "</tr><tr><td></td><td align='right'></td><td>&nbsp;</td><td>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "</tr><tr><td></td><td align='right' valign='top'><strong>Message:</strong></td>" +
        "<td>&nbsp;</td><td background='media/images/txt_bg1.gif' style='border:solid 1px #d6d6d6; background-repeat:repeat-x;'>" +
            "<label>" +
                "<textarea name='txtMessage' id='txtMessage' style='border:0; background-color:transparent; padding:4px 0; " +
                    "color:#999999; text-transform:none; background-repeat:repeat-x; padding:4px; width:100%; height:100px;'>" +
                "</textarea>" +
            "</label>" +
        "</td><td align='right' valign='top'>*</td><td align='left' valign='top'>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td></tr><tr><td></td><td align='right' valign='top'>&nbsp;</td>" +
        "<td>&nbsp;</td><td >&nbsp;</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td></tr><tr><td></td><td align='right' valign='top'>&nbsp;</td><td>&nbsp;</td>" +
        "<td align='right' >" +
            "<ul>" +
                "<li class='match' style='float:right'><a href='#' onclick='sendEmailControls();'><span>Send</span></a></li>" +
                "<li class='match' style='float:right'><a href='#' onclick='emtyEmailControls();'><span>Reset</span></a></li>" +
            "</ul>" +
        "</td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td></tr><tr><td></td>" +
        "<td align='right' valign='top'>&nbsp;</td><td>&nbsp;</td><td align='right' >&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td></tr><tr><td></td>" +
        "<td align='right' valign='top'>&nbsp;</td><td>&nbsp;</td><td align='left' ><strong>* Required fields</strong></td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "</tr><tr><td></td>" +
        "<td align='right' valign='top'>&nbsp;</td><td>&nbsp;</td><td align='left' ></td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "</tr><tr><td></td>" +
        "<td align='right' valign='top'>&nbsp;</td><td>&nbsp;</td><td align='left' ><span id='messSpan'></span></td>" +
        "<td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td><td align='left' valign='top'>&nbsp;</td>" +
        "</tr></table><br /></div>";

    $("#container").append(newBigDiv);
    checkMainHeightContact();
}

function checkDoubleImages() {
    if ($("img[src*='goal.cc-logo-add.png']").length > 1) {
        var index = $("img[src*='goal.cc-logo-add.png']").length;
        $("img[src*='goal.cc-logo-add.png']:first").parent().remove();       
    }
}