
// $Id: LTF-Transaction.js,v 1.7 2009/09/27 12:46:58 lenz-mobile Exp $

/**
 * TRANSACTION HANDLERS
 */

var boTransazioneAttiva = false;

function startTransaction( stTransaction, stParameter ) {

    if ( stTransaction.length >  0 ) {

        boTransazioneAttiva = true;

        if ( window.startTransactionApplicativa) {
            startTransactionApplicativa( stTransaction, stParameter);
        }

        document.forms[0].TPF_VERBO.value = stTransaction;
        document.forms[0].TPF_XPAR1.value = stParameter;
        document.forms[0].submit();
    }
}


function doOnLoad( boDisableBackHistory, stErr) {

    if ( boDisableBackHistory == "1") {
        if (history.length > 1){
            eval("history.forward()");
        }
    }

    if ( window.onLoadApplicativo ) {
        onLoadApplicativo();
    }

    if ( stErr.length > 0 ) {
        alert( "Alert:\n" + stErr );
    }
}

/**
 * MISC
 */


function setCss(menuItem, myClass) {
    if( document.getElementById ) {
        menuItem.parentNode.className = myClass;
    }	
}


// imposta il focus su un controllo dato.
function setFocus( stCtrlName ) {    
    var myTextField = document.getElementById( stCtrlName );
    if ( myTextField ) {
        myTextField.focus();
    }
}

function baseOpenPopUp( stURL, stWidth, stHeight, stScrollbar ) {
    unique = new Date().getTime();
    stDestUrl = stURL + "&cachebreak=" + unique;
    eval("page" + unique + " = window.open( stDestUrl, '" + unique + "', 'toolbar=0,scrollbars=" + stScrollbar + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + stWidth + ",height=" + stHeight + ",left=490,top=200');");
}

function openSmallPopUp( stUrl ) {
    baseOpenPopUp( stUrl, 300, 150, "0" );
}


function logS( s ) {
    $( "#logframe" )
        .html(
            "<li>" + s + "<p>"
            + $( "#logframe" ).html()
        );

}


// AUDIO STUFF
// requires <div id="soundSpan"></div>

/**
 * Passo:
 * - il valore del suono yellow
 * - il valore del suono red
 * - 'on' o 'off' a seconda che sia acceso o spento l'audio
 */
function triggerAudioAlarms( stSoundYellow, stSoundRed, stAudio) {

    if ( stAudio == "off" ) {
        setAlarmSound( "" );
    } else
    // cerca celle del tipo stDataYellow e stDataRed
    if ( $( ".stDataRed" ).length > 0 ) {
        setAlarmSound( stSoundRed );
    } else
    if ( $( ".stDataYellow" ).length > 0 ) {
        setAlarmSound( stSoundYellow );
    } else {
        // no sound
        setAlarmSound( "" );
    };

    //logS( "Yellow: " + $( ".stDataYellow" ).length   );
}

function setAlarmSound( soundChosen ) {
    //logS( "Playing sound: '" + soundChosen + "':" + soundChosen.length );
    if ( soundChosen.length > 0 ) {
        $( "#soundSpan" ).html( "<embed src='" + soundChosen + "' width='0' height='0' hidden=true autostart=true loop=false>" );
 		} else {
        $( "#soundSpan" ).html( "" );
    }
   //logS( "HTML" + $( "#soundSpan" ).html() );

}



// $Log: LTF-Transaction.js,v $
// Revision 1.7  2009/09/27 12:46:58  lenz-mobile
// Refactoring funzioni audio per realtime/wallboard
//
// Revision 1.6  2009/09/21 15:16:31  lenz
// Uso jQuery
//
// Revision 1.5  2008/06/06 12:39:48  lenz
// Bug #399: Chiusura di chiamate ongoing.
//
// Revision 1.4  2008/06/06 09:06:30  lenz
// Bug #399: apertura dei popup.
//
// Revision 1.3  2007/05/12 21:12:11  lenz
// Merge IMM4
//
// Revision 1.2.4.1  2007/04/12 09:30:40  lenz
// Bug #89: Focus preimpostato su pagine editor di PCodes e Outcomes
//
//


