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 loadornot(popupurl, popupcookiename, iwidth, iheight, applycoockie)
{
    //alert('height=' + iheight);
    if (get_cookie(popupcookiename)=='')
    {
        //alert('hi in cookie is not here');
        loadpopup(popupurl, popupcookiename, iwidth, iheight, applycoockie);
        document.cookie=""+popupcookiename+"=yes"
    }
    else
    {
        //alert('not in coockie is there')
        if(applycoockie == 0)
        {
            loadpopup(popupurl, popupcookiename, iwidth, iheight, applycoockie);
            document.cookie=""+popupcookiename+"=yes"
        }
    } 
}
function loadpopup(popupurl, popupcookiename, iwidth, iheight)
{
    //alert('height=' + iheight);
    var width = screen.availWidth;
    var height = screen.availHeight;
    var screenX;
    var screenY;
    screenX = width / 2 - (iwidth/2);
    screenY = height / 2 - (iheight/2);
        
        if (screenX < 0)
        {
          screenX = 0
        }
        
        if (screenY < 0)
        {
          screenY = 0
        }
    var value='';
    //alert('height=' + iheight);
    win2=window.open(popupurl,popupcookiename,"width=" + iwidth + ",height=" + iheight + ",scrollbars=yes,location=yes,status=yes,screenX=" + screenX + ",left=" + screenX + ",screenY=" + screenY + ",top=" + screenY);
    win2.focus()
}


