﻿function centerWindow(page, w, h) {

    //numero casuale per assegnare un nome diverso ogni volta che
    //richiamo la funzione
    var iRand = Math.round(Math.random() * 1000000);
    var sHandle = iRand.toString();
    //centratura finestra
    var xMax = screen.width, yMax = screen.height;
    var xOffset = (xMax - w) / 2;
    var yOffset = (yMax - h) / 2;
    //apre finestra
    finestra = window.open(page, sHandle, 'width=' + w + ',height=' + h + ',screenX=' + xOffset + ',screenY=' + yOffset + ',top=' + yOffset + ',left=' + xOffset + ',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
 }

 //---------------------------------------------------------

 String.prototype.endsWith = function (str) {
    return (this.match(str + "$") == str)
 }

 //---------------------------------------------------------

 function Trim() {
    return this.replace(/\s+$|^\s+/g, "");
 }
 String.prototype.Trim = Trim;
