Greasy Fork is available in English.

FCup Script

Fcup Toolmenü

// ==UserScript==
// @name         FCup Script
// @namespace    https://greasyfork.org/users/83290
// @version      3.6.4.4
// @author       Criyessei | mot33
// @description  Fcup Toolmenü
// @homepage     https://www.fcup-tools.de/tools
// @icon         https://i.ibb.co/tJC5RX3/HFWRRt6.png
// @supportURL   https://forum.fussballcup.de/showthread.php?t=417372
// @include      http*://futbolcup.net*
// @include      http*://fussballcup.de*
// @include      http*://fussballcup.at*
// @include      http*://futbolcup.pl*
// @include      http*://footcup.fr*
// @include      http*://footballcup.nl*
// @include      http*://forum.fussballcup.de/*
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @require      https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
// @require      https://greasyfork.org/scripts/380695-%C3%BCbersetzung/code/%C3%9Cbersetzung.js?version=803518
// @connect      greasyfork.org
// @run-at       document-end
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_listValues
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==

if(location.protocol!='https:'){ //Routing to secure protocol
    let pageHref = location.href;
    location.href = 'https'+pageHref.substring(pageHref.indexOf(':'));
    return;
}

/*-------------GLOBAL VERIABLES-------------*/

let TOOL = {
    "sources":{
        "get":(name,type)=>{
            return 'https://mot96.lima-city.de/'+name+'.'+type;/*Thanks to mot33*/
        }
    },
    "serverTimeR":0,
    "serverDatas":{
        "tr":{
            "flag"                : "TUR",
            "language"            : "Turkish",
            "footballerPositions" : {
                "Position1":"KL",
                "Position2":"DD",
                "Position3":"DI",
                "Position4":"OD",
                "Position5":"OL",
                "Position6":"OR",
                "Position7":"OH",
                "Position8":"FO"
            },
            "Leagues"             : {
                "League1" : "2. Amatör Lig",
                "League2" : "1. Amatör Lig",
                "League3" : "Süper Amatör Lig",
                "League4" : "Bölgesel Amatör Lig",
                "League5" : "TFF 3.Lig",
                "League6" : "TFF 2.Lig",
                "League7" : "Spor Toto 1.Lig",
                "League8" : "Spor Toto Süper Lig"
            },
            "replaceClubName"     : " 'den Profil",
            "ScriptAuthorClubId"  : "670524",
            "ClubExchange"        : "Kulüp Değiştirme",
            "acceptedBidText"     : "kabul edildi",
            "rejectedBidText"     : "reddedildi",
            "readBidText"         : "okundu",
            "newBidText"          : "yeni",
            "youngPlayer"         : {"title":'Genç Oyuncu',"beforeName":"yetiyor.","afterName":"Detaylı incele"},
            "increaseBid"         : {"title":"Transfer Pazarı","control":"tarafından geçildi.","beforeName":"Transfer Pazarı","afterName":"için transfer teklifin"},
            "sellPlayer"          : {"title":"Assistent: Transfer Pazarı","control":"yıllık kontrat imzaladı","beforeName":"</h2>","afterName":", <div"},
            "ageDates"            : [26483328, 26527104, 26570880, 26614656, 26658432, 26702208, 26746104, 26789880, 26833656, 26877432, 26921208]
        },
        "de":{
            "flag"                : "DEU",
            "language"            : "German", /*The game language*/
            "footballerPositions" : {
                "Position1":"TW",
                "Position2":"AV",
                "Position3":"IV",
                "Position4":"DM",
                "Position5":"LM",
                "Position6":"RM",
                "Position7":"OM",
                "Position8":"ST"
            },
            "Leagues"             : {
                "League1" : "Kreisliga",
                "League2" : "Landesliga",
                "League3" : "Verbandsliga",
                "League4" : "Oberliga",
                "League5" : "Regionalliga",
                "League6" : "3. Liga",
                "League7" : "2. Bundesliga",
                "League8" : "1. Bundesliga"
            },
            "replaceClubName"     : "Profil von",
            "ScriptAuthorClubId"  : "1286060",
            "ClubExchange"        : "Vereinswechsel",
            "acceptedBidText"     : "akzeptiert",
            "rejectedBidText"     : "abgelehnt",
            "readBidText"         : "gelesen",
            "newBidText"          : "neu",
            "youngPlayer"         : {"title":'Jugendspieler',"beforeName":"diesen ","afterName":" mal"},
            "increaseBid"         : {"title":"Transfermarkt","control":"überboten","beforeName":"für ","afterName":" wurde"},
            "sellPlayer"          : {"title":"Assistent: Transfermarkt","control":"ausgehandelt","beforeName":"Spieler ","afterName":" hat"},
            "ageDates"            : [25877484, 25922760, 25965096, 26008872, 26052648, 26096424, 26141640, 26183976, 26227692, 26271468, 26315244, 26359020, 26402796, 26446632, 26490408, 26534184, 26579400, 26621736, 26665512, 26709288, 26753004, 26796780]
        },
        "at":{
            "flag"                : "AUT",
            "language"            : "German",
            "footballerPositions" : {
                "Position1":"TW",
                "Position2":"AV",
                "Position3":"IV",
                "Position4":"DM",
                "Position5":"LM",
                "Position6":"RM",
                "Position7":"OM",
                "Position8":"ST"
            },
            "Leagues"             : {
                "League1" : "2. Klasse",
                "League2" : "1. Klasse",
                "League3" : "Gebietsliga",
                "League4" : "2. Landesliga",
                "League5" : "Landesliga",
                "League6" : "Regionalliga",
                "League7" : "Erste Liga",
                "League8" : "Österreichische Bundesliga"
            },
            "replaceClubName"     : "Profil von",
            "ScriptAuthorClubId"  : "1510674",
            "ClubExchange"        : "Vereinswechsel",
            "acceptedBidText"     : "akzeptiert",
            "rejectedBidText"     : "abgelehnt",
            "readBidText"         : "gelesen",
            "newBidText"          : "neu",
            "ageDates"            : [26542884,26588100,26630436,26674212,26717988,26761764,26805540],
            "youngPlayer"         : {"title":'Jugendspieler',"beforeName":"diesen ","afterName":" mal"},
            "increaseBid"         : {"title":"Transfermarkt","control":"überboten","beforeName":"für ","afterName":" wurde"},
            "sellPlayer"          : {"title":"Assistent: Transfermarkt","control":"ausgehandelt","beforeName":"Spieler ","afterName":" hat"}
        },
        "pl":{
            "flag"                : "POL",
            "language"            : "Polish",
            "footballerPositions" : {
                "Position1":"BR",
                "Position2":"OZ",
                "Position3":"OŚ",
                "Position4":"DP",
                "Position5":"LP",
                "Position6":"PP",
                "Position7":"OP",
                "Position8":"N"
            },
            "Leagues"             : {
                "League1" : "Klasa B",
                "League2" : "Klasa A",
                "League3" : "Liga okręgowa",
                "League4" : "4 Liga",
                "League5" : "3 Liga",
                "League6" : "2 Liga",
                "League7" : "1 Liga",
                "League8" : "Ekstraklasa"
            },
            "replaceClubName"     : "Profil",
            "ScriptAuthorClubId"  : "2074",
            "ClubExchange"        : "Zmienia klub",
            "acceptedBidText"     : "Zaakceptowane",
            "rejectedBidText"     : "Odrzucone",
            "readBidText"         : "przeczytana",
            "newBidText"          : "nowy",
            "youngPlayer"         : {"title":'Junior',"beforeName":"dokładniej","afterName":"i zaproś"},
            "increaseBid"         : {"title":"Rynek transferowy","control":"została przebita przez","beforeName":"spłaty za","afterName":"została"},
            "sellPlayer"          : {"title":"Assistent: Rynek transferowy","control":"periodzie rynku transferowego","beforeName":"</h2>","afterName":"wynegocjował"},
            "ageDates"            : [26196708, 26240484, 26284260, 26328036, 26371812, 26415588, 26459364, 26503140, 26546916, 26590692, 26634468, 26678244, 26722020, 26765796, 26809572, 26853348, 26897124, 26940900, 26984676, 27028452, 27072228, 27116004, 27159780, 27203556, 27247332],
        },
        "fr":{
            "flag"                : "FRA",
            "language"            : "French",
            "footballerPositions" : {
                "Position1":"GB",
                "Position2":"DL",
                "Position3":"DC",
                "Position4":"Mdf",
                "Position5":"MG",
                "Position6":"MD",
                "Position7":"MO",
                "Position8":"BT"
            },
            "Leagues"             : {
                "League1" : "PH",
                "League2" : "DHR",
                "League3" : "DH",
                "League4" : "CFA 2",
                "League5" : "CFA",
                "League6" : "National",
                "League7" : "Ligue 2",
                "League8" : "Ligue 1"
            },
            "replaceClubName"     : "Profil de",
            "ScriptAuthorClubId"  : "169948",
            "ClubExchange"        : "Clubs Changer",
            "acceptedBidText"     : "approuvé",
            "rejectedBidText"     : "rejeté",
            "readBidText"         : "lu",
            "newBidText"          : "nouveau",
            "ageDates"            : [25733556, 25778772, 25821109, 25864884, 25908660, 25952436, 25996212, 26039988, 26083764, 26127540, 26171316],
            "youngPlayer"         : {"title":'Jeune joueur',"beforeName":"d'œil sur ce","afterName":"..."},
            "increaseBid"         : undefined,
            "sellPlayer"          : undefined
        },
        "nl":{
            "flag"                : "NLD",
            "language"            : "Dutch",
            "footballerPositions" : {
                "Position1":"GK",
                "Position2":"VV",
                "Position3":"CV",
                "Position4":"DM",
                "Position5":"LM",
                "Position6":"RM",
                "Position7":"AM",
                "Position8":"AV"
            },
            "Leagues"             : {
                "League1" : "4e Klasse",
                "League2" : "3e Klasse",
                "League3" : "2e Klasse",
                "League4" : "1e Klasse",
                "League5" : "Hoofdklasse",
                "League6" : "Topklasse",
                "League7" : "1e Divisie",
                "League8" : "Eredivisie"
            },
            "replaceClubName"     : "Profiel van",
            "ScriptAuthorClubId"  : "108310",
            //Aşağıdaki kısım düzeltilmeli!
            "ClubExchange"        : "Kulüp Değiştirme",
            "acceptedBidText"     : "Geaccepteerd",
            "rejectedBidText"     : "Afgewezen",
            "readBidText"         : "Gelezen",
            "newBidText"          : "Nieuw",
            "youngPlayer"         : {"title":'Jeugdspeler',"beforeName":"De speler","afterName":"zou zeker"},
            "increaseBid"         : {"title":"Transfer markt","control":"overboden","beforeName":"transferbod op","afterName":"werd door"},
            "sellPlayer"          : undefined,
            "ageDates"            : undefined
        }
    },
    "alternativeLanguage":"English",
    "TrainingPlan":[
        [0,1,3,8,6,10,4,2],
        [9,6,3,7,8,10,5,4,11,2],
        [9,6,3,7,8,10,5,4,11,2],
        [6,9,3,7,10,8,4,11,5,2],
        [10,3,8,5,9,11,6,4,7,2],
        [10,3,8,5,9,11,6,4,7,2],
        [11,3,8,10,2,4,6,9,5,7],
        [11,3,8,2,10,6,4,5,9,7]
    ],
    FeaturesOfScript:undefined
    /* flag,zone,language,footballerPositions,Leagues,replaceClubName,ScriptAuthorClubId,ClubExchange,acceptedBidText,
       rejectedBidText,readBidText,newBidText,youngPlayer,increaseBid,buyPlayer,ageDates
    */
},
    playerObject,
    TransferMarketClubs = {},
    TransferMarketValues = {"ligaIndex":0,"checkBox":false},
    Features = {
        all:{},
        IsActive:function(featureId,hover_selector=!1){
            let status,//1 => exist and active , 0 => exist and inactive, 2 => new feature and inactive
                active, //1 => running feature  , 0 => non-working feature
                feature = TOOL.FeaturesOfScript[featureId];
            if(feature == undefined){
                active = 0;
                status = 2; //New feature
            }
            else active = status = feature?1:0;
            Features.all[featureId]={status:status};
            if(hover_selector!=!1) Features.all[featureId].hover_selector = hover_selector;
            return active;
        },
        clear:function(){
            Features.all={};
            $('#FeaturesOfScript > tbody').html('');
            $('#FeaturesOfScript > tbody').parent().hide();
        },
        show:function(){
            var all = Features.all;
            if(Object.keys(all).length){
                let sayac=0,div,Feature,FeaturesName;
                for(let FeaturesId in all){
                    Feature = all[FeaturesId];
                    FeaturesName = scriptTexts.FeaturesName[FeaturesId] || FeaturesId;
                    if(Feature.status==2){//New feature
                        TOOL.FeaturesOfScript[FeaturesId] = true;
                        SetCookie('FeaturesOfScript',TOOL.FeaturesOfScript);
                        GiveNotification(
                            true,
                            GetLocaleText('NewFeature1')+' "<font k="'+FeaturesId+'">'+FeaturesName+'</font>". '+GetLocaleText('NewFeature2')
                        );
                        delete Feature;
                        continue;
                    }
                    div = $('<div class="slideThree"></div>');
                    if(Feature.hover_selector!=undefined){
                        div.attr('hover_selector',Feature.hover_selector);
                        $(Feature.hover_selector).css('transition','background-color 1s;');
                    }
                    div.append(
                        '<input type="checkbox" id="'+FeaturesId+'" class="slideThreeInput" '+(Feature.status?'checked="checked"':'')+' value="None">'+
                        '<label for="'+FeaturesId+'" k=""></label>'
                    );
                    $('#FeaturesOfScript > tbody').append(
                        '<tr class="'+(!(sayac%2)?'odd':'even')+'">'+
                        '<td><label k="'+FeaturesId+'">'+FeaturesName+'</label></td>'+
                        '<td>'+div[0].outerHTML+'</td>'+
                        '</tr>'
                    );
                    sayac++;
                }
                $('#FeaturesOfScript > tbody > tr .slideThreeInput').click(function(){
                    TOOL.FeaturesOfScript[this.id] = this.checked;
                    SetCookie('FeaturesOfScript',TOOL.FeaturesOfScript);
                    if(!this.checked) $('.addedBy_'+this.id).remove();
                });
                if(Object.keys(all).length) $('#FeaturesOfScript > tbody').parent().show();

                $('#FeaturesOfScript > tbody .slideThreeInput:checked').parent('[hover_selector]').mouseenter(function(){
                    $($(this).attr('hover_selector')).addClass('animate-flicker');
                }).mouseleave(function(){
                    $($(this).attr('hover_selector')).removeClass('animate-flicker');
                });
            }
        }
    },
    AllIntervals = {},
    Intervals = {
        named : {},
        anonymous:[],
        create : function(func,delay,name=!1){
            if(name) Intervals.named[name] = setInterval(func,delay);
            else{
                let sayac = setInterval(function(){
                    func(()=>{
                        clearInterval(sayac)
                        Intervals.anonymous.find((item,index,array)=>{
                            if(item==sayac){
                                array.splice(index,1);
                                return 1;
                            }
                        });
                    });
                },delay)
                Intervals.anonymous.push(sayac);
            }
        },
        clear : function(){
            let named = Intervals.named;
            for(var name in named){
                clearInterval(named[name]);
                delete named[name];
            }
            let anonymous = Intervals.anonymous,
                i=0;
            for(;i<anonymous.length;i++){
                clearInterval(anonymous[i]);
            }
            Intervals.anonymous=[];
        }
    };
/*-----------END GLOBAL VERIABLES-----------*/

PageLoad(()=>{
    if(typeof serverTime!=="number"
       || $('#ChangeContent').length
      ){
        if(location.search.indexOf('action=logout') //Çıkış yapıldı
           && $('#tutorial-container > div > div.message > form').length
          ) location.href = location.origin; //Go main page
        return;
    }

    //SHOW COOKIES IN CONSOLE
    (cookies=>{
        console.clear();
        if(cookies.length)
            cookies = FixCookies(cookies);

        if(!cookies.length){
            console.log("%c! ANY COOKIES ARE EXIT",'color:red;font-weight:bold;font-size:15px;');
            return;
        }

        console.log("%cCOOKIES","color:white;text-align:center;font-size:15px;padding:2px 500px;background-color:black;border-radius:7px;text-weight:bold;display:inline;");
        cookies.sort(function(a,b){
            let s1=a.substring(0,a.indexOf('_')+1),
                s2=b.substring(0,b.indexOf('_')+1);
            if((a=a.substring(a.indexOf('_')+1))>(b=b.substring(b.indexOf('_')+1))) return 1;
            else if(a<b) return -1;
            return s1>s2;
        });

        let maxLongKey = cookies[0].length;
        for(let i=1;i<cookies.length;i++){
            let length = cookies[i].length;
            if(length>maxLongKey) maxLongKey = length;
        }

        for(let i=0;i<cookies.length;i++){
            let cookieKey = cookies[i],
                find = cookieKey.indexOf('_');
            console.log(
                '%c' + cookieKey.substring(0,find) + '%c' + (find!=-1?'_':'   ') + '%c' + cookieKey.substring(find+1) + (" ").repeat(Math.abs(maxLongKey-cookieKey.length+(find!=-1?0:-3))) + ' %c: %c%o',
                'font-weight:bold;color:blue;',
                'font-weight:bold;color:orange;',
                'font-weight:bold;color:green;',
                'font-weight:bold;color:black;',
                'color:black;',
                GM_getValue(cookieKey)
            );
        }
        console.log('\n\n');

    })(GM_listValues());

    PageLoad(()=>{
        let server = $('#body').attr('class').replace(' loading','');// return tr/de/at/pl/fr
        if(!(server in TOOL.serverDatas)){
            GiveNotification(false,"This server is not available in the script!");
            return;
        }
        TOOL.server = server; //Özellikler içerisinde server bilgisi gerekirse tekrar elde etmek yerine tool değişkeninde saklıyoruz.

        TOOL.serverDatas = TOOL.serverDatas[server]; //Server bilgilerinin içerisinden açık olan server bilgisini seçiyoruz. Diğer server bilgilerine gerek yok.
        for(let dataKey in TOOL.serverDatas){
            TOOL[dataKey] = TOOL.serverDatas[dataKey]; //Server bilgilerini aktarıyoruz.
        }
        delete TOOL.serverDatas; //Aktarılan server ve diğer serverların bilgilerine artık gereksinim kalmıyor.

        TOOL.serverTimeR = serverTime*1000 - new Date().getTime();
        $('<button id="TimeTrigger">').hide().appendTo('body').click(function(){
            $(this).off().remove();
            let d = JSON.parse($(this).attr('data'));
            TOOL.serverTimeR = new Date(d.year,d.month-1,d.day,d.hour,d.minute,d.second) - new Date();
            $('<script>').html((()=>{
                let codes = showServerTime.toString(),
                    find1 = codes.indexOf('{')+1,
                    find2 = codes.indexOf('//{end}',find1)+7;
                return codes.substring(0,find1)+codes.substring(find2);
            })()).appendTo('body').remove();
        });
        $('<script>').html((()=>{
            let codes = showServerTime.toString(),
                find = codes.indexOf('{')+1;
            return codes.substring(0,find)+"\n"+
                "$('#TimeTrigger').attr('data',JSON.stringify({year:year,month:month,day:day,hour:hour,minute:minute,second:second})).click();"+
                "\n//{end}"+codes.substring(find);
        })()).appendTo('body').remove();

        TOOL.FeaturesOfScript=GetCookie(
            'FeaturesOfScript',
            {
                'ConstructionCountdown'            : !0,
                'ClubExchange'                     : !0,
                'RankingOfPlayers'                 : !0,
                'TrainingControl'                  : !0,
                'RematchMatch'                     : !0,
                'InviteSimulationMatch'            : !0,
                'TrainingGroups'                   : !1,
                'CampHistory'                      : !0,
                'TransferDates'                    : !0,
                'GoOffer'                          : !0,
                'FilterTransferMarket'             : !0,
                'FilterOwnOffers'                  : !0,
                'ShowOwnOfferInMarket'             : !0,
                'ShowBoughtPlayers'                : !0,
                'ShowStrengthChange'               : !0,
                'ShowRealStrength'                 : !1,
                'CalculateNonYoungPlayersStrength' : !0,
                'YoungPlayersHistory'              : !0,
                'CalculatingStrengthOfYoungPlayer' : !0,
                'DownloadTable'                    : !0,
                'AddImage'                         : !0,
                'ShowEloRating'                    : !0,
                'QuickShopping'                    : !0,
                'ShowAsistantLevelIncrease'        : !0,
                'QuickBet'                         : !0,
                'CancelFriendlyMatchInvites'       : !0,
                'MatchAnalyst'                     : !0,
                'NumberOfFootballerChecker'        : !0
            }
        );

        _scriptTexts = scriptTexts; //Dil değiştirildiğinde diğer dillerin metinlerini geri elde edebilmek için saklıyoruz.

        let userLanguage = GM_getValue('userLanguage',{});
        if(userLanguage[server]
           && (scriptTexts = scriptTexts[userLanguage[server]])
          ) TOOL.language = userLanguage[server]; //Kullanıcının açık server için seçtiği dil varsa o dil tekrar seçiliyor.
        else if(!(
            TOOL.language
            && (scriptTexts = _scriptTexts[TOOL.language]) //Server dili mevcut ve metinleri mevcut ise seçiliyor
        )){
            scriptTexts = _scriptTexts[TOOL.alternativeLanguage]; //Eğer mevcut değilse scriptin alternatif dili seçilerek kullanıcıya bu konu hakkında uyarı veriliyor.
            GiveNotification(true,"This script hasn't yet been translated into "+TOOL.language+"!<br>Alternative language["+scriptTexts.Language+"] selected!");
            TOOL.language = TOOL.alternativeLanguage;
        }
        /*Fix Age Dates*/
        if(Array.isArray(TOOL.ageDates)){
            let ageDates = TOOL.ageDates.slice(0),
                ServerTime = GetServerTime();
            if(ageDates[ageDates.length-1]*60000<ServerTime) TOOL.ageDates = undefined;
            else{
                while(ageDates.length){
                    let date = ageDates[0]*60000;
                    if(date>ServerTime) break;
                    ageDates.splice(0,1);
                }
                if(!ageDates.length) TOOL.ageDates = undefined;
                else TOOL.ageDates = ageDates.slice(0);
            }
        }
        /**/
        let clubDatas = GetCookie('clubDatas');
        if(CheckClubData(clubDatas) == 'not-exist'){
            //Eğer kulüp bilgileri mevcut değilse, kullanıcının verileri silinmiş olabilir yada kullanıcı scripti ilkkez yüklüyordur.

            let header = { //Scriptin açılış menüsünün baş kısmı
                content : GetLocaleText('NeedNecessaryInformation')+
                '<img src="'+TOOL.sources.get('unhappy','png')+'" alt="unhappy" height="25px" style="position:absolute;margin: 4px 0 4px 5px;">',
                css : {'text-align':'center'}
            };

            let div = { //Scriptin açılış menüsünün içeriği
                footer : !0,
                close  : !0,
                class  : 'container'
            };
            div.content=
                '<p style="color:red;margin-bottom:10px;font-weight:bold;text-align:left;font-size:12px;">'+GetLocaleText('InformScriptWorking')+'</p>'+
                '<p style="color:blue;font-weight:bold;text-align:left;font-size:12px;margin-Bottom:10px;">'+GetLocaleText('HelpDataUploading')+'</p>'+
                '<p style="text-align:center;margin-bottom:25px;">'+
                '   <img id="uploadCookies" class="grow" title="'+GetLocaleText('UploadDatas',null,!1)+'" src="https://i.ibb.co/WzvZS4s/Untitled.png" style="cursor:pointer;" height="40px">'+
                '</p>'+
                '<h3>'+GetLocaleText('EnterClubInformation')+' :</h3>'+
                '<table style="width:280px;margin:0 auto 15px auto;border-radius:6px;color:#111b9c;background-color:white;box-shadow: 5px 10px 8px #3939398c;">'+
                '   <tbody>'+
                '      <tr class="odd">'+
                '         <td style="border:0;text-align:center;padding-Left:5px;">'+GetLocaleText('TrainerLevel')+'</td>'+
                '         <td style="border:0;">'+
                '            <label class="menü">'+
                '               <select id="AntrenörSeviyesi1" style="font-size:12px;width:55px;margin:0 auto;text-align-last: center;">'+
                '                  <option value="10" k="SortLevel" selected>10 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="9" k="SortLevel">9 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="8" k="SortLevel">8 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="7" k="SortLevel">7 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="6" k="SortLevel">6 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="5" k="SortLevel">5 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="4" k="SortLevel">4 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="3" k="SortLevel">3 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="2" k="SortLevel">2 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="1" k="SortLevel">1 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="0" k="SortLevel">0 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '               </select>'+
                '            </label>'+
                '         </td>'+
                '      </tr>'+
                '      <tr class="even">'+
                '         <td style="border:0;border-radius:6px 0 0 6px;text-align:center;padding-Left:5px;">'+GetLocaleText('YoungTrainerLevel')+'</td>'+
                '         <td style="border:0;border-radius:0 6px 6px 0;">'+
                '            <label class="menü">'+
                '               <select id="GAntrenörSeviyesi1" style="font-size:12px;width:55px;margin:0 auto;text-align-last: center;">'+
                '                  <option value="10" k="SortLevel" selected>10 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="9" k="SortLevel">9 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="8" k="SortLevel">8 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="7" k="SortLevel">7 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="6" k="SortLevel">6 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="5" k="SortLevel">5 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="4" k="SortLevel">4 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="3" k="SortLevel">3 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="2" k="SortLevel">2 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="1" k="SortLevel">1 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  <option value="0" k="SortLevel">0 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '               </select>'+
                '            </label>'+
                '         </td>'+
                '      </tr>'+
                '   </tbody>'+
                '</table>'+
                '<p style="text-align:center;">'+CreateButton('butonOnayla',GetLocaleText('Confirm')+' !')+'</p>';

            ShowDialog(div,header);

            $('#butonOnayla').click(function(){
                $(this).off();
                let span = $(this).find('span:last'),
                    html = span.html(),
                    clubDatas = {
                        "trainerLevel"    : parseInt($('#AntrenörSeviyesi1').val()),
                        "yTrainerLevel"   : parseInt($('#GAntrenörSeviyesi1').val())
                    },
                    self = $('.self-link');
                span.html('<img src="/designs/redesign/images/icons/loading/16x16.gif" style="margin-top: -1px;">');
                if(self.length){
                    clubDatas.clubId = $('.self-link').first().attr('clubid');
                    clubDatas.clubName = $('.self-link').first().text().trim();
                    Continue();
                }
                else{
                    GetPage('?w='+worldId+'&area=user&module=profile&action=show','profile-show',function(html){
                        clubDatas.clubId = $(html).find('div.container.profile-trophy > div.profile > ul.profile-box-club > li:nth-child(2) > a')[0].href;
                        let b = clubDatas.clubId.indexOf('clubId=')+7;
                        clubDatas.clubId = clubDatas.clubId.substring(b,clubDatas.clubId.indexOf('&',b));
                        clubDatas.clubName = $(html).find('h2').first().text().replace(TOOL.replaceClubName,'').trim();
                        Continue();
                    });
                }
                function Continue(){
                    span.html(html);
                    SetCookie('clubDatas',clubDatas);
                    closeFocus({target: $('.close')});
                    showScriptMenu(clubDatas);
                }
            });
            $('#uploadCookies').click(function(){
                ReadTextFile(
                    function(cookiesText){
                        cookiesText = cookiesText.split('CookieKey&:');
                        cookiesText.splice(0,1);
                        for(let i = 0 ; i < cookiesText.length ; i++){
                            let b = cookiesText[i].indexOf(':'),
                                key = cookiesText[i].substring(0,b),
                                data = cookiesText[i].substring(b+1);
                            GM_setValue(key,JSON.parse(data));
                        }
                        let cookiesList = GM_listValues();
                        if(cookiesList.length)
                            cookiesList = FixCookies(cookiesList);

                        closeFocus({target: $('.close')});
                        GiveNotification(true,GetLocaleText('DataLoaded'));
                        showScriptMenu(GetCookie('clubDatas'));
                    }
                );
            });
        }
        else showScriptMenu(clubDatas); //Scriptin menüsü getirilecek.
        function CheckClubData(clubDatas){
            if(typeof clubDatas == "object"){
                if(clubDatas.trainerLevel==undefined ||
                   clubDatas.yTrainerLevel==undefined ||
                   clubDatas.clubId==undefined ||
                   clubDatas.clubName==undefined
                  ) return 'incorrect';
                return 'correct';
            }
            return 'not-exist';
        }
        function showScriptMenu(clubDatas){
            if(CheckClubData(clubDatas) != 'correct'){
                location.reload();
                return;
            }
            for(let dataKey in clubDatas)
                TOOL[dataKey] = clubDatas[dataKey]; //Kulüp bilgileri, özelliklerde kullanılmak üzere data değişkenine kayıt ediliyor.

            $('html, body').animate({ scrollTop: 0 }, 'fast'); //Sayfanın başına getiriliyor. Menü ortaya çıkartılacak.
            var add =
                '<div class="box" id="ScriptMenu" style="position:absolute;">'+
                '   <h2>'+GetLocaleText('ScriptMenuTitle')+'</h2>'+
                '   <table class="table">'+
                '      <thead>'+
                '         <tr>'+
                '            <th>'+GetLocaleText('Explanation')+'</th>'+
                '            <th>'+GetLocaleText('Action')+'</th>'+
                '         </tr>'+
                '      </thead>'+
                '      <tbody>'+
                '         <tr class="odd">'+
                '            <td>'+GetLocaleText('DownloadData')+'</td>'+
                '            <td>'+CreateButton('downloadCookies',GetLocaleText('Download'),'','width:35px;')+'</td>'+
                '         </tr>'+
                '         <tr class="even">'+
                '            <td>'+GetLocaleText('UploadDatas')+'</td>'+
                '            <td>'+CreateButton('uploadCookies',GetLocaleText('Load'),'','width:35px;')+'</td>'+
                '         </tr>'+
                '         <tr class="odd">'+
                '            <td>'+GetLocaleText('DeleteData')+'</td>'+
                '            <td>'+CreateButton('removeCookies',GetLocaleText('Delete'),'','width:35px;')+'</td>'+
                '         </tr>'+
                '         <tr class="even">'+
                '            <td>'+GetLocaleText('GameLanguage')+'</td>'+
                '            <td>'+
                '               <label class="menü">'+
                '                 <select id="gameLanguage" style="width:69px;margin:0 auto;text-align-last: center;">'+
                '                    <option selected value="'+TOOL.language+'" >'+GetLocaleText('Language',null,!1)+' *</option>'+
                '                 </select>'+
                '              </label>'+
                '           </td>'+
                '        </tr>'+
                '     </tbody>'+
                '     <tbody id="ExtraFeatures" style="display:none;">'+
                '        <tr class="odd">'+
                '           <td>'+GetLocaleText('TrainerLevelS')+'</td>'+
                '           <td>'+
                '              <label class="menü">'+
                '                 <select id="AntrenörSeviyesi" k="trainerLevel" currentvalue="'+TOOL.trainerLevel+'" style="width:55px;margin:0 auto;text-align-last: center;">'+
                '                     <option value="10">10 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="9">9 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="8">8 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="7">7 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="6">6 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="5">5 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="4">4 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="3">3 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="2">2 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="1">1 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="0">0 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  </select>'+
                '               </label>'+
                '            </td>'+
                '         </tr>'+
                '         <tr class="even">'+
                '            <td>'+GetLocaleText('YoungTrainerLevelS')+'</td>'+
                '            <td>'+
                '               <label class="menü">'+
                '                  <select id="GAntrenörSeviyesi" k="yTrainerLevel" currentvalue="'+TOOL.yTrainerLevel+'" style="width:55px;margin:0 auto;text-align-last: center;">'+
                '                     <option value="10">10 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="9">9 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="8">8 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="7">7 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="6">6 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="5">5 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="4">4 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="3">3 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="2">2 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="1">1 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                     <option value="0">0 '+GetLocaleText('SortLevel',null,!1)+'</option>'+
                '                  </select>'+
                '               </label>'+
                '            </td>'+
                '         </tr>'+
                '         <tr style="height:20px;line-height:20px;display:none;">'+
                '            <td colspan="2" style="text-align:center;">'+CreateButton('saveChangeProperties',GetLocaleText('Update'),'','padding:3px 8px;width:43px;')+'</td>'+
                '         </tr>'+
                '      </tbody>'+
                '      <tfoot>'+
                '         <tr style="line-height:10px;height:10px;">'+
                '            <td colspan="2">'+
                '               <p style="width: 60px;border-top:1px solid gray;margin:0 auto 2px;">'+
                '                  <img id="özellikAcKapa" src="'+TOOL.sources.get('show','png')+'" alt="show" width="15px" style="cursor:pointer;margin-top:2px;">'+
                '               </p>'+
                '            </td>'+
                '         </tr>'+
                '      </tfoot>'+
                '   </table>';
            add+= //Scriptin özelliklerinin gösterileceği tablo ekleniyor.
                '   <table class="table" style="margin-Top:10px;display:none;table-layout:fixed;" id="FeaturesOfScript">'+
                '      <thead>'+
                '         <tr style="background:none;">'+
                '            <th width="60%">'+GetLocaleText('Features')+'</th>'+
                '            <th>'+GetLocaleText('Action')+'</th>'+
                '         </tr>'+
                '      </thead>'+
                '      <tbody>'+
                '      </tbody>'+
                '   </table>';
            add+= //Script menüsünün en alt kısmı ekleniyor.
                '   <div style="font-family:Comic Sans MS;color:white;font-weight:bold;background-color:black;margin:15px -5px -6px -5px;border-radius: 0 0 6px 6px;padding:5px 0;text-align:center;">'+
                '      <p style="font-size:10px;margin:0;">'+
                ' <label>'+GetLocaleText('QuestionHelp')+' : </label>'+
                '<a href="https://forum.fussballcup.de/showthread.php?t=417372&page=22 "style="color:#14ffff;text-decoration:none;cursor:pointer;font-size: 10px;"target="_blank">'+
                '<label'+GetLocaleText('ClickMe')+'</label>'+
                '       </a>'+
                '      </p>'+
                '<p style="font-size:10px;margin:0;">'+
                '         <label>'+GetLocaleText('ScriptWriter')+' : </label>'+
                '         <a href="#/index.php?w='+worldId+'&amp;area=user&amp;module=profile&amp;action=show&amp;clubId='+TOOL.ScriptAuthorClubId+'" style="color:#14ffff;text-decoration:none;cursor:pointer;font-size: 10px;">'+
                '            Criyessei | mot33'+
                '         </a>'+
                '      </p>'+
                '   </div>'+
                '</div>'

            //Script menüsü için toogle buton ekleniyor ve açılıp-kapanabilmesi için click eventi ekleniyor.
            $('#section-inner-container').after('<div id="scriptMenuToggleBtn" class="active"></div>');
            $('#scriptMenuToggleBtn').click(function(){
                if($(this).hasClass('active')){
                    $(this).removeClass('active');
                    $('#ScriptMenu').slideUp();
                }
                else{
                    $(this).addClass('active');
                    $('#ScriptMenu').slideDown();
                }
            });

            //Script menüsü butondan sonra ekleniyor.
            $('#section-inner-container').after(add);

            //Script menüsü hareket ettirilebilecek.
            $( "#ScriptMenu" ).draggable({ handle: "h2" });

            let OtherLanguages = scriptTexts.OtherLanguages;

            //Script menüsüne seçili dil eklenmiş durumda fakat diğer diller şimdi ekleniyor.
            for(var langKey in OtherLanguages){
                $('#gameLanguage').append('<option value="'+langKey+'">'+OtherLanguages[langKey]+'</option>');
            }

            //Oyun dili değiştirilmek istendiğinde yapılacak kodlar ekleniyor.
            $('#gameLanguage').change(function(){
                //Select box kitleniyor.Bu sayede dil değiştirilene kadar tekrar değiştirilmesine izin verilmiyor.
                this.disabled = true;
                this.style.cursor = 'not-allowed';

                //Yeni dil seçiliyor.
                var language = this.value; //Dil id'si : Turkish,English,German,Polish,French...
                TOOL.language = language;
                scriptTexts = _scriptTexts[language];

                //Eğer yeni seçilen dil scriptin alternatif dili değilse alternatif metinler alınıyor.
                let alternativeTexts=TOOL.alternativeLanguage!=language?_scriptTexts[TOOL.alternativeLanguage]:{};

                //Script metinlerinin bulunduğu st tagları teker teker seçilen dile çeviriliyor.
                $('st').each(function(){
                    $(this).html(GetLocaleText($(this).attr('k')));
                });

                //Antrenör ve genç antrenör levellerinin seçildiği select boxlardaki metinler çevriliyor..
                $('#AntrenörSeviyesi > option').add($('#GAntrenörSeviyesi > option')).each(function(){
                    $(this).text(this.value+' '+GetLocaleText('SortLevel',null,!1)+(this.textContent.endsWith(' *')?' *':'')); //NOT:Seçili optionların sonunda ' *' bulunur.
                });

                //Seçilen dilde bulunan diğer dillerin çevrilmiş metinleri alınıyor.
                OtherLanguages = scriptTexts.OtherLanguages;
                var o = this.selectedIndex; //Dil değiştirme select boxının seçili indexi alınıyor.

                //Diller çevriliyor.
                $('#gameLanguage > option').each(function(i){
                    if(i!=o) $(this).text(OtherLanguages[this.value]);
                    else $(this).text(scriptTexts.Language+' *'); //Seçili dile ' *' ekleniyor.
                });

                //Script menüsünde bulunan özellik tablosundaki metinler çeviliyor.
                $('#FeaturesOfScript > tbody > tr').each(function(){
                    var l = $(this).find('label').first();
                    l.html(scriptTexts.FeaturesName[l.attr('k')]);
                });

                //Yeni bir özellik eklenince çıkan bildirim metni çevriliyor.
                $('#feedback > p.notice > font').each(function(){
                    let k;
                    if(k = $(this).attr('k')){
                        $(this).text(scriptTexts.FeaturesName[k]);
                    }
                });

                //Seçilen dil açık olan server için kullanıcı dil tercihlerine ekleniyor. Bu dil sonraki oyun ziyaretlerinde de etkili oluyor.
                let userLanguage = GM_getValue('userLanguage',{});
                userLanguage[TOOL.server] = language;
                GM_setValue('userLanguage',userLanguage);

                //Kitlenen select box açılıyor.
                this.disabled = false;
                this.style.cursor = '';
            });

            //Geçerli olan antrenör ve genç antrenör seviyeleri aktif ediliyor ve sonlarına ' *' ekleniyor.
            $('#AntrenörSeviyesi').val(TOOL.trainerLevel);
            $('#AntrenörSeviyesi > option:selected')[0].innerHTML+=' *';
            $('#GAntrenörSeviyesi').val(TOOL.yTrainerLevel);
            $('#GAntrenörSeviyesi > option:selected')[0].innerHTML+=' *';

            //Script menüsünde çok yer kaplamaması için gizlenen antrenör ve genç antrenör select boxlarının gizlenip-gösterilebilmesi için click eventi oluşturuluyor.
            $('#özellikAcKapa').click(function(){
                $('#ExtraFeatures').toggle();
                let a = $('#özellikAcKapa').attr('alt');// show - hide
                $(this).attr('src',TOOL.sources.get(a=='show'?'hide':'show','png'));
                $(this).attr('alt',a=='show'?'hide':'show');
                if(a=='hide'){
                    $('#AntrenörSeviyesi').val($('#AntrenörSeviyesi').attr('currentvalue'));
                    $('#GAntrenörSeviyesi').val($('#GAntrenörSeviyesi').attr('currentvalue'));
                    $('#saveChangeProperties').parents('tr').first().hide();
                }
            });

            //Antrenör veya genç antrenör seviyesi güncel seviyesinden farklı olursa kayıt etme butonu gösteriliyor,aksi taktirde gizleniyor.
            $('#AntrenörSeviyesi').add($('#GAntrenörSeviyesi')).change(function(){
                let o=$('#'+(this.id=='AntrenörSeviyesi'?'GAntrenörSeviyesi':'AntrenörSeviyesi'));
                $('#saveChangeProperties').parents('tr').first()[
                    this.value!=$(this).attr('currentvalue') || o.val()!=o.attr('currentvalue')?'show':'hide'
                ]();
            });

            //Değiştirilen antrenör ve|veya genç antrenör seviyeleri kayıt ediliyor ve sayfa yenilenerek değişikli(ğin|klerin) gösterilmesi sağlanıyor.
            $('#saveChangeProperties').click(function(){
                $(this).parents('tr').first().hide();
                var clubDatas = GetCookie('clubDatas');
                clubDatas.trainerLevel = parseInt($('#AntrenörSeviyesi').val());
                clubDatas.yTrainerLevel = parseInt($('#GAntrenörSeviyesi').val());
                SetCookie('clubDatas',clubDatas);
                location.reload();
            });

            //Script verilerilerinin indirilmesi
            $('#downloadCookies').click(function(){
                let cookies = GM_listValues().sort(function(a,b){
                    let s1=a.substring(0,a.indexOf('_')+1),
                        s2=b.substring(0,b.indexOf('_')+1);
                    if((a=a.substring(a.indexOf('_')+1))>(b=b.substring(b.indexOf('_')+1))) return 1;
                    else if(a<b) return -1;
                    return s1>s2;
                }),
                    cookiesText = '',
                    ekle='',
                    veri;
                for(let i = 0; i < cookies.length ; i++){
                    ekle = '';
                    if(!(veri = GM_getValue(cookies[i]))) continue;
                    ekle = Array.isArray(veri)?returnArrayString(veri):JSON.stringify(veri,null,'\t');
                    cookiesText +='CookieKey&:'+cookies[i]+':'+ekle+'\n\n';
                }
                if(cookiesText.trim()) DownloadAsTextFile(cookiesText,'Fcup Script Datas');
                else GiveNotification(false,GetLocaleText('NotDataExist'));
                function returnArrayString(array){
                    let o='[';
                    for(let i = 0 ; i < array.length ; i++){
                        o+=Array.isArray(array[i])?returnArrayString(array[i]):JSON.stringify(array[i],null,'\t')+',';
                    }
                    o = o.substring(0,o.length-1)+']';
                    return o;
                }
            });

            //İndirilen script verilerinin yüklenmesi
            $('#uploadCookies').click(function(){
                ReadTextFile((cookiesText)=>{
                    cookiesText = cookiesText.split('CookieKey&:');
                    cookiesText.splice(0,1);
                    let b,key,data,currentData;
                    for(let i = 0;i < cookiesText.length ; i++){
                        b = cookiesText[i].indexOf(':');
                        key = cookiesText[i].substring(0,b);
                        data = JSON.parse(cookiesText[i].substring(b+1));
                        currentData = GM_getValue(key);
                        GM_setValue(key,data);
                    }
                    let cookiesList = GM_listValues;
                    if(cookiesList.length)
                        cookiesList = FixCookies(cookiesList);

                    GiveNotification(true,GetLocaleText('DataLoaded')+'!!');
                    location.reload();
                });
            });

            //Scriptin sıfırlanması
            $('#removeCookies').click(function(){
                if(confirm(GetLocaleText('AskDeleteTheData',null,!1))){
                    let cookies = GM_listValues();
                    for(let i = 0; i < cookies.length ; i++)
                        GM_deleteValue(cookies[i]);
                    GiveNotification(true,GetLocaleText('DataCleared'));
                    location.reload();
                }
            });

            //Version Checker
            GM_xmlhttpRequest({
                method: "GET",
                url: "https://greasyfork.org/scripts/40715-fcup-script/code/FCup%20Script.meta.js",
                onload: function(response) {
                    var text = response.responseText;
                    var b = text.indexOf('@version')+8;
                    var b1 = text.indexOf('/',b);
                    var version = text.substring(b,b1).trim();
                    var currentVersion = GM_info.script.version;
                    if(version>currentVersion){
                        let header = {
                            css : {'text-align':'center'},
                            content : '<span class="icon" style="background:url(/designs/redesign/images/layout/icons_sprite.png?v=2.2.6.14231) 0 -1180px no-repeat;margin-Right:10px;float:left;margin:6px;">'+
                            '</span>'+GetLocaleText('ReleasedVersion',[version],!1)
                        };
                        let div = {
                            footer : !0,
                            close  : !0,
                            class  : 'container'
                        };
                        div.content =
                            '<img src="https://image.ibb.co/jrcFap/Untitled.png" style="height: 73px;float:left;margin: -15px 0 0 -15px;">'+
                            '<p style="font-size:15px;margin-Bottom:10px;font-weight: bold;color:red;text-align:center;">'+GetLocaleText('CurrentVersion')+' '+currentVersion+
                            '<label style="color:green;margin-Left:50px">'+GetLocaleText('NewVersion')+' : '+version+'</label></p>'+
                            '<p style="font-size:14px;font-weight: bold;color:blue">'+
                            GetLocaleText('UpdateTheScriptInfo',['<a href="https://greasyfork.org/scripts/40715-fcup-script/code/FCup%20Script.user.js" style="font-size:14px">','</a>'],!1)+
                            '</p>'+
                            '<p style="text-align:center;width="515px" style="-webkit-border-radius: 15px;margin-Top:15px;"></p>'+
                            '<p style="margin-Top:20px;text-align:center;">'+CreateButton('relaodPage',GetLocaleText('RefreshPage'))+'</p>';
                        ShowDialog(div,header);
                        $('#relaodPage').click(function(){
                            location.reload();
                        });
                    }
                    else console.log('[Version control] => %cVersion up to date.','color:green;');
                },
                onerror: function() {
                    console.log('[Version control] => %cFail!','color:red;');
                }
            });

            //plObj[Oyuncu verileri] nin kaydedilmesi
            $.get('?area=user&module=formation&action=index&layout=none',function(response) {
                let r = response.content,
                    b = r.lastIndexOf('var plObj');
                if(b!=-1){
                    b = r.indexOf('=',b);
                    playerObject = JSON.parse(r.substring(b+1,r.indexOf('}};',b)+2));
                    if(!typeof playerObject=='object' //Kadroda oyuncu olunca "plObj = {...};" oluyor.
                       || Array.isArray(playerObject) //Kadroda hic oyuncu olmazsa "plObj = [];" oluyor.
                      ) playerObject = undefined;
                }
            });
            //Canlı maçlardaki eventlere erişerek maçlara yeni atraksiyonlar eklenebiliyor.
            $('#body').append('<input type="button" style="display:none;" id="NewMatchEvents">');
            $("#NewMatchEvents").click(function(){
                let event = JSON.parse($(this).attr('k'));
                if(event.message) {
                    if(event.special == 'penaltyStart') {/*Penaltı atışları başladı*/
                    }
                    if(event.special == 'overtimeStart') {/*Maç 90+ uzadı!*/
                    }
                    /*if(event['lastActiveMinute']) {
                        }*/
                    if(event.type == 'goal' || //Normal maç içi gol
                       event.type == 'penalty' || //Bunu kontrol et
                       (event.type == 'penaltyShootout' && event.goal == 'goal')){
                        if(currentLive.lastActiveMin < 120) { // GOOOOALL : event['team']
                            if(currentLive.ownMatch && event.team == currentLive.ownSquad){
                                goalSound.currentTime = 0;
                                goalSound.play();
                            }
                        }
                    }
                    else if(event.type == 'change' && event.squad != currentLive.ownSquad) {
                        /*var outPl = $('#field-player-' + event['out']);
                            var inPl = $('#field-player-' + event['in']);
                            // do not change position if player already on final position, e.g. after reload
                            if(inPl.parent('#opponent-bank').length) {
                                var outPlPos = outPl.parent();
                                var inPlPos = inPl.parent();
                                outPlPos.append(inPl);
                                inPlPos.append(outPl);
                            }*/
                    }
                    else if(event.type == 'info'){
                        var min = event.min;
                        var whistle = $('#whistle'+(min==1?1:min==45?2:event.action=='end'?3:2));
                        if(whistle.length){
                            whistle=whistle[0];
                            whistle.currentTime = 0;
                            whistle.play();
                        }
                    }
                    if(event.type == 'change') {
                        /*if (currentLive.players[event['squad']][event['out']]['a_position'] == 'NONE' || currentLive.players[event['squad']][event['out']]['a_position'] == 'TW') {
                                currentLive.players[event['squad']][event['in']]['a_position'] = currentLive.players[event['squad']][event['out']]['a_position'];
                                currentLive.players[event['squad']][event['out']]['a_position'] = 'Bank';
                            }*/
                    }
                }

                if(event.type == 'penaltyShootout') { //Penaltı atışları
                    if (event.goal == 'goal') { //Penaltı atışı gol oldu
                        //Gol atan takım => event.team
                    }
                    else if(event.goal == 'miss'){ //Penaltı atışı kaçtı
                    }
                }
                if(event.type == 'red' || event.type == 'yellow' || event.type == 'yellow_red') {
                    let whistle1 = $('#whistle1');
                    if(whistle1.length){
                        whistle1 = whistle1[0];
                        whistle1.currentTime=0;
                        whistle1.play();
                    }
                    if(currentLive.ownMatch && event.squad == currentLive.ownSquad){
                        $('#DivCards').show();
                        $('#'+event.type+'_card').show();
                        setTimeout(()=>{
                            $('#DivCards').hide();
                            $('#'+event.type+'_card').hide();
                        },event.delay);
                    }
                    /*var player = $('#field-player-' + event['player']);
                        player.removeClass('weak');
                        player.addClass(event['type']);
                        if (event['type'] != 'yellow') {
                            if (event['squad'] == currentLive.ownSquad) {
                                $('#out-of-match').append($('#field-player-' + event['player']));
                                var playerObj = currentLive.players[currentLive.ownSquad][event['player']];
                                if (playerObj) {
                                    $('#field-player-points-' + event['player']).html(playerObj['points']);
                                    player.off();
                                }
                            } else {
                                $('#opponent-out-of-match').append($('#field-player-' + event['player']));
                            }
                            currentLive.players[event['squad']][event['player']]['a_position'] = 'Bank';
                        }*/
                }
                if(event.type == 'penaltyShootoutScore') {
                    // message = currentLive.getMessageElement(event['min']);
                    // $(message).addClass('info');
                    // $(message).append(event['template']);
                    // $('#match-messages').prepend($(message));
                }
                if(event.type == 'move') {
                    /*if (event['squad'] != currentLive.ownSquad) {
                            var flPl = $('#field-player-' + event['player']);
                            if (flPl && !flPl.parent('#opponent-bank').length) {
                                var nEl;
                                if (event['vPos'] == -1 && event['hPos'] == -1) {
                                    nEl = $('#opponent-positions-goalie');
                                } else {
                                    // calculate opponent position
                                    var y = Math.abs(event['vPos'] - 9);
                                    var x = Math.abs(event['hPos'] - 4);
                                    nEl = $('#Positions_' + y + '_' + x);
                                }
                                nEl.prepend(flPl);
                            }
                        }*/
                }
                if(event.action == 'end') {
                    if (event.template) {
                        /*var shootout = currentLive.getMessageElement(event['min']);
                            $(shootout).addClass('info');
                            $(shootout).append(event['template']);
                            $('#match-messages').append(shootout);*/
                    }
                    /*currentLive.timeElement.html(event['min']);
                        currentLive.commit();*/
                }
                if(event.type == 'injured') {
                    /*currentLive.players[event['squad']][event['player']]['initial_health'] -= event['injuring'];
                        currentLive.setHealthStatus(event['player'], currentLive.players[event['squad']][event['player']]['initial_health']);*/
                }
                if(event.type == 'bonusHealthLoss') {
                    /*var side = event['side'];
                        var icon = $('.' + side + ' .icon.formation-bonus.health').first();
                        icon.addClass('disabled');
                        icon.attr('tooltip', 'formation-bonus-health-inactive');*/
                }
                if(event.type == 'bonusHealthGain') {
                    /*var side = event['side'];
                        var icon = $('.' + side + ' .icon.formation-bonus.health').first();
                        icon.removeClass('disabled');
                        icon.attr('tooltip', 'formation-bonus-health-active');*/
                }
                if(event.type == 'bonusFormationLoss') {
                    /*var side = event['side'];
                        var icon = $('.' + side + ' .icon.formation-bonus.formation').first();
                        icon.addClass('disabled');
                        icon.attr('tooltip', 'formation-bonus-formation-inactive');*/
                }
                if(event.type == 'bonusFormationGain') {
                    /*var side = event['side'];
                        var icon = $('.' + side + ' .icon.formation-bonus.formation').first();
                        icon.removeClass('disabled');
                        icon.attr('tooltip', 'formation-bonus-formation-active');*/
                }
                if(event.type == 'bonusLeadershipLoss') {
                    /*var side = event['side'];
                        var icon = $('.' + side + ' .icon.formation-bonus.leadership').first();
                        icon.addClass('disabled');
                        icon.attr('tooltip', 'formation-bonus-leadership-inactive');*/
                }
            });
            let codes = Live.toString(),
                b = codes.indexOf('{')+1;
            codes = codes.substring(0,b)+
                `\n\t$('#match > div.fixture').append('<img src="https://cdn1.iconfinder.com/data/icons/interface-elements/32/accept-circle-512.png" height="25px" style="position:absolute;right: -7px;top: 13px;">');\n`+
                codes.substring(b);
            b = codes.search(/this.writeMessage\s*=\s*function/);
            b = codes.indexOf('{',b)+1;
            b = codes.indexOf('{',b)+1;
            codes = codes.substring(0,b)+
                (()=>{
                let codes = (()=>{
                    //This codes were written by FCUP Script.
                    if(currentLive.requestMin != 0){
                        $("#NewMatchEvents").attr("k",JSON.stringify(event));
                        $("#NewMatchEvents").click();
                        if(event.action == 'end'){
                            let audios = [backgroundSound,fan1,fan2];
                            for(let i = 0 ; i < audios.length ; i++){
                                if(!audios[i].paused){
                                    let j = audios[i].volume*100;
                                    for(let t = j ; j>=0 ; j--){
                                        ((j,i)=>{
                                            let time = setTimeout(function(){
                                                audios[i].volume = j/100;
                                                if(audios[i].volume == 0){
                                                    audios[i].pause();
                                                }
                                            },(t-j)*50);
                                        })(j,i);
                                    }
                                }
                            }
                        }
                    }
                    else{
                        if(event.action == 'end'){
                            $(backgroundSound).attr('stop',true);
                            let audios = [backgroundSound,fan1,fan2];
                            for(let i = 0 ; i < audios.length ; i++){
                                if(!audios[i].paused){
                                    audios[i].pause();
                                }
                            }
                        }
                    }
                    if(event.type == 'goal' || event.type == 'penalty' || (event.type == 'penaltyShootout' && event.goal == 'goal')){
                        if(currentLive.lastActiveMin < 120){
                            var squad = currentLive.homeId == event.team ? "home":"away";
                            var player = {id:null,name:$('<div>'+event.message+'</div>').find('.'+squad+':last').text().trim()};
                            var players = currentLive.players[currentLive[squad+'Id']];
                            var ids = [];
                            for(var playerId in players){
                                var p = players[playerId];
                                if(p.a_position != "Bank"){
                                    if(p.lastname == player.name){
                                        ids.push(p.id);
                                    }
                                }
                            }
                            if(ids.length==1){
                                player.id = ids[0];
                                var spn = $('#player-goals-'+player.id);
                                if(!spn.length){
                                    $('#'+squad+'-goals').append(
                                        (parseInt($('#'+currentLive.matchId).find('.score-'+squad).first().text())>0?" , ":"")+
                                        '<span style="color:#'+(squad=="home"?'f00':'0ec6e7')+';white-space:nowrap;">'+
                                        '<img src="https://image.ibb.co/jdRxmK/Ads_z.png" height="15px;" style="vertical-align:middle;margin: -1px 2px 0 0;">'+
                                        '<span id="player-goals-'+player.id+'" style="color:white;font-size: 10px;font-weight:bold;">['+event.min+']</span> '+player.name+
                                        '</span>'
                                    );
                                }
                                else{
                                    var text = spn.text();
                                    spn.text(text.substring(0,text.length-1)+','+event.min+']');
                                }
                            }
                        }
                    }
                }).toString();
                return codes.substring(codes.indexOf('{')+1,codes.lastIndexOf('}'));
            })()+
                codes.substring(b);
            let script = document.createElement('script');
            script.id = 'LiveFunction';
            script.innerHTML = codes;
            $(document.head).append(script);

            /*Thanks to mot33*/
            (()=>{
                if (window.top != window.self) return; //sayfa iframe olmadığında bu özellik çalışacak.
                $("#chatToggleBtn").css('top','+=23px');//Düzenleme yapılıyor.
                var notiz = false;
                (()=>{
                    GM_addStyle(`
#notice_in {
color: white;
font-size: 12px;
background-color: #088A08;
padding: 3px;
width: 130px;
margin: auto;
border-radius: 10px;
cursor: pointer;
letter-spacing: 0.11em;
}

#notice_out {
width: 100%;
background-color: transparent;
padding: 10px;
border: 0px solid #088A08;
}

.notiz_button {
box-shadow: rgba(0, 0, 0, 0.75) 11px 10px 29px -5px;
font-size: 13px;
padding: 2px;
width: 120px;
cursor: pointer;
text-align: center;
cursor: pointer;
margin: 15px;

.button span {
cursor: pointer;
display: inline-block;
position: relative;
}

.button span:after {
content: '»';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}

.button:hover span:after {
opacity: 5;
right: 0;
}


}
#Notizbereich {
border-radius: 12px;
position:static;
margin:5px;
height: 150px;
background-color: #FFFFFF;
border: 1px solid #DF0101;
padding: 0px;
}

`);
                })();
                var notice_area = document.createElement("div");
                notice_area.setAttribute('id', 'notice_area');

                var notice_in = document.createElement("div");
                notice_in.setAttribute('id', 'notice_in');
                notice_in.addEventListener("click", openNotice, false);

                var notice_out = document.createElement("div");
                notice_out.setAttribute('id', 'notice_out');

                var clue_text = document.createElement("p");
                clue_text.innerHTML = '<font style="color:#1C6125;border-radius:7px;padding:3px 4px;text-align:center;opacity:0;" id="change_clue"></font>';

                var Notice_Text = document.createElement("p");
                var Notice_Buttons = document.createElement("p");
                var element = document.createElement("p");
                var Notice_Textarea = document.createElement("textarea");
                var Notice_Savebutton = document.createElement("input");
                var Notice_Resetbutton = document.createElement("input");

                Notice_Textarea.cols = "80";
                Notice_Textarea.rows = "5";
                Notice_Textarea.placeholder = GetLocaleText('WriteANote',null,!1);
                Notice_Textarea.style.borderRadius = "10px";
                Notice_Textarea.style.padding = "4px 5px";
                Notice_Textarea.style.maxWidth = $('#header').width()+"px";
                Notice_Textarea.style.minHeight = "59px";
                Notice_Textarea.style.minWidth = "345px";
                Notice_Textarea.setAttribute('id', 'Notizbereich');
                Notice_Textarea.appendChild(document.createTextNode(GetCookie('Notiz','')));

                Notice_Savebutton.type = "Button";
                Notice_Savebutton.value = GetLocaleText('SaveNote',null,!1);
                Notice_Savebutton.setAttribute('class', 'notiz_button');
                Notice_Savebutton.addEventListener("click", save, false);

                Notice_Resetbutton.type = "Button";
                Notice_Resetbutton.value = GetLocaleText('ClearField',null,!1);
                Notice_Resetbutton.setAttribute('class', 'notiz_button');
                Notice_Resetbutton.addEventListener("click", reset, false);

                Notice_Buttons.appendChild(Notice_Savebutton);
                Notice_Buttons.appendChild(Notice_Resetbutton);


                Notice_Text.appendChild(Notice_Textarea);
                Notice_Text.appendChild(Notice_Buttons);

                notice_out.appendChild(Notice_Text);
                notice_out.appendChild(clue_text);
                notice_out.appendChild(notice_in);

                notice_area.appendChild(notice_in);
                notice_area.appendChild(notice_out);


                document.body.insertBefore(notice_area, document.body.firstChild);
                document.body.appendChild(element);

                document.getElementById("notice_in").innerHTML = GetLocaleText('OpenNote');
                notice_out.style.display="none";
                var lock = false;
                function openNotice(){
                    if(lock) return;
                    $('#notice_out').slideToggle(750);
                    lock = true;
                    setTimeout(function(){lock=false;},750);
                    if(!notiz){
                        $('#notice_in').html(GetLocaleText('CloseNote'));
                        $("#chatToggleBtn").animate({ "top": "+=163px" }, 750 );
                    }
                    else{
                        $('#notice_in').html(GetLocaleText('OpenNote'));
                        $("#chatToggleBtn").animate({ "top": "-=163px" }, 750 );
                    }
                    notiz = notiz?false:true;
                }

                function save(){
                    SetCookie('Notiz', $('#Notizbereich').val());
                    change_clue(GetLocaleText('SavedNote'));
                }
                var interval;
                function change_clue(value){
                    $('#change_clue').animate({'opacity':1});
                    clearInterval(interval);
                    $('#change_clue').html(value);
                    interval = setTimeout (function() {
                        $('#change_clue').animate({'opacity':0},200);
                        setTimeout(()=>{
                            $('#change_clue').html('');
                        },200);
                    }, 2800);
                }

                function reset(){
                    $('#Notizbereich').val('');
                    change_clue(GetLocaleText('ClearedNote'));
                }
            })();

            //Sayfa değiştirilince main fonksiyonu çağırılıyor.
            $('#body').append('<input type="button" style="display:none;" id="ChangeContent">');
            $('#ChangeContent').click(function(){
                if(!$('#content').find('h2').first().attr('Fixed')) PageLoad(main); //Sayfa değiştirilince Fixed özelliği olmayacağı için undefined değeri dönecek ve main fonksiyonu çalıştırılacak.
            });

            //The function named updateLayout are needed update for the FCUP Script. Because when the page change, fcup script should work then.
            $(document.head).append(
                "<script id='FunctionupdateLayout'>"+
                (()=>{
                    let codes = (updateLayout).toString();
                    codes = 'function updateLayout'+codes.substring(codes.indexOf('('));
                    return codes.substring(0,codes.lastIndexOf('}'))+"$('#ChangeContent').click();}";
                })()+
                "</script>"
            );


            //Arranged openCard function
            $('body').append(
                '<script id="updateEvents" type="text/javascript">'+
                '('+(()=>{ //This function was arranged by FCUP Script
                    openCard = function(event) {
                        var pid = event.target.getAttribute('pid');
                        element = $('#info-' + pid);
                        element.addClass('open-dialog');
                        element.dialog({
                            closeText : "",
                            height : 345,
                            width : 460,
                            resizable : false
                        });
                        //New codes added here
                        let div_dialog = element.parent();
                        div_dialog.css('display','none');
                        div_dialog.fadeIn(400);
                        if(parseInt($('#agreement-info-'+pid+' > li:nth-child(8) > div > div.bar-text').text())>=55 &&
                           !$('#info-'+pid+' > div.name > img.captain_icon').length
                          ) $('#info-'+pid+' > div.name').append('<img class="captain_icon" src="https://i.ibb.co/Sy52rxz/Captain.png" style="height:20px;float:none;margin:-7px 0 0 3px;vertical-align:middle;cursor:title="Kapitän">');
                    };
                    //$('#updateEvents').remove();
                }).toString()+')();'+
                '</script>'
            );


            //Click event function(for .negotiation-bid-player elements) was rewritten for some features work properly by FCUP Script.
            $('body').append(
                '<script id="removeEvents" type="text/javascript">'+
                '('+(()=>{ //This function was rewritten by FCUP Script
                    //Removing the current function.
                    $('body').off('click', '.negotiation-bid-player');
                    //Remove this tag
                    $('#removeEvents').remove();
                }).toString()+')();'+
                '</script>'
            );

            //Adding new function
            $('body').on('click', '.negotiation-bid-player', function(e) {
                let element  = $(this),                //Onaylama butonu
                    id       = element.attr('unique'), //return player-29820872
                    playerId = element.attr('player'), //Oyuncunun id si alınıyor.
                    clubId   = element.attr('club'),   //Bizim kulüp id'imiz alınıyor.
                    offer    = '',                     //Teklif ettiğimiz ücret
                    amount   = '',                     //Oyuncuya vereceğimiz maaş
                    duration = '',                     //Oyuncuyla anlaşacağımız sezon sayısı
                    params,                            //Servere gönderilecek data
                    negotiation_type,                  //Müzakere tipi = [offer,negotiateDebts,negotiateWithOwnPlayer,acceptNegotiation]
                    pl;

                //Onaylama butonu gizleniyor.
                element.hide();

                //Onaylama butonunun olduğu yere yükleniyor gifi ekleniyor.
                element.parent().append($('<div class="load-icon loading" id="loading-' + id + '"></div>'));

                if ($('#bid-offer-' + id).length    //Oyuncuyu satın almak için kulübe teklif ettiğimiz input mevcutsa
                    && $('#bid-offer-' + id).val()  //İnputun değeri boş değilse
                   ){ //Oyuncuya teklif veriliyor.
                    negotiation_type = 'offer';
                    //Geri dönmeyi sağlayan buton gizleniyor.
                    $('#info-player-' + playerId + ' .abort-negotiation-button-container').first().hide();
                    offer = $('#bid-offer-' + id).val();

                    //Example : {"elements": '{"offer":{"0":"1111;2222;3333"}}'}
                    params = {
                        'elements': JSON.stringify({
                            'offer': {
                                0: playerId + ';' + clubId + ';' + offer
                            }
                        })
                    };
                }
                else if($('#bid-amount-' + id).length   //Teklif ettiğimiz maaş inputu mevcutsa
                        && $ ('#bid-amount-' + id).val() //İnput boş değilse
                       ){//Oyuncu ile sözleşme yapılıyor.

                    if($('#own-offers').length){//Transfer pazarı sayfası açık ise ya kendi oyuncumuzla yeni sözleşme imzalıyoruz. Yada yeni bir oyuncu satın alırken futbolcuyla sözleşme imzalıyoruz.
                        if((pl = $('#own-offers').find('tbody > tr span[pid="player-'+playerId+'"]')).length){ //Sözleşme imzalanan oyuncu tekliflerimiz tablosunda ise yeni bir oyuncu alarak sözleşme imzalıyoruz
                            negotiation_type = 'negotiateDebts';
                            pl = pl.parents('tr').first();
                        }
                        else//Tekliflerimizin bulunduğu tabloda yoksa, kendi oyuncumuz ile sözleşme imzalıyoruzdur.
                            negotiation_type = 'negotiateWithOwnPlayer';
                    }
                    else //Transfer pazarı sayfası açık değil. Not : Burada sıkıntı olabilir.
                        negotiation_type = 'negotiateWithOwnPlayer';

                    amount = amountControl[id].numberUnFormat($('#bid-amount-' +id).val()); //Formatı sıfırlıyor.Noktalar kaldırılıyor.Artık integer.

                    if($('#bid-duration-' + id).length   //Teklif ettiğimiz sezon inputu mevcutsa
                       && $('#bid-duration-' + id).val() //İnput boş değilse
                      ) duration = durationControl[id].numberUnFormat($('#bid-duration-' + id).val()); //Formatı sıfırlıyor.Noktalar kaldırılıyor.

                    //Example : {"elements":'{"negotiateDebts":{"0":"1111;2222;amount=33333;duration=3"}}'}
                    params = {
                        'elements': JSON.stringify({
                            'negotiateDebts': {
                                0: playerId + ';' + clubId + ';amount=' + amount + ';duration=' + duration
                            }
                        })
                    };
                }
                else{ //Gözlemcinin getirdiği oyuncu için kapora ödeniyor.
                    negotiation_type = 'acceptNegotiation';
                    //Example : {"elements":'{"acceptNegotiation":{"0":"1111;2222"}}'}
                    params = {
                        'elements': JSON.stringify({'acceptNegotiation': {0: playerId + ';' + clubId}})
                    };
                }
                //Servere istek gönderiliyor.
                $.get(
                    '/index.php?w='+worldId+'&area=user&module=player&action=negotiate&complex=0',
                    params,
                    function(response) { //İstek başarılı oldu!
                        //Yükleniyor gifi kaldırılıyor.
                        $('#loading-'+id).remove();

                        let div = document.createElement('div');
                        div.innerHTML = response;

                        try{
                            switch(negotiation_type){
                                case "offer":
                                    break;
                                case "negotiateDebts":
                                case "negotiateWithOwnPlayer":
                                    let texts,negotiate_success = !1;
                                    $(div).find('script').each(function(i){
                                        texts = $(this).html();
                                        //window.location.href = $('span[pid=player-' + 29823205 + ']').first().attr('ref')
                                        if(texts.indexOf("window.location.href = $('span[pid=player-' + "+playerId+" + ']').first().attr('ref')")!=-1){
                                            $(div).find('script')[i].remove();
                                            negotiate_success = !0;
                                            let notification_text;
                                            if(negotiation_type=="negotiateWithOwnPlayer"){//Kendi oyuncumuz ile başarılı bir şekilde sözleşme imzaladık!
                                                notification_text = GetLocaleText('SuccessfullyContract');
                                            }
                                            else{//Yeni bir oyuncuyu sözleşme imzalayarak satın aldık.
                                                let data = GetCookie('PlayersData',{}),
                                                    playerName = pl.find('.player-name:first').text().trim();
                                                if(!data.BuyPlayers) data.BuyPlayers = [];
                                                data.BuyPlayers.splice(0,0,{
                                                    playerCountry : pl.find('td:nth-child(1) > img').attr('src').match(/\w+.gif/)[0].replace('.gif',''),
                                                    playerId      : playerId,
                                                    playerName    : playerName,
                                                    position      : pl.find('td:nth-child(3)').text().trim(),
                                                    strength      : parseInt(pl.find('td:nth-child(4)').text()),
                                                    age           : parseInt(pl.find('td:nth-child(5)').text()),
                                                    salary        : parseInt(amount),
                                                    price         : parseInt(pl.find('td:nth-child(8)').attr('sortvalue')),
                                                    season        : parseInt(duration),
                                                    club          : {
                                                        id        : parseInt(pl.find('td:nth-child(6) > a').attr('clubid')),
                                                        name      : pl.find('td:nth-child(6) > a').text().trim()
                                                    },
                                                    date : GetDateText(GetServerTime()),

                                                });
                                                SetCookie('PlayersData',data);
                                                notification_text = GetLocaleText('SuccessfullyTransferred',[playerName],!1);
                                            }
                                            //Onaylama butonunu gizlemeye gerek yok çünkü en başta gizliyoruz : element.hide();
                                            //$('#negotiation-bid-player-' + playerId).hide();
                                            //Böyle bir element yok ki!
                                            $('#info-window-player-' + playerId + ' .abort-negotiation-button-container').first().hide();
                                            setTimeout(function(){
                                                location.href = $('span[pid=player-' + playerId + ']').first().attr('ref');
                                                if(notification_text)
                                                    PageLoad(function(){
                                                        GiveNotification(true,notification_text);
                                                    });
                                            },2000);
                                            $('.negotiation table, .negotiation .info').each(function(key, e) {
                                                e.hide();
                                            });
                                            return false;
                                        }
                                    });
                                    break;
                                default://acceptNegotiation
                                    break;
                            }
                        }
                        catch(err){
                            CatchError(err,'negotiation-bid-player');
                        }

                        //Konteynıra server tarafından verilen cevap konuluyor.
                        $('#negotiate-container-' + id).html(div.innerHTML);


                        //Reklamları güncelleme
                        updateAds();

                        //
                        $('body').trigger('content:changed');
                    }
                ).fail(function(){
                }).always(function(){
                });
            });


            PageLoad(main);//Oyuna girildiğinde çalışacak
        }
        /*Script css kodları:*/
        $('head').append('<link id="font-awesome" rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">');
        (()=>{
            GM_addStyle(`
.disHighlight{
user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-touch-callout: none;
-o-user-select: none;
-moz-user-select: none;
}
@keyframes flickerAnimation {
0%   { opacity:1; }
50%  { opacity:0; }
100% { opacity:1; }
}
@-o-keyframes flickerAnimation{
0%   { opacity:1; }
50%  { opacity:0; }
100% { opacity:1; }
}
@-moz-keyframes flickerAnimation{
0%   { opacity:1; }
50%  { opacity:0; }
100% { opacity:1; }
}
@-webkit-keyframes flickerAnimation{
0%   { opacity:1; }
50%  { opacity:0; }
100% { opacity:1; }
}
.animate-flicker {
background-color : #910e0ea8;
-webkit-animation: flickerAnimation 1s infinite;
-moz-animation: flickerAnimation 1s infinite;
-o-animation: flickerAnimation 1s infinite;
animation: flickerAnimation 1s infinite;
}

#scriptMenuToggleBtn{
position:absolute;
top:-44px;
right:-23px;
height:40px;
width:40px;
background-image: url(https://i.ibb.co/tJC5RX3/HFWRRt6.png);
z-index:20;
opacity:.5;
cursor:pointer;
}
#scriptMenuToggleBtn:hover , #scriptMenuToggleBtn.active{
opacity:1;
}
#ScriptMenu > table > tbody > tr > td{
word-wrap: break-word;
white-space: normal;
line-height: 15.5px;
padding:3px 6px;
}
#ScriptMenu{
z-index:10;
position: absolute;
width: 180px;
background: white;
top: 0;
right: -180px;
overflow-wrap: break-word;
display: block;
margin: 0 auto;
padding:5px;
border-radius: 8px;
font-size:10px;
border: 1px solid black!important;
box-sizing: border-box;
}
#ScriptMenu > h2{
width: 100%;
color: white;
font-weight: bold;
border: 0;
margin: -5px 0 0 -5px;
text-align: center;
font-size: 14px;
height: 30px;
background:url(/designs/redesign/images/layout/headlines_sprite.gif) 0 -70px repeat-x;
border-radius: 7px 7px 0 0;
margin-bottom:5px;
cursor:move;
}
table.table thead th:first-of-type{
border-radius : 7px 0 0 7px;
}
table.table thead th:last-of-type{
border-radius : 0 7px 7px 0;
}
table.table th{
background : #c01700;
}
table.table tbody tr.even > td{
background: #eee;
}
table.table tbody tr > td:first-of-type{
padding-left:5px;
text-align:left;
}
table.table tbody tr.even > td:first-of-type{
border-radius : 7px 0 0 7px;
}
table.table tbody tr.even > td:last-of-type{
border-radius : 0 7px 7px 0;
}
table.table tbody td{
border-bottom: 0;
}
div.box p{
margin-Bottom:5px;
}
.slideThree input[type=checkbox]{
visibility: hidden;
}
.slideThree {
width: 55px;
height: 21px;
background: #333;
margin: 0;
-webkit-border-radius: 55px;
-moz-border-radius: 50px;
border-radius: 50px;
position: relative;
-webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
-moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
}
.slideThree:after {
content: \'Off\';
font: 9px/26px Arial, sans-serif;
color: red;
position: absolute;
right: 7px;
top: -2px;
z-index: 0;
font-weight: bold;
text-shadow: 1px 1px 0px rgba(255,255,255,.15);
}
.slideThree:before {
content: \'On\';
font: 9px/26px Arial, sans-serif;
color: #00bf00;
position: absolute;
left: 7px;
top: -2px;
z-index: 0;
font-weight: bold;
}
.slideThree label {
display: block;
width: 25px;
height: 17px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
-webkit-transition: all .4s ease;
-moz-transition: all .4s ease;
-o-transition: all .4s ease;
-ms-transition: all .4s ease;
transition: all .4s ease;
cursor: pointer;
position: absolute;
top: 2px;
left: 3px;
z-index: 1;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
background: #fcfff4;
background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#fcfff4\', endColorstr=\'#b3bead\',GradientType=0 );
}
.slideThree input[type=checkbox]:checked + label {
left: 26px;
}
label.menü > select {
padding:4px;
margin: 0;
-webkit-border-radius:9px;
-moz-border-radius:4px;
border-radius:4px;
-webkit-box-shadow: 0 px 0 #ccc, 0 -1px #fff inset;
-moz-box-shadow: 0 2px 0 #ccc, 0 -1px #fff inset;
box-shadow: 0 2px 0 #ccc, 0 -1px #fff inset;
background: #f8f8f8;
color:#888;
border:none;
outline:none;
display: inline-block;
-webkit-appearance:none;
-moz-appearance:none;
appearance:none;
cursor:pointer;
}
label.menü > select {
padding-right:18px;
font-size:9px;
width:45px;
margin:0 auto;
text-align-last: center;
}
label.menü {
position:relative
}
label.menü:after {
content:'<>';
font:8px \"Consolas\", monospace;
color:#aaa;
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
right:2px;
top:2px;
padding:0 0 2px;
border-bottom:0px solid #ddd;
position:absolute;
pointer-events:none;
}
label.menü:before {
content:'';
right:0px;
top:0px;
width:5px;
height:px;
background:#f8f8f8;
position:absolute;
pointer-events:none;
display:block;
}
@keyframes fadeInDown {
0% {
opacity: 0;
transform: translateY(-1.25em);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.openClose[open] {
animation-name: fadeInDown;
animation-duration: 0.5s;
}
@keyframes fadeInDown {
0% {
opacity: 0;
transform: translateY(-1.25em);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.details5[open] {
animation-name: fadeInDown;
animation-duration: 0.5s;
}
@keyframes fadeInUp {
0% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-1.25em);
}
}
.openClose[close] {
animation-name: fadeInUp;
animation-duration: 0.5s;
}

.checkbox_1 {
display: none;
}

.checkbox_1 + label:before {
cursor: pointer;
content: \'\\2714\';
border: 0.1em solid #d95555;
border-radius: 0.2em;
display: inline-block;
width: 1.1em;
height: 1em;
padding-left: 0em;
padding-bottom: 0.3em;
padding-top:-0.1em;
margin-right: 0em;
vertical-align: middle;
text-align:center;
color: #d95555;
transition: .2s;
}

.checkbox_1 + label:active:before {
transform: scale(0);
}

.checkbox_1:checked + label:before{
background-color: red;
border-color: red;
color: #fff;
}

/*** custom checkboxes ***/

.checkbox_2 { display:none; } /* to hide the checkbox itself */
.checkbox_2 + label:before {
font-family: FontAwesome;
display: inline-block;
}

.checkbox_2 + label:before { content: \'\\f096\'; } /* unchecked icon */
.checkbox_2 + label:before { letter-spacing: 2px; } /* space between checkbox and label */
.checkbox_2:not(:checked):hover + label:before{content: \'\\f046\';color:#6f6e6e;letter-spacing: 0;}

.checkbox_2:checked + label:before { content: \'\\f046\'; } /* checked icon */
.checkbox_2:checked + label:before { letter-spacing: 0; } /* allow space for check mark */

.sorting_players{
font-size:10px;
text-align:center;
padding:5px 0;
margin-bottom: 9px;
border-bottom: 1px solid white;
line-height:1.5;
}
.sorting_players > label{
display:inline-block;
}
.sorting_players > label:not(:first-child){
margin-left:8px;
}
.sorting_players > label > input{
vertical-align:middle;
margin:-3px 1px 0 0;
cursor:pointer;
}
.sorting_players st{
color:#c8c7c7;
}
.sorting_players input:checked + st{
color : #04da97;
}

.filterByPositions{
margin: -3px 0 7px;
text-align: center;
}
.filterByPositions > .filter_position{
border-radius: 20%;
background-color:green;
cursor: pointer;
display:inline-block;
padding:2px 0;
font-size: 8px;
color: white;
min-width: 20px;
opacity:1;
margin:2px;
}
.filterByPositions > .filter_position.not_active{
opacity:0.3;
}
.grow,.grow2 {
transition: all .2s ease-in-out;
}
.grow:hover {
transform: scale(1.1);
}
.grow2:hover{
transform: scale(1.5);
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 20px;
  background: #d3d3d3;
  outline: none;
  opacity: 0.7;
  -webkit-transition: .2s;
  transition: opacity .2s;
}

.slider:hover {
  opacity: 1;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  border-radius:6px;
  width: 30px;
  height: 20px;
  background: #4CAF50;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  border-radius:6px;
  width: 30px;
  height: 20px;
  background: #4CAF50;
  cursor: pointer;
}

`);
        })();
    });
});

function main(){
    console.log('Server Time : '+new Date(GetServerTime()).toLocaleString());

    //Özelliklerin olduğu tablo temizleniyor. Çünkü sayfa değiştirildi ve bu sayfada başka özellikler olabilir.
    Features.clear();

    //Önceki sayfalardan kalan sayaçlar sıfırlanıyor.
    Intervals.clear();

    //Önceki sayfadan çalışan sayaçlar sıfırlanıyor.
    for(let intervalName in AllIntervals){
        clearInterval(AllIntervals[intervalName]);
        AllIntervals[intervalName] = undefined;
    }

    //Bir sonraki yaş atlamaya kalan süre sayaç şeklinde en alt menüye ekleniyor.
    (()=>{
        let ServerTime = GetServerTime(),
            ageDates = TOOL.ageDates;
        if(!ageDates //Yaş atlama tarihleri mevcut değilse
           || $('#FutureAge').length //Geri sayım sayacı bulunuyorsa
           || ageDates[ageDates.length-1]*60000<ServerTime //Server zamanı, yaş atlama tarihlerinin sonuncusundan büyükse
          ) return;
        let NewAgeRemainingSeconds,
            ageDate,
            i = 0;
        for(; i < ageDates.length ; i++){
            ageDate = ageDates[i]*60000;//Dakika cinsinden diziye eklenen yaş atlama tarihleri mili saniyeye çevriliyor.
            if(ageDate>ServerTime){
                NewAgeRemainingSeconds = parseInt((ageDate-ServerTime)/1000);//Yaş atlamaya kalan saniye hesaplanıyor.
                $('#footer > div').css('width','300px');
                $('#footer > .server-infos').prepend(
                    '<li style="padding: 4px 5px;font-size:12px;" title="'+new Date(ageDate).toLocaleString()+'">'+
                    GetLocaleText('NewAge')+' : <label id="FutureAge">'+ShowCountDownTime(NewAgeRemainingSeconds--)+'</label>'+
                    '</li>'
                );
                Intervals.create((clear)=>{
                    $('#FutureAge').html(ShowCountDownTime(NewAgeRemainingSeconds--));
                    if(NewAgeRemainingSeconds==-1){
                        $('#FutureAge').html('Yaş Atladı');
                        clear();
                    }
                },1000);
                break;
            }
        }
    })();
    //Açık olan sayfayı script algılıyor ve gerekli kodları çalıştırıyor.
    let ActiveCategory=$('#nav > ul > li > div.category.active').parents('li').index(),
        Page=new (function(){
            this.pr=location.hash.substring(location.hash.indexOf('?')+1).split('&').reduce(function (result, item) {
                let parts = item.split('=');
                result[parts[0]] = parts[1];
                return result;
            }, {});
            this.on=function(a){
                for(let i in a){
                    if(!(this.pr[i] && a[i]==this.pr[i])) return 0;
                }
                return 1;
            }
        })(),
        pageIsDetected=!0;
    if(ActiveCategory>=0 && ActiveCategory<=5){
        switch(ActiveCategory){
            case 0:
                if(Page.on({module:'main',action:'home'}) || Page.on({module:'main',action:'acceptSimulation'}) || Page.on({module:'main',action:'deleteSimulation'})){//Ana Sayfa


                    //Özellik: İnşaat geri sayım
                    if(Features.IsActive("ConstructionCountdown",'#clubinfocard > ul > li:nth-child('+($('#clubinfocard > ul > li').length+1)+'),#clubinfocard > ul > li:nth-child('+($('#clubinfocard > ul > li').length+2)+')')){
                        /*
                            ÖZELLİK : ConstructionCountdown ~  İnşaat geri sayım
                            Kulüp arsasında ve stadyumda inşaat varsa ana sayfada inşaatların bitimine kalan zaman gösteriliyor.
                        */
                        $('#clubinfocard > ul').append(
                            '<li><img width="16px" src="'+TOOL.sources.get('construction','png')+'" alt="construction" style="margin:-3px 0 0 0;vertical-align:middle;"><span class="label">'+GetLocaleText('Buildings')+':</span><span id="countdown_buildings">'+GetLocaleText('Loading')+'...</span></li>'
                        );
                        $('.likebox').css('marginBottom','-40px');
                        let modules = ["buildings"],
                            i=0;
                        for(; i < 2 ; i++){
                            let module = modules[i];
                            if(TOOL["finishDate_"+module]){
                                let seconds = parseInt((TOOL["finishDate_"+module] - GetServerTime()) /1000);
                                let cd = $('#countdown_'+module);
                                cd.attr('title',new Date(TOOL["finishDate_"+module]).toLocaleString());
                                start(seconds,cd);
                            }
                            else getData(module);


                    }
                        function getData(module){
                            GetPage('?w='+worldId+'&area=user&module='+module+'&action=index&_=squad','content',function(content){
                                let cd = $(content).find('.countdown');
                                if(cd.length){
                                    let seconds = parseInt(cd.first().attr('x')),
                                        finishDate = GetServerTime()+seconds*1000;
                                    TOOL["finishDate_"+module] = finishDate; //Bitiş süresinin bir kere alınması yeterli.
                                    cd = $('#countdown_'+module);
                                    cd.attr('title',new Date(TOOL["finishDate_"+module]).toLocaleString());
                                    start(seconds,cd);
                                }
                                else{
                                    let icerik = '';
                                    if(module=='buildings'){//buildings
                                        if($(content).find('.build').length)
                                            icerik = '<a href="#/index.php?w='+worldId+'&area=user&module='+module+'&action=index&_=squad" <span="" style="color: #51ff44;">'+GetLocaleText('GoToBuildings')+'</a>';
                                        else
                                            icerik = '<font color="white">'+GetLocaleText('Full')+'</font>';
                                    }

                                    $('#countdown_'+module).html(icerik);
                                }
                           });
                        }

                        function start(seconds,e){
                            e.html(ShowCountDownTime(seconds--));
                            Intervals.create(()=>{
                                if(seconds<1){
                                    e.html('<font style="color: #b20b0b;font-weight:bold;">'+GetLocaleText('ItIsOver')+' !</font>');
                                    clearInterval(Intervals.named[e[0].id]);
                                    delete Intervals.named[e[0].id];
                                    return;
                                }
                                e.html(ShowCountDownTime(seconds--));
                            },1000,e[0].id);
                        }
                    }

                    //Özellik: Rövanş maçı
                    if(!$('#matches > ul.matches.simulations').find('.no-entry').length &&
                       Features.IsActive("RematchMatch",'.sendSimulation')
                      ){
                        /*
                            ÖZELLİK : RematchMatch ~  Rövanş maçı
                            Deplasmanda simülasyon yapılan/yapılacak bir maç varsa ve o takıma simülasyon daveti göndermediysek.....
                        */
                        let requests = {
                            "myRequest":{
                                "accepted":[],
                                "unaccepted":[]
                            },
                            "otherRequest":{
                                "accepted":[],
                                "unaccepted":[]
                            }
                        };
                        $('#matches > ul.matches.simulations > li').each(function(){
                            let ul = $('ul',this),
                                o = ul.find('.squad-home .self-link').length?"myRequest":"otherRequest",
                                u;
                            if(o=="otherRequest")
                                u = ul.find('.show-button a[href*="acceptSimulation"]').length?"unaccepted":"accepted";
                            else//myRequest
                                u = ul.find('.show-button a[href*="match&id="]').length?"accepted":"unaccepted";
                            requests[o][u].push(ul);
                        });
                        let oa = requests.otherRequest.accepted,
                            i;
                        //Kabul etmiş olduğumuz deplasman isteğimiz olacak fakat o takıma gönderdiğimiz bir simülasyon davetimiz olmayacak.
                        for(i = 0; i < oa.length ; i++){
                            let find = !1,
                                clubId = $('li.col.info > span.squad-home > a',oa[i]).attr('clubid'),
                                m = requests.myRequest.accepted.concat(requests.myRequest.unaccepted),
                                j;
                            for(j = 0; j < m.length ; j++){
                                if(clubId == $('li.col.info > span.squad-away > a',m[j]).attr('clubid')){
                                    find = true;
                                    break;
                                }
                            }
                            if(!find){
                                let ul = oa[i];
                                ul.find('.show-button').append('<img class="sendSimulation" src="'+TOOL.sources.get('again','png')+'" alt="again" style="cursor:pointer;vertical-align:middle;" width="35px" k="'+clubId+'">');
                            }
                        }
                        $('.sendSimulation').click(function(){
                            let img = $(this);
                            img.hide();
                            img.after('<img src="/designs/redesign/images/icons/loading/16x16.gif" style="vertical-align:middle;margin-left:7px;">');
                            GetPage('?w='+worldId+'&area=user&module=profile&action=show&clubId='+$(this).attr('k'),'profile-show',function(html){
                                let href = $(html).find('.button-container-friendly-invite-button > a').attr('href'),
                                    b = href.indexOf('invite=')+7,
                                    matchId = href.substring(b,href.indexOf('&',b));
                                GetPage("?w="+worldId+"&area=user&module=simulation&action=index&squad="+matchId,'feedback',function(html){
                                    img.next().remove();
                                    img.remove();
                                    if($(html).find('.error').length)
                                        GiveNotification(false,GetLocaleText('SimulationRequestAvailable'));
                                    else
                                        GiveNotification(true,GetLocaleText('SimulationRequestSent'));
                                });
                            });
                        });
                    }

                    //Yeni gelen genç oyuncuların geliş tarihlerini bulma
                    let yData=TOOL.youngPlayer;
                    if(yData){ //{"title":'Jugendspieler',"beforeName":"diesen ","afterName":" mal"}
                        GetMessagesByTitle(yData.title,(messages)=>{
                            let YoungPlayers = GetCookie('YoungPlayers',{MessageBox:{},show:[]}),
                                MessageBox = YoungPlayers.MessageBox,
                                message,html,start,end,playerName,date,newPlayer=0;
                            if(!MessageBox || typeof MessageBox != 'object')
                                MessageBox = YoungPlayers.MessageBox = {};

                            for(let i = 0 ; i < messages.length ; i++){
                                message = messages[i];//element : $('#newscenter-preview-'+id)
                                html = message.html().trim();
                                start = html.indexOf(yData.beforeName)+yData.beforeName.length;
                                end = html.indexOf(yData.afterName,start);
                                playerName = html.substring(start,end);
                                date = message.parents('tr').first().find('.last-column').text().trim();
                                message.html(html.substring(0,start)+'<font style="cursor:default;" title="'+yData.title+'" color="#89f4ff">'+playerName+'</font>'+html.substring(end));
                                playerName=playerName.trim();
                                if(!MessageBox[playerName]){
                                    MessageBox[playerName] = date;
                                    newPlayer++;
                                }
                            }
                            if(newPlayer)
                                SetCookie('YoungPlayers',YoungPlayers);
                        });
                    }

                    //Futbolcuya verilen teklif geçilirse kolay bir şekilde bu futbolcuyu transfer pazarında görüntüleyebileceğiz.
                    let iData = TOOL.increaseBid;
                    if(iData){// {"title":"Transfermarkt","control":"überboten","beforeName":"für ","afterName":" wurde"}
                        GetMessagesByTitle(iData.title,(messages)=>{
                            let text,message,messageP=[];
                            for(let i=0; i<messages.length; i++){
                                message = messages[i]; // $ element
                                text = message.text().trim();
                                if(text.indexOf(iData.control)!=-1)
                                    messageP.push(message.parent());
                            }
                            for(let i = 0 ; i < messageP.length ; i++){
                                messageP[i].click(function(){
                                    let messageId = this.id.split('-')[2],
                                        intName = 'OpenMessage_'+messageId,
                                        k,max=50;
                                    Intervals.create(()=>{
                                        k = $('#readmessage-home');
                                        if(k.length){
                                            let a = $('<div>'+k.html()+'</div>');
                                            a.find('a').remove();
                                            let playerName = a.text().trim(),
                                                start = playerName.indexOf(iData.beforeName)+iData.beforeName.length,
                                                end = playerName.indexOf(iData.afterName,start);
                                            playerName = playerName.substring(start,end).trim();
                                            k.html(k.html().replace(playerName,'<font style="cursor:default;" color="#89f4ff">'+playerName+'</font>'));
                                            k.find('a:last').click(function(){
                                                SetCookie('increaseBid',{playerName:playerName,process:1});
                                            });
                                            clearInterval(Intervals.named[intName]);
                                            delete Intervals.named[intName];
                                        }
                                        else{
                                            if(!--max){
                                                clearInterval(Intervals.named[intName]);
                                                delete Intervals.named[intName];
                                            }
                                        }
                                    },50,intName);
                                });
                            }
                        });
                    }

                    //Sattığımız oyuncudan ne kadar kazanç sağladığımızı gösterebilmek için
                    let sData = TOOL.sellPlayer;
                    if(sData){ //{"title":"Assistent: Transfermarkt","control":"ausgehandelt","beforeName":"Spieler ","afterName":" hat"}
                        let PlayersData = GetCookie('PlayersData');
                        if(PlayersData){
                            GetMessagesByTitle(sData.title,(messages)=>{
                                let html,message;
                                for(let i=0; i<messages.length ; i++){
                                    message = messages[i]; // $ element
                                    html = message.html().trim();
                                    if(html.indexOf(sData.control)!=-1){
                                        let start = html.indexOf(sData.beforeName)+sData.beforeName.length,
                                            end = html.indexOf(sData.afterName,start),
                                            playerName = html.substring(start,end).trim(),
                                            a = message.find('a'),
                                            club = {
                                                id   : a.attr('clubid'),
                                                name : a.text().trim()
                                            },
                                            SellPlayers;
                                        message.html(html.substring(0,start)+'<font style="cursor:default;" color="#89f4ff">'+playerName+'</font>'+html.substring(end));

                                        if(!PlayersData.SellPlayers){
                                            PlayersData.SellPlayers = {};
                                        }
                                        SellPlayers = PlayersData.SellPlayers;
                                        if(!SellPlayers[playerName]){
                                            let AcceptedOffers = PlayersData.AcceptedOffers,
                                                foundPlayers = [];
                                            for(let playerId in AcceptedOffers){
                                                let playerData = AcceptedOffers[playerId],
                                                    playerName_ = playerData.playerName;
                                                if(playerName_.split(',').reverse().join(' ').trim() == playerName){
                                                    let offers = playerData.offers;
                                                    for(let clubId in offers){
                                                        if(clubId == club.id){
                                                            playerData.playerId = playerId;
                                                            playerData.clubId = clubId;
                                                            foundPlayers.push(playerData);
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                            if(!foundPlayers.length){//Hiç seçenek bulunamadı!
                                            }
                                            else if(foundPlayers.length==1){
                                                let playerData = foundPlayers[0];
                                                let offer = playerData.offers[playerData.clubId]
                                                SellPlayers[playerName] = {
                                                    playerName : playerData.playerName,
                                                    playerId   : playerData.playerId,
                                                    clubId     : clubId,
                                                    clubName   : offer.clubName,
                                                    price      : offer.price,
                                                    date       : message.parents('tr').find('td.last-column').text().trim()
                                                };
                                                delete AcceptedOffers[playerData.playerId];
                                                let BuyPlayers = PlayersData.BuyPlayers,
                                                    purchase=!1;
                                                if(BuyPlayers && BuyPlayers.length){
                                                    for(let i = 0 ; i < BuyPlayers.length ; i++){
                                                        if(BuyPlayers[i].playerId == playerData.playerId){
                                                            purchase=BuyPlayers[i].price;
                                                            SellPlayers[playerName].purchase = purchase;
                                                            break;
                                                        }
                                                    }
                                                }
                                                SetCookie('PlayersData',PlayersData);
                                                ShowLabels(message,offer.price,purchase);
                                            }
                                            else{//Çok seçenek bulundu
                                            }
                                        }
                                        else{
                                            ShowLabels(message,SellPlayers[playerName].price,SellPlayers[playerName].purchase);
                                        }
                                    }
                                }
                                function ShowLabels(e,sale,purchase=!1){
                                    let text = '<p style="text-align:center;font-weight:bold;margin-top:10px;">';
                                    if(purchase)
                                        text+='<label style="color: #a11717;font-family:\'comic sans\';font-size: 15px;">'+GetLocaleText('PurchasePrice')+': '+parseInt(purchase).toLocaleString()+'<span class="icon currency"></span></label>';
                                    if(sale)
                                        text+='<label style="color: blue;font-family:\'comic sans\';font-size: 15px;margin:0 15px;">'+GetLocaleText('SalePrice')+': '+parseInt(sale).toLocaleString()+'<span class="icon currency"></span></label>';
                                    if(purchase){
                                        let profit = parseInt(sale)-parseInt(purchase);
                                        text+='<label style="color:'+(profit>0?'green':profit<0?'#9d2527;font-weight:bold':'white')+';font-family:\'comic sans\';font-size: 15px;">'+GetLocaleText('Profit')+': '+profit.toLocaleString()+'<span class="icon currency"></span></label>';
                                    }
                                    text+='</p>';
                                    $(e).append(text);
                                }
                            });
                        }
                    }

                    function GetMessagesByTitle(title,func){
                        let id,messages=[],message,_title;
                        $('#deleteForm > table > tbody').find('.odd,.even').each(function(){
                            id = $(this).attr('id').split('-')[1];
                            message = $('#newscenter-preview-'+id);
                            _title = message.find('h2').first().text().replace(/\s\s+/g, ' ').trim();
                            if(_title == title)
                                messages.push(message);
                        });
                        if(messages.length)
                            func(messages);
                    }

                    //Dizilişteki oyuncu sayısını çekip ana sayfada gösteriyor.
                    if(Features.IsActive('NumberOfFootballerChecker','#clubinfocard > ul > li:nth-child('+($('#clubinfocard > ul > li').length+1)+')')){
                        $('#clubinfocard > div.club-avatar').append("<li><span class='label'>"+GetLocaleText('Team')+":</span> <label id='auf_count_number'></label></li>");
                        $('.likebox').css('marginBottom','-8px');
                        GetPage("?w="+worldId+"&area=user&module=formation&action=index",'formation-count',function(html){
                            let count_number = $(html).text();
                            if(count_number == "11")
                                $('#auf_count_number').html('<span style="position:relative;left:-160px;">'+'11/11');
                            else
                                $('#auf_count_number').html('<span style="position:relative;left:-160px;color: red;text-shadow:0.5px 0.5px white;"> '+count_number+'/11</span>');
                        });
                    }


                    //Gelecek maçlardaki rakiplerin analizi
                    (()=>{
                        let box = $('#matches > ul.matches.next'),
                            next_matches;
                        if(box.find('.no-entry').length ||
                           !(next_matches = box.find('>li')).length
                          ) return;
                        if(Features.IsActive('MatchAnalyst','#matches > ul.matches.next')){
                            let matches=[],
                                match,li;
                            next_matches.each(function(i){
                                match={};
                                li = $(this).find('>ul>li');
                                match.type = $(li[0]).find('.icon.match')[0].className.replace('icon','').replace('match','').trim();
                                match.time = $(li[1]).find('>p').text().match(/([0-9]{2}:[0-9]{2}:[0-9]{2})/)[0];
                                if(match.type == 'tournament' && parseInt(match.time.split(':')[0])>17)
                                    match.isSpecialTournament = !0;
                                match.date = $(li[1]).find('>p').text().replace(match.time,'').trim();
                                match.home = {
                                    tricot : {
                                        shorts  : $(li[2]).find('img[src$="shorts.png"]').attr('color') ,
                                        tricot  : $(li[2]).find('img[src$="tricot.png"]').attr('color') ,
                                        design  : $(li[2]).find('img[src$="design.png"]').attr('color') ,
                                        model   : $(li[2]).find('img[src$="details.png"]').attr('model')
                                    },
                                    logo : $(li[3]).find('.squad-home > .club-logo-container > img'),
                                    id   : $(li[3]).find('.squad-home > a').attr('clubid'),
                                    name : $(li[3]).find('.squad-home > a').text().trim()
                                };
                                if(match.home.logo.length){
                                    let e = match.home.logo.attr('src'),
                                        x = e.lastIndexOf('/');
                                    match.home.logo = e.substring(e.lastIndexOf('/',x-1)+1,x);
                                }
                                else match.home.logo=0;
                                match.away = {
                                    tricot : {
                                        shorts  : $(li[4]).find('img[src$="shorts.png"]').attr('color') ,
                                        tricot  : $(li[4]).find('img[src$="tricot.png"]').attr('color') ,
                                        design  : $(li[4]).find('img[src$="design.png"]').attr('color') ,
                                        model : $(li[4]).find('img[src$="details.png"]').attr('model')
                                    },
                                    logo : $(li[3]).find('.squad-away > .club-logo-container > img'),
                                    id   : $(li[3]).find('.squad-away > a').attr('clubid'),
                                    name : $(li[3]).find('.squad-away > a').text().trim()
                                };
                                if(match.away.logo.length){
                                    let e = match.away.logo.attr('src'),
                                        x = e.lastIndexOf('/');
                                    match.away.logo = e.substring(e.lastIndexOf('/',x-1)+1,x);
                                }
                                else match.away.logo=0;
                                matches.push(match);
                            });

                            box.html('');
                            box[0].style="display:none;margin: 0px;height: 214px;background: url('https://i.ibb.co/pxPRgSL/background-image.png');color: white;padding: 5px;position: relative;";

                            //Create Next Matches Tables
                            let p_match,n_match,matchId,compare;
                            for(let i=0;i<matches.length ;i++){
                                compare = {
                                    'elo_rating':!1, //elo sayfası(takım ismi)
                                    'squad_strength':!1, //Kadro sayfası(takım id) yada takım gücü sayfası(lig)
                                    'squad_strength_details':!1, //takım gücü sayfası(lig)
                                    'league':!1, //Kadro sayfası(takım id)
                                    'league_rank':!1, //Kadro sayfası(takım id)
                                    'strongest_player':!1, //Kadro sayfası(takım id)
                                    'trophy':[], //Kadro sayfası(takım id)
                                    'stadium_capacity':!1, //Kadro sayfası(takım id)
                                    'stadium_infrastructure':!1, //Kadro sayfası(takım id)
                                    'league_prev_matches_skor':!1 //lig fikstürü(lig)
                                };
                                match = matches[i];
                                p_match = i-1>-1?matches[i-1]:0;
                                n_match = i+1<matches.length?matches[i+1]:0;
                                matchId=match.home.id+'_'+match.away.id+'_'+i;

                                compare.elo_rating=!0;
                                compare.squad_strength=!0;
                                compare.strongest_player=!0;
                                switch(match.type){
                                    case "tournament":
                                        //Turnuva sayfasına gidip, katıldığımız turnuvaları çek
                                        if(match.isSpecialTournament){// 20:00:00
                                            //compare.trophy.push();
                                        }
                                        else{// 14:00:00
                                        }
                                        break;
                                    case "friendly":// 16:00:00
                                        compare.stadium_capacity=!0;
                                        compare.trophy.push(70);
                                        compare.stadium_infrastructure=!0;
                                        break;
                                    case "league":// 18:00:00
                                        compare.squad_strength_details=!0;
                                        compare.league_prev_matches_skor=!0;
                                        break;
                                }
                                box.append(
                                    '<div class="matches" id="'+matchId+'" '+(p_match?'prev_match="'+(p_match.home.id+'_'+p_match.away.id+'_'+(i-1))+'"':'')+' '+(n_match?'next_match="'+(n_match.home.id+'_'+n_match.away.id+'_'+(i+1))+'"':'')+' style="height:100%;position:relative;'+(i>0?"display:none;":"")+'">'+
                                    '<p style="font-size: 15px;color:white;text-align:center;font-weight:bold;">'+match.date+', '+match.time+'</p>'+

                                    '<div style="height:70%;width:90%;margin:5px auto 0 auto;position:relative;z-index:1;">'+

                                    '<div style="height:100%;width: 48%;float:left;">'+
                                    '<div style="position:relative;margin-bottom: 22px;">'+

                                    '<div class="tricot-container" style="display: inline-block;margin:0 5px -14px 0;">'+
                                    '<img src="/tricots/'+match.home.tricot.model+'/'+match.home.tricot.shorts+'/shorts.png" alt="" model="'+match.home.tricot.model+'" color="'+match.home.tricot.shorts+'" class="background shorts png">'+
                                    '<img src="/tricots/'+match.home.tricot.model+'/'+match.home.tricot.tricot+'/tricot.png" alt="" model="'+match.home.tricot.model+'" color="'+match.home.tricot.tricot+'" class="background tricot png">'+
                                    '<img src="/tricots/'+match.home.tricot.model+'/'+match.home.tricot.design+'/design.png" alt="" model="'+match.home.tricot.model+'" color="'+match.home.tricot.design+'" class="background design png">'+
                                    '<img src="designs/redesign/images/tricots/'+match.home.tricot.model+'/details.png" alt="" model="'+match.home.tricot.model+'" class="png">'+
                                    '</div>'+
                                    '<a href="#/index.php?w='+worldId+'&area=user&module=profile&action=show&clubId='+match.home.id+'" clubid="'+match.home.id+'"'+(match.home.id==TOOL.clubId?' class="self-link"':'')+' style="font-size: 13px;font-weight: bold;text-decoration: none;">'+match.home.name+'</a>'+
                                    (match.home.logo?'<img src="/avatars/'+worldId+'/squad/'+match.home.logo+'/'+match.home.id+'" style="position:absolute;top: 7px;right:5px;">':'')+

                                    '</div>'+
                                    '<div id="comparison_'+matchId+'_home">'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;">'+GetLocaleText('EloRank')+' :</strong> <span class="ELO">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;">'+GetLocaleText('SquadStrength')+' :</strong> <span class="Squad_Strength">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;">'+GetLocaleText('Leauge')+' :</strong> <span class="League">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;">'+GetLocaleText('Rank')+' :</strong> <span class="Rank">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;"><strong style="float:left;">'+GetLocaleText('StrongestPlayer')+' :</strong> <span class="Strong_Player">...</span></p>'+
                                    '</div>'+
                                    '</div>'+


                                    '<div style="height:100%;width: 49%;float:right;text-align:right;border-left:1px solid white;padding-left: 7px;">'+
                                    '<div style="position:relative;margin-bottom: 22px;">'+


                                    (match.away.logo?'<img src="/avatars/'+worldId+'/squad/'+match.away.logo+'/'+match.away.id+'" style="position:absolute;top: 7px;left:5px;">':'')+
                                    '<a href="#/index.php?w='+worldId+'&area=user&module=profile&action=show&clubId='+match.away.id+'" clubid="'+match.away.id+'"'+(match.away.id==TOOL.clubId?' class="self-link"':'')+' style="font-size: 13px;font-weight: bold;text-decoration: none;">'+match.away.name+'</a>'+
                                    '<div class="tricot-container" style="display: inline-block;margin:0 0 -14px 5px;">'+
                                    '<img src="/tricots/'+match.away.tricot.model+'/'+match.away.tricot.shorts+'/shorts.png" alt="" model="'+match.away.tricot.model+'" color="'+match.away.tricot.shorts+'" class="background shorts png">'+
                                    '<img src="/tricots/'+match.away.tricot.model+'/'+match.away.tricot.tricot+'/tricot.png" alt="" model="'+match.away.tricot.model+'" color="'+match.away.tricot.tricot+'" class="background tricot png">'+
                                    '<img src="/tricots/'+match.away.tricot.model+'/'+match.away.tricot.design+'/design.png" alt="" model="'+match.away.tricot.model+'" color="'+match.away.tricot.design+'" class="background design png">'+
                                    '<img src="designs/redesign/images/tricots/'+match.away.tricot.model+'/details.png" alt="" model="'+match.away.tricot.model+'" class="png">'+
                                    '</div>'+

                                    '</div>'+
                                    '<div id="comparison_'+matchId+'_away">'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;"> '+GetLocaleText('EloRank')+' :</strong> <span class="ELO"></span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;"> '+GetLocaleText('SquadStrength')+' :</strong> <span class="Squad_Strength">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;"> '+GetLocaleText('Leauge')+' :</strong> <span class="League">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;border-bottom:1px solid white;padding:1px 0;"><strong style="float:left;"> '+GetLocaleText('Rank')+' :</strong> <span class="Rank">...</span></p>'+
                                    '<p style="text-align:right;font-size: 12px;margin-bottom:1px;"><strong style="float:left;"> '+GetLocaleText('StrongestPlayer')+' :</strong> <span class="Strong_Player">...</span></p>'+
                                    '</div>'+
                                    '</div>'+


                                    '</div>'+

                                    '<span class="fixture '+match.type+'" style="width:128px;position:absolute;bottom: 0;left: 0;"></span>'+
                                    '</div>'
                                );
                                getElo('#'+matchId+'>div>div:nth-child(1) span.ELO',match.home.name)
                                getElo('#'+matchId+'>div>div:nth-child(2) span.ELO',match.away.name)
                                getClubPage('#'+matchId+'>div>div:nth-child(1)',[
                                    'Squad_Strength',
                                    'League',
                                    'Rank',
                                    'Strong_Player'
                                ],match.home.id);
                                getClubPage('#'+matchId+'>div>div:nth-child(2)',[
                                    'Squad_Strength',
                                    'League',
                                    'Rank',
                                    'Strong_Player'
                                ],match.away.id);
                            }

                            //Create Animation
                            if(matches.length>1){
                                box.append(
                                    '<img matches_length="'+matches.length+'" id="prev_match" src="https://i.ibb.co/p468SYn/Untitled.png" style="display:none;height: 18px;position:absolute;left:2px;top:50%;cursor:pointer;transform:translate(0,-50%)">'+
                                    '<img matches_length="'+matches.length+'" id="next_match" src="https://i.ibb.co/p468SYn/Untitled.png" style="height: 18px;position:absolute;right:2px;top:50%;cursor:pointer;transform:translate(0,-50%)-moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1);">'
                                );
                                $('#prev_match,#next_match').click(function(){
                                    $('#prev_match,#next_match').css("pointer-events", "none");
                                    let k = this.id=='next_match'?1:0,
                                        close_e = $('#matches > ul.matches.next').find('>div.matches:visible'),
                                        open_e = $('#'+close_e.attr(k?'next_match':'prev_match'));
                                    close_e.hide("slide", { direction: k?'left':'right' }, 200);
                                    setTimeout(()=>{
                                        open_e.show("slide", { direction: k?'right':'left' }, 300);
                                        $('#prev_match,#next_match').css("pointer-events", "auto");
                                    },250);
                                    $('#prev_match')[open_e.attr('prev_match')?'show':'hide']();
                                    $('#next_match')[open_e.attr('next_match')?'show':'hide']();
                                });
                            }

                            //Functions
                            function getElo(c,clubName){
                                $(c).html('<img src="/designs/redesign/images/icons/loading/16x16.gif" id="LoadingTable" style="margin-left:10px;vertical-align:middle;">');
                                $.get('index.php?club=' + clubName + '&_qf__form=&module=rating&action=index&area=user&league=&path=index.php&layout=none',function(response) {
                                    var html = document.createElement('html');
                                    html.innerHTML = response.content;
                                    var result = $(html).find('.odd');
                                    if(result.length){
                                        result = result[0];
                                        var sıra = result.getElementsByTagName('td')[0].textContent;
                                        $(c).text(sıra);
                                    }
                                    else $(c).text('-');
                                }).fail(function() {
                                    $(c).text('-');
                                });
                            }
                            function getClubPage(a,b,clubId){
                                for(let i=0;i<b.lengtg;i++)
                                    $(a+' .'+b[i]).html('<img src="/designs/redesign/images/icons/loading/16x16.gif" id="LoadingTable" style="margin-left:10px;vertical-align:middle;">');
                                GetPage('?w='+worldId+'&area=user&module=profile&action=show&clubId='+clubId,'profile-show',function(html){
                                    let contents = $(html).find('ul.profile-box-squad > li:nth-child(1)').contents();
                                    if(!contents.length) //Kein Verein gefunden.
                                        return;
                                    $(a+' .'+b[0]).html($(html).find('ul.profile-box-squad > li:nth-child(1)').contents()[1].textContent);
                                    let leaguetable = html.querySelector('#leaguetable');
                                    if(leaguetable
                                       && !$('.no-entry',leaguetable).length){
                                        $(a+' .'+b[1]).html($('>h2',leaguetable).text().trim());
                                        $(a+' .'+b[2]).html($('> div.container > div > table',leaguetable).find('a[clubid="'+clubId+'"]').parents('tr:first').find('td:first').text().trim());
                                    }
                                    else{
                                    }
                                    let o = $('.profile-box-squad .open-card',html),
                                        span = $(a+' .'+b[3]);
                                    if(!o.length){
                                        span.html(GetLocaleText('NotFound'));
                                        return;
                                    }
                                    let name = o.next().find('.ellipsis');
                                    if(name.length) name = name[0].title;
                                    else{
                                        name = o.next().text();
                                        name = name.substring(0,name.indexOf('('));
                                    }
                                    span.html('<span pid="player-'+o.attr('pid').split('-')[1]+'" class="icon details open-card" style="float:none;"></span> ' + name);
                                });

                            }
                        }
                    })();
                }
                else if(Page.on({module:'team',action:'squad'})){
                    //Özellik: Antrenman kontrolü
                    if(Features.IsActive("TrainingControl"))
                        TrainingControl();


                    //Özellik: Kulüp değişimi
                    if(Features.IsActive("ClubExchange")){
                        /*
                            Kulüp değiştiren futbolcuları bulup bunu anlatan bir görsel ekleyip, görselin üzerine gelindiğinde hangi kulübe ne zaman gideceğinin bilgisini veren.
                            Ve üzerine tıklandığında da kulübün sayfasını yeni sayfada açan bir özelliktir.
                        */
                        let ClubExchange = {
                            initial_data : GetCookie('ClubExchange',{}),
                            new : {},// Exp : {3252352:0,234131:1} , 0=>error , 1=>success
                            selector : [],
                            finish : 0,
                            initial : function(){
                                let initial_data = ClubExchange.initial_data;
                                $('#players-table-overview > tbody > tr').add($('#players-table-overview-club > tbody > tr')).each(function(){
                                    let openCard;
                                    if(!(openCard = $(this).find('.open-card')).length) return true;
                                    let playerId = openCard.attr('pid').split('-')[1],
                                        table = $(this).parents('table')[0].id.replace('players-table-',''),// overview or overview-club
                                        index = $(this).index(),
                                        td_contract = $('td:nth-child(11)',this);
                                    if(td_contract.text().indexOf(TOOL.ClubExchange)!=-1){//td_contract da Kulüp Değişimi yazıyor olmali...
                                        //Bu futbolcu kulüp değiştiriyor!!!
                                        let playerData = initial_data[playerId];
                                        if(!playerData) //Oyuncunun gidiş bilgileri mevcut değilse
                                            ClubExchange.getPage(playerId,table,index);
                                        else //Oyuncunun gidiş bilgileri mevcutsa
                                            ClubExchange.addImage(playerData,table,index);
                                    }
                                });
                            },
                            getPage : function(playerId,table,index){
                                ClubExchange.new[playerId]=0;//Varsayılan değer olarak sayfa çekmeyi başarısız sayıyoruz.
                                $.get('index.php?w='+worldId+'&area=user&module=player&action=index&complex=0&id=' + playerId,function(response){
                                    ClubExchange.new[playerId]=1;//default olarak başarısız olarak varsayılan değeri başarılı değere çeviriyoruz.
                                    let li = $('<div>'+response+'</div>').find('.data.attributes > ul > li:last'),
                                        a = li.find('a'),
                                        club = {
                                            id   : a.attr('clubid'),
                                            name : a.text().trim()
                                        };
                                    li.find('a,strong').remove();
                                    let li_text = li.text().trim(),
                                        date = li_text.match(/(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})/g);
                                    if(date){
                                        date=date[0];
                                        let playerData =  {date:date,club:club},
                                            data = GetCookie('ClubExchange',{});
                                        data[playerId] = playerData;
                                        SetCookie('ClubExchange',data);
                                        ClubExchange.addImage(playerData,table,index)
                                    }
                                }).always(function() {
                                    let _new = ClubExchange.new;
                                    if(ClubExchange.finish++==Object.keys(_new).length){//Tüm üstekler başarılı yada başarısız bir şekilde bitti!
                                        //Eğer daha önceden kayıtlı edilmiş bir futbolcu varsa(kulübü terkeden) şimdi o oyuncu bulunmazsa kulübü terk etmiştir. Onu kayıtlardan çıkarmamız lazım.
                                        let initial_data = ClubExchange.initial_data,
                                            current_data = GetCookie('ClubExchange',{}),
                                            counter = 0;
                                        for(let playerId in initial_data){
                                            if(_new[playerId]==undefined){//Oyuncu çoktan kulübü terk etmiş..
                                                counter++;
                                                delete current_data[playerId];
                                            }
                                        }
                                        if(counter)
                                            SetCookie('ClubExchange',current_data);
                                    }
                                });
                            },
                            addImage : function(playerData,table,index){
                                let d = playerData.date.split('.'),
                                    sec = parseInt((new Date(d[2],parseInt(d[1])-1,d[0],3).getTime()-GetServerTime())/1000),
                                    tds = [
                                        $('#players-table-'+table+' > tbody > tr:nth-child('+(index+1)+') > td:nth-child(11)'),
                                        $('#players-table-'+(table=='overview'?'agreements':'agreements-club')+' > tbody > tr:nth-child('+(index+1)+') > td:nth-child(8)')
                                    ];
                                //this.selector.push('#players-table-'+table+' > tbody > tr:nth-child('+(index+1)+') > td:nth-child(11)','#players-table-'+(table=='overview'?'agreements':'agreements-club')+' > tbody > tr:nth-child('+(index+1)+') > td:nth-child(8)');
                                $(tds).each(function(){
                                    $(this).html(
                                        '<a href="#/index.php?w='+worldId+'&area=user&module=profile&action=show&clubId='+playerData.club.id+'" target="_blank">'+
                                        '<img title="'+GetLocaleText('ClubExchange',[playerData.date,playerData.club.name],!1)+'" src="'+TOOL.sources.get('exchange','png')+'" alt="exchange" height="15px" style="background-color: #00fff7;border-radius: 50%;cursor:pointer;margin-right: 4px;">'+
                                        '</a>'+
                                        '<font title="'+GetLocaleText('RemainingTime',null,!1)+' : '+($('<div>'+ShowCountDownTime(sec)+'</div>').text())+'">' + playerData.date+'</font>'
                                    );
                                });
                            }
                        };
                        ClubExchange.initial();
                    }


                    if($('#players-table-changes > tbody').find('.open-card').length &&
                       true // Feature is active?
                      ){
                        /*let ClubExchangeActive = (Features.all.ClubExchange || {status : 0}).status == 1,
                            control = ClubExchangeActive ? (td)=>{
                            return td.find('img[alt="exchange"]').length;
                        } : (td)=>{
                            return td.text().indexOf(TOOL.ClubExchange)!=-1
                        };*/

                        let players = $('#players-table-changes > tbody > tr');
                        $('#players-table-changes').prev('h3').append('<span style="float:right;">'+players.length+' '+GetLocaleText(players.length!=1?'Players':'Player')+'</span>');

                        /*let p = {
                            goingPlayers : {
                                before_TM_date : 0,
                                after_TM_date  : 0
                            },
                            youngPlayers : 0
                        },
                            TM_date = players.first().find('td.last-column').text().match(/(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})/g);
                        if(TM_date){
                            //TM_date = TM_date[0].split('.'); // ["11", "02", "2019"]
                            //TM_date = new Date(TM_date[2],parseInt(TM_date[1])-1,TM_date[0]);
                            $('#players-table-overview > tbody > tr').add($('#players-table-overview-club > tbody > tr')).each(function(){
                                let table = $(this).parents('table')[0].id.replace('players-table-',''),// overview or overview-club
                                    index = $(this).index(),
                                    td_contract = $('td:nth-child(11)',this);
                                if(IsYoungPlayer($(this).find('td:nth-child(12)')))
                                    p.youngPlayers++;
                                else if(control(td_contract)){
                                    console.log("Exchange : %o",td_contract[0]);
                                }
                            });
                        }*/
                    }


                    let buttons = [];
                    if($('#players-table-overview > tbody > tr').find('.open-card').length &&
                       Features.IsActive("RankingOfPlayers","#RankingOfPlayersButton")
                      ){ //Eğer kadroda oyuncu varsa
                        //Özellik: Oyuncuların sıralaması
                        //Tab tuşuna basıldığında bir sonraki oyuncunun forma numarasını ayarlamak için gerekli kodlar aşağıda yazılmıştır.
                        let players = $('#players-table-overview > tbody > tr');
                        players.each(function(i){
                            $(this).find('td:nth-child(6) > span > input[type="text"]').attr('tabindex',i+1);
                        });
                        $('#squad-handle-container').append('<input type="button" value="'+GetLocaleText('SortPlayers',null,!1)+'" id="RankingOfPlayersButton" title="Oyuncu sıralaması şu şekilde yapılır;\u000dEn iyi kaleciye 1,\u000dDiğer oyunculara güce göre,\u000dGençlere 90\'dan başlanarak ilk gelen gençten son gelen gence göre\u000dnumara verilir." style="-webkit-border-radius: 7px !important; padding: 2px 5px; border: 1px solid #999;font-size: 9px;margin:16px 90px 0 40px;">');
                        $('#RankingOfPlayersButton').click(function(){
                            let klText = TOOL.footballerPositions.Position1,
                                kl=[],genc=[],diger=[];
                            $('#players-table-overview > tbody > tr').each(function(i){
                                let mevki = $(this).find('td:nth-child(3)')[0].textContent.trim(),
                                    güc = parseInt($(this).find('td:nth-child(4)')[0].textContent),
                                    yas = parseInt($(this).find('td:nth-child(5)')[0].textContent);
                                if(IsYoungPlayer($(this).find('td:nth-child(12)'))){
                                    let tarih = $(this).find('td:nth-child(11)')[0].textContent.split('.');
                                    tarih = new Date(tarih[2],parseInt(tarih[1])-1,tarih[0]).getTime();
                                    genc.push({'i':i,tarih:tarih});
                                }
                                else if(mevki===klText){
                                    kl.push({'i':i,güc:güc,yas:yas});
                                }
                                else{
                                    diger.push({'i':i,güc:güc,yas:yas});
                                }
                            });
                            let maxKl = {güc:0,i:null},
                                spliceIndex = null;
                            for(let i = 0 ; i < kl.length; i++){
                                if(kl[i].güc>maxKl.güc){
                                    maxKl.güc = kl[i].güc;
                                    maxKl.i = kl[i].i;
                                    spliceIndex = i;
                                }
                            }
                            let no = 1;
                            if(maxKl.i!=null){
                                //Kaleci varsa, en güçlü kaleciyi 1.sıraya al!
                                $('#players-table-overview > tbody > tr:nth-child('+(maxKl.i+1)+') > td:nth-child(6) > span > input[type="text"]').val(no);
                                $('#players-table-overview > tbody > tr:nth-child('+(maxKl.i+1)+') > td:nth-child(6) > span > input[type="text"]').attr('tabindex',no++);

                                //En güçlü kaleciyi çıkart ve geri kalanını diger adlı diziye aktar
                                kl.splice(spliceIndex,1);
                                for(let i = 0 ; i < kl.length ; i++){
                                    diger.push({'i':kl[i].i,'güc':kl[i].güc,'yas':kl[i].yas});
                                }
                            }

                            //En güçlüden en güçsüze göre sırala
                            diger.sort(function(a,b){
                                if(b.güc-a.güc!==0) return b.güc-a.güc;
                                else return a.yas-b.yas;
                            });

                            //Genç hariç geri kalanını sırala
                            for(let i = 0 ; i < diger.length ; i++){
                                $('#players-table-overview > tbody > tr:nth-child('+(diger[i].i+1)+') > td:nth-child(6) > span > input[type="text"]').val(no);
                                $('#players-table-overview > tbody > tr:nth-child('+(diger[i].i+1)+') > td:nth-child(6) > span > input[type="text"]').attr('tabindex',no++);
                            }

                            //Genç oyuncuları geliş tarihlerine göre sırala. Geliş tarihi en küçük olan ilk olmalı!
                            genc.sort(function(a,b){
                                return a.tarih-b.tarih;
                            });

                            //Genç oyuncuları 90 dan başlayarak sırala
                            for(let i = 0 ; i < genc.length ; i++){
                                $('#players-table-overview > tbody > tr:nth-child('+(genc[i].i+1)+') > td:nth-child(6) > span > input[type="text"]').val(90+i);
                                $('#players-table-overview > tbody > tr:nth-child('+(genc[i].i+1)+') > td:nth-child(6) > span > input[type="text"]').attr('tabindex',90+i);
                            }
                            $('#players-table-overview > tfoot > tr > td:nth-child(2) > span > a > span').click();
                        });
                        buttons.push($('#RankingOfPlayersButton'));
                    }
                    if(buttons.length){
                        $('#squad-handle-container > li').click(function(){
                            let fonk = $(this).index()?'slideUp':'slideDown';
                            $.each(buttons,function(){
                                $(this)[fonk]('slow');
                            })
                        });
                    }

                    //Özellik: Güç değişimini göster
                    if($('#players-table-changes > tbody').find('.open-card').length &&
                       Features.IsActive("ShowStrengthChange")
                      ){//At least one player has been transferred.
                        let control = 0,
                            data = GetCookie('PlayersData',{});
                        if(!data.BuyPlayers) data.BuyPlayers = [];
                        let BuyPlayers = data.BuyPlayers;
                        if(BuyPlayers.length){
                            $('#players-table-changes > tbody > tr').each(function(){
                                let playerId = $(this).find('.open-card').attr('pid').split('-')[1];
                                for(let i = 0 ; i < BuyPlayers.length ; i++){
                                    if(BuyPlayers[i].playerId == playerId){
                                        let currentStrength = parseInt($(this).find('td:nth-child(4)').text()),
                                            oldStrength = BuyPlayers[i].strength,
                                            difference = currentStrength-oldStrength;
                                        if(difference){
                                            control++;
                                            $(this).find('td:nth-child(4)').append('<span style="color:#42ff35;margin-left:2px;" class="changed-property new-player">(+'+difference+')</span>');
                                        }
                                        let td = $(this).find('.last-column');
                                        if(td.length){
                                            td.css('position','relative');
                                            td.append('<img title="'+GetLocaleText('InfoStrengthChange',null,!1)+'" src="'+TOOL.sources.get('data','png')+'" alt="data" height="15px" style="position:absolute;top:9px;right:10px;">');
                                        }
                                    }
                                }
                            });
                        }

                        if(!control) delete Features.all["ShowStrengthChange"];
                        else Features.all["ShowStrengthChange"].hover_selector = '#players-table-changes > tbody span.changed-property.new-player';
                    }

                    //Özellik: Oyuncuların gerçek gücünü göster
                    if(Features.IsActive(
                        "ShowRealStrength",
                        "#players-table-overview > tbody td:nth-child(4)[realstrength],"+
                        "#players-table-overvie-club > tbody td:nth-child(4)[realstrength],"+
                        "#players-table-agreements > tbody td:nth-child(4)[realstrength],"+
                        "#players-table-agreement-club > tbody td:nth-child(4)[realstrength],"+
                        "#players-table-skills > tbody td:nth-child(4)[realstrength],"+
                        "#players-table-skill-club > tbody td:nth-child(4)[realstrength]"
                    )){
                        let positionName = TOOL.footballerPositions,
                            tables =
                            [
                                ["#players-table-overview","#players-table-agreements","#players-table-skills"],
                                ["#players-table-overview-club","#players-table-agreements-club","#players-table-skills-club"]
                            ],
                            counter = 0;
                        for(let i = 0 ; i < tables.length ; i++){
                            let first_table = $(tables[i][0]);
                            if(!first_table.find('.open-card').length) continue;
                            $('>tbody>tr',first_table).each(function(rowIndex){
                                let row = $(this),
                                    position = row.find('> td:nth-child(3)').text().trim();
                                let skills = [];
                                $(tables[i][2]).find('> tbody > tr:nth-child('+(rowIndex+1)+')').find('.skill-column').each(function(){
                                    skills.push(parseFloat($(this).text()));
                                });
                                let strengthColumn = row.find('> td:nth-child(4)'),
                                    currentStrength = parseInt(strengthColumn.attr('sortvalue')),
                                    realStrength = GetRealStrength(skills,position);

                                if(isNaN(realStrength)) return true;
                                realStrength = realStrength.toFixed(2);

                                let difference = (realStrength - currentStrength).toFixed(2),
                                    color = difference>0?"green":difference<0?"#a62c2c":"#d9d9d9";

                                for(let j = 0 ; j < 3 ; j++){
                                    strengthColumn = $(tables[i][j]).find('>tbody > tr:nth-child('+(rowIndex+1)+') > td:nth-child(4)');
                                    strengthColumn.html(strengthColumn.html().replace(currentStrength,realStrength)).css('color',color).attr('title',(difference>0?'+':'')+difference).attr('realstrength',realStrength);
                                }
                                ++counter;
                            });
                        }
                        if(!counter) delete Features.all.ShowRealStrength;
                    }

                    if(TOOL.ageDates){
                        if(Features.IsActive("CalculateNonYoungPlayersStrength","#CalculateFutureStrength")){
                            let tables =
                                [
                                    ['#players-table-overview','#players-table-skills'],
                                    ['#players-table-overview-club','#players-table-skills-club']
                                ],
                                add =
                                '<h3>'+GetLocaleText('CalculateNonYoungPlayersStrength')+'</h3>'+
                                '<div id="CalculateFutureStrength" style="text-align:center;margin:5px auto;border-radius:15px;background-color:#4a6b3247;">'+
                                   '<div style="border-radius:15px 15px 0 0;background-color:#4a6b32;padding:15px 15px 5px 15px;margin-bottom:20px;">',
                                select =
                                '<select id="selectPlayers" style="margin:0 0 0 20px;text-align-last: center; border-radius: 10px; padding: 3px 2px; background-color: black; color: green;" onfocus="this.style.backgroundColor=\'green\';this.style.color=\'black\';" onfocusout="this.style.backgroundColor=\'black\';this.style.color=\'green\';">'+
                                   '<option value="0">'+GetLocaleText('ChoosePlayer')+'</option>';
                            for(let i = 0 ; i < tables.length ; i++){
                                let first_table = $(tables[i][0]);
                                if(!first_table.find('.open-card').length) continue;
                                first_table.find('> tbody > tr').each(function(rowIndex){
                                    let row = $(this);
                                    if(IsYoungPlayer(row.find('td:nth-child(12)'))) return true;
                                    let position = row.find('td:nth-child(3)').text().trim(),
                                        playerId = row.find('.open-card').attr('pid').split('-')[1],
                                        playerName = row.find('.player-name').text(),
                                        skills = [];
                                    $(tables[i][1]+' > tbody > tr:nth-child('+(rowIndex+1)+') .skill-column').each(function(){
                                        skills.push(parseFloat($(this).text()));
                                    });
                                    select+='<option value="'+playerId+'" position="'+position+'" age="'+row.find('td:nth-child(5)').text()+'" skill="'+skills.join(',')+'">['+position+'] '+playerName+'</option>';
                                });
                            }
                            select += '</select>';
                            add+= GetLocaleText('ChoosePlayer')+': ' + select;
                            add+='</div></div>';
                            $('#squad > div.squad.personal').append('<hr>'+add);
                            tables = add = select = undefined;

                            let ageDates = TOOL.ageDates,
                                age_length = ageDates.length,
                                serverTime = GetServerTime(),
                                nextAgesDates = [];
                            for(let i = 0 ; i < age_length ; i++){
                                if(ageDates[i]*60000>serverTime){
                                    nextAgesDates.push(ageDates[i]);
                                };
                            }
                            $('#selectPlayers').attr('nextAgesDates',nextAgesDates.join(','));
                            ageDates = age_length = serverTime = nextAgesDates = undefined;

                            $('#selectPlayers').change(function(){
                                $('#Comparison,#chooseRange,#ChoosedPlayer').add($('#ChangeSkillLimit').parents('p').first()).remove();
                                if(this.value!=0){
                                    let nextAgesDates = $(this).attr('nextAgesDates').split(','),
                                        selectedOption = $('option:selected',this),
                                        age = parseInt(selectedOption.attr('age')),
                                        position = selectedOption.attr('position'),
                                        skills = selectedOption.attr('skill').split(','),
                                        text =
                                        '<span pid="player-'+this.value+'" class="icon details open-card" style="float:none;margin-top: -3px;" id="ChoosedPlayer"></span>'+
                                        '<p style="margin-top:5px;">'+
                                           GetLocaleText('SkillPassLimitPoint') + ' : '+
                                           '<input id="ChangeSkillLimit" type="number" style="border-radius:7px;border:1px solid gray;width:75px;text-align:center;padding:0 2px;" value="990" step="10" max="990" min="0" onkeypress="return event.charCode >= 48 &amp;&amp; event.charCode <= 57">'+
                                        '</p>'+
                                        '<p id="chooseRange" style="margin:10px 0;"> '+GetLocaleText('ChooseAge')+' :'+
                                           '<input type="range" id="ageRange" class="slider" min="'+age+'" max="'+Math.min(age+nextAgesDates.length,(position==TOOL.footballerPositions.Position1?43:41))+'" value="'+age+'" style="vertical-align: middle;margin:0 5px;border-radius:8px;width:300px;">'+
                                           '<label id="lblageRange">'+age+'</label>'+
                                        '</p>';
                                    selectedOption = undefined;

                                    for(let i in skills) skills[i] = parseFloat(skills[i]);

                                    $(this).after(text);
                                    text = undefined;

                                    $('#ChangeSkillLimit').keyup(function(){
                                        let val = $(this).val();
                                        if(isNaN(val)) val = 0;
                                        val = parseInt(val);
                                        if(val<$(this).attr('min')) val = $(this).attr('min');
                                        else if(val>$(this).attr('max')) val = $(this).attr('max');
                                        if($(this).val() != val) $(this).val(val);
                                    }).mouseenter(function(){
                                        $(this).focus();
                                        $(this).select();
                                    }).change(function(){
                                        $('#ageRange').trigger('oninput');
                                    });

                                    document.getElementById('ageRange').oninput = function() {
                                        $('#Comparison').remove();
                                        $('#lblageRange').text(this.value);

                                        if(parseInt(this.value)>age){
                                            let now = GetServerTime(),
                                                targetDate = nextAgesDates[parseInt(this.value)-age-1]*60000,
                                                remainingTrainings = FindNumberOfTraining(now,targetDate),// [x,y] x=> not premium, with premium
                                                trainingScore = parseInt(TOOL.trainerLevel)*0.25+0.5,
                                                result1 = CalculateFutureStrength(
                                                    skills,
                                                    remainingTrainings[0],
                                                    trainingScore,
                                                    position,parseInt($('#ChangeSkillLimit').val())
                                                ),
                                                result2 = CalculateFutureStrength(
                                                    skills,
                                                    remainingTrainings[0]+remainingTrainings[1],
                                                    trainingScore,
                                                    position,
                                                    parseInt($('#ChangeSkillLimit').val())
                                                );//{currentStrength:currentStrength,nextStrength:nextStrength,nextSkills:nextSkills}
                                            trainingScore = undefined;

                                            let tables =
                                                [
                                                    {
                                                        title    : GetLocaleText('Now')+' ('+GetDateText(now)+')',
                                                        skills   : skills,
                                                        age      : age,
                                                        strength : result1.currentStrength
                                                    },
                                                    {
                                                        title            : GetLocaleText('NonCreditTraining')+' ('+GetDateText(targetDate)+')',
                                                        skills           : result1.nextSkills,
                                                        age              : parseInt(this.value),
                                                        strength         : result1.nextStrength,
                                                        numberOfTraining : remainingTrainings[0]
                                                    },
                                                    {
                                                        title            : GetLocaleText('CreditTraining')+' ('+GetDateText(targetDate)+')',
                                                        skills           : result2.nextSkills,
                                                        age              : parseInt(this.value),
                                                        strength         : result2.nextStrength,
                                                        numberOfTraining : remainingTrainings[0]+remainingTrainings[1]
                                                    }
                                                ],
                                                skillsId = ['penalty_area_safety', 'catch_safety', 'two_footed', 'fitness', 'shot', 'header', 'duell', 'cover', 'speed', 'pass', 'endurance', 'running', 'ball_control', 'aggressive'],
                                                code = '<div class="infosheet" id="Comparison" style="text-align:center;margin-bottom:10px;">';
                                            now = remainingTrainings = targetDate = undefined;

                                            for(let tablesIndex = 0 ; tablesIndex < 3 ; tablesIndex++){
                                                code +=
                                                    '<div class="data skills" style="height:100%;padding:5px;background-color: #58793d;border-radius:5px;position:static;'+(tablesIndex!=2?"margin-right:25px;":"")+'">'+
                                                       '<h2 style="font-size: 12px;margin-bottom:5px;border:none;line-height:25px;height:25px;background: #4a6b32;width:auto;font-weight:bold;">'+
                                                          tables[tablesIndex].title+
                                                       '</h2>'+
                                                       '<ul style="margin:3px 0;">'+
                                                          '<li class="odd">'+
                                                             '<span style="float:left;">Ø</span>'+
                                                             '<span style="color:white;font-weight:bold;">'+
                                                                (typeof tables[tablesIndex].strength == 'number'?(tables[tablesIndex].strength).toFixed(2):tables[tablesIndex].strength)+
                                                             '</span>'+
                                                          '</li>'+
                                                          '<li class="odd">'+
                                                             '<span style="float:left;">'+
                                                                GetLocaleText('Age')+
                                                             '</span>'+
                                                             '<span style="color:white;font-weight:bold;">'+
                                                                tables[tablesIndex].age+
                                                             '</span>'+
                                                          '</li>'+
                                                       '</ul>'+
                                                    '<ul style="margin:0;">';

                                                for(let j = 0 ; j < 14 ; j++){
                                                    var span='<span',
                                                        prevValOfSkill = tables[0].skills[j],
                                                        valueOfSkill = prevValOfSkill,
                                                        changedValue = '';
                                                    if(tablesIndex!=0 && tables[tablesIndex].skills[j]){
                                                        valueOfSkill = tables[tablesIndex].skills[j];
                                                        if(valueOfSkill!=prevValOfSkill){
                                                            span+= ' style="color:#ff0808"';
                                                            changedValue=
                                                                '<span class="changed-property" style="color:#3db3d5e6">'+
                                                                   '(+'+(valueOfSkill-prevValOfSkill).toFixed(2)+')'+
                                                                '</span>';
                                                        }
                                                    }
                                                    if(valueOfSkill>=990) span+=' class="maximum"';
                                                    span+='>'+valueOfSkill+changedValue+'</span>';

                                                    let skillId = skillsId[j];
                                                    code +=
                                                        '<li class="odd">'+
                                                           '<strong>'+
                                                              '<span class="icon '+skillId+'" tooltip="tt_'+skillId+'"></span>'+
                                                           '</strong>'+
                                                           span+
                                                        '</li>';
                                                }
                                                code += '</ul>';

                                                if(tablesIndex>0){
                                                    code +=
                                                        '<ul style="margin:4px auto 2px auto">'+
                                                           '<li class="odd" style="float:none;margin:auto;margin-bottom:1px;">'+
                                                              '<span style="float:left;">'+
                                                                 GetLocaleText('Training')+
                                                              '</span>'+
                                                              '<span style="color:white;font-weight:bold;">'+
                                                                 tables[tablesIndex].numberOfTraining+
                                                              '</span>'+
                                                           '</li>'+
                                                        '</ul>';
                                                }
                                                code +='</div>';
                                            }
                                            code += '</div>';
                                            $('#chooseRange').parent().parent().append(code);
                                        }
                                    };
                                }
                            });
                        }

                        if(Features.IsActive("CalculatingStrengthOfYoungPlayer")){
                            let tables =
                                [
                                    ["#players-table-overview","#players-table-agreements","#players-table-skills"],
                                    ["#players-table-overview-club","#players-table-agreements-club","#players-table-skills-club"]
                                ],
                                trainingScore = parseInt(TOOL.yTrainerLevel)+0.5,
                                featureElements = [];
                            for(let i = 0 ; i < tables.length ; i++){
                                let first_table = $(tables[i][0]);
                                if(!first_table.find('.open-card').length) continue;
                                $('>tbody>tr',first_table).each(function(rowIndex){
                                    let row = $(this);
                                    if(!IsYoungPlayer(row.find('td:nth-child(12)'))) return true;
                                    let startDate = GetServerTime(),
                                        position = row.find('td:nth-child(3)').text().trim(),
                                        currentAge = parseInt(row.find('td:nth-child(5)').text()),
                                        skills = [];
                                    $(tables[i][2]+' > tbody > tr:nth-child('+(rowIndex+1)+')').find('.skill-column').each(function(){
                                        skills.push(parseFloat($(this).text()));
                                    });
                                    let finishDate = row.find('td:nth-child(11)').text().trim().match(/(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})/g);
                                    if(!finishDate.length) return true;
                                    finishDate = finishDate[0].split('.');
                                    finishDate = new Date(finishDate[2],parseInt(finishDate[1])-1,parseInt(finishDate[0])+1).getTime();
                                    let trainings = FindNumberOfTraining(startDate,finishDate),
                                        result1 = CalculateFutureStrength(skills,trainings[0],trainingScore,position),
                                        result2 = CalculateFutureStrength(skills,trainings[0]+trainings[1],trainingScore,position);
                                    //{currentStrength:currentStrength,nextStrength:nextStrength,nextSkills:nextSkills}
                                    let nextAge = currentAge,
                                        dates = [],
                                        remainingDay = '-',
                                        start = !1,
                                        ageDates = TOOL.ageDates;
                                    for(let p = 0 ; p < ageDates.length ; p++){
                                        let date = ageDates[p]*60000;
                                        if(start){
                                            if(date <= finishDate){
                                                dates.push({
                                                    s : 'color:white;',
                                                    v : GetDateText(date)
                                                });
                                                nextAge++;
                                            }
                                            else{
                                                dates.push({
                                                    s : 'color:aqua;border-top:1px solid white;padding-top:1px;margin-top:1px;display:block;',
                                                    v : GetDateText(date)
                                                });
                                                remainingDay = ((date-finishDate)/86400000).toFixed(1);
                                                break;
                                            }
                                            continue;
                                        }
                                        if(startDate<date){
                                            start = !0;
                                            p--;
                                        }
                                    }

                                    let title =
                                        GetLocaleText('EndYouth',[
                                            ((finishDate-startDate)/86400000).toFixed(1),
                                            TwoDigit(new Date(finishDate).getDate())+'.'+
                                            TwoDigit(new Date(finishDate).getMonth()+1)+'.'+
                                            new Date(finishDate).getFullYear()
                                        ],!1)+';\n'+
                                        GetLocaleText('Age',null,!1)+' : '+nextAge+'\nØ : '+
                                        result1.nextStrength+' - ' + result2.nextStrength+'\n'+
                                        GetLocaleText('RemainingNumberOfNormalTraining',null,!1)+' : ' + trainings[0]+'\n'+
                                        GetLocaleText('RemainingNumberOfCreditTraining',null,!1)+' : ' + trainings[1]+'\n'+
                                        GetLocaleText('RemainingNextAgeDay',[remainingDay],!1);

                                    let selector = "";
                                    for(let tablesIndex = 0 ; tablesIndex < 2 ; tablesIndex++){
                                        MouseEnterLeaveEvent(
                                            $(selector = tables[i][tablesIndex]+' > tbody > tr:nth-child('+(rowIndex+1)+') > td:nth-child(4)'), // Strength column
                                            $(tables[i][tablesIndex]+' > tbody > tr:nth-child('+(rowIndex+1)+') > td:nth-child(5)'), // Age column
                                            result1.nextStrength,
                                            nextAge,
                                            result2.nextStrength,
                                            result1.currentStrength,
                                            currentAge,
                                            row.find('.open-card').attr('pid').split('-')[1],
                                            row.find('> td.name-column > span.player-name').text().trim(),
                                            dates
                                        );
                                        featureElements.push(selector);
                                        featureElements.push(tables[i][tablesIndex]+' > tbody > tr:nth-child('+(rowIndex+1)+') > td:nth-child(5)');
                                        $(selector = tables[i][tablesIndex]+' > tbody > tr:nth-child('+(rowIndex+1)+') > td:nth-child('+[11,8][tablesIndex]+')').attr('title',title);
                                        featureElements.push(selector);
                                    }

                                    //$('#players-table-agreements > tbody > tr:nth-child('+(i+1)+') > td:nth-child(8)')[0].title = title;
                                    if(i==0){
                                        let u = this.getElementsByClassName('open-card')[0],
                                            index;
                                        if((index = Object.values(TOOL.footballerPositions).findIndex(x=>x==position)) == -1) return true;
                                        let TrainingSkills = TOOL.TrainingPlan[index]; // [9,6,3,7,8,10,5]
                                        for(let tablesIndex = 0 ; tablesIndex < tables[i].length ; tablesIndex++)
                                            ClickOpenCard(
                                                $(tables[i][tablesIndex]+' > tbody > tr:nth-child('+(rowIndex+1)+') .open-card'),
                                                TrainingSkills
                                            );
                                    }
                                });
                            }
                            if(featureElements.length)
                                Features.all.CalculatingStrengthOfYoungPlayer.hover_selector = featureElements.join(',');
                            else
                                delete Features.all.CalculatingStrengthOfYoungPlayer;
                            trainingScore = tables = featureElements= undefined;

                            function MouseEnterLeaveEvent(strengthColumn,ageColumn,newStrength,nextAge,premiumNewStrength,currentStrength,currentAge,playerId,playerName,dates){
                                let strengthColHtml=strengthColumn.html(),
                                    ageColHtml=ageColumn.html();

                                if(!toolTipObj.data['youngPlayerStrengthInfo_'+playerId]){
                                    let tr =
                                        [
                                            [GetLocaleText('Strength',null,!1),strengthColumn.attr('sortvalue')],
                                            [GetLocaleText('RealStrength',null,!1),currentStrength],
                                            [GetLocaleText('NonCreditTraining',null,!1),newStrength + ' (' + (newStrength-currentStrength>0?'+':'') + (newStrength-currentStrength).toFixed(2)+')'],
                                            [GetLocaleText('CreditTraining',null,!1),premiumNewStrength + ' (' + (premiumNewStrength-currentStrength>0?'+':'') + (premiumNewStrength-currentStrength).toFixed(2)+')']
                                        ],
                                        html =
                                        '<h3 style="text-align:center;margin-bottom:2px;">'+
                                           '<label style="border-bottom:1px solid white;padding:0 2px;">'+
                                              playerName+
                                            '</label>'+
                                        '</h3>'+
                                        '<table>'+
                                           '<tbody>';
                                    playerName = currentStrength = undefined;
                                    for(let i = 0 ; i < tr.length ; i++){
                                        html +=
                                            '<tr style="line-height:20px;height:20px;">'+
                                               '<td style="border-bottom:none;text-align:left;">'+
                                                  tr[i][0]+
                                                  '<span style="float:right;margin:0 2px;">:</span>'+
                                               '</td>'+
                                               '<td style="border-bottom:none;text-align:left;">'+
                                                  tr[i][1]+
                                               '</td>'+
                                            '</tr>';
                                    }
                                    html += '</tbody></html>';
                                    toolTipObj.data['youngPlayerStrengthInfo_'+playerId] = html;

                                    html =
                                        '<h3 style="text-align:center;margin-bottom:2px;">'+
                                           '<label style="border-bottom:1px solid white;padding:0 2px;">'+
                                              'Age : '+currentAge+" => "+nextAge+" ("+(nextAge-currentAge>0?'+':'') + (nextAge-currentAge) + ')'+
                                           '</label>'+
                                        '</h3>';
                                    let temp = currentAge;
                                    for(let i = 0 ; i < dates.length ; i++,temp++)
                                        html+='<label style="'+dates[i].s+'">'+temp+'=>'+(temp+1)+' | ' + dates[i].v + (i+1<dates.length?'</label><br>':'');
                                    dates = currentAge = undefined;
                                    toolTipObj.data['youngPlayerAgeInfo_'+playerId] = html;
                                }
                                strengthColumn.attr('tooltip','youngPlayerStrengthInfo_'+playerId);
                                ageColumn.attr('tooltip','youngPlayerAgeInfo_'+playerId);
                                strengthColumn.attr('title','');
                                playerId = undefined;

                                strengthColumn.add(ageColumn).mouseenter(function(){
                                    strengthColumn.html('<label style="color:#00e7ff;">'+newStrength+' / '+premiumNewStrength+'</label>');
                                    ageColumn.html('<label style="color:#00e7ff;">'+nextAge+'</label>');
                                });

                                strengthColumn.add(ageColumn).mouseleave(function(){
                                    $(toolTipObj.toolTipLayer).hide();
                                    strengthColumn.html(strengthColHtml);
                                    ageColumn.html(ageColHtml);
                                });
                            }
                            function ClickOpenCard(openCard,TrainingSkills){
                                if(!openCard.length) return;
                                openCard.click(function(){
                                    let openCard = $(this);
                                    openCard.off();
                                    let rowIndex = openCard.parents('tr').index()+1;
                                    $('#players-table-overview > tbody > tr:nth-child('+rowIndex+') .open-card').off();
                                    $('#players-table-agreements > tbody > tr:nth-child('+rowIndex+') .open-card').off();
                                    $('#players-table-skills > tbody > tr:nth-child('+rowIndex+') .open-card').off();
                                    rowIndex = undefined;

                                    let playerId = openCard.attr('pid').split('-')[1];
                                    if($('#info-player-'+playerId).length) return;

                                    let max = 300;
                                    AllIntervals['OpenCard_'+playerId] = setInterval(function(){
                                        if(!openCard.hasClass('loading')){
                                            clearInterval(AllIntervals['OpenCard_'+playerId]);
                                            AllIntervals['OpenCard_'+playerId] = undefined;

                                            let infoDiv = $('#info-player-'+playerId),
                                                lis = infoDiv.find('div.data.skills > ul:first > li'),
                                                romanNumerals  = ["I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV"];
                                            for(let p = 0 ; p < 3 ; p++){
                                                lis[TrainingSkills[p]].style.backgroundColor = '#00585d';
                                                $(lis[TrainingSkills[p]]).append(
                                                    '<label style="float:left;">'+
                                                       romanNumerals[p]+
                                                    '</label>'
                                                );
                                            }

                                            infoDiv.find('.skill:not(.maximum)').each(function(){
                                                let skillValue = parseFloat(this.textContent);
                                                $(this).mouseenter(function(){
                                                    let result = MaxValueOfSkill(skillValue,parseInt(TOOL.yTrainerLevel)+0.5);
                                                    if(result.numberOfTrainings>0){
                                                        $(this).css({
                                                            'color':'#5eff0c',
                                                            'font-weight':'bold'
                                                        }).attr(
                                                            'title',
                                                            GetLocaleText('AfterTrainings',[result.numberOfTrainings],!1)
                                                        ).text(result.maxvalue);
                                                    }
                                                }).mouseleave(function(){
                                                    $(this).css({
                                                        'color':'',
                                                        'font-weight':''
                                                    }).removeAttr('title').text(skillValue);
                                                });
                                            });
                                            return false;
                                        }
                                        if(--max<1){
                                            clearInterval(AllIntervals['OpenCard_'+playerId]);
                                            AllIntervals['OpenCard_'+playerId] = undefined;
                                        }
                                    },50);
                                });
                                openCard = undefined;
                            }
                        }
                    }

                    if($('#players-table-overview-club > tbody').find('.open-card').length){
                        let YoungPlayers = GetCookie('YoungPlayers',{MessageBox:{},show:[]}),
                            MessageBox = YoungPlayers.MessageBox,
                            show = YoungPlayers.show,
                            update = 0;
                        if(!MessageBox || typeof MessageBox != 'object')
                            MessageBox = YoungPlayers.MessageBox = {};
                        if(!Array.isArray(show))
                            show = YoungPlayers.show = [];

                        $('#players-table-overview-club > tbody > tr').each(function(){
                            if(IsYoungPlayer($('td:nth-child(12)',this))){
                                let playerId = $('.open-card',this).attr('pid').split('-')[1],
                                    playerName = $('.player-name',this).text().trim(),
                                    playerName_ = playerName.split(','),
                                    found = !1;
                                playerName_ = playerName_[1].trim()+', '+playerName_[0];
                                for(let i = 0 ; i < show.length ; i++){
                                    if(playerId == show[i].id){
                                        found = !0;
                                        if(show[i].date_ && MessageBox[playerName_]){
                                            show[i].date = MessageBox[playerName_];
                                            delete MessageBox[playerName_];
                                            delete show[i].date_;
                                            ++update;
                                        }
                                        break;
                                    }
                                }
                                if(!found){
                                    let data = {
                                        id       : playerId,
                                        name     : playerName,
                                        position : $('td:nth-child(3)',this).text().trim(),
                                        strength : parseInt($('td:nth-child(4)',this).attr('sortvalue')),
                                        age      : parseInt($('td:nth-child(5)',this).text()),
                                    };
                                    if(MessageBox[playerName_]){
                                        data.date = MessageBox[playerName_];
                                        delete MessageBox[playerName_];
                                    }
                                    else{
                                        let now = new Date(GetServerTime());
                                        data.date_ = TwoDigit(now.getDate())+'.'+TwoDigit(now.getMonth()+1)+'.'+now.getFullYear();
                                    }
                                    show.splice(0,0,data);
                                    ++update;
                                }
                            }
                        });
                        if(update) SetCookie('YoungPlayers',YoungPlayers);
                    }
                    let players = GetCookie('YoungPlayers',{MessageBox:{},show:[]}).show;
                    if(players.length && Features.IsActive("YoungPlayersHistory","#genc-oyuncular-tablo")){
                        players.sort(function(a,b){
                            a = (a.date || a.date_).split('.');
                            b = (b.date || b.date_).split('.');
                            return new Date(b[2],b[1]-1,b[0]).getTime() - new Date(a[2],a[1]-1,a[0]).getTime();
                        });
                        let max = 10,
                            sayfaSayısı = Math.ceil(players.length/max),
                            acıkSayfa = 1;
                        $('#squad > div.squad.personal').append(
                            '<hr>'+
                            '<div class="table-container" id="container-genc">'+
                               '<h3>'+GetLocaleText('TitleOfYoungPlayersTable')+'</h3>'+
                               '<table id="genc-oyuncular-tablo" class="sortable-table sortable">'+
                                  '<thead>'+
                                     '<tr>'+
                                        '<th class="name-column sortcol">'+
                                            GetLocaleText('Name')+
                                        '</th>'+
                                        '<th class="position-column sortcol">'+
                                            GetLocaleText('Position')+
                                         '</th>'+
                                        '<th class="strength-column sortcol" tooltip="tt_strength">'+
                                           'Ø'+
                                        '</th>'+
                                        '<th class="age-column sortcol">'+
                                           GetLocaleText('Age')+
                                        '</th>'+
                                        '<th class="sortcol">'+
                                           GetLocaleText('Date')+
                                        '</th>'+
                                     '</tr>'+
                                  '</thead>'+
                                  '<tbody id="tbody-genc-oyuncular">'+
                                     CreateTable(players)+
                                  '</tbody>'+
                              '</table>'+
                           '</div>'
                        );
                        if(sayfaSayısı>1) CreateMenu(false,players.length);
                        players = undefined;

                        function CreateTable(players){
                            let trs ='',
                                player;
                            for(let i = 0 , k = (acıkSayfa-1)*max ; i < max && i+k < players.length ; i++){
                                player = players[i+k];
                                trs+=
                                    '<tr class="'+(!(i%2)?"odd":"even")+'">'+
                                       '<td class="name-column">'+
                                          '<span pid="player-'+player.id+'" class="icon details open-card"></span>'+
                                          '<span class="player-name">'+
                                             player.name+
                                          '</span>'+
                                       '</td>'+
                                       '<td>'+
                                          player.position+
                                       '</td>'+
                                       '<td sortvalue="'+player.strength+'">'+
                                          player.strength+
                                       '</td>'+
                                       '<td>'+
                                          player.age+
                                       '</td>'+
                                       '<td'+(player.date_?' title="It may not be true."':'')+'>'+
                                          (player.date || player.date_)+
                                       '</td>'+
                                    '</tr>';
                            }
                            return trs;
                        }
                        function CreatePageLabel(sayfa){
                            return '<label class="page" style="color:white;cursor:pointer;text-decoration:underline;">'+sayfa+'</label> | ';
                        }
                        function CreateMenu(c,playersLength){
                            let text = '<div class="pager">';
                            if(acıkSayfa>=15){
                                for(let i = 1 ; i <=3 ; i++)
                                    text+=CreatePageLabel(i);
                                text+='... | ';
                                for(let i = acıkSayfa-10 ; i < acıkSayfa ; i++)
                                    text+=CreatePageLabel(i);
                            }
                            else
                                for(let i = 1 ; i < acıkSayfa ; i++)
                                    text+=CreatePageLabel(i);
                            text+='<strong>'+acıkSayfa+'</strong>'+(acıkSayfa!=sayfaSayısı?' | ':'');
                            if(acıkSayfa<=sayfaSayısı-14){
                                for(let i = acıkSayfa+1 ; i<=acıkSayfa+10; i++)
                                    text+=CreatePageLabel(i);
                                text+='... | ';
                                for(let i = sayfaSayısı-2 ; i < sayfaSayısı ; i++)
                                    text+=CreatePageLabel(i);
                            }
                            else
                                for(let i = acıkSayfa+1 ; i < sayfaSayısı ; i++)
                                    text+=CreatePageLabel(i);
                            if(acıkSayfa!==sayfaSayısı)
                                text+='<label class="page" style="color:white;cursor:pointer;text-decoration: underline;">'+sayfaSayısı+'</label>';
                            text+=' '+GetLocaleText('total')+' : '+playersLength+'</div>';
                            let e = $('#genc-oyuncular-tablo');
                            if(c){
                                e.prev().remove();
                                e.next().remove();
                            }
                            e.before(text);
                            e.after(text);
                            $('#container-genc').find('.page').click(function(){
                                acıkSayfa = parseInt($(this).text());
                                let players = GetCookie('YoungPlayers',{MessageBox:{},show:[]}).show;
                                $('#tbody-genc-oyuncular').html(CreateTable(players));
                                CreateMenu(true,players.length);
                            });
                        }
                    }
                }
                else if(Page.on({module:'formation',action:'index'})){
                    if(($('#squad').find('span.field-player').length>1 ||
                        $('#bank').find('span.field-player').length>1
                       ) && true //Ve özellik aktif ise
                      ){
                        playerObject = plObj;//Update


                        if($('#squad').find('span.field-player').length>1){//Kadro dışında kalan oyuncu varsa
                            CreateSortingPlayers('squad');
                            $('#squad').css('height','auto');
                        }
                        if($('#bank').find('span.field-player').length>1){//Kadro dışında kalan oyuncu varsa
                            CreateSortingPlayers('bank',27);
                        }
                        function CreateSortingPlayers(divId,addHeight=0){
                            $('#'+divId).css('min-height',parseInt($('#'+divId).css('height'))+addHeight);
                            $('#'+divId+' > h3').after(
                                '<p class="sorting_players">'+
                                   '<label><input type="radio" name="sorting_preference_'+divId+'" value="Position">'+GetLocaleText('Position')+'</label>'+
                                   '<label><input type="radio" name="sorting_preference_'+divId+'" value="Strength">'+GetLocaleText('Strength')+'</label>'+
                                '</p>'+
                                '<p class="filterByPositions"></p>'
                            );
                            let positions = [],
                                POSITIONS = Object.values(TOOL.footballerPositions),
                                pos;
                            $('#'+divId).find('span.field-player').each(function(){
                                pos = $(' > div > div.position',this).text();
                                if(positions.findIndex(x=>x==pos)==-1) positions.push(pos);
                            });
                            positions.sort((a,b)=>{
                                return POSITIONS.findIndex(x=>x==a)-POSITIONS.findIndex(x=>x==b);
                            });
                            let filterByPositions = $('#'+divId+' > p.filterByPositions');
                            for(let i=0;i<positions.length;i++){
                                pos = positions[i];
                                let index = POSITIONS.findIndex(x=>x==pos);
                                filterByPositions.append('<span class="filter_position disHighlight" style="background-color:'+['green','#72ed72','#72ed72','#3f8a83','yellow','yellow','yellow','red'][index]+';color:'+['white','black','black','white','black','black','black','white'][index]+';">'+pos+'</span>');
                            }
                            filterByPositions.find('.filter_position').click(function(){
                                $(this).css("pointer-events", "none");
                                let that = $(this),
                                    isActive = !$(this).hasClass('not_active'),
                                    pos = $(this).text();
                                that.parents('div.ui-droppable').find('span.field-player').each(function(){
                                    if($('> div > div.position',this).text()==pos) $(this)[isActive?'slideUp':'slideDown'](200);
                                });
                                that[isActive?'addClass':'removeClass']('not_active');
                                setTimeout(function(){
                                    that.css("pointer-events", "auto");
                                },200);
                            });
                        }
                        $('.sorting_players input').click(function(){
                            let sorting = this.value,
                                div = $(this).parents('div.ui-droppable'),
                                players = div.find('span.field-player'),
                                positions;
                            switch(sorting){
                                case 'Position':
                                    positions = Object.values(TOOL.footballerPositions);
                                    players.sort(function(a,b){
                                        let compare;
                                        if(compare = positions.findIndex(x=>x==$(' > div > div.position',a).text()) - positions.findIndex(x=>x==$(' > div > div.position',b).text())) return compare;
                                        else if(compare = parseInt($(' > div > div.strength',b).text())-parseInt($(' > div > div.strength',a).text())) return compare;
                                        else return plObj[a.id.split('-')[2]].age-plObj[b.id.split('-')[2]].age;
                                    }).appendTo(div);
                                    break;
                                case 'Strength':
                                    positions = Object.values(TOOL.footballerPositions);
                                    players.sort(function(a,b){
                                        let compare;
                                        if(compare = parseInt($(' > div > div.strength',b).text()) - parseInt($(' > div > div.strength',a).text())) return compare;
                                        else if(compare = positions.findIndex(x=>x==$(' > div > div.position',a).text()) - positions.findIndex(x=>x==$(' > div > div.position',b).text())) return compare;
                                        else return plObj[a.id.split('-')[2]].age-plObj[b.id.split('-')[2]].age;
                                    }).appendTo(div);
                                    break;
                            }
                        });
                        let sorting_preferences = undefined || {squad:'Position',bank:'Strength'}
                        $('#squad .sorting_players input[value="'+sorting_preferences.squad+'"]').click();
                        $('#bank .sorting_players input[value="'+sorting_preferences.bank+'"]').click();
                    }

                    if(true){
                        $('#formation-select-captain > span > select > option:not([value="0"])').each(function(){
                            let playerId = this.value;
                            if(!plObj[playerId]) return true;
                            let attr_leadership = parseInt(plObj[playerId].attr_leadership),
                                text = $(this).html(),
                                find = text.indexOf(')');
                            if(find==-1) return true;
                            $(this).html("(" + attr_leadership + ")" + text.substring(find+1));
                        });

                        let selectedPlayer = plObj[$('#formation-select-captain > span > select > option:selected').val()];
                        if(selectedPlayer){
                            let attr_leadership = selectedPlayer.attr_leadership,
                                text = $('#formation-select-captain > span > div.button > span.text').html(),
                                find = text.indexOf(')');
                            $('#formation-select-captain > span > div.button > span.text').html("(" + attr_leadership + ")" + text.substring(find+1));
                        }

                        let li = $(SelectBox.instances[$('#formation-select-captain > span').attr('instance')].expand[0]).find('li') ;
                        li.each(function(){
                            let playerId = this.getAttribute('idvalue');
                            if(!plObj[playerId]) return true;
                            let attr_leadership = parseInt(plObj[playerId].attr_leadership),
                                text = $(this).html(),
                                find = text.indexOf(')');
                            if(find==-1) return true;
                            $(this).html("(" + attr_leadership + ")" + text.substring(find+1));
                            $(this).attr('attr_leadership',attr_leadership);
                        });

                        let options = li,
                            arr = options.map(function(_, o) {
                            return {
                                text       : $(o).text(),
                                idvalue    : $(o).attr('idvalue'),
                                leadership : $(o).attr('attr_leadership')
                            };
                        }).get();

                        arr.sort(function(o1, o2) {
                            return o2.leadership-o1.leadership;
                        });

                        options.each(function(i, option) {
                            $(option).text(arr[i].text);
                            $(option).attr('idvalue',arr[i].idvalue);
                            $(option).attr('attr_leadership',arr[i].leadership);
                        });
                    }
                }
                else if(Page.on({module:'team'}) && !Page.on({action:'camp'})){
                    if(Page.on({action:'index'})){
                        if(GetCookie("TrainingGroups")!=undefined){
                            if(Features.IsNotActive("TrainingGroups")){
                                var data = GetCookie("TrainingGroups");
                                $('#training > div.schedule > div.table-container > table > tbody > tr').each(function(i){
                                    if($('th',this).length){
                                        var grupId = i/4 + 1;
                                        var th = $('th',this)[1];
                                        th.style.textAlign = 'left';
                                        th.style.fontSize = '11px';
                                        toolTipObj.data['showPlayersInGroups']=GetLocaleText('NoInformation')+'!';
                                        if(data[grupId]!==undefined){
                                            var oyuncuSayısı = data[grupId].length;
                                            if(oyuncuSayısı!==0){
                                                th.innerHTML = GetLocaleText('TrainingGroupInformation',['<strong grupId="'+grupId+'" style="color:green;font-size:12px;cursor:default;" tooltip="showPlayersInGroups">'+oyuncuSayısı+'</strong>'],!1);
                                                $('strong',th).mouseenter(function(){
                                                    var d = GetCookie("TrainingGroups")[$(this).attr('grupId')];
                                                    var text = '';
                                                    for(var i = 0 ; i < d.length ; i++){
                                                        text+='['+d[i].position+'] '+d[i].name+'<br>';
                                                    }
                                                    text = text.substring(0,text.length-4);
                                                    toolTipObj.data['showPlayersInGroups'] = text;
                                                });
                                            }
                                            else{
                                                th.innerHTML = GetLocaleText('NoPlayersInTheGroup');
                                            }
                                        }
                                        else{
                                            th.innerHTML = GetLocaleText('NoRecord');
                                        }
                                    }
                                });
                            }
                        }
                    }
                    else if(Page.on({action:'groups'})){
                        if(Features.IsActive("TrainingControl")){
                            TrainingControl();
                        }
                        /*-------------TrainingGroups----------*/
                        var data = {};
                        $('#players-table-skills > tbody > tr').each(function(i){
                            var grupId = $('#'+i).find('select').val();
                            var playerName = $('.player-name',this).text().trim();
                            var position = $('td:nth-child(3)',this).text().trim();
                            var kayıt = {name:playerName,position:position};
                            if(data[grupId]===undefined){
                                data[grupId] = [kayıt];
                            }
                            else{
                                data[grupId].push(kayıt);
                            }
                        });
                        var mk = $('#0 > select')[0].options.length;
                        for(var i = 1 ; i<= mk ; i++){
                            if(data[i]===undefined){
                                data[i]=[];
                            }
                        }
                        SetCookie('TrainingGroups',data);
                        /*--------------------------------------*/
                    }
                    else if(Page.on({action:'settings'})){
                        var elementOfGroups = $('#groupNameForm > table > tbody').find('input');
                        elementOfGroups.attr('maxlength',16);
                        elementOfGroups.mouseenter(function(){
                            $(this).focus();
                            $(this).attr('placeHolder',$(this).val());
                            $(this).val('');
                        });
                        elementOfGroups.mouseleave(function(){
                            if($(this).val()===""){
                                $(this).val($(this).attr('placeHolder'));
                            }
                            $(this).removeAttr('placeHolder');
                            $(this).focusout();
                        });
                    }
                }
                else if(Page.on({module:'team',action:'camp'})){
                    if(Features.IsActive("CampHistory")){
                        let data = GetCookie('CampHistory',[]);
                        $('#camp').append(
                            '<div id="allCamps">'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -641px; float: left; opacity: 0.2;" id="camps_1"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -962px; float: left; opacity: 0.2;" id="camps_2"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -214px; float: left; opacity: 0.2;" id="camps_3"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -534px; float: left; opacity: 0.2;" id="camps_4"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -748px; float: left; opacity: 0.2;" id="camps_5"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -321px; float: left; opacity: 0.2;" id="camps_6"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -0px; float: left; opacity: 0.2;" id="camps_7"></div>'+
                            '<div class="image" style="margin-Right:4px; background-position: 0px -854px; float: left; opacity: 0.2;" id="camps_10"></div>'+
                            '</div>'
                        );
                        if(data.length){/*Show*/
                            var activeCamps = [];
                            //Tablo oluşturuluyor.
                            var text =
                                '<table id="lastCamps">'+
                                '<thead>'+
                                '<tr style="background:url();">'+
                                '<th colspan="7">'+GetLocaleText('PreviouslyVisitedCamps')+'</th>'+
                                '</tr>'+
                                '<tr>'+
                                '<th style="text-align:left;">'+GetLocaleText('No')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('Camp')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('Country')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('Price')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('_Skills')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('Definition')+'</th>'+
                                '<th style="text-align:left;">'+GetLocaleText('Date')+'</th>'+
                                '</tr>'+
                                '</thead>'+
                                '<tbody>';
                            for(let i = 0 ; i < data.length ;i++){
                                let camp = data[i];
                                activeCamps.push(camp.campNo);
                                let imagesPos = [641,962,214,534,748,321,0,428,108,855][camp.campNo-1];
                                text+='<tr>'+
                                    '<td style="color:white;font-weight: bold;text-align:center;">'+(i+1)+'</td>'+
                                    '<td width="160" style="text-align:left;">'+
                                    '<h3 style="margin:0;">'+camp.campName+'</h3>'+
                                    '<div class="image" style="display:none;margin: 1px auto 3px; background-position: 0 -'+imagesPos+'px;"></div></td>'+
                                    '<td width="100" style="text-align:left;">'+
                                    '<img class="flag" name="__tooltip" tooltip="tt_'+camp.country.img+'" src="/static/images/countries/'+camp.country.img+'.gif" alt=""> '+camp.country.name+'</td>'+
                                    '<td width="80" style="text-align:left;">'+camp.price+
                                    '<span class="icon currency"></span></td>'+
                                    '<td style="text-align:left;">';
                                for(let j = 0 ; j < camp.skills.length ; j++){
                                    text+='<span style="margin-Right:3px;" class="icon '+camp.skills[j]+'" name="__tooltip" tooltip="tt_'+camp.skills[j]+'"></span>';
                                }
                                text+='</td>'+
                                    '<td style="white-space: pre-wrap;font-Size:10px;line-height: 1.5;text-align:left;">'+camp.description+'</td>'+
                                    '<td>'+
                                    '<img src="'+TOOL.sources.get('clock','png')+'" alt="clock" style="margin:0 2px 1px 0;cursor:help;text-align:left;" title="'+GetLocaleText('ServerDate',null,!1)+'">'+dateFormat(camp.date)+'</td></tr>';
                            }
                            function dateFormat(a){
                                let b = a.split('.');
                                b = new Date(b[2],parseInt(b[1])-1,parseInt(b[0])+3);
                                return a+' - ' + TwoDigit(b.getDate())+'.'+TwoDigit(b.getMonth()+1)+'.'+b.getFullYear();
                            }
                            text+='</tbody> <tfoot> <tr> </tr> </tfoot> </table>';
                            $('#allCamps').before(text);
                            $('#lastCamps').find('.image').each(function(){
                                let image = $(this);
                                $(this).parent('td').mouseenter(function(){
                                    image.slideDown();
                                });
                                $(this).parent('td').mouseleave(function(){
                                    image.slideUp();
                                });
                            });

                            //Gidilen kampları daha görünür yapıyoruz.
                            for(let i = 0 ; i < activeCamps.length ; i++){
                                $('#camps_'+activeCamps[i]).css('opacity',1);
                            }
                        }
                        if(!$('#camp > div.list-container > ul > li.disabled').length //Kamp ayarlama inaktif olmayacak.
                           && !$('#camp > div.list-container > ul > li > p.not-available').length //Kamplar kullanılmıyor olmayacak.
                          ){/*Save*/
                            //Kamplar açık ve gidilebiliyor!
                            var camps = $('#camp > div.list-container > ul > li');
                            camps.each(function(){
                                let parent = this,
                                    buton = $('div.buttons > span > a',this);
                                buton.attr('href_',buton.attr('href'));
                                buton.removeAttr('href');
                                buton.click(function(){
                                    $(this).off();
                                    let skills = $('ul > li',parent),
                                        _skills = [];
                                    skills.each(function(){
                                        _skills.push($('span',this).first().attr('class').replace('icon ',''));
                                    });
                                    let country = {name:'Berlin',img:'DEU'};
                                    country.name = $('p',parent).first().text().trim();
                                    var img = $('p > img',parent).first().attr('src');
                                    country.img = img.substring(img.lastIndexOf('/')+1,img.lastIndexOf('.'));
                                    //Yeni kampı en öne ekle!
                                    data.splice(0,0,{
                                        campName    : $('h3',parent).first().text(),
                                        campNo      : $(parent).attr('class').replace('camp-',''),
                                        date        : $('span',this).first().text().trim().match(/(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})/g)[0],
                                        skills      : _skills,
                                        price       : $('span.currency-number',parent).text().trim(),
                                        country     : country,
                                        description : $('p.description',parent).text().trim(),
                                    });
                                    SetCookie('CampHistory',data);
                                    location.href = buton.attr('href_');
                                });
                            });
                        }
                    }
                }
                else if(Page.on({module:'transfermarket',action:'scout'})){
                }
                else if(Page.on({module:'transfermarket',action:'index'})){
                    /*Transfermarket Filter*/
                    $('.table-container:first').children().first().after(
                        '<div id="show_transfermarket_filter" style="margin:5px 0;">'+
                        '&#10148; <span style="cursor:pointer;" id="ShowAllPlayers">'+GetLocaleText('ShowAllPlayers')+'</span><br>'+
                        '&#10148; <span style="cursor:pointer;" id=OnlyForeignPlayers>'+GetLocaleText('OnlyForeignPlayers')+'</span><br>'+
                        '</div>'
                    );
                    $('#ShowAllPlayers').click(function(){
                        $('#content > div.container.transfermarket > div.table-container > table > tbody > tr').each(function(i){
                            $(this).show();
                            $(this).attr('class',i%2==0?"odd":"even");
                        });
                        $('#OnlyForeignPlayers').css({
                            'background-color':'',
                            'padding':'',
                            'margin-left':'0px',
                            'border-radius':''
                        });
                    });
                    $('#OnlyForeignPlayers').click(function(){
                        let count = 0;
                        $('#content > div.container.transfermarket > div.table-container > table > tbody > tr').each(function(i){
                            if(!$('td:nth-child(1) > img',this).attr('src').endsWith(TOOL.flag+'.gif')){
                                $(this).show();
                                $(this).attr('class',(count++)%2==0?"odd":"even");
                            }
                            else
                                $(this).hide();
                        });
                        $(this).css({
                            'background-color':'green',
                            'padding':'2px',
                            'margin-left':'-2px',
                            'border-radius':'7px'
                        });
                    });


                    //Kulüp arama kısmındaki tüm metni silmek için.
                    $('#club').after('<img style="float:right;margin:2px 2px 0 0;cursor:pointer;" id="clearText" src="'+TOOL.sources.get('remove','png')+'" alt="remove" width="10px">');
                    $('#clearText').click(function(){
                        clearText('club');
                        function clearText(id){
                            let text = $('#'+id).val(),
                                length = text.length;
                            while(length>0){
                                setTimeout(function(){
                                    let t = $('#'+id).val();
                                    $('#'+id).val(t.substring(0,t.length-1));
                                },(text.length-length)*25);
                                length--;
                            }
                        }
                    });



                    /*Features : TransferDates*/
                    if(Features.IsActive("TransferDates")){
                        let save = false,
                            LeagueData = GetCookie('LeagueData');
                        if(LeagueData != undefined){
                            if((LeagueData.lastMatchDate+86400000)<=GetServerTime()) save = true;
                            else ShowTransfermarktDates(LeagueData);
                        }
                        else save = true;
                        if(save){
                            GetPage('?w='+worldId+'&area=user&module=statistics&action=games','content',function(html){
                                SaveLeagueData($(html),ShowTransfermarktDates);
                            });
                        }
                        function ShowTransfermarktDates(LeagueData){
                            let aDay = 24*60*60*1000,
                                OyuncularınGeldigiSaat = {saat:3,dakika:0,saniye:0},
                                TarihinDegistigiSaat = {saat:0,dakika:0,saniye:0},
                                firstMatchDate = LeagueData.firstMatchDate,
                                firstHalfFinalMatchDate= LeagueData.firstHalfFinalMatchDate,
                                lastMatchDate= LeagueData.lastMatchDate,
                                now = GetServerTime(),
                                OyuncularınGelmeTarihi = null,
                                TransferinDegisecegiTarih = null;
                            OyuncularınGeldigiSaat = (OyuncularınGeldigiSaat.saat*3600+OyuncularınGeldigiSaat.dakika*60+OyuncularınGeldigiSaat.saniye)*1000;
                            TarihinDegistigiSaat = (TarihinDegistigiSaat.saat*3600+TarihinDegistigiSaat.dakika*60+TarihinDegistigiSaat.saniye)*1000;
                            if((firstMatchDate-1*aDay+OyuncularınGeldigiSaat)>now)/*Alınan Oyuncu Bir Sonraki Gün Gelecek*/
                                OyuncularınGelmeTarihi = new Date(new Date(now).getFullYear(),new Date(now).getMonth(),new Date(now).getDate()+1).getTime()+OyuncularınGeldigiSaat;
                            else if((firstHalfFinalMatchDate+OyuncularınGeldigiSaat)>now)/*Alınan Oyuncular Lig Arasında Gelecek*/
                                OyuncularınGelmeTarihi = firstHalfFinalMatchDate+aDay+OyuncularınGeldigiSaat;
                            else/*Alınan Oyuncu Lig Sonunda Gelecek*/
                                OyuncularınGelmeTarihi = lastMatchDate+aDay+OyuncularınGeldigiSaat;

                            if((firstMatchDate-1*aDay+TarihinDegistigiSaat)>now)/*Transfer Tarihinin Değişeceği Tarih*/
                                TransferinDegisecegiTarih = firstMatchDate-1*aDay+TarihinDegistigiSaat;
                            else if((firstHalfFinalMatchDate+TarihinDegistigiSaat)>now)/*Transfer Tarihinin Değişeceği Tarih*/
                                TransferinDegisecegiTarih = firstHalfFinalMatchDate+TarihinDegistigiSaat;
                            var baslik = $('#content > h2:nth-child(1)');
                            var baslikText = baslik.text();
                            var transferTarihi = baslikText.substring(baslikText.lastIndexOf(':')+1,baslikText.lastIndexOf(')')).trim();
                            var text = GetLocaleText('TransferDate')+' : ' + transferTarihi;
                            text+='             '+GetLocaleText('FootballersAreComing')+' : <label style="color:#17fc17;" intervalName="OyuncularGelecek" class="cntDwnTrnsfMrkt" title="'+GetDateText(OyuncularınGelmeTarihi)+'" lastDate="'+OyuncularınGelmeTarihi+'"></label>';
                            if(TransferinDegisecegiTarih){
                                text+='             '+GetLocaleText('TransferDateWillChange')+' : <label style="color:orange;" intervalName="TarihDegisecek" class="cntDwnTrnsfMrkt" title="'+GetDateText(TransferinDegisecegiTarih)+'" lastDate="'+TransferinDegisecegiTarih+'"></label>';
                            }
                            baslik.html(text);
                            $('.cntDwnTrnsfMrkt').each(function(){
                                var t = $(this);
                                var intervalName = t.attr('intervalName');
                                geriSay();
                                AllIntervals[intervalName] = setInterval(function(){
                                    geriSay();
                                },1000);
                                function geriSay(){
                                    var sec = parseInt((parseInt(t.attr('lastDate'))-GetServerTime())/1000);
                                    if(sec<=0){
                                        clearInterval(AllIntervals[intervalName]);
                                        AllIntervals[intervalName] = undefined;
                                        t.html(GetLocaleText('ItIsOver'));
                                        return;
                                    }
                                    var min=0,hour=0,day=0;
                                    if(sec>59){
                                        min = parseInt(sec/60);
                                        sec = sec%60;
                                        if(min>59){
                                            hour = parseInt(min/60);
                                            min = min%60;
                                            if(hour>23){
                                                day = parseInt(hour/24);
                                                hour = hour%24;
                                            }
                                        }
                                    }
                                    var r = '';
                                    if(day!=0){
                                        r = day + ' '+GetLocaleText(day==1?'aDay':'Days')+' ';
                                    }
                                    if(day!=0 || hour!=0){
                                        r += TwoDigit(hour)+':';
                                    }
                                    if(day!=0 || hour!=0 || min!=0){
                                        r += TwoDigit(min)+':';
                                    }
                                    t.html(r+TwoDigit(sec));
                                }
                            });
                        }
                    }



                    /*Features : OfferWasPassed*/
                    if(GetCookie('increaseBid')){//{playerName:'Criyessei',process:1}
                        if(Features.IsActive("GoOffer")){
                            let playerName = GetCookie('increaseBid'),
                                process = playerName.process,
                                find_player = !1;
                            playerName = playerName.playerName;
                            if(process==1){
                                //Teklif tablonuzda oyuncu varsa devam edecek.
                                if($('#own-offers > tbody').find('.open-card').length){
                                    $('#own-offers > tbody > tr').each(function(){
                                        if(playerName == $(this).find('.name-column').first().text().trim()){
                                            find_player = !0;
                                            let clubName = $(this).find('td.name-column').last().attr('sortvalue');
                                            if($('#club').val()==clubName){
                                                find_player = !1;
                                                process_2();
                                            }
                                            else{
                                                $('#age_min').val(16);
                                                $('#age_max').val(34);
                                                $('#searchform > ul > li.strength > span:nth-child(2) > input[type="text"]').val(0);
                                                $('#searchform > ul > li.strength > span:nth-child(3) > input[type="text"]').val(999);
                                                $('#positions').val(0);
                                                $('#club').val(clubName);
                                                SetCookie('increaseBid',{playerName:playerName,process:2});
                                                $('#searchform > ul > li.transfermarket-search-button > span > a > span').click();
                                            }
                                            return false;
                                        }
                                    });
                                }
                            }
                            else{
                                process_2();
                            }
                            function process_2(){
                                if($('#content > div.container.transfermarket > div.table-container > table > tbody').find('.open-card').length){
                                    $('#content > div.container.transfermarket > div.table-container > table > tbody > tr').each(function(){
                                        if(playerName == $(this).find('.name-column').first().text().trim()){
                                            find_player = !0;
                                            let tr = this,
                                                pageHeight = $(window).height();
                                            $('html, body').animate({ scrollTop: getOffset(tr).top-pageHeight/2 }, 'fast');
                                            setTimeout(function(){
                                                tr.style = 'background-color: #fff2ac; background-image: linear-gradient(to right, #ffe359 0%, #fff2ac 100%);';
                                                setTimeout(function(){
                                                    tr.style='';
                                                },2000);
                                            },200);
                                            DeleteCookie('increaseBid');
                                            return false;
                                        }
                                    });
                                }
                            }
                            if(!find_player){
                                GiveNotification(false,"Sorry, some things went wrong. I didn't see your offer.");
                                DeleteCookie('increaseBid');
                            }
                        }
                    }



                    /*Show bought players*/
                    if(Features.IsActive("ShowBoughtPlayers")){
                        let data = GetCookie('PlayersData',{});
                        if(data.BuyPlayers==undefined)
                            data.BuyPlayers = [];
                        var BoughtPlayers = data.BuyPlayers;
                        if(BoughtPlayers.length){
                            ShowBoughtPlayersList(BoughtPlayers);
                            ShowProfit();
                        }
                        else{
                            UploadPlayersData();
                        }
                        function ShowBoughtPlayersList(BoughtPlayers){
                            var text =
                                '<h3>'+GetLocaleText('ListofPurchasedFootballers')+
                                '<img style="float:right;cursor:pointer;margin-Right:5px;" src="'+TOOL.sources.get('download','png')+'" alt="download" width="15px" height="15px" title="Liste Herunterladen" id="downloadData">'+
                                '<img style="margin-Right:7px;float:right;cursor:pointer" src="'+TOOL.sources.get('remove2','png')+'" alt="remove2" width="15px" height="15px" title="Lösche die Liste" id="RemovePlayersData">'+
                                '</h3>'+
                                '<table class="sortable-table sortable" id="purchased-players">'+
                                '<thead>'+
                                '<tr class="">'+
                                '<th class="nosort">'+GetLocaleText('Country')+'</th>'+
                                '<th class="name-column sortcol">'+GetLocaleText('Name')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('SortPosition')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol" name="__tooltip" tooltip="tt_strength"> Ø <span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('Age')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('Salary')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('Price')+'</th>'+
                                '<th class="nosort">'+GetLocaleText('Contract')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('Club')+'<span class="sort-status"></span> </th>'+
                                '<th class="sortcol">'+GetLocaleText('Date')+'<span class="sort-status"></span></th>'+
                                '<th class="sortcol">'+GetLocaleText('Delete')+'</th>'+
                                '</tr>'+
                                '</thead>'+
                                '<tfoot>'+
                                '<tr class="even">'+
                                '<td class="last-column" colspan="9"></td>'+
                                '</tr>'+
                                '</tfoot>'+
                                '<tbody>';
                            for(let i = 0 ; i < BoughtPlayers.length ; i++){
                                let a = BoughtPlayers[i];
                                text+=
                                    '<tr class="'+(i%2===0?"odd":"even")+'">'+
                                    '<td> <img name="__tooltip" tooltip="tt_'+a.playerCountry+'" src="/static/images/countries/'+a.playerCountry+'.gif"> </td>'+
                                    '<td style="white-space: pre-wrap;line-height: 1.5;width:25%;max-width:30%;text-align:left;">'+
                                    '<span pid="player-'+a.playerId+'" class="icon details open-card"></span>'+
                                    '<span class="player-name">'+a.playerName+'</span>'+
                                    '</td>'+
                                    '<td>'+a.position+'</td>'+
                                    '<td>'+a.strength+'</td>'+
                                    '<td>'+a.age+'</td>'+
                                    '<td>'+(a.salary).toLocaleString()+'<span class="icon currency"></span></td>'+
                                    '<td>'+(a.price).toLocaleString()+'<span class="icon currency"></span></td>'+
                                    '<td>'+a.season+' '+GetLocaleText(a.season==1?"Season":"Seasons")+'</td>'+
                                    '<td style="text-align: left;white-space: pre-wrap;line-height: 1.5;width:17%;max-width:20%;" sortvalue="'+a.club.name+'">'+
                                    '<a href="#/index.php?w='+worldId+'&amp;area=user&amp;module=profile&amp;action=show&amp;clubId='+a.club.id+'" clubid="'+a.club.id+'">'+a.club.name+'</a>'+
                                    '</td>'+
                                    '<td>'+a.date+'</td>'+
                                    '<td class="last-column">'+
                                    '<img class="DeletePurchasedPlayerData" id="remove_player_'+a.playerId+'" src="'+TOOL.sources.get('remove3','png')+'" alt="remove3" heigth="15px" width="15px" style="cursor:pointer">'+
                                    '</td>'+
                                    '</tr>';
                            }
                            text+='</tbody> </table>';
                            $('#own-offers').after(text);
                            $('#downloadData').click(function(){
                                DownloadAsTextFile(JSON.stringify(BoughtPlayers),"Bought Players' Datas",);
                            });
                            $('#RemovePlayersData').click(function(){
                                if(confirm(GetLocaleText('Warning',null,!1))){
                                    $('#purchased-players').prev().remove();
                                    $('#purchased-players').remove();
                                    let data = GetCookie('PlayersData');
                                    data.BuyPlayers = undefined;
                                    SetCookie('PlayersData',data);
                                    UploadPlayersData();
                                }
                            });
                            $('#purchased-players').find('.DeletePurchasedPlayerData').click(function(){
                                let playerId = $(this).attr('id').split('_')[2],
                                    _playerId;
                                for(let i = 0 ; i < BoughtPlayers.length ; i++){
                                    _playerId = BoughtPlayers[i].playerId;
                                    if(_playerId == playerId){
                                        BoughtPlayers.splice(i,1);
                                        var data = GetCookie('PlayersData');
                                        data.BuyPlayers = BoughtPlayers;
                                        SetCookie('PlayersData',data);
                                        var tr = $(this).parents('tr');
                                        var index = tr.index();
                                        tr.hide(400);
                                        setTimeout(function(){
                                            tr.remove();
                                            var players = $('#purchased-players > tbody > tr');
                                            if(players.length){
                                                for(var j = index ; j < players.length ; j++){
                                                    players[j].className = j%2==0?"odd":"even";
                                                }
                                            }
                                            else{
                                                $('#purchased-players').prev().remove();
                                                $('#purchased-players').remove();
                                                UploadPlayersData();
                                            }
                                        },400);
                                        break;
                                    }
                                }
                            });
                        }
                        function UploadPlayersData(){
                            var ekle =
                                '<div align="center">'+
                                '<label style="color: #a5e4c6;font-weight: bold;">'+GetLocaleText('UploadPlayersData')+' : </label>'+
                                '<input type="file" accept=".txt" id="UploadPlayerData">'+
                                '</div>';
                            $('#own-offers').after(ekle);
                            var fileInput = document.getElementById('UploadPlayerData');
                            fileInput.addEventListener('change', function(e) {
                                var file = fileInput.files[0];
                                var textType = /text.*/;
                                if (file.type.match(textType)) {
                                    var reader = new FileReader();
                                    reader.onload = function(e) {
                                        var PlayersData = JSON.parse(reader.result);
                                        var data = GetCookie('PlayersData');
                                        data.BuyPlayers = PlayersData;
                                        SetCookie('PlayersData',data);
                                        $('#UploadPlayerData').parent().remove();
                                        ShowBoughtPlayersList(PlayersData);
                                        ShowProfit();
                                    };
                                    reader.readAsText(file);
                                } else {
                                    GiveNotification(false,GetLocaleText('ChooseNotebook'));
                                }
                            });
                        }
                        function ShowProfit(){
                            var data = GetCookie('PlayersData',{BuyPlayers:[]});
                            if(data.BuyPlayers==undefined)
                                data.BuyPlayers = [];
                            var BoughtPlayers = data.BuyPlayers;
                            if(BoughtPlayers.length){
                                $('#foreigner-offers > tbody > tr').each(function(){
                                    var playerId = $(this).find('.open-card').attr('pid').split('-')[1];
                                    for(var i = 0 ; i < BoughtPlayers.length ; i++){
                                        if(BoughtPlayers[i].playerId == playerId){
                                            var offer = $(this).find('td:nth-child(8)').attr('sortvalue');
                                            if(offer){
                                                offer = parseInt(offer);
                                                var price = BoughtPlayers[i].price;
                                                var profit = offer - price;
                                                var element = $(this).find('td:nth-child(8) > span > span.currency-number');
                                                if(profit>0){
                                                    element.css('color','#20ff63');
                                                }else if(profit==0){
                                                    element.css('color','white');
                                                }else{
                                                    element.css('color','#a10c00');
                                                }
                                                element.after(
                                                    '<span title="'+(GetLocaleText(profit<0?'Loss':'Gain',null,!1))+' : '+(profit).toLocaleString()+' €" style="font-weight: bold;color: #42ead4;display:none;">'+
                                                    (price).toLocaleString()+'</span>'
                                                );
                                                Show(element);
                                            }
                                            break;
                                        }
                                    }
                                });
                                function Hide(element){
                                    element.mouseleave(function(){
                                        $(this).off();
                                        $(this).parent().off();
                                        $(this).hide();
                                        $(this).prev().show();
                                        Show($(this).prev());
                                    });
                                    element.parent().mouseleave(function(){
                                        $(this).off();
                                        $(element).off();
                                        element.hide();
                                        element.prev().show();
                                        Show(element.prev());
                                    });
                                }
                                function Show(element){
                                    element.mouseenter(function(){
                                        $(this).off();
                                        $(this).hide();
                                        $(this).next().show();
                                        Hide($(this).next());
                                    });
                                }
                            }
                        }
                    }


                    //Transfer pazarındaki oyuncuların open-card elementlerini değişkene aktarıyoruz.
                    let playersInTransferMarket = {};
                    $('#content > div.container.transfermarket > div.table-container > table > tbody > tr').each(function(){
                        var card = $(this).find('.open-card');
                        if(card.length){
                            var playerId = card.attr('pid').split('-')[1];
                            playersInTransferMarket[playerId] = card;
                        }
                    });

                    //Tekliflerimizin durumunu kaydediyoruz.
                    let OwnOffers = {};
                    if($('#own-offers> tbody').find('.open-card').length){
                        $('#own-offers> tbody > tr').each(function(){
                            let OCard = $(this).find('.open-card'),
                                playerId = OCard.attr('pid').split('-')[1],
                                price = parseInt($(this).find('td:nth-child(8)').attr('sortvalue')),
                                bidStatus = $(this).find('td:nth-child(7)').text().trim().toLowerCase();
                            OwnOffers[playerId]= {
                                price     : price,
                                bidStatus : bidStatus
                            };
                        });
                    }


                    //Oyuncu ismine tıklayıp teklifimize gidebilir,tekliflerimizin durumunu renkten ayırt edebiliriz ve teklifimiz geçildiyse mouse ile üzerine gelip teklifimizi görebiliriz.
                    if(Features.IsActive("ShowOwnOfferInMarket")){
                        let players = $('#content > div.container.transfermarket > div.table-container > table > tbody');
                        if(players.find('.open-card').length){
                            players = players.find('tr');
                            players.each(function(i){
                                let playerId = $(this).find('.open-card').attr('pid').split('-')[1];
                                if(OwnOffers[playerId]){
                                    let club = $(this).find('td:nth-child(8) > a'),
                                        bidStatus = OwnOffers[playerId].bidStatus,
                                        color,
                                        title = '';
                                    switch(bidStatus){
                                        case TOOL.acceptedBidText.toLowerCase():
                                            color = '#20ff63';
                                            title = GetLocaleText('AcceptedOwnOffer',null,!1);
                                            break;
                                        case TOOL.rejectedBidText.toLowerCase():
                                            color = '#9e0e0e';
                                            title = GetLocaleText('RejectedOwnOffer',null,!1);
                                            break;
                                        case TOOL.readBidText.toLowerCase():
                                            color = '#fcbd0f';
                                            title = GetLocaleText('ReadOwnOffer',null,!1);
                                            break;
                                        default:
                                            color = '#ffffff82';
                                            title = GetLocaleText('NewOwnOffer',null,!1);
                                            break;
                                    }
                                    var playerName = $(this).find('.player-name:first');
                                    if(club.length){
                                        if(club.hasClass('self-link')){
                                            $(this).find('.currency-number').first().css('color',color);
                                        }
                                        else if(bidStatus != TOOL.rejectedBidText){
                                            //Bu oyuncuya verdiğimiz geçilmiş fakat bizim teklifimiz reddedilmemiş ise
                                            var price = OwnOffers[playerId].price;
                                            showMyOffer(playerName,$(this).find('.currency-number:first'),club,price,color);
                                            title += '\u000d'+GetLocaleText('PassedOwnOffer',null,!1);
                                        }
                                    }
                                    playerName[0].style = 'background-color : '+color+';border-radius:7px;padding:1px 3px;';
                                    playerName[0].title = title;
                                    goToMyOffer(playerName,playerId);
                                }
                            });
                            function goToMyOffer(playerName,playerId){
                                let _playerId;
                                playerName.click(function(){
                                    $('#own-offers > tbody > tr').each(function(){
                                        _playerId = $(this).find('.open-card').attr('pid').split('-')[1];
                                        if(_playerId == playerId){
                                            $('html, body').animate({ scrollTop: getOffset(this).top-$(window).height()/2 }, 'fast');
                                            this.style = 'background-color: #fff2ac; background-image: linear-gradient(to right, #ffe359 0%, #fff2ac 100%);';
                                            let tr = this;
                                            setTimeout(function(){
                                                tr.style = '';
                                            },2000);
                                            return;
                                        }
                                    });
                                });
                            }
                            function showMyOffer(e1,e2,club,price,color){
                                let temp = {
                                    price : e2.html(),
                                    clubId : club.attr('clubid'),
                                    clubName : club.text().trim()
                                };
                                e1.add(e2).mouseenter(function(){
                                    e2.html('<font style="color:'+color+';">'+(price).toLocaleString()+'</font>');
                                    club.attr('clubid',TOOL.clubId);
                                    club.addClass('self-link');
                                    club.text(TOOL.clubName);
                                });
                                e1.add(e2).mouseleave(function(){
                                    e2.html(temp.price);
                                    club.attr('clubid',temp.clubId);
                                    club.removeClass('self-link');
                                    club.text(temp.clubName);
                                });
                            }
                        }
                    }


                    //Sattığımız oyunculara gelen teklifleri kabul edersek veya reddedersek bunların kayıtlarını almamız gerekiyor.
                    $('#foreigner-offers > tbody > tr').each(function(i){
                        if($(this).find('.accept-button').length){
                            $(this).find('.button:first > a').attr('_href',$(this).find('.button:first > a')[0].href);
                            $(this).find('.button:first > a').removeAttr('href');
                            $(this).find('.button:first > a').click(function(){
                                $(this).off();
                                let data = GetCookie('PlayersData',{});
                                if(!data.AcceptedOffers)
                                    data.AcceptedOffers = {};
                                let AcceptedOffers = data.AcceptedOffers,
                                    tr = $(this).parents('tr'),
                                    playerId = tr.find('.open-card').attr('pid').split('-')[1],
                                    playerName = tr.find('.player-name').text().trim(),
                                    clubId = tr.find('.name-column > a').attr('clubid'),
                                    clubName = tr.find('.name-column')[1].getAttribute('sortvalue').trim(),
                                    price = tr.find('td:nth-child(8) .currency-number').text().split('.').join(''),
                                    date = GetDateText(GetServerTime());
                                if(!AcceptedOffers[playerId]){
                                    AcceptedOffers[playerId] = {
                                        playerName:playerName,
                                        offers:{
                                            [clubId]:{
                                                clubName : clubName,
                                                price    : price,
                                                date     : date //17.01.2019 15:55:25
                                            }
                                        }
                                    };
                                }
                                else{
                                    AcceptedOffers[playerId].offers[clubId] = {
                                        clubName : clubName,
                                        price    : price,
                                        date     : date
                                    };
                                }
                                SetCookie('PlayersData',data);
                                $(this).attr('href',$(this).attr('_href'));
                                $(this).click();
                            });
                        }
                        else{
                            let dismiss_button = $(this).find('td.last-column > a'),
                                href,a;
                            if(dismiss_button.length
                               && (a=(href=dismiss_button.attr('href')).indexOf('do=dismissOfferAcceptance')!=-1)
                              ){
                                let clubId = $('td:nth-child(6) > a',this).attr('clubid'),
                                    clubName = $(this).find('.name-column')[1].getAttribute('sortvalue').trim(),
                                    playerId = $(this).find('.open-card').attr('pid').split('-')[1],
                                    playerName = $(this).find('.player-name').text().trim(),
                                    data = GetCookie('PlayersData',{}),
                                    price = $(this).find('td:nth-child(8) .currency-number').text().split('.').join(''),
                                    save = !0,
                                    AcceptedOffers;
                                if(!data.AcceptedOffers)
                                    data.AcceptedOffers = {};
                                AcceptedOffers = data.AcceptedOffers;
                                if(!AcceptedOffers[playerId]){
                                    AcceptedOffers[playerId] = {
                                        playerName: playerName,
                                        offers:{
                                            [clubId] : {
                                                clubName : clubName,
                                                price    : price,
                                                date     : '-' //17.01.2019 15:55:25
                                            }
                                        }
                                    };
                                }
                                else{
                                    if(!AcceptedOffers[playerId].offers[clubId]){
                                        AcceptedOffers[playerId].offers[clubId] = {
                                            clubName : clubName,
                                            price    : price,
                                            date     : '-'
                                        };
                                    }
                                    else{
                                        save = !1;
                                    }
                                }
                                if(save){
                                    SetCookie('PlayersData',data);
                                }
                            }
                        }
                    });

                    //Teklifi iptal etmek için butona basıyoruz
                    if(Page.pr.do && Page.pr.playerid && Page.pr.clubid){
                        let playerId = Page.pr.playerid,
                            clubId = Page.pr.clubid,
                            playerFound = !1;
                        $('#foreigner-offers > tbody > tr').each(function(){
                            let openCard = $(this).find('.open-card');
                            if(openCard.length
                               && openCard.attr('pid').split('-')[1] == playerId
                               && $(this).find('td.name-column:last > a').attr('clubid') == clubId
                              ){//Bu oyuncunun teklifi reddedilmeye çalışıldı fakat tabloda hala ismi bulunuyor!
                                playerFound = !0;
                                return false;
                            }
                        });
                        if(!playerFound){
                            //Linkteki id'iye sahip futbolcunun teklifi reddedilmeye çalışıldı ve tabloda ismi yok. Eğer kabul edilmiş tekliflerde datası varsa silinecek.
                            let data = GetCookie('PlayersData',{}),
                                AcceptedOffers = data.AcceptedOffers,
                                playerData;
                            if(AcceptedOffers //AcceptedOffers mevcut
                               && (playerData = AcceptedOffers[playerId]) //Data mevcut
                               && playerData.offers[clubId] //Bu kulübün bu oyuncuda teklif kaydı var
                              ){
                                delete playerData.offers[clubId]; //Teklif siliniyor
                                if(Object.keys(playerData.offers).length) //Geriye hiç teklif kalmazsa
                                    delete AcceptedOffers[playerId]; //Oyuncunun datası siliniyor
                                SetCookie('PlayersData',data)
                            }
                        }
                    }



                    //Kendi tekliflerimizi filtreliyoruz:
                    if($('#own-offers > tbody').find('.open-card').length &&
                       Features.IsActive("FilterOwnOffers")
                      ){
                        $('#own-offers').parent().before(
                            '<div style="text-align:center;" id="divFilterOwnOffers">'+
                            '   <label style="color: white; font-size: 13px;" title="'+new Date(GetServerTime()).toLocaleDateString()+'">'+
                            '      <input type="checkbox">'+
                            '      '+GetLocaleText('TodayOffers')+
                            '   </label>'+
                            '   <label style="color: white; font-size: 13px;">'+
                            '      <input type="checkbox" style="margin-Left:20px;" checked>'+
                            '      '+GetLocaleText('AcceptedOffers')+
                            '   </label>'+
                            '   <label style="color: white; font-size: 13px;">'+
                            '      <input type="checkbox" style="margin-Left:20px;" checked>'+
                            '      '+GetLocaleText('ReadingOffers')+
                            '   </label>'+
                            '   <label style="color: white; font-size: 13px;">'+
                            '      <input type="checkbox" style="margin-Left:20px;" checked>'+
                            '      '+GetLocaleText('RejectedOffers')+
                            '   </label>'+
                            '   <label style="color: white; font-size: 13px;">'+
                            '      <input type="checkbox" style="margin-Left:20px;" checked>'+
                            '      '+GetLocaleText('NewOffers')+
                            '   </label>'+
                            '</div>');
                        $('#divFilterOwnOffers > label > input').click(function(){
                            $('#divFilterOwnOffers > input').attr('disabled',true);
                            let filter = {},
                                today = new Date(GetServerTime()).toLocaleDateString();
                            $('#divFilterOwnOffers > label > input').each(function(i){
                                filter[$(this).next().attr('k')]=this.checked;
                            });
                            let count = 0;
                            $('#own-offers > tbody > tr').each(function(){
                                let bidStatus = $(this).find('td:nth-child(7)').text().trim().toLowerCase(),
                                    date = $(this).find('td:nth-child(9)').text().trim(),
                                    show =
                                    (filter.AcceptedOffers && bidStatus==TOOL.acceptedBidText.toLowerCase()) ||
                                    (filter.ReadingOffers && bidStatus==TOOL.readBidText.toLowerCase()) ||
                                    (filter.RejectedOffers && bidStatus==TOOL.rejectedBidText.toLowerCase()) ||
                                    (filter.NewOffers && bidStatus==TOOL.newBidText.toLowerCase());
                                show = show && filter.TodayOffers?date.indexOf(today)!=-1:show;
                                if(show){
                                    $(this).attr('class',(count++)%2==0?"odd":"even");
                                    $(this).show();
                                }
                                else
                                    $(this).hide();
                            });
                            $('#divFilterOwnOffers > input').removeAttr('disabled');
                        });
                    }



                    $('#content').find('.search-container').after('<div id="transferMarktMenu" style="clear:both;margin-left:18px;position:relative;"></div>');
                    if($('#content > div.container.transfermarket > div.table-container > table > tbody').find('.open-card').length){
                        if($('#club').val()!=TOOL.clubName){
                            if(Features.IsActive("FilterTransferMarket")){
                                let players = $('#content > div.container.transfermarket > div.table-container > table > tbody > tr'),
                                    select = GetLocaleText('ShowOnlyOneLeague')+' : '+
                                    '<select style="-webkit-border-radius: 7px;margin-Left:10px;text-align-last:center;" id="select_lig">'+
                                    '<option value="0" selected="selected">'+GetLocaleText('SelectLeague')+':</option>',
                                    leagues = TOOL.Leagues,
                                    myLeague = (GetCookie('LeagueData',{league:false})).league,
                                    leagueValue = 1,
                                    count=0;
                                for(let leagueKeys in leagues){
                                    select+= '<option value="'+(leagueValue++)+'">'+leagues[leagueKeys]+'</option>';
                                }
                                select += '</select>'+
                                    '<label style="display:none;vertical-align: middle;">'+
                                    '<input id="only_one_lig" type="checkBox" style="margin-Left:10px;"></input>'+
                                    '<label for="only_one_lig">'+GetLocaleText('ShowOnlyOneLeague')+'</label>'+
                                    '</label>'+
                                    '<p'+($('#positions').val()=='0'?'':' style="display:none;"')+'>'+
                                    '<input id="NoKeeperPlayers" type="checkBox" style="margin-left:0;">'+
                                    '<label for="NoKeeperPlayers">'+GetLocaleText('AllExceptGoalkeeper')+'</label>'+
                                    '</p>';
                                $('#transferMarktMenu').append(select);
                                if(myLeague){
                                    $('#select_lig > option').each(function(i){
                                        if($(this).text()==myLeague){
                                            $(this).css({
                                                'background-color':'#8c0505',
                                                'color':'white'
                                            });
                                            $(this).attr('title','Own League')
                                            for(let j=i-1,c=0;j>0&&c<2;j--,c++){
                                                $('#select_lig > option:nth-child('+(j+1)+')').css('background-color','orange');
                                                $('#select_lig > option:nth-child('+(j+1)+')').attr('title','Sub League');
                                            }
                                            let LENG = $('#select_lig > option').length;
                                            for(let j=i+1,c=0;j<=LENG&&c<2;j++,c++){
                                                $('#select_lig > option:nth-child('+(j+1)+')').css('background-color','#17fc17');
                                                $('#select_lig > option:nth-child('+(j+1)+')').attr('title','Upper League');
                                            }
                                            for(let j=i-3;j>0;j--)
                                                $('#select_lig > option:nth-child('+(j+1)+')').css('background-color','yellow');
                                            for(let j=i+3;j<=LENG;j++)
                                                $('#select_lig > option:nth-child('+(j+1)+')').css('color','#808080');
                                            return false;
                                        }
                                    });
                                }
                                $('#content > div.container.transfermarket > div.table-container > h3').after(
                                    '<p style="background-Color:black;color:white;line-height:33px;text-align:center;" id="filterPlayerInformation"></p>'
                                );
                                //Change çalışmıyor
                                $('#positions').change(function(){
                                    $('#NoKeeperPlayers').parent()[this.value=='0'?'slideDown':'slideUp']();
                                });
                                $('#NoKeeperPlayers').click(function(){
                                    TransferMarketValues["NoKeeperPlayers"] = this.checked;
                                    if(this.checked
                                       && $('#positions').val()=='0'
                                      ){
                                        players.each(function(){
                                            if($(this).css('display')!=='none'){
                                                if(this.getElementsByTagName('td')[2].innerHTML === TOOL.footballerPositions.Position1){
                                                    $(this).hide();
                                                }
                                            }
                                        });
                                    }
                                    else{
                                        if($('#only_one_lig')[0].checked){
                                            var lig = $('#select_lig')[0].options[$('#select_lig')[0].selectedIndex].textContent.trim();
                                            players.each(function(){
                                                var clubId = this.getElementsByClassName('name-column')[1].getElementsByTagName('a')[0].getAttribute('clubid');
                                                if(TransferMarketClubs[clubId].indexOf(lig)!==-1){
                                                    $(this).show();
                                                }
                                            });
                                        }
                                        else{
                                            players.each(function(){
                                                $(this).show();
                                            });
                                        }
                                    }
                                    showFilterInfo();
                                });
                                $('#select_lig').change(function(){
                                    TransferMarketValues["ligaIndex"]= this.selectedIndex;
                                    if(this.value==0){
                                        $('#only_one_lig').parent().slideUp();
                                        $('#only_one_lig')[0].checked = false;
                                        TransferMarketValues["checkBox"] = false;
                                        players.each(function(i){
                                            this.className = i%2===0?"odd":"even";
                                            $(this).show();
                                        });
                                    }
                                    else{
                                        $('#only_one_lig').parent().slideDown();
                                        if($('#only_one_lig')[0].checked){
                                            tablo_oku();
                                        }
                                    }
                                });
                                $('#only_one_lig').click(function(){
                                    TransferMarketValues["checkBox"] = this.checked;
                                    if(this.checked){
                                        tablo_oku();
                                    }
                                    else{
                                        if($('#NoKeeperPlayers')[0].checked){
                                            var c = 0;
                                            players.each(function(i){
                                                if(this.getElementsByTagName('td')[2].innerHTML !== TOOL.footballerPositions.Position1){
                                                    this.className = c%2===0?"odd":"even";
                                                    this.style.display='';
                                                    c++;
                                                }
                                            });
                                        }
                                        else{
                                            players.each(function(i){
                                                this.className = i%2===0?"odd":"even";
                                                $(this).show();
                                            });
                                        }
                                        showFilterInfo();
                                    }
                                });
                                if(TransferMarketValues["NoKeeperPlayers"]){
                                    if($('#positions').val()=='0')
                                        $('#NoKeeperPlayers').click();
                                    else{
                                        TransferMarketValues["NoKeeperPlayers"] = !1;
                                        $('#NoKeeperPlayers')[0].checked = !1;
                                    }
                                }
                                if(TransferMarketValues["ligaIndex"]!==0){
                                    document.getElementById('select_lig').selectedIndex = TransferMarketValues["ligaIndex"];
                                    $('#only_one_lig').parent().show();
                                    if(TransferMarketValues["checkBox"]){
                                        $('#only_one_lig')[0].checked=true;
                                        tablo_oku();
                                    }
                                }
                                function tablo_oku(){
                                    $('#select_lig')[0].disabled=true;
                                    $('#only_one_lig')[0].disabled=true;
                                    $('#NoKeeperPlayers')[0].disabled=true;
                                    $('#only_one_lig').parent().hide();
                                    $('#only_one_lig').parent().after('<img src="/designs/redesign/images/icons/loading/16x16.gif" id="LoadingTable" style="margin-left:10px;vertical-align:middle;">');
                                    count = 0;
                                    players.each(function(){
                                        var clubId = this.getElementsByClassName('name-column')[1].getElementsByTagName('a')[0].getAttribute('clubid');
                                        if(!TransferMarketClubs[clubId]){
                                            count++;
                                            kulüp_bilgileri_cek(clubId);
                                        }
                                    });
                                    if(count==0){
                                        tablo_göster();
                                    }
                                }
                                function kulüp_bilgileri_cek(clubId){
                                    var urlPath = 'index.php?w='+worldId+'&area=user&module=club&action=index&complex=0'+ '&id=' + clubId;
                                    $.get(urlPath, function(response){
                                        var a = $('<diV>'+response+'</div>').find('ul > li:first');
                                        a.find('strong').remove();
                                        var leuage = a.text().trim();
                                        TransferMarketClubs[clubId] = leuage;
                                        count--;
                                        if(count===0){
                                            tablo_göster();
                                        }
                                    });
                                }
                                function tablo_göster(){
                                    var kl_gösterme = TransferMarketValues["NoKeeperPlayers"] && $('#positions').val()=="0"?true:false;
                                    var görüntülenecek_lig = document.getElementById('select_lig').options[document.getElementById('select_lig').selectedIndex].textContent;
                                    players.each(function(i){
                                        var clubId = this.getElementsByClassName('name-column')[1].getElementsByTagName('a')[0].getAttribute('clubid');
                                        var mevki = this.getElementsByTagName('td')[2].innerHTML;
                                        if(TransferMarketClubs[clubId].indexOf(görüntülenecek_lig)!==-1 && !(kl_gösterme && mevki===TOOL.footballerPositions.Position1)){
                                            this.className = i%2==0?"odd":"even";
                                            $(this).show();
                                        }
                                        else{
                                            $(this).hide();
                                        }
                                    });
                                    $('#select_lig')[0].disabled=false;
                                    $('#only_one_lig')[0].disabled=false;
                                    $('#NoKeeperPlayers')[0].disabled=false;
                                    $('#LoadingTable').remove();
                                    $('#only_one_lig').parent().show();
                                    showFilterInfo();
                                }
                                function showFilterInfo(){
                                    var show = 0;
                                    players.each(function(){
                                        if($(this).css('display')!=='none'){
                                            show++;
                                        }
                                    });
                                    if(players.length !== show){
                                        $('#filterPlayerInformation').html(GetLocaleText('FilterPlayerInformation',[players.length,show],!1));
                                    }
                                    else{
                                        $('#filterPlayerInformation').html('');
                                    }
                                }
                            }
                        }
                        else{
                            let toplamÜcret = 0;
                            $('#content > div.container.transfermarket > div.table-container > table > tbody > tr').each(function(){
                                var o = $('td:nth-child(7)',this).find('.currency-number');
                                if(o.length) toplamÜcret += parseInt(o.first().text().replace(/\./g,''));
                            });
                            if(toplamÜcret)
                                $('#content > div.container.transfermarket > div.table-container > table > tfoot > tr').html('<td colspan="6"></td><td style="color:#edfdff;font-weight:bold;">'+(toplamÜcret).toLocaleString()+' <span class="icon currency"></span></td><td colspan="3"></td>');
                        }
                    }


                    //Kulübümüzün transfer pazarını göstermek için:
                    $('#transferMarktMenu').append(CreateButton('ShowMyTransferMarket',GetLocaleText('ShowMyMarket'),'margin-Right:12px;top:0;right:0;position:absolute;'));
                    $('#ShowMyTransferMarket').click(function(){
                        $('#age_min').val(16);
                        $('#age_max').val(34);
                        $('#searchform > ul > li.strength > span:nth-child(2) > input[type="text"]').val(0);
                        $('#searchform > ul > li.strength > span:nth-child(3) > input[type="text"]').val(999);
                        $('#positions').val(0);
                        $('#club').val(TOOL.clubName);
                        $('#searchform > ul > li.transfermarket-search-button > span > a > span').click();
                    });



                    /*Functions that only work this page*/
                    function getOffset( el ){
                        var _x = 0;
                        var _y = 0;
                        while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
                            _x += el.offsetLeft - el.scrollLeft;
                            _y += el.offsetTop - el.scrollTop;
                            el = el.offsetParent;
                        }
                        return { top: _y, left: _x };
                    }
                }
                else pageIsDetected=!1;
                break;
            case 1:
                if(Page.on({module:'statistics',action:'games'})){
                    var e = $('#content').find('.date-selector');
                    if(e.length){
                        var save = false;
                        var LeagueData = GetCookie('LeagueData');
                        if(LeagueData !==undefined){
                            if((LeagueData.lastMatchDate+86400000)<=GetServerTime()){
                                save = true;
                            }
                        }
                        else{
                            save = true;
                        }
                        if(save){
                            SaveLeagueData($('#content'));
                        }
                    }
                }
                else if(Page.on({module:'statistics',action:'table'})){
                    if(Features.IsActive("DownloadTable")){
                        printScreen('statistics-league-table',GetLocaleText('LeagueTable',null,!1));
                    }
                }
                else if(Page.on({module:'friendly'})){
                    if(true){
                        if(!$('#own-invitations-table > tbody > tr').find('.no-invites').length){
                            $('#invitations > div.table-container > div:nth-child(1) > h3').append(CreateButton('ClearInvitations',GetLocaleText('CancelUnnecessaryDays'),'float:right;margin-right:5px;'));
                            $('#ClearInvitations').click(function(){
                                var doluTarihler = {};
                                $('#friendly-matches > tbody > tr').each(function(){
                                    doluTarihler[$(this).find('td:nth-child(2)').attr('sortvalue')] = '';
                                });
                                var silinecekIstekKeyleri = [];
                                $('#own-invitations-table > tbody > tr').each(function(){
                                    if(doluTarihler[$(this).find('td:nth-child(2)').attr('sortvalue')]!==undefined){
                                        var href = $(this).find('td.last-column > a')[0].href;
                                        silinecekIstekKeyleri.push(href.substring(href.indexOf('delete=')+7,href.lastIndexOf('&')));
                                    }
                                });
                                if(silinecekIstekKeyleri.length){
                                    clearInvitations();
                                }
                                function clearInvitations(){
                                    if(!silinecekIstekKeyleri.length){
                                        main();
                                        return;
                                    }
                                    var key = silinecekIstekKeyleri[0];
                                    silinecekIstekKeyleri.splice(0,1);
                                    location.href = "#/index.php?w="+worldId+"&area=user&module=friendly&action=index&delete="+key;
                                    PageLoad(clearInvitations);
                                }
                            });
                        }
                    }
                    if(!$('#away-invitations-table > tbody .no-invites').length //Hazırlık maçı davetleri varsa
                       && Features.IsActive("CancelFriendlyMatchInvites") //Özellik aktifse
                      ){
                        let invites = $('#away-invitations-table > tbody > tr');
                        if(invites.length>1){
                            $('#away-invitations-table > thead > tr > th:last').append('<input type="checkbox" class="checkbox_1" id="SelectAllInvites"><label title="Select All" style="line-height:20px;float:right;margin-top: 2.5px;" for="SelectAllInvites"></label>');
                            $('#SelectAllInvites').click(function(){
                                $('#away-invitations-table > tbody .CancelInvite'+(this.checked?':not(:checked)':':checked')).prop('checked',this.checked);
                                $('#CancelInvites')[this.checked?'slideDown':'slideUp']();
                            });
                        }
                        $('#away-invitations-table > tbody > tr').each(function(i){
                            let a = $('.icon.delete',$(this)).parent(),
                                decline = a.attr('href'),
                                find = decline.indexOf('&decline=')+9;
                            decline = decline.substring(find,decline.indexOf('&',find));
                            a.after(
                                '<input id="Cancel_invite_'+i+'" class="CancelInvite checkbox_2" style="vertical-align:middle;margin:0;" type="checkbox" decline="'+decline+'">'+
                                '<label for="Cancel_invite_'+i+'" class="disHighlight" style="cursor:pointer;"></label>');
                            a.remove();
                        });
                        let prev_index=undefined;
                        $('.CancelInvite').click(function(e){
                            let index = $(this).parents('tr').index();
                            if(e.shiftKey && prev_index!=undefined){
                                $('#away-invitations-table > tbody > tr').slice(Math.min(prev_index,index),Math.max(prev_index,index)+1).find('.CancelInvite').prop('checked',this.checked);
                            }
                            prev_index = index;
                            $('#CancelInvites')[$('#away-invitations-table > tbody .CancelInvite:checked').length?'slideDown':'slideUp']();
                            if(!this.checked && $('#SelectAllInvites').prop('checked')) $('#SelectAllInvites').prop('checked',false);
                            else if(this.checked
                                    && !$('#SelectAllInvites').prop('checked')
                                    && !$('#away-invitations-table > tbody .CancelInvite:not(:checked)').length
                                   ) $('#SelectAllInvites').prop('checked',true);
                        });
                        $('#away-invitations-table > tfoot > tr > td').append(CreateButton('CancelInvites',GetLocaleText('CancelSelectedInvites'),'display:none;float:right;'));
                        $('#CancelInvites').click(function(){
                            let checked;
                            if(!(checked = $('#away-invitations-table > tbody .CancelInvite:checked')).length) return;
                            let links = [];
                            checked.each(function(){
                                links.push({tr:$(this).parents('tr'),decline:$(this).attr('decline')});
                            });
                            let invites_length=links.length,
                                counter=0;
                            for(let i=0;i<invites_length;i++){
                                CancelInvite(links[i]);
                            }
                            let control_time=0;
                            function CancelInvite(obj,err=0){
                                let success;;
                                //     index.php?w=3401&area=user&module=friendly&action=index&decline=668249_1550581200
                                $.get('index.php?w='+worldId+'&area=user&module=friendly&action=index&decline='+obj.decline+'&layout=none',function(response){
                                    //Veri alımı başarılı oldu.
                                    let feedback;
                                    if(!(feedback=response.feedback).trim()    //feedback yoksa
                                       || !(feedback = $(feedback)).length     //tag bulunamadıysa
                                       || (feedback=feedback)[0].tagName!='P' //doğru tak değilse
                                       || !feedback.hasClass('notice')         //bildirim başarılı değilse
                                      ){
                                        console.log("feedback isn't exist || length=0 || tagname!='P'");
                                        success=!1;
                                        err = 3;
                                        return;
                                    }else{
                                        success=!0;
                                        console.log("Canceling invite ["+obj.decline+"] is successfull!");
                                    }
                                }).fail(function(){
                                    //Veri alımı başarısız oldu. 3 Kere veri alımını tekrar dene. Eğer 2 kez daha başarısız olursa işlemi sonlandır.
                                    if(++err<3) CancelInvite(obj,err);
                                }).always(function(){
                                    if(success   //Veri alımı başarılı
                                       || err==3 //veya 3 kere denenmesine rağmen veri alınamadı!
                                      ){
                                        counter++;
                                        let tr = obj.tr;
                                        if(success){
                                            tr.fadeOut(1000,()=>{
                                                tr.remove();
                                            });
                                            control_time=new Date().getTime()+1000; // 1000 salise sonra satır silinecek.Eğer o esnada finish fonksiyonu çalışırsa..
                                        }else{
                                            tr.find('.CancelInvite').prop('checked',false);
                                            BlinkEvent(tr,1000);
                                        }
                                        if(counter==invites_length)
                                            setTimeout(finish,control_time-new Date().getTime());
                                    }
                                });
                            }
                            function finish(){
                                if(!$('#away-invitations-table > tbody > tr').length){
                                    $('#away-invitations-table > tbody').append('<tr class="odd"> <td class="no-invites last-column" colspan="4"> - </td> </tr>');
                                    $('#SelectAllInvites').parent().find('label[for=SelectAllInvites]').remove();
                                    $('#SelectAllInvites').remove();
                                    $('#CancelInvites').remove();
                                }
                            }
                        });
                    }
                }
                else if(Page.on({module:'simulation'})){
                    if(GetCookie('LeagueData') !==undefined){
                        if(true){
                            var LeagueData = GetCookie('LeagueData');
                            if((LeagueData.lastMatchDate+86400000)>GetServerTime()){
                                var Clubs = LeagueData.clubs;
                                var takımlar = $('#simulations > tbody').find('.name-column');
                                for(var i = 0 ; i < takımlar.length ; i++){
                                    var clubId = $(takımlar[i]).find('a').attr('clubid');
                                    if(Clubs[clubId]!==undefined){
                                        $(takımlar[i]).parent().css('background','green');
                                        $(takımlar[i]).parent().attr('title',GetLocaleText('SameLeague',null,!1));
                                    }
                                }
                            }
                            else{
                                DeleteCookie('LeagueData');
                            }
                        }
                    }
                }
                else if(Page.on({module:'tournament'})){
                    if($('#tournaments > div.container.upcoming > div > table > tfoot > tr > td').html()=="" &&
                       !$('#tournaments > div.container.upcoming > div > table > tbody').find('.name-column').length?false:true){
                        if(TOOL.tournaments==undefined){
                            $('#button-container-create-own-tournament').after(CreateButton('BtnSortTournaments',GetLocaleText('SortTournaments'),'top:55px;'));
                            $('#BtnSortTournaments').click(function(){
                                $(this).remove();
                                TOOL.tournaments = [];
                                $('#tournaments-handle-container > .handle').off();
                                var pa = $('#tournaments > div.container.upcoming > div > table > tfoot > tr > td');
                                var _CounT_;
                                if(pa.html()!=""){
                                    var pageCount = $('#tournaments > div.container.upcoming > div > table > tfoot > tr > td > a').length+1;
                                    var currentPage=-1;
                                    if(pa.find('strong').length){
                                        currentPage = parseInt(pa.find('strong').first().text());
                                        saveTournament($('#tournaments > div.container.upcoming > div > table > tbody'),false,toolTipObj.data);/*save page that is open*/
                                    }
                                    var lookPage = [];
                                    for(var i = 1 ; i <= pageCount ; i++)
                                        if(i!=currentPage)
                                            lookPage.push(i);
                                    _CounT_ = lookPage.length;
                                    $('#button-container-create-own-tournament').after(
                                        '<span style="position: absolute;top: 55px;right: 52px;">'+
                                        '<img src="/designs/redesign/images/icons/loading/16x16.gif" style="vertical-align:middle;margin-right: 3px;">'+
                                        'Sayfa <span id="TournamentStatus">0</span>/'+_CounT_+
                                        '</span>'
                                    );
                                    for(var i = 0 ; i < _CounT_ ; i++){
                                        getTournamentPage(lookPage[i])
                                    }
                                }
                                else{
                                    var tbody = $('#tournaments > div.container.upcoming > div > table > tbody');
                                    if(tbody.find('.name-column').length){
                                        saveTournament(tbody,true,toolTipObj.data);/*save current page*/
                                    }
                                    else{
                                        /*no tournaments*/
                                    }
                                }

                                function getTournamentPage(page){
                                    var success = false;
                                    $.get('index.php?area=user&module=tournament&action=index&section=upcoming&posupcoming='+((page-1)*20)+'&path=index.php&layout=none',
                                          function(response) {
                                        $('#TournamentStatus').text(parseInt($('#TournamentStatus').text())+1);
                                        --_CounT_;
                                        var tbody = $($('<div>'+response.content+'</div>')[0].querySelector('#tournaments')).find('.container.upcoming').find('table:first > tbody');
                                        var tooltip = JSON.parse(response.tooltip);
                                        if(tbody.find('.name-column').length){
                                            var fin = _CounT_==0?true:false;
                                            if(fin)
                                                $('#TournamentStatus').parent().remove();
                                            saveTournament(tbody,fin,tooltip);
                                        }
                                        success = true;
                                    }).always(function() {
                                        if(!success){
                                            console.log('There is an error!');
                                        }
                                    });
                                }
                                function saveTournament(tbody,finish,tooltip){
                                    function dateNum(date){
                                        date = date.split('.');
                                        return parseInt(new Date(date[2],parseInt(date[1])-1,date[0])/86400000);
                                    }
                                    tbody.find('tr').each(function(i){
                                        if(!$(this).find('.first-column > .credits').length){
                                            var tournament = {};
                                            tournament.password = $(this).find('.first-column > .password').length?true:false;
                                            tournament.tournamentName = $(this).find('.name-column:first>a').text().trim();
                                            tournament.tournamentId = $(this).find(' td.info-column > a > img').attr('tooltip').replace('tt_','');
                                            tournament.tooltip = tooltip['tt_'+tournament.tournamentId];
                                            var totalPrice = 0;
                                            var koo = false;
                                            $(tournament.tooltip).find('div.tournament-tooltip-table > table > tbody > tr').each(function(j){
                                                if($(this).find('.last-column')){
                                                    totalPrice += parseInt($(this).find('td.last-column > span > span.currency-number').text().split('.').join(''));
                                                }
                                                else{
                                                    koo = true;
                                                    return;
                                                }
                                            });
                                            if(!koo){
                                                tournament.totalPrice = totalPrice;
                                                tournament.tournamentType = $(this).find('td:nth-child(3) > span')[0].className.replace('icon','').trim();
                                                var a = $(this).find('td:nth-child(4) > a');
                                                tournament.club = {
                                                    id:a.attr('clubid'),
                                                    name:a.text().trim()
                                                };
                                                tournament.start = $(this).find('td:nth-child(5)').text().trim();
                                                tournament.startK = dateNum(tournament.start);
                                                tournament.end = $(this).find('td:nth-child(6)').text().trim();
                                                tournament.endK = dateNum(tournament.end);
                                                TOOL.tournaments.push(tournament);
                                            }
                                        }
                                        else{
                                        }
                                    });
                                    if(finish){
                                        sortTournaments('money',1);
                                        showTournaments();
                                    }
                                }
                            });
                            if(!$('#tournaments-handle-container > li:nth-child(2)').hasClass('active'))
                                $('#BtnSortTournaments').hide();
                            $('#tournaments-handle-container > .handle').click(function(){
                                if($(this).attr('target')!==".container.upcoming"){
                                    $('#BtnSortTournaments').hide();
                                }
                                else{
                                    $('#BtnSortTournaments').show();
                                }
                            });
                        }
                        else{
                            /*Show saved tournaments*/
                            showTournaments();
                        }
                        function showTournaments(){
                            var table = $('#tournaments > div.container.upcoming > div > table');
                            var thead = $('thead>tr',table);
                            thead.before('<tr style="background:none;"><th colspan="8" style="background-color: #075971;border-radius: 7px 7px 0 0;" id="ShowNumberOfTournament">'+TOOL.tournaments.length+' '+GetLocaleText('Showtournaments')+' </th></tr>');
                            $('th:nth-child(6)',thead).after('<th class="SortTournaments" sort="money" k="-1" style="cursor:pointer;">'+GetLocaleText('totalprice')+'</th>');
                            var th = $('th:nth-child(5)',thead);
                            th.addClass('SortTournaments');
                            th.attr('sort','date');
                            th.attr('k','1');
                            th.css('cursor','pointer');
                            th.addClass('SortTournaments');
                            $('tfoot > tr > td',table).html('');
                            addRows()
                            $('.SortTournaments').click(function(){
                                var k = parseInt($(this).attr('k'));
                                sortTournaments($(this).attr('sort'),k);
                                addRows();
                                $(this).attr('k',k*-1);
                            });
                            function addRows(){
                                var ownTournaments = [];
                                var own = $('#tournaments > div.container.own > div > table > tbody');
                                if(own.find('.info-column').length){
                                    own.find('tr').each(function(){
                                        if(!$(this).find('.tournament').length){
                                            var start = $(this).find('td:nth-child(4)').text().trim().split('.');
                                            start = parseInt(new Date(start[2],parseInt(start[1])-1,start[0])/86400000);
                                            var end = $(this).find('td:nth-child(5)').text().trim().split('.');
                                            end = parseInt(new Date(end[2],parseInt(end[1])-1,end[0])/86400000);
                                            ownTournaments.push({start:start,end:end});
                                        }
                                    });
                                }
                                function TurnuvaÇakıştı(a,b){
                                    var r = false;
                                    for(var i = 0 ; i < ownTournaments.length ; i++){
                                        var c = ownTournaments[i].start;
                                        var d = ownTournaments[i].end;
                                        if((a<=d && a>=c) || (b>=c && b<=d)){
                                            r = true;
                                            break;
                                        }
                                    }
                                    return r;
                                }
                                var tbody = $('tbody',table);
                                tbody.html('');
                                var o = TOOL.tournaments;
                                for(var i = 0 ; i < o.length ; i++){
                                    tbody.append(
                                        '<tr '+(TurnuvaÇakıştı(o[i].startK,o[i].endK)==true?'style="background-color:#00000099;" ':"")+'class="'+(i%2==0?"odd":"even")+'">'+
                                        '<td class="first-column">'+(o[i].password?'<span class="icon password"></span>':"")+'</td>'+
                                        '<td class="name-column">'+
                                        '<a href="#/index.php?w='+worldId+'&area=user&module=tournament&action=tournament&tournament='+o[i].tournamentId+'">'+o[i].tournamentName+'</a>'+
                                        '</td>'+
                                        '<td><span class="icon '+o[i].tournamentType+'" tooltip="tt_tournament_type_'+o[i].tournamentType+'"></span></td>'+
                                        '<td class="name-column">'+
                                        '<div class="club-logo-container"></div>'+
                                        '<a href="#/index.php?w='+worldId+'&area=user&module=profile&action=show&clubId='+o[i].club.id+'" clubid="'+o[i].club.id+'">'+o[i].club.name+'</a>'+
                                        '</td>'+
                                        '<td class="date-column" sortvalue="'+o[i].startK+'">'+o[i].start+'</td>'+
                                        '<td class="date-column" sortvalue="'+o[i].endK+'">'+o[i].end+'</td>'+
                                        '<td>'+(o[i].totalPrice).toLocaleString()+'</td>'+
                                        '<td class="last-column info-column">'+
                                        '<a href="#/index.php?w='+worldId+'&area=user&module=tournament&action=tournament&tournament='+o[i].tournamentId+'">'+
                                        '<img src="/designs/redesign/images/icons/tooltip.gif" name="__tooltip" tooltip="tt_'+o[i].tournamentId+'">'+
                                        '</a>'+
                                        '</td>'+
                                        '</tr>'
                                    );
                                    if(toolTipObj.data['tt_'+o[i].tournamentId]==undefined){
                                        toolTipObj.data['tt_'+o[i].tournamentId] = o[i].tooltip;
                                    }
                                }
                            }
                        }
                        function sortTournaments(type,k){
                            switch(type){
                                case "money":
                                    TOOL.tournaments.sort(function(a,b){
                                        return k*(b.totalPrice-a.totalPrice);});
                                    break;
                                case "date":
                                    TOOL.tournaments.sort(function(a,b){
                                        return k*(a.startK-b.startK);});
                                    break;
                            }
                        }
                    }
                }
                else if(Page.on({module:'betoffice'})){
                    if(Features.IsActive("QuickBet")){
                        var t = $('#betoffice-container').find('.matches').find('tbody');
                        if(t.find('.club-logo-container').length){
                            t.find('tr').each(function(){
                                if($(this).find('.last-column').find('select').length){
                                    var k = this.getElementsByClassName('bet-quote');
                                    for(var j = 0 ; j < k.length ; j++){
                                        var radio = k[j].getElementsByTagName('span')[0];
                                        $(radio).click(function(){
                                            var e = $(this).parents('tr').find('select')[0];
                                            var q = $(this).parents('tr').find('.last-column > span > div > span')[0];
                                            if(!$(this).hasClass('checked')){
                                                e.selectedIndex = e.options.length-1;
                                                q.innerHTML = e.options[e.selectedIndex].innerHTML;
                                            }
                                            else{
                                                e.selectedIndex = 0;
                                                q.innerHTML=0;
                                            }
                                        });
                                    }
                                }
                            });
                        }
                    }
                }
                else pageIsDetected=!1;
                break;
            case 2:
                if(Page.on({module:'club',action:'sponsors'})){
                }
                else if(Page.on({module:'publicrelations'})){
                }
                else if(Page.on({module:'assistants'})){
                    if(Features.IsActive("ShowAsistantLevelIncrease")){
                        var key = 'AsistanLevel';
                        var data = GetCookie(key,{});
                        var o = [];
                        $('#assistants').find('.bar-text').each(function(){
                            var level = this.textContent.trim();
                            var b = level.indexOf(' ');
                            level = level.substring(b,level.indexOf(' ',b+1));
                            var value = parseInt($(this).prev().find('div')[0].style.width.replace('%',''));
                            var asistant = $($(this).parents('li')[1]).index();
                            var asistantName = $(this).parents('ul').first().find('li:first > span').text();
                            if(data[asistant]!==undefined){
                                if(data[asistant].name == asistantName){
                                    var difference = value - data[asistant].v;
                                    if(difference>0){
                                        var asistantType = $(this).parents('li').find('h3').text().trim();
                                        o.push({asistantType:asistantType,asistantName:asistantName,difference:difference});
                                    }
                                }
                            }
                            data[asistant] = {name:asistantName,v:(level*100+value)};
                        });
                        if(o.length){
                            var text = GetLocaleText('SeminarIsOver')+'<br>';
                            for(var i = 0 ; i < o.length-1 ; i++){
                                text += o[i].asistantName+'['+o[i].asistantType+'] : +'+o[i].difference+'%<br>';
                            }
                            text += o[o.length-1].asistantName+'['+o[o.length-1].asistantType+'] : +'+o[o.length-1].difference;
                            GiveNotification(true,text);
                        }
                        SetCookie(key,data);
                    }
                    if(true){
                        var bars = $('#assistants').find('.bar');
                        var values = [];
                        bars.each(function(){
                            values.push(parseInt(this.style.width.replace('%','')));
                            this.style.width = '0%';
                        });
                        if(values.length){
                            AllIntervals["Asistants"] = setInterval(function(){
                                for(var i = 0 ; i < bars.length ; i++){
                                    var width = bars[i].style.width;
                                    width = parseInt(width.substring(0,width.lastIndexOf('%')));
                                    if(width<values[i]){
                                        bars[i].style.width = (width+1)+'%';
                                    }
                                    else{
                                        bars.splice(i,1);
                                        values.splice(i,1);
                                        if(bars.length==0){
                                            clearInterval(AllIntervals["Asistant"]);
                                            AllIntervals["Asistant"] = undefined;
                                        }
                                    }
                                }
                            },20);
                        }
                    }
                }
                else if(Page.on({module:'finances'})){
                }
                else if(Page.on({module:'stadium'})){
                }
                else if(Page.on({module:'buildings'})){
                }
                else if(Page.on({module:'shop'})){
                    if(Features.IsActive("QuickShopping")){
                        $('#shop-content > .shop').each(function(){
                            var shop = this;
                            if($(shop).find('.shadow').length){
                                return;
                            }
                            var e = $('div.table-container',shop)[0].getElementsByClassName('multi');
                            for(var i = 0 ; i < e.length ; i++){
                                var k = e[i].getElementsByTagName('tbody')[0].getElementsByTagName('tr');
                                for(var j = 0 ; j < k.length ; j++){
                                    var t = k[j].getElementsByClassName('last-column order-quantity')[0];
                                    if(t!==undefined){
                                        if(t.getElementsByClassName('input-container')[0]!==undefined){
                                            var tk = t.innerHTML;
                                            var b = tk.indexOf('</span> / ')+7;
                                            var b1 = tk.indexOf('<span',b);
                                            var mi = tk.substring(b+3,b1).trim();
                                            t.innerHTML = tk.substring(0,b)+'<span class="TrOk disHighlight" style="cursor:pointer;"> / '+mi+'</span>'+tk.substring(b1);
                                            ClickTrOk(t.getElementsByClassName('TrOk')[0]);
                                        }
                                    }
                                }
                            }
                            var t = $('div.button-container > span.button.button-container-disabled.premium > a > span',shop)[0];
                            t.removeAttribute('class');
                            t.removeAttribute('tooltip');
                            t.removeAttribute('name');
                            t.style.cursor = 'pointer';
                            t.innerHTML = GetLocaleText('FillAll');
                            t.parentElement.removeAttribute('href');
                            $(t).click(function(){
                                var k = shop.getElementsByClassName('TrOk');
                                if(this.textContent==scriptTexts.FillAll){
                                    for(var i = 0 ; i < k.length ; i++){
                                        k[i].previousSibling.getElementsByTagName('input')[0].value = k[i].textContent.replace('/','').trim();
                                    }
                                    this.innerHTML=GetLocaleText('EmptyAll');
                                }
                                else{
                                    for(var i = 0 ; i < k.length ; i++){
                                        k[i].previousSibling.getElementsByTagName('input')[0].value = 0;
                                    }
                                    this.innerHTML=GetLocaleText('FillAll');
                                }
                            });
                            t = $('div.button-container > span:nth-child(3) > a > span',shop)[0];
                            t.innerHTML = GetLocaleText('Ordering');
                        });
                        function ClickTrOk(e){
                            $(e).click(function(){
                                var va = e.textContent.replace('/','').trim();
                                var t = e.previousSibling.getElementsByTagName('input')[0];
                                if(e.previousSibling.getElementsByTagName('input')[0].value!==va){
                                    t.value = va;
                                }
                                else{
                                    t.value=0;
                                }
                            });
                        }
                    }
                }
                else pageIsDetected=!1;
                break;
            case 3:
                if(Page.on({module:'rating'})){
                }
                else if(Page.on({module:'statistics',action:'season'})){
                    if(Features.IsActive("DownloadTable")){
                        printScreen('season-league-table',GetLocaleText('MatchResultsTable',null,!1));
                    }
                }
                else if(Page.on({module:'tournament',action:'history'})){
                }
                else if(Page.on({module:'statistics',action:'squadstrenght'})){
                    if(Features.IsActive("DownloadTable")){
                        printScreen('squad-strengths',GetLocaleText('SquadStrengthTable',null,!1));
                    }
                }
                else if(Page.on({module:'statistics',action:'goalgetter'})){
                    if(Features.IsActive("DownloadTable")){
                        printScreen('goalgetters',GetLocaleText('GoalScorerTable',null,!1));
                    }
                }
                else if(Page.on({module:'statistics',action:'sales'})){
                }
                else if(Page.on({module:'team',action:'history'})){
                }
                else pageIsDetected=!1;
                break;
            case 4:
                if(Page.on({module:'press'})){
                    if(Page.on({action:'index'})){/*Newspaper homepage*/
                    }
                    else if(Page.on({action:'article'})){/*Edit page*/
                        if(Features.IsActive("AddImage")){
                            $('#Toolbar_designArea > ul').append(
                                '<li class="" title="'+GetLocaleText('AddImage',null,!1)+'" style="cursor:pointer;" id="liAddImage" onmouseenter="'+
                                '$(\'#liAddImage\').attr(\'class\',\'hover\');" onmouseleave="$(\'#liAddImage\').attr(\'class\',\'\');">'+
                                '<img src="'+TOOL.sources.get('image','png')+'" alt="image" width="20px" height="20px"></li>');
                            $('#liAddImage').click(function(){
                                AddImageCodes($('#designArea')[0]);
                            });
                        }
                    }
                    else if(Page.on({action:'topnews'})){/*Topnew*/
                    }
                    else if(Page.on({action:'settings'})){/*Settings*/
                    }
                    else if(Page.on({action:'comment'})){/*Article*/
                    }
                }
                else if(Page.on({module:'friends'})){
                }
                else if(Page.on({module:'main',action:'neighbors'})){
                }
                else if(Page.on({module:'profile',action:'signatures'})){
                }
                else pageIsDetected=!1;
                break;
            case 5:
                if(Page.on({module:'premium'})){
                }
                else if(Page.on({module:'profile',action:'index'})){
                }
                else if(Page.on({module:'profile',action:'club'})){
                    if(Features.IsActive("AddImage")){
                        $('#Toolbar_profile-edit-club-information > ul').append(
                            '<li class="" title="'+GetLocaleText('AddImage',null,!1)+'" style="cursor:pointer;" id="liAddImage" onmouseenter="'+
                            '$(\'#liAddImage\').attr(\'class\',\'hover\');" onmouseleave="$(\'#liAddImage\').attr(\'class\',\'\');">'+
                            '<img src="'+TOOL.sources.get('image','png')+'" alt="image" width="20px" height="20px"></li>');
                        $('#liAddImage').click(function(){
                            AddImageCodes($('#profile-edit-club-information')[0]);
                        });
                    }
                }
                else if(Page.on({module:'profile',action:'show'})){
                    if(Page.on({clubId:TOOL.clubId}) || !Page.pr.clubId){
                    }
                    else{
                        if(Features.IsActive("InviteSimulationMatch")){
                            var matchId = $('#profile-show').find('.button-container-friendly-invite-button > a').attr('href');
                            var b = matchId.indexOf('invite=')+7;
                            matchId = matchId.substring(b,matchId.indexOf('&',b));
                            $('#profile-show').find('.profile-actions')[0].innerHTML+= "<a href='#/index.php?w="+worldId+"&area=user&module=simulation&action=index&squad=" + matchId + "' class='button'><span>"+GetLocaleText('InviteSimulation')+"</span></a>";
                        }
                    }
                    if(Features.IsActive("ShowEloRating")){
                        var clubName = $('#profile-show > h2:nth-child(1)').text().replace(TOOL.replaceClubName,'').trim();
                        $('#profile-show > div.container.profile-trophy > div.profile > ul.profile-box-club').append(
                            '<li><strong>'+GetLocaleText('EloRank')+' : </strong> <span class="icon details loading" id="SpanEloRating"></span></li>');
                        $.get('index.php?club=' + clubName + '&_qf__form=&module=rating&action=index&area=user&league=&path=index.php&layout=none',function(response) {
                            var html = document.createElement('html');
                            html.innerHTML = response.content;
                            var result = $(html).find('.odd');
                            $('#SpanEloRating')[0].className='';
                            if(result.length){
                                result = result[0];
                                var sıra = result.getElementsByTagName('td')[0].textContent;
                                $('#SpanEloRating').text(sıra);
                            }
                            else{
                                $('#SpanEloRating').css('color','gray');
                                $('#SpanEloRating').text('-');
                            }
                        });
                    }
                }
                else if(Page.on({module:'mail'})){
                }
                else if(Page.on({module:'tricotshop'})){
                }
                else pageIsDetected=!1;
                break;
        }
    }
    else{
        //Oyun menüsünde olmayan sayfalar buraya eklendi.
        if(Page.on({module:'live',action:'index'})){ //Canlı yayın index sayfası.
        }
        else if(Page.on({module:'live',action:'league'})){ //Canlı yayın lig maçları sayfası.
        }
        else if(Page.on({module:'live',action:'match'})){ //İzlenen canlı yayın maçı sayfası.
            if($('#match').length){//Match is exist
                // Add images
                $('#goal-event-container').after(
                    '<div style="display:none;" class="match event-container" id="DivCards">'+
                    '   <img src="'+TOOL.sources.get('yellowCard','png')+'" alt="yellowCard" style="display:none;" id="yellow_card">'+
                    '   <img src="'+TOOL.sources.get('redCard','png')+'" alt="redCard" style="display:none;" id="red_card">'+
                    '   <img src="'+TOOL.sources.get('yellowRedCard','png')+'" alt="yellowRedCard" style="display:none;" id="yellow_red_card">'+
                    '</div>'
                );

                // Add audios
                $('#goal-event-container').after(
                    '<div id="Songs">'+
                    '   <audio id="goalSound" src="https://static.wixstatic.com/mp3/fcacd5_2794b8a8827a475eaf9a3241be0c42d5.mp3"></audio>'+
                    '   <audio id="whistle1" src="https://static.wixstatic.com/mp3/fcacd5_4f0052fc29104ead86761cbb08d50774.mp3"></audio>'+
                    '   <audio id="whistle2" src="https://static.wixstatic.com/mp3/fcacd5_b967408abf59401d9b71778ea45ae2b9.mp3"></audio>'+
                    '   <audio id="whistle3" src="https://static.wixstatic.com/mp3/fcacd5_c4ccd759ec62404cb59f6a8ff906e110.mp3"></audio>'+
                    '   <audio id="backgroundSound" loop src="https://static.wixstatic.com/mp3/fcacd5_5a27a4e8ed2a482099ea0ba8839d4db9.mp3"></audio>'+
                    '   <audio id="fan1" loop src="https://static.wixstatic.com/mp3/fcacd5_d7123a0a3c2f469cbdf603067579de93.mp3"></audio>'+
                    '   <audio id="fan2" loop src="https://static.wixstatic.com/mp3/fcacd5_fde7b7b934d24cf98771cc022eb6bee3.mp3"></audio>'+
                    '</div>'
                );

                // Add Goals Container
                $('#match-messages').before(
                    '<div style="width: 840px;position: absolute;left: 65px;top: 101px;color:white;">'+
                    '   <div id="home-goals" style="float:left;width:48%;height:100%;text-align:center;overflow: auto;line-height:16px;height:38px;"></div>'+
                    '   <div id="away-goals" style="float:right;width:48%;height:100%;text-align:center;overflow: auto;line-height:16px;height:38px;"></div>'+
                    '</div>'
                );

                // Is this match own?
                currentLive.ownMatch = $('#'+currentLive.matchId +' h3 a[clubid="'+TOOL.clubId+'"]').length;

                //Background Sound is playing
                let backgroundSound = $('#backgroundSound')[0];
                backgroundSound.currentTime = 0;
                backgroundSound.volume = 0;
                backgroundSound.play();
                let times = [];
                for(let i = 1 ; i <= 50 ; i++){
                    ((i)=>{
                        let time = setTimeout(()=>{
                            if(!$('#backgroundSound').attr('stop')){
                                backgroundSound.volume = i/100;
                            }
                            else{
                                for(let j = 0 ; j < times.length ; j++){
                                    clearInterval(times[j]);
                                }
                            }
                        },(i-1)*50);
                        times.push(time);
                    })(i);
                }

                //Show or hide home/away team's players in field.
                for(let squadId in currentLive.players){
                    ((index,playersClass)=>{
                        let data = {
                            home:{
                                style:'position:absolute;Top:600px;',
                                id:"homePlayersFilter",
                                text:GetLocaleText('ShowHomeSquad')
                            },
                            away:{
                                style:"position:absolute;Top:600px;Right:20px;",
                                id:"awayPlayersFilter",
                                text:GetLocaleText('ShowAwaySquad')
                            }}[index],
                            e =
                            '<div style="'+data.style+'">'+
                            '   <input type="checkBox" id="'+data.id+'" checked="">'+
                            '   <label for="'+data.id+'" style="cursor:pointer;">'+data.text+'</label>'+
                            '</div>';
                        $('#formation-container').append(e);
                        if(index==="away"){
                            $('#match-handle-container').css('height',"36px");
                            $('#match-handle-container > li:first').css('height',"36px");
                        }
                        $('#'+data.id).click(function(){
                            var check = this.checked;
                            $('#field').find('.field-player').each(function(){
                                if($(this).hasClass(playersClass)){
                                    $(this)[check?'addClass':"removeClass"]('hover');
                                }
                            });
                        });
                    })(squadId == currentLive.homeId?"home":"away",squadId == currentLive.ownSquad?"own-player":"opponent");
                }
            }
        }
        else pageIsDetected=!1;
    }

    //Sayfanın düzeltildiği ana başlığa bildiriliyor.
    $('#content').find('h2').first().attr('Fixed',GetServerTime());

    //Sayfalarda çalışan özelliklerin olduğu tablo gösteriliyor
    Features.show();

    if(!pageIsDetected){
        $('#FeaturesOfScript').after('<p class="not-detected-info" style="color:red;font-weight:bold;text-align:center;border: 1px dotted gray;border-radius:7px;margin:10px 0"'+GetLocaleText('notdetected')+'"</p>');
    }
    else $('#ScriptMenu .not-detected-info').remove();
}

/*------------FUNCTIONS---------------*/
function GetPage(url,querySelector,success,fail=0){
    $.post(undefined, url, function(response) {
        let html = $('<html>').html(response),q;
        if((q = html.find('#'+querySelector)).length)
            success(q[0]);//sayfadaki istenilen bölümü fonksiyona vererek çağırıyor.
        else
            CatchError(querySelector+" not found.","GetPage > success");

        //Başka sayfalardan veri çekince güncel sayfadaki güvenlik numarası değişmiş oluyor.Bundan dolayı güncel sayfada post edildiğinde çalışmıyor.
        let newSecureId = $(html).find('input[name="secureId"][type="hidden"]');
        if(newSecureId.length)
            $('body').find('input[name="secureId"][type="hidden"]').val(newSecureId.first().val());
    }).fail(function(){
        if(++fail<3){
            setTimeout(function(){
                GetPage(url,querySelector,success,fail);
            },250);
        }
        else CatchError('Not success','GetPage > fail('+fail+')');
    });
}
function ShowDialog(div,header=undefined){
    $('#container > .shadow').show();

    let focus = $('<div>').attr('id',div.id || null).css({
        'padding'   : '15px',
        'width'     : '580px',
        'wordWrap'  : 'break-word',
        'textAlign' : 'center!important',
        'box-sizing': 'border-box'
    }).css(div.css || {}).addClass('focus visible').addClass(div.class || null).html(div.content || '');

    if(typeof header == 'object'){
        let h2 = $('<h2>').css(header.css || {}).html(header.content || '').css({
            width        : '100%',
            paddingLeft  : '0px',
            paddingRight : '0px',
            top          : '0px',
            transform    : 'translateY(-100%)'
        });
        focus.prepend(h2);
    }

    if(div.footer) focus.append('<div class="footer"></div>');

    if(div.close) focus.append('<div class="close" style="position:absolute;top:-46px"></div>');

    $('#container').append(focus);

    //Set In The Midst
    let topOffset = $(window).scrollTop() + ($(window).innerHeight() - focus.height()) / 2;
    if (topOffset < 190) topOffset = 190;
    focus.css({
        'position': 'absolute',
        'top'     : topOffset + 'px',
        'left'    : ($(window).scrollLeft() + ($(window).innerWidth() / 2) - (focus.width() / 2 + focus.parent().offset().left)) + 'px'
    });

    $('html, body').animate({ scrollTop: 0 }, 'fast');
}
function CreateButton(id,value,buttonStyle='',spanStyle=''){
    return ''+
        '<span class="button disHighlight" id="'+id+'" style="cursor:pointer;'+buttonStyle+'">'+
        '   <a class="button" style="text-decoration:none;">'+
        '      <span style="'+spanStyle+'">'+value+'</span>'+
        '   </a>'+
        '</span>';
}
function ReadTextFile(func){
    $('<input type="file" accept="text/plain">').change(function(e){
        let file = this.files[0];
        if (file.type == 'text/plain') {
            let reader = new FileReader();
            reader.onload = function(e) {
                func(reader.result);
            };
            reader.readAsText(file);
        }
    }).click();
}
function DownloadAsTextFile(text,filename){
    $('<a download="'+(filename||'Fcup Script Datas')+'.txt">').attr('href','data:text/plain,' + text.replace(/\n/g, "%0D%0A"))[0].click();
}
function GetDateText(ms){
    let d = new Date(ms);
    return TwoDigit(d.getDate())+"."+
        TwoDigit(d.getMonth()+1)+"."+
        d.getFullYear()+' '+
        TwoDigit(d.getHours())+":"+
        TwoDigit(d.getMinutes())+":"+
        TwoDigit(d.getSeconds());
}
function ShowCountDownTime(seconds){
    if(seconds<0) return '-';
    let minutes = 0,hours = 0,text='';
    if(seconds>59)
        if((minutes = parseInt(seconds/60))>59)
            if((hours = parseInt(minutes/60))>23)
                text = parseInt(hours/24)+' '+GetLocaleText(hours<48?'aDay':'Days')+' ';
    return text + TwoDigit(hours%24)+':'+TwoDigit(minutes%60)+':'+TwoDigit(seconds%60);
}
function IsYoungPlayer(td){
    return $(td).find('[tooltip="tt_extendNotPossibleJunior"]').length;
}
function TrainingControl(){
    function getElementOffsetWidth(e) {
        var element = $(e).clone().appendTo('body');
        var width = element.outerWidth();
        element.remove();
        return width;
    }
    let trainingPlan = TOOL.TrainingPlan,
        Positions = Object.values(TOOL.footballerPositions),
        SkillsName = scriptTexts.Skills;
    $('#players-table-skills > tbody > tr').each(function(){
        let position = $(this).find('td:nth-child(3)').text().trim(),
            developSkills = trainingPlan[Positions.findIndex(x => x==position)];// [0,1,3,6,8]
        if(!developSkills) return true;
        let skills = $(this).find('.skill-column');
        for(let i = 0 ; i < developSkills.length ; i++){//Geliştirilecek yetenek aranıyor
            let s = $(skills[developSkills[i]]).find('span');
            if(s.hasClass("maximum"))
                continue;//Bu geliştirilecek yetenek maksimumsa bir sonraki geliştirilecek yeteneğe bak.
            else if(s.hasClass("next-training"))
                break;//Bu geliştirilecek yetenek geliştirilmeye devam ediyorsa doğru yoldasın.
            else{//Bu geliştirilecek yetenek maksimum değil ve geliştirilmeye devam edilmiyorsa.Bir sıkıntı var.
                //Ya farklı bir yetenek geliştiriliyor yada hiçbir yetenek geliştirilmiyor.
                let skillName = SkillsName[developSkills[i]],
                    left = (getElementOffsetWidth(s[0])-15)/2,
                    value = s.text().trim(),
                    playerName = $(this).find('.player-name').text().trim();
                s.html(
                    '<img title="'+GetLocaleText('ImproveSkillTitle',[skillName],!1)+'!!!" src="'+TOOL.sources.get('here','gif')+'" alt="here" width="15px" height="15px" '+
                    'style="-webkit-transform: rotate(90deg);margin:-8px 0 0 '+left+'px;position:absolute;">'+value
                );
                if($(skills[0]).parent().find('span.next-training').length)
                    GiveNotification(false,GetLocaleText('FaultyTrainingMessage',[playerName,skillName.toLowerCase(),!1]));
                else
                    GiveNotification(true,GetLocaleText('TrainingMessage',[playerName,skillName.toLowerCase()],!1));
                break;
            }
        }
    });
}
function SaveLeagueData(cntnt,func=undefined){
    if(cntnt.find('.date-selector').length){
        var toplamLigHaftası = cntnt.find('.date-selector').find('.day').length;
        var t = $('div > div.table-container > h3',cntnt)[0].textContent;
        var b = t.indexOf(':')+1;
        var k = parseInt(t.substring(b,b=t.indexOf('-',b)));
        b++;
        var lastMatchDate = t.substring(b,t.indexOf(' ',t.indexOf('.',b))).trim().split('.');
        var addDay = toplamLigHaftası-k+(k<=(toplamLigHaftası/2)?3:0);
        lastMatchDate = new Date(lastMatchDate[2],parseInt(lastMatchDate[1])-1,parseInt(lastMatchDate[0])+addDay).getTime();
        var firstMatchDate = lastMatchDate-(toplamLigHaftası-1+3)*(24*60*60*1000);
        var firstHalfFinalMatchDate = firstMatchDate+(toplamLigHaftası/2-1)*(24*60*60*1000);
        var kulüpler = $('div > div.table-container > table > tbody',cntnt).find('.name-column');
        var _k={};
        var ts = false;
        for(var i = 0 ; i < kulüpler.length ; i++){
            var clubId = $(kulüpler[i]).find('a').attr('clubid');
            if(clubId!==TOOL.clubId){
                var clubName = $(kulüpler[i]).find('a').text().trim();
                _k[clubId]=clubName;
            }
            else{
                ts = true;
            }
        }
        if(ts){
            let LeagueData = {
                league                  : cntnt.find('select:first > option:selected').text().trim(),
                firstMatchDate          : firstMatchDate,
                firstHalfFinalMatchDate : firstHalfFinalMatchDate,
                lastMatchDate           : lastMatchDate,
                clubs                   : _k
            };
            SetCookie('LeagueData',LeagueData);
            if(func) func(LeagueData);
        }
    }
}
function FindNumberOfTraining(_tarih,tarih_){
    let Program1 =
        [
            {36000:1,54000:1},
            {36000:1,54000:1},
            {25200:1,36000:1,54000:1},
            {36000:1,54000:1}
        ],
        Program2 =
        [
            {25200:1},
            {},
            {},
            {}
        ];
    function antrenmanSayısıBul_(gün,s,t){
        var antrenman = 0;
        for(var saat in gün){
            if(saat>s==t?true:false){
                antrenman++;
            }
        }
        return antrenman;
    }
    var day = new Date(_tarih).getHours()*3600+new Date(_tarih).getMinutes()*60+new Date(_tarih).getSeconds();
    var dayIndex = parseInt((_tarih-new Date().getTimezoneOffset()*60*1000)/86400000)%4; // 0 === 2+premium , 1 = 2 antrenman , 2 === 3 antrenman , 3 === 2 antrenman
    var kalanNormalAntrenmanSayısı = antrenmanSayısıBul_(Program1[dayIndex],day,true);
    var kalanKrediliAntrenmanSayısı = antrenmanSayısıBul_(Program2[dayIndex],day,true);
    var tomorrow = new Date(new Date(_tarih).getFullYear(),new Date(_tarih).getMonth(),new Date(_tarih).getDate()+1).getTime();
    var dayDifference = tarih_-tomorrow;
    if(dayDifference>=0){
        dayDifference = parseInt((dayDifference)/86400000);
        dayIndex = (dayIndex+1)%4;
        kalanNormalAntrenmanSayısı += parseInt(dayDifference/4)*9;
        kalanKrediliAntrenmanSayısı += parseInt(dayDifference/4);
        dayDifference %= 4;
        for(var k = 0 ; k < dayDifference ; k++){
            kalanNormalAntrenmanSayısı += antrenmanSayısıBul_(Program1[dayIndex],dayIndex,true);
            kalanKrediliAntrenmanSayısı += antrenmanSayısıBul_(Program2[dayIndex],dayIndex,true);
            dayIndex = (dayIndex+1)%4;
        }
        day = new Date(tarih_).getHours()*3600+new Date(tarih_).getMinutes()*60+new Date(tarih_).getSeconds();
        kalanNormalAntrenmanSayısı += antrenmanSayısıBul_(Program1[dayIndex],day,false);
        kalanKrediliAntrenmanSayısı += antrenmanSayısıBul_(Program2[dayIndex],day,false);
    }
    else{
        day = new Date(tarih_).getHours()*3600+new Date(tarih_).getMinutes()*60+new Date(tarih_).getSeconds();
        kalanNormalAntrenmanSayısı -= antrenmanSayısıBul_(Program1[dayIndex],day,true);
        kalanKrediliAntrenmanSayısı -= antrenmanSayısıBul_(Program2[dayIndex],day,true);
    }
    return [kalanNormalAntrenmanSayısı,kalanKrediliAntrenmanSayısı];
}
function MaxValueOfSkill(currentValue,trainingScore,maxVal=990){
    let diff = maxVal-currentValue,
        maxvalue = currentValue,
        numberOfTrainings = 0;
    if(diff>0){
        numberOfTrainings = Math.floor(diff/trainingScore);
        if(diff>numberOfTrainings*trainingScore) ++numberOfTrainings;
        maxvalue = currentValue+numberOfTrainings*trainingScore
    }
    return {
        "maxvalue":maxvalue,
        "numberOfTrainings":numberOfTrainings
    };
}
function CalculateFutureStrength(currentSkills,numberOfTrainings,trainingScore,position,maxVal=990){
    let TrainingRankingOfSkills = TOOL.TrainingPlan[Object.values(TOOL.footballerPositions).findIndex(x=>x==position)], // [9,6,3,7,8,10,5]
        nextSkills = currentSkills.slice(0);

    for(let i = 0 ; i < TrainingRankingOfSkills.length && numberOfTrainings>0 ; i++){//[9,6,3,7,8,10,5]
        let skillIndex = TrainingRankingOfSkills[i],
            value = nextSkills[skillIndex];
        if(value>=maxVal)//Bir sonraki yeteneği geliştir.
            continue;
        let result = MaxValueOfSkill(value,trainingScore,maxVal);
        if(result.numberOfTrainings <= numberOfTrainings){
            value = result.maxvalue;
            numberOfTrainings -= result.numberOfTrainings;
        }
        else{
            value+=numberOfTrainings*trainingScore;
            numberOfTrainings = 0;
        }
        nextSkills[skillIndex] = value;
    }
    let currentStrength = GetRealStrength(currentSkills,position),
        nextStrength    = GetRealStrength(nextSkills,position);
    return {
        currentStrength : typeof currentStrength == "number" ? currentStrength.toFixed(2) :currentStrength,
        nextStrength    : typeof nextStrength == "number" ? nextStrength.toFixed(2) : nextStrength,
        nextSkills      : nextSkills.slice(0)
    };
}
function GetRealStrength(skills,position){
    let Positions = TOOL.footballerPositions,
        StrengthFactorsOfPositions = {
            ["/"+Positions.Position1+"/"]:[{"0":5},{"1":5},{"3":4},{"8":3},{"6":2},{"10":1},{"4":1},{"2":1}],
            ["/"+Positions.Position2+"/"+Positions.Position3+"/"+Positions.Position4+"/"]:[{"6":4},{"9":4},{"3":3},{"8":2},{"10":2},{"4":2},{"5":2},{"7":2},{"11":2},{"2":1}],
            ["/"+Positions.Position5+"/"+Positions.Position6+"/"]:[{"3":4},{"10":4},{"8":3},{"5":3},{"6":2},{"4":2},{"7":2},{"9":2},{"11":2},{"2":1}],
            ["/"+Positions.Position7+"/"+Positions.Position8+"/"]:[{"11":4},{"3":3},{"8":3},{"10":3},{"2":3},{"6":2},{"4":2},{"5":1},{"7":1},{"9":1}]
        },
        StrengthFactors = Object.values(StrengthFactorsOfPositions)[Object.keys(StrengthFactorsOfPositions).findIndex(x=>x.indexOf('/'+position+'/')!=-1)];
    Positions = StrengthFactorsOfPositions = undefined;
    if(!StrengthFactors) return "-";

    let strength = 0,
        _skills = [],
        factors = [],
        skillIndex,
        factor,
        value;
    StrengthFactors.map(function(obj){
        _skills.push(Object.keys(obj)[0]);
        factors.push(Object.values(obj)[0]);
    });
    StrengthFactors = undefined;
    for(let i = 0; i < _skills.length ; i++){
        skillIndex = _skills[i];
        factor = factors[i];
        value = skills[skillIndex];
        strength += value/28*factor;
    }
    return strength;
}
function printScreen(tableName,fileName){
    if(!$('#html2canvas').length)
        $('head').append('<script id="html2canvas" type="text/javascript" src="https://html2canvas.hertzen.com/dist/html2canvas.min.js">');
    if(!$('#pntScrnButton').length){
        $('#'+tableName+' > tfoot > tr > td').html(
            '<img id="pntScrnButton" src="'+TOOL.sources.get('printscreen','png')+'" alt="printscreen" height="30px" style="cursor:pointer;" title="'+GetLocaleText('DownloadTable',null,!1)+'">'
        );
        $('#pntScrnButton').click(function(){
            $('#pntScrnButton').hide().after('<span class="load-icon loading" style="float:none;margin:0 auto;"></span>');
            $('#'+tableName).css('background','#6e9a5a url(images/layout/box_bg.gif) 0 -200px repeat-x');
            html2canvas(document.querySelector('#'+tableName)).then(function(canvas) {
                $('<a download="'+fileName+'.png">').attr("href", canvas.toDataURL())[0].click();
                $('#pntScrnButton').show().next().remove();
            });
        });
    }
}
function AddImageCodes(a){
    let txt = prompt(GetLocaleText('EnterImageLink',null,!1) + ' :', "");
    if (!txt || !(txt=txt.trim())) return;
    let intStart = a.selectionStart,
        img = new Image();
    img.onload = function() {
        txt = '[color=rgb(255, 255, 255);background-image: url('+txt+');width:'+this.width+'px;height:'+this.height+'px;display:block;overflow:visible;margin:0 auto;][/color]';
        a.value = String(a.value).substring(0, intStart) + txt + String(a.value).substring(a.selectionEnd);
        a.selectionStart = intStart;
        a.selectionEnd = intStart+txt.length;
        a.focus();
    };
    img.src = txt;
}
function CatchError(e,where){
    console.log('%c[FCUP-SCRİPT] %cERROR%c | '+ e + '%c\tIn'+where,'color:blue;font-weight:bold;','color:red;','','float:right;color:green;');
}
function SetCookie(key,data){
    GM_setValue(TOOL.server+'_'+key,data); //(tr_clubDatas,data)
}
function GetCookie(key,defaultValue=undefined){
    return GM_getValue(TOOL.server+'_'+key,defaultValue);
}
function DeleteCookie(key){
    GM_deleteValue(TOOL.server+'_'+key);
}
function GiveNotification(NotificationType,Text){
    $('#feedback').prepend(
        '<p class="'+(NotificationType==true?'notice':'error')+'" style="left: 0px;'+(NotificationType?'background:#1ba0de;border: 1px solid #000000;':'')+'">'+
           '<span class="icon"></span>'+Text+
        '</p>'
    );
    $('#feedback p:not(.minified)').each(function (a,e) {
        $(e).css('left',($(document).width() - $(e).outerWidth()) / 2);
        setTimeout(()=>{
            $(e).addClass('minified').css({left : 0});
        },4000);
    });
    $('#feedback p').each(function (key) {
        if (key > 19) {
            $(this).slideUp(function() {
                $(this).remove();
            });
        }
    });
}
function PageLoad(func){
    setTimeout(function(){
        if(!$('#body').hasClass('loading')) func();
        else{
            let a = setInterval(function(){
                if(!$('#body').hasClass('loading')){
                    clearInterval(a);
                    func();
                }
            },50);
        }
    },10);
}
function TwoDigit(a){
    return (a<10?"0":"")+a;
}
function GetServerTime(){//return ms
    return TOOL.serverTimeR+new Date().getTime();
}
function BlinkEvent(e,duration,duration2=2500,times=5){
    times = Math.max(times,1);
    if(e.attr('BlinkEvent')!=undefined){
        if(e.attr('BlinkEvent')!=0){
            e.attr('BlinkEvent',times);
            return;
        }
        else
            e.attr('BlinkEvent',times);
    }
    e.attr('BlinkEvent',times);
    e.css('background-color','#910e0ea8');
    f();
    let blink = setInterval(f, duration);
    function f(){
        e.fadeOut(duration/2);
        e.fadeIn(duration/2);
        let times = parseInt(e.attr('BlinkEvent'))||1;
        e.attr('BlinkEvent',--times);
        if(times<1){
            clearInterval(blink);
            setTimeout(()=>{
                if(e.attr('BlinkEvent')==0){
                    e.css('transition','background-color 1s').css('background-color','');
                    setTimeout(()=>{
                        if(e.attr('BlinkEvent')==0){
                            e.css('transition','');
                            e.removeAttr('BlinkEvent');
                        }
                    },1000);
                }
            },duration2);
        }
    }
}
function FixCookies(cookiesList){
    let cookieKey,cookieName,find,server;
    for(let i = 0 ; i < cookiesList.length ; i++){
        cookieKey = cookiesList[i];
        if((find = cookieKey.indexOf('_')) == -1) server = null;
        else server = cookieKey.substring(0,find);

        let deleteCookie = !1;
        switch(cookieName = cookieKey.substring(find+1)){
            case 'clubDatas':
                let clubDatas = GM_getValue(cookieKey);
                if(typeof clubDatas == 'object'){
                    if(clubDatas.trainingProgram!=undefined){
                        delete clubDatas.trainingProgram;
                        GM_setValue(cookieKey,clubDatas);
                    }
                }
                else deleteCookie = !0;
                break;
            case 'LeagueData':
                let LeagueData = GM_getValue(cookieKey);
                if(typeof LeagueData == 'object' && !$.isEmptyObject(LeagueData)){
                    if(LeagueData.hasOwnProperty('IlkMacTarihi')){
                        LeagueData.firstMatchDate = LeagueData.IlkMacTarihi;
                        LeagueData.firstHalfFinalMatchDate = LeagueData.IlkYarıSonMacTarihi;
                        LeagueData.lastMatchDate = LeagueData.SonMacTarihi;
                        LeagueData.league = LeagueData.lig;
                        delete LeagueData.IlkMacTarihi;
                        delete LeagueData.IlkYarıSonMacTarihi;
                        delete LeagueData.SonMacTarihi;
                        delete LeagueData.lig;
                        GM_setValue(cookieKey,LeagueData);
                    }
                }
                else deleteCookie = !0;
                break;
            /*case 'ClubExchange':
                let ClubExchange = GM_getValue(cookieKey);
                if(typeof ClubExchange == 'object' && !$.isEmptyObject(ClubExchange)){
                    for(let PlayerId in ClubExchange){
                        let date = ClubExchange.date; //03.02.2019
                    }
                }
                else deleteCookie = !0;
                break;
            case 'YoungPlayers':
                let YoungPlayers = GM_getValue(cookieKey);
                if(typeof YoungPlayers == 'object'){

                }
                else deleteCookie = !0;
                break;*/
            case 'AutomaticTraining':
                deleteCookie = !0;
                break;
            case 'PlayersHealth':
                deleteCookie = !0;
                break;
            case 'SquadsStrength':
                deleteCookie = !0;
                break;
            case 'FeaturesOfScript':
                let features = GM_getValue(cookieKey);
                if(typeof features == 'object'){
                    let changed = 0;
                    if(features.PlayersHealth){
                        delete features.PlayersHealth;
                        changed++;
                    }
                    /*
                    ...
                    */
                    if(changed){
                        if($.isEmptyObject(features)) deleteCookie = !0;
                        else GM_setValue(cookieKey,features);
                    }
                }
                break;
        }
        if(deleteCookie){
            GM_deleteValue(cookieKey);
            cookiesList.splice(i--,1);
        }
    }
    return cookiesList;

}