var SENS ="down";
function showTeam(content, teamid){
    $.ajax({
        type: "POST",
        url: "getmatchsteam.php",
        data: "teamid="+teamid+"&content="+content,
        beforeSend: function(){
            $("#contentteam").fadeOut("fast");
        },
        success: function(response){
            $("#contentteam").html(response);
            $("#contentteam").fadeIn("slow");
        },
        error:function (xhr, ajaxOptions, thrownError){
            alert(xhr.status);
            alert(thrownError);
        }
    });
}

function initMap(place){
    initLink();
    showMatch("results","down");
    if (GBrowserIsCompatible()) {
        var map = new GMap(document.getElementById("gybur"));
        var map2 = new GMap(document.getElementById("galriv"));
        map.setCenter(new GLatLng(46.4493750,6.877409), 16);
        map.addOverlay(new GMarker(new GLatLng(46.4493750,6.877409)));
        map.setMapType(G_HYBRID_MAP);
        map.setUIToDefault();
        map2.setCenter(new GLatLng(46.460255,6.840507), 16);
        map2.addOverlay(new GMarker(new GLatLng(46.460255,6.840507)));
        map2.setMapType(G_HYBRID_MAP);
        map2.setUIToDefault();
    }
}

function showMatch(content, sens){
    $.ajax({
        type: "GET",
        url: "getresultmatchs.php",
        data: "content="+content,
        beforeSend: function(){
            $("#fn_content").html("<img class='loader' alt='loader' src='img/loader.gif' />");
        },
        success: function(response){
            if(content == "matchs"){
                document.getElementById("matchs").style.color="#E38B00";
                document.getElementById("results").style.color="#000000";
            }
            else if(content == "results"){
                document.getElementById("matchs").style.color="#000000";
                document.getElementById("results").style.color="#E38B00";
            }
            $("#fn_content").html(response);
            $("#fn_content").fadeIn("slow");
            document.getElementById("fn_content").scrollTop =0;
            setTimeout('move("down");',1250);
        },
        error:function (xhr, ajaxOptions, thrownError){
            alert(xhr.status);
            alert(thrownError);
        }
    });
}

function move(sens) {
    if(sens =="down")
    {
        var oldTop = document.getElementById("fn_content").scrollTop;
        document.getElementById("fn_content").scrollTop +=1;
        if(document.getElementById("fn_content").scrollTop == oldTop){
            clearTimeout(timerdown);
            SENS = "up";
            setTimeout('move("up");',1250);
        }
        else
            timerdown=setTimeout('move("down");',90);
    }
    else if(sens=="up"){

        document.getElementById("fn_content").scrollTop -=1;
        timerup=setTimeout('move("up");',90);
        if(document.getElementById("fn_content").scrollTop == 0){
            clearTimeout(timerup);
            SENS = "down";
            setTimeout('move("down");',1250);
        }
    }
}
function change_fn_content(content){
        
    showMatch(content, SENS);
}
