
//var exp = 0;   // the number at the left reflects the number of days for the cookie to last
               // modify it according to your needs

function newCookie(name,value,days) {
 if (days) {
   var date = new Date();
   date.setTime(date.getTime()+(days*24*60*60*1000));
   var expires = "; expires="+date.toGMTString(); 
   //alert(days);
   }
   else var expires = "";
   document.cookie = name+"="+value+expires+"; path=/"; }

   
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1) { 
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 popup_withcookie(url,width,height,exp,cookiename) {
  var num = get_cookie(cookiename)
  // alert('popup ' + num)
  if ((num < 1) || (exp==-1)) { 
  newCookie(cookiename,'1', exp);
 SW=window.open(url,'NewWin','toolbar=no,status=no,width=' + width + ',height=' + height + ',scrollbars=no,modal=yes')
 //SW.moveTo(190,240); 
 }
}
