
var sPath = window.location.pathname;

var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

if(sPage != 'mobile_voip')
{

    //Pop-under window- By JavaScript Kit
    //Credit notice must stay intact for use
    //Visit http://javascriptkit.com for this script

    //specify page to pop-under
    var popunder="/mobile_voip";

    if (screen)
    {
        var width = screen.width;
        var height = screen.height;
    }
    //specify popunder window features
    //set 1 to enable a particular feature, 0 to disable
    var winfeatures="location=1,resizable=yes,scrollbars=yes,fullscreen=yes,width="+width+",height="+height;

    //Pop-under only once per browser session? (0=no, 1=yes)
    //Specifying 0 will cause popunder to load every time page is loaded
    var once_per_session=1;

    ///No editing beyond here required/////

    function get_cookie(Name) {
        var search = Name + "="
        var returnvalue = "";

        if (document.cookie.length > 0) {
            offset = document.cookie.indexOf(search)
            if (offset != -1) { // if cookie exists
                offset += search.length
                // set index of beginning of value
                end = document.cookie.indexOf(";", offset);
                // set index of end of cookie value
                if (end == -1)
                    end = document.cookie.length;
                returnvalue=unescape(document.cookie.substring(offset, end))
            }
        }
        return returnvalue;
    }

    function loadpopunder(){
        win2=window.open(popunder,"MobileVoip",winfeatures);
        if (win2)
        {
            win2.blur();
            window.focus();
        }
    }

    /* disable popunder*/
    /*
    $(document).ready(function() {
        $('a').click(function(){
            if($(this).attr('href') == "/mobile_voip")
            {
                var cookieExpireTime = new Date();
                cookieExpireTime.setTime(cookieExpireTime.getTime() + (1000 * 60 * 60 * 24 * 30)); // 30 days expire time
                document.cookie = "popunder=yes; expires=" + cookieExpireTime.toGMTString() + '; path=/;';
            }
        });

        $('body').click(function() {
            if (get_cookie('popunder')=='')
            {
                var cookieExpireTime = new Date();
                cookieExpireTime.setTime(cookieExpireTime.getTime() + (1000 * 60 * 60 * 24 * 30)); // 30 days expire time
                document.cookie = "popunder=yes; expires=" + cookieExpireTime.toGMTString() + '; path=/;';
                loadpopunder();
            }
        });
    });
    */
}
