function popBartolini(orderId)
{
    var orderId = DefaultValue(orderId,0);
    var orderUrl = "http://as777.bartolini.it/vas/sped_det_show.hsm?referer=sped_numspe_par.htm&Nspediz={0}&RicercaNumeroSpedizione=Ricerca";
    var genericUrl = "http://as777.bartolini.it/vas/sped_numspe_par.htm?lang=it";
    if( orderId )
        WindowOpen(Format(orderUrl,orderId),'winBartolini',955,600);
    else
        WindowOpen(genericUrl,'winBartolini',955,600);
}

// LIBRARY ////////////////////////////////////////////////////////////////////////////////////////

function DefaultValue(wValue,wDefault)
{
    wDefault = (typeof(wDefault) == 'undefined') ? '' : wDefault;
    
    var bCond1 = typeof(wValue) == 'undefined';
    var bCond2 = typeof(wValue) == 'null';
    var bCond3 = (wValue == "");

    return (bCond1 || bCond2 || bCond3) ? wDefault: wValue ;
}

function Format(sString){
    for(i = 1; i < arguments.length; i++){
        sString = sString.replace('{' + (i - 1) + '}', arguments[i]);
    }
    return sString;
}

function OpenPrivacy()
{
	return WindowOpen('/privacy.html', 'winPrivacy', 600, 600, "yes", "yes", true);
}

function WindowOpen(sUrl, sName, iWidth, iHeight, sResizable, sScrollbars, bCentered)
{
    iWidth = DefaultValue(iWidth,300);
    iHeight = DefaultValue(iHeight,400);
    sName = DefaultValue(sName,"newWin");
    sResizable = DefaultValue(sResizable,"no");
    sScrollbars = DefaultValue(sScrollbars,"no");
    bCentered = DefaultValue(bCentered,false);
    sTopLeft = "";

    if( bCentered ){
        iLeft = (screen.width  - iWidth)/2;
        iTop = (screen.height - iHeight)/2;
        sTopLeft = Format(",top={0},left={1}",iTop,iLeft);
    }

    sOptions = Format('width={0},height={1},resizable={2},scrollbars={3},status=no,location=no,toolbar=no',iWidth,iHeight,sResizable,sScrollbars,sTopLeft);

    winNew = window.open(sUrl,sName,sOptions);

    if (window.focus)
        winNew.focus();

    return winNew;
}

function Trim(sString)
{
    while (sString.substring(0,1) == ' ')
    sString = sString.substring(1, sString.length);
    
    while (sString.substring(sString.length-1, sString.length) == ' ')
    sString = sString.substring(0,sString.length-1);
    
    return sString;
}

