
    // Sliding Popup Script http://karlagius.com/2009/02/08/creating-a-sitepoint-like-sliding-popup-in-jquery/
    function SlidingPopup(clickherebuttonheight, duration, delay, cookiename, cookielifetime) {

        //Exit if the browser is not supported (IE6).
       if (IsUnsupportedUserAgent())return;

        $(document).ready(function() {
                  var rect = document.body.getBoundingClientRect();
                    var zoomLevel = (rect.right - rect.left) / document.body.clientWidth;
            //var leftposition = ($(".promo table").width() - $("#sliding_popup").width()) / 2
          //var leftposition = ($(".promo").outerWidth() - $("#sliding_popup").width()) / 2
          var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
 winW = document.body.offsetWidth;
 winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 winW = document.documentElement.offsetWidth;
 winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
 winW = window.innerWidth;
 winH = window.innerHeight;
}


          $("#sliding_popup").css({ "display": 'block' })
         // var showleftposition = -1 * (winW - $(".promo").outerWidth() - $(".SlidingPopup").width())/(2 * (screen.width / winW) * (screen.width / winW))
         var showtopposition = ($(window).height() - $("#sliding_popup").height())/(5 * (screen.width / winW) * (screen.width / winW))
         var showleftposition = 0 
         var leftposition = -1 * ($(".promo").outerWidth() - $(".SlidingPopup").width())/2 + 5
         if (navigator.appName == 'Microsoft Internet Explorer')
         {
       		leftposition =  -1 * $(".promo").outerWidth()/2 + 5
         	showleftposition =  -1 * ($(".promo").outerWidth() - $(".SlidingPopup").width())/2 
         }
            var heightposition = clickherebuttonheight - $(".SlidingPopup").height()
            //alert(navigator.appName)
            //alert(leftposition)
            var popup = $("#sliding_popup")
                .css({ "top": heightposition })
                .css({ "left": leftposition })
                .height(0).show()
            if (NotReceivedPopup(cookiename)) {
                popup.css({ "left": leftposition })
                ShowPopup(cookiename, cookielifetime, popup, duration, showleftposition,showtopposition);
                HidePopup(heightposition, duration, delay, leftposition);
               
            }

        });
    }

    function ShowPopup(cookiename, cookielifetime, popup, duration, showleftposition, showtopposition) {
        popup.show().animate({ top: showtopposition  ,left: showleftposition}, duration * 1.5);
        ReceivedPopup(cookiename, cookielifetime);
        
    }

    function NotReceivedPopup(cookiename) {
        return document.cookie.indexOf(cookiename) < 0;
    }

    function ReceivedPopup(cookiename, cookielifetime) {

        var cookie_date = new Date();  // current date & time
        var milli = cookie_date.getMilliseconds() + cookielifetime;
        cookie_date.setMilliseconds(milli);
        cookie_date.setTime(cookie_date.getTime());

        //    var date = new Date();
        //    date.setDate(date.getDate() + cookielifetime);
        document.cookie = cookiename + "=true;expires=" + cookie_date.toUTCString() + ";path=/";
        //document.cookie = cookiename + "=true;expires=;path=/";
    }

    function IsUnsupportedUserAgent() {
        return (!window.XMLHttpRequest);
    }
    function HidePopup(heightposition, duration, delay, leftposition) {

        var destroy = function() { $("#sliding_popup").animate({ top: heightposition , left: leftposition }, duration, function() { $("#sliding_popup").show(); }) };
        self.setTimeout(destroy, delay);
        
    }


