var defaultCookieTime = 60; //one day by default (set in terms of minutes)
jQuery(document).ready(function()    { //js code to be executed on page load completed.
if(jQuery.cookie('sreqshown')==null)    { //if cookie is not set yet, means this is where we know that this is the first ever visit of this user and we will show him/her sliding box with some content
var ww = jQuery(window).width(); //get width of the web page window
var ppw = jQuery("#popupslider").width(); //get width of sliding box
var leftm = (ww-ppw)/2; //do half of it, resulting "leftm" is the left margin needed to place the box in center of page horizontally

jQuery("#popupslider").animate({opacity: "1", left: "0" , left: leftm}, 1000).show(); //using animate method of jQuery to load pop up on page load. The box starts sliding from the far left and slides until it reaches the middle position of page we just calculated above (see leftm)
jQuery("#popup").show();
var activeCookieTime = new Date(); //creating date object
activeCookieTime.setTime(activeCookieTime.getTime() + (defaultCookieTime * 60 * 1000)); //setting cookie time using previously set variable "defaultCookieTime" which is measured in minutes. So for a day it is 1440.
jQuery.cookie('sreqshown', true, { expires: activeCookieTime, path: '/' }); //setting the cookie now
}

jQuery("#closepp").click(function() { //we usually include a "Close" link within the sliding box so user could close this box if he/she wanted to do so.
jQuery("#popupslider").animate({opacity: "hide", left: "0"}, 1000).show(); //when user clicks "Close" it reverse the sliding animation to make the box disappear sliding from right to left.
jQuery("#popup").animate({opacity: "hide"}, 500).show();
});
});
