//
//	© 2009 InWise Internet Company do Brasil S.A. - Todos os direitos reservados
//	www.inwise.com.br
//

// Índice atual do Wizard
var iWizardIndex = 0;

function WizardNavigateFrame( sFrame, iIndexCount ) {

	var iWizard = -1;
	var hFrame = GetFrame( sFrame );
	if ( hFrame != null )
		iWizard = hFrame.WizardNavigate( iIndexCount );

	WizardUpdateButtons(( sFrame == 'OrderSoftphoneIFrame' )? "Softphone" : "Penphone", iWizard );
	return true;

}

function WizardNavigate( iIndexCount ) {

	if ( OnWizardNavigate( iWizardIndex + iIndexCount )) {

		// Esconde o passo anterior
		var hLayer = document.getElementById( "WizardStep" + iWizardIndex );
		if ( hLayer != null )
			hLayer.style.display = "none";

		// Incrementa o contador
		iWizardIndex += iIndexCount;

		// Exibe o novo passo
		hLayer = document.getElementById( "WizardStep" + iWizardIndex );
		if ( hLayer != null )
			hLayer.style.display = "block";

	}

	return iWizardIndex;

}

function WizardUpdateButtons( sButtonName, iCurrentIndex ) {

	var iLastIndex = 2;

	var hPreviousButton = document.getElementById( "WizardNavigatePrevious" + sButtonName );
	var hNextButton = document.getElementById( "WizardNavigateNext" + sButtonName );
	var hCloseButton = document.getElementById( "WizardNavigateClose" + sButtonName );
	var hCancelButton = document.getElementById( "WizardNavigateCancel" + sButtonName );

	UpdateButtonEnabled( hPreviousButton, ( iCurrentIndex > 0 ));
	UpdateButtonEnabled( hNextButton, ( iCurrentIndex < iLastIndex ));

	if ( iCurrentIndex == iLastIndex ) {

		hCloseButton.style.display = "none";
		hCancelButton.style.display = "inline";

	} else {

		hCloseButton.style.display = "inline"
		hCancelButton.style.display = "none";

	}

	return true;

}