﻿var exit = true;

$(function() {
    $('.tooltip').hover(function() {
        $(this).addClass('showTooltip');
    },
    function() {
        $(this).removeClass('showTooltip');
    });
   
    
    $("a").click(function() {
        exit = false;
    });
$("area").click(function() {
        exit = false;
    });

if (window.location.href.toLowerCase().indexOf('sitefinity') < 0 &&window.location.href.toLowerCase().indexOf('unsubscribe.aspx') < 0)
{
    window.onbeforeunload = function() {
        exitwindow();
    }
	$().submit(function() {
        exit = false;
    });
}


$(".MPVCompletedTournaments .MPVTournament").click(function() {
        $(".MPVWinners").hide('fast');
        $(this).parent().children(".MPVWinners").show('fast');
    });

	
if (location.href.indexOf("Download-Assist.aspx") != -1)
	$("#divDownloadHelper").show("slow");

});

function exitwindow() {	
	if (location.href.toUpperCase().indexOf('SITEFINITY') > -1) return;
	if (location.href.toUpperCase().indexOf('RESPONSIBLE-GAMING') > -1) return;
	if (location.href.toUpperCase().indexOf('SELF-ASSESSMENT-TEST') > -1) return;
	if (window.location.href.toLowerCase().indexOf('unsubscribe.aspx') > 0) return;
    if (exit) {
        //if (window.location.href.toUpperCase().indexOf('BINGO') > -1) {
        //    var url = 'http://www.piggspeak.co.sz/ExitPop-Bingo.aspx';
        //    var win = 'toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,width=600,height=600';
       // }
        //else {
            var url = 'http://www.piggspeak.co.sz/ExitPop-PiggsPeak.aspx';
            var win = 'toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,width=880,height=550';
        //}
        window.open(url, 'Exciting_Offers', win);
    }
}

//BTag transfer code
$(function() {
    $.expr[':'].external = function(obj) {
        var h = obj.href.toUpperCase();
        return (obj.hostname != location.hostname) && (h.indexOf('BTAG=') == -1) && (h.indexOf('HTTP://') != -1);
    };

    $('a:external, area:external').each(function() {
        var btag = $("#btagspan").text();
	var url = this.href;
        var prefix = "&";
        if (this.href.indexOf("?") == -1) prefix = "?";
	if (this.href.indexOf("btag1") == -1)
		url += prefix + "btag1=" + btag;
        url += "&bTag=" + btag;
	
//alert(url);
	$(this).attr("href", url);
    });
});