﻿function launchCenter(url, name, height, width) 
{      
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    str += ",location=0,status=1,scrollbars=1,toolbars=0,resize=1";
  }
  var urlWithoutSingleQuote = replaceIt(url, "singlequote", "'");
  return window.open(urlWithoutSingleQuote, name, str);
}

function replaceIt(sString, sReplaceThis, sWithThis) 
{ 
   if (sReplaceThis != "" && sReplaceThis != sWithThis) 
   { 
      var counter = 0; 
      var start = 0; 
      var before = ""; 
      var after = ""; 
      while (counter<sString.length) { 
         start = sString.indexOf(sReplaceThis, counter); 
         if (start == -1) { 
           break; 
         } 
         else { 
            before = sString.substr(0, start); 
            after = sString.substr(start + sReplaceThis.length, sString.length); 
            sString = before + sWithThis + after; 
            counter = before.length + sWithThis.length; 
         } 
      } 
  } 
  return sString; 
} 