$.getScript = function(url, callback){
    $.ajax({
        type: "GET",
        url: url,
        success: callback,
        dataType: "script",
        cache: true
    });
};
/* cart check */
$.getScript("/_js/jquery.cooquery.min.js", function(){
    //check for cookie
    var value = $.readCookie('dfg_tm_cart');
    if( value == '1' )
        $('#tm_cart_link').show();
});

function loadScript(context, url_title){

    if (context == "PP1" || "PP2") {
        $.getScript("/scripts/jquery.cycle.all.min.js");
        $.getScript("/scripts/image.autosize.js");
        $.getScript("/_js/dfg_pp.js");
    }

    if (context == "T1") {
        $.getScript("/scripts/jquery.cycle.all.min.js");
        $.getScript("/scripts/image.autosize.js");
    }

    switch (context) {
        case 'CatIndex':
            moveCatIndexAds();
            catTips();
            break;
        case 'Home':
            moveHomeWid();
            break;
        case 'PP1':
            $.preloadImages (
                'http://cdn2.download-free-games.com/imgs/prod/screens/'+url_title+'_1_m.jpg',
                'http://cdn2.download-free-games.com/imgs/prod/screens/'+url_title+'_2_m.jpg',
                'http://cdn2.download-free-games.com/imgs/prod/screens/'+url_title+'_3_m.jpg'
                );

            /*
            $.getScript("/_js/jcarousellite_1.0.1.min.js", function(){
                $("#cat-feat").jCarouselLite({
                    circular: true,
                    scroll: 4,
                    visible: 4,
                    btnNext: ".next",
                    btnPrev: ".prev"
                });
            });
            */
            break;
        case 'PP2':
                $.preloadImages (
                    'http://cdn2.download-free-games.com/imgs/prod/screens/'+url_title+'_1_m.jpg',
                    'http://cdn2.download-free-games.com/imgs/prod/screens/'+url_title+'_2_m.jpg'
                    );
            /*
            $.getScript("/_js/jcarousellite_1.0.1.min.js", function(){
                $("#cat-feat").jCarouselLite({
                    circular: true,
                    scroll: 4,
                    visible: 4,
                    btnNext: ".next",
                    btnPrev: ".prev"
                });
            });
            */
            break;
        case 'UtilIndex':
            moveCatIndexAds();
            break;
        default:
            break;
    }
}
/* movers */
function moveCatIndexAds(){
    $('#test-ss').appendTo('#cat-top-wid');
    $('#wid-addthis').appendTo('#cat-key');
}
function moveHomeWid(){
    $("#test-ss").appendTo("#home-sb");
}

/* general */
function platpopup(popurl){
    var winpops=window.open(popurl,"","width=440,height=440,scrollbars,resizable");
}
function smpopup(popurl){
    var winpops=window.open(popurl,"","width=440,height=340,scrollbars,resizable");
}
//xe currency convertor
function xeccwindow(price_usd) {
    XECurrencyWindow = window.open ('', 'XECurrencyWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=200,width=620');
    XECurrencyWindow.focus();
    XECurrencyWindow.location.href = 'http://www.xe.com/pca/input.php?Amount='+price_usd+'&FromSelect=USD';
}
function openpopup(popurl){
    var winpops=window.open(popurl,"","width=480,height=370,status,scrollbars,resizable")
}
/* CatIndex ClueTips */
function catTips(){
$('a.tips').cluetip({
            splitTitle: '|', // use the invoking element's title attribute to populate the clueTip...
            // ...and split the contents into separate divs where there is a "|"
            showTitle: true, // hide the clueTip's heading
            clickThrough: true,
            waitImage: false
        });
}

/* TryMedia Cart Cookie Code */
$('.tm-order').click(function(){
    $.setCookie('dfg_tm_cart', '1', {
        duration: 0, // in days
        path : '/',
        domain : 'download-free-games.com',
        secure : false
    });
});
