(function ($) {
    $.goals = function () {


        //  1.  First create the goals in GetClicky 
        //  2.  Fill in the goal ID's in this script
        //  3.  Upload the script
        //  4.  Add the following to the head section, just before the </head> tag:
        //      <script src="../DIR/goals.js" type="text/javascript"></script>
        //      <script type="text/javascript">$(document).ready(function() {$.goals();});</script>



        var host_id = window.location.hostname;
        if (host_id == 'www.australian-casinos-online.com') {
            var as_id = '668';         // AS traffic
            var aj_id = '669';         // AJ traffic
            var wj_id = '670';         // WJ traffic

            var as_exe_id = '682';     // AS exe
            var aj_exe_id = '683';     // AJ exe
            var wj_exe_id = '684';     // WJ exe

            var ayb_id = '685';        // AYB traffic
        }

        else if (host_id == 'www.canadian-casinos-online.com') {
            var as_id =  ' 671';         // AS traffic
            var aj_id = '672';         // AJ traffic
            var wj_id = '673';         // WJ traffic

            var as_exe_id = '678';     // AS exe
            var aj_exe_id = '679';     // AJ exe
            var wj_exe_id = '680';     // WJ exe

            var ayb_id = '681';        // AYB traffic
        }

        else if (host_id == 'www.onlinecasinosrealmoney.com') {
            var as_id = '696';         // AS traffic
            var aj_id = '697';         // AJ traffic
            var wj_id = '698';         // WJ traffic

            var as_exe_id = '708';     // AS exe
            var aj_exe_id = '709';     // AJ exe
            var wj_exe_id = '710';     // WJ exe

            var ayb_id = '711';        // AYB traffic
        }

        else if (host_id == 'www.casinoswelt.com') {
            var as_id = '749';         // AS traffic
            var aj_id = '750';         // AJ traffic
            var wj_id = '751';         // WJ traffic

            var as_exe_id = '757';     // AS exe
            var aj_exe_id = '758';     // AJ exe
            var wj_exe_id = '759';     // WJ exe

            var ayb_id = '760';        // AYB traffic
        }

        else if (host_id == 'www.mobilejackpots.com') {
            var as_id = '674';         // AS traffic
            var aj_id = '675';         // AJ traffic
            var wj_id = '676';         // WJ traffic

            var as_exe_id = '686';     // AS exe
            var aj_exe_id = '687';     // AJ exe
            var wj_exe_id = '688';     // WJ exe

            var ayb_id = '689';        // AYB traffic
        }





        // DO NOT EDIT ANYTHING BELOW HERE

        //AS
        var regexp_1 = /http:\/\/\w*\.allslotscasino\.com\/[Aa]ll[Ss]lots\.exe/;
        var regexp_2 = /http:\/\/\w*\.allslotscasino\.com\/\w*\.\w*/;
        var regexp_3 = /http:\/\/\w*\.allslotscasino\.com/;

        //AJ
        var regexp_4 = /http:\/\/\w*\.alljackpotscasino\.com\/[Aa]ll[Jj]ackpots\.exe/;
        var regexp_5 = /http:\/\/\w*\.alljackpotscasino\.com\/\w*\.\w*/;
        var regexp_6 = /http:\/\/\w*\.alljackpotscasino\.com/;

        //WJ
        var regexp_7 = /http:\/\/\w*\.wildjackcasino\.com\/[Ww]ild[Jj]ack\.exe/;
        var regexp_8 = /http:\/\/\w*\.wildjackcasino\.com\/\w*\.\w*/;
        var regexp_9 = /http:\/\/\w*\.wildjackcasino\.com/;

        //AYB
        var regexp_10 = /http:\/\/\w*\.allyoubet\.com\/\w*\.\w*/;
        var regexp_11 = /http:\/\/\w*\.allyoubet\.com/;

        var revenue = '1';

            if ((as_id != undefined) && (as_exe_id != undefined)) {
                $("a").filter(
                    function () {
                        if ($(this).attr('href') != undefined) {
                            if (regexp_1.test($(this).attr('href'))) {
                                $(this).addClass('AS-exe');
                                $(this).click(function () {
                                    clicky.goal(as_exe_id, revenue);
                                });
                            }
                            else if (regexp_2.test($(this).attr('href')) || regexp_3.test($(this).attr('href'))) {
                                $(this).addClass('AS-traffic');
                                $(this).click(function () {
                                    clicky.goal(as_id, revenue);
                                });
                            }
                        }
                });
            }

            if ((aj_id != undefined) && (aj_exe_id != undefined)) {
                $("a").filter(
                function () {
                    if ($(this).attr('href') != undefined) {
                        if (regexp_4.test($(this).attr('href'))) {
                            $(this).addClass('AJ-exe');
                            $(this).click(function () {
                                clicky.goal(aj_exe_id, revenue);
                            });
                        }
                        else if (regexp_5.test($(this).attr('href')) || regexp_6.test($(this).attr('href'))) {
                            $(this).addClass('AJ-traffic');
                            $(this).click(function () {
                                clicky.goal(aj_id, revenue);
                            });
                        }
                    }
                });
            }

            if ((wj_id != undefined) && (wj_exe_id != undefined)) {
                $("a").filter(
                function () {
                    if ($(this).attr('href') != undefined) {
                        if (regexp_7.test($(this).attr('href'))) {
                            $(this).addClass('WJ-exe');
                            $(this).click(function () {
                                clicky.goal(wj_exe_id, revenue);
                            });
                        }
                        else if (regexp_8.test($(this).attr('href')) || regexp_9.test($(this).attr('href'))) {
                            $(this).addClass('WJ-traffic');
                            $(this).click(function () {
                                clicky.goal(wj_id, revenue);
                            });
                        }
                    }
                });
            }

            if (ayb_id != undefined) {
                $("a").filter(
                function () {
                    if (regexp_10.test($(this).attr('href')) || regexp_11.test($(this).attr('href'))) {
                        $(this).addClass('AYB-traffic');
                        $(this).click(function () {
                            clicky.goal(ayb_id, revenue);
                        });
                    }
                });
            }
    }
})(jQuery);
