<HTML>
<HEAD>
#include "header.inc"
#include "debug_js.inc"
#include "constants.inc"

<TITLE>Remote Assistance Settings</TITLE>
<meta http-equiv="MSThemeCompatible" content="Yes">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK id="UI_StyleSheet1" REL="stylesheet" TYPE="text/css" HREF="hcp://system/css/shared.css">
<LINK id="UI_StyleSheet" REL="stylesheet" TYPE="text/css" HREF="../../Css/rc.css">
<Script id="script1" name="script1" Language="javascript">

var vArgs=window.dialogArguments;
var L_ERRACCESSDENIED_Text    = "Directly launching this page is not allowed. ";
var L_RCCTL_Text                = "Remote Assistance failed. Please try again. ";

//
// VOIP Messages
//
var L_ERRVOIP2_Text              = c_szVoiceError;

/*
Function : OnApply()
Description : Gets called when the Apply button is pressed.
			  This apply the settings based upon the options selected
*/
function OnApply()
{
    InitTrace();
	TraceFunctEnter("OnApply");
	
	try
	{
		if (optSS.checked)
		{
			vArgs[0].frames.idFrameScreen.g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.EnableSmartSizing=true;
			vArgs[0].frames.idFrameStatus.idStatus.innerHTML="&nbsp;&nbsp;<strong>Status: </strong>" + vArgs[0].frames.idFrameStatus.g_szStatusMsg + " [Scaled view]" ;			
			vArgs[0].frames.idFrameStatus.Helper_UpdateMode(1);
			vArgs[1].SetProfileString("Scaling", 1);
		}	
		else if(optAS.checked)
		{
			vArgs[0].frames.idFrameScreen.g_oSAFRemoteAssistanceHelper.m_oSAFRemoteDesktopClient.EnableSmartSizing=false;
			vArgs[0].frames.idFrameStatus.idStatus.innerHTML = "&nbsp;&nbsp;<strong>Status: </strong>" + vArgs[0].frames.idFrameStatus.g_szStatusMsg + " [Full view]" ;
			vArgs[0].frames.idFrameStatus.Helper_UpdateMode(0);
			vArgs[1].SetProfileString("Scaling", 0);
		}	

		// We need to change the Voice Compression if a radio button setting has been modified
		if ((optStd.checked == true) && (vArgs[0].g_VoipBandwidth == 1))
		{

			// Caught a change from high to low, set the SamplingRate property
			vArgs[0].g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.SamplingRate = 1;
            
			// Send a message to the server (helpee)
			vArgs[0].Helper_SendControlCommand( c_szVoipBandwidthToLow)

			// Change state variable from 1 to 0
			vArgs[0].g_VoipBandwidth = 0;

		} else if ((optHigh.checked == true) && (vArgs[0].g_VoipBandwidth == 0))
		{

        	// Caught a change from low to high, set the SamplingRate property
			vArgs[0].g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.SamplingRate = 2;

			// Send a message to the server (helpee)
			vArgs[0].Helper_SendControlCommand( c_szVoipBandwidthToHigh)

			// Change state variable from 0 to 1
			vArgs[0].g_VoipBandwidth = 1;
		}
	}
	catch(error)
	{		
		vArgs[0].FatalError(L_RCCTL_Text,error);
	}
	
	TraceFunctLeave();	
}

/*
Function : Tuning()
Description : Gets called when the Audio Tuning Wizard button is pressed.
			
*/
function Tuning()
{
	TraceFunctEnter("Tuning");
	
	var lRet = 0;

	try
	{
		vArgs[0].g_oSAFRemoteAssistanceHelper.m_oSAFIntercomClient.RunSetupWizard();

		// Send a message to the server that the SetupWizard succeeded
		vArgs[0].Helper_SendControlCommand( c_szVoipWizardGood);

		// set me to good
		vArgs[0].g_stateVoipMe = 1;

		// Now we make the check to see if we can enable voice.
		// If me and you are good < 2 then enable
		if ( (vArgs[0].g_stateVoipMe < 2) && (vArgs[0].g_stateVoipYou < 2) )
		{

			// Ungray voice button
#ifdef _OLDTOOLBAR
			vArgs[0].frames.idFrameTools.btnVoice.disabled = false;
#else
            vArgs[0].frames.idFrameTools.idTB.SetState( "btnVoice", true );
#endif

			vArgs[0].g_bStartEnabled = true;
			vArgs[0].g_bVoIPEnabled = true;

		}
		
		
	}	
	catch(error)
	{
	    vArgs[0].g_bVoIPEnabled = false;
		vArgs[0].DisplayMessage(L_ERRVOIP2_Text);

		// set me to bad
		vArgs[0].g_stateVoipMe = 2;

		// gray voice button
#ifdef _OLDTOOLBAR
		vArgs[0].frames.idFrameTools.btnVoice.disabled = true;
#else
        vArgs[0].frames.idFrameTools.idTB.SetState( "btnVoice", false );
#endif

		// vArgs[0].g_bStartEnabled = false;

		// Send a message to the server that the SetupWizard failed
		vArgs[0].Helper_SendControlCommand( c_szVoipWizardBad);


	}	
	
	TraceFunctLeave();	
}

/*
Function : OnLoad()
Description : Gets called on the load of the page.
			  Options are initialised based upon the settings recorded.
*/
function OnLoad()
{
	TraceFunctEnter("OnLoad");
	
	try
	{	
		if (vArgs[1].GetProfileString("Scaling")==1)
		{
		  	optSS.checked=true;
		}
		else
		{
			optAS.checked=true;	
		}		

		// Show current compression setting through the 'rdAS' radio button
		if (vArgs[0].g_VoipBandwidth == 0)
		{
			optStd.checked = true;
		} 
		else
		{
			optHigh.checked = true;
		}

        // Disable the Audio wizard button if we are on a voice session
        if ((vArgs[0].g_bVoipConnected == true))
        {
            btnATW.disabled = true;
        }
        else
            btnATW.disabled = false; 
	}	
	catch(error)
	{
 
		idBody.style.visibility = "hidden";
		alert( L_ERRACCESSDENIED_Text );
		return;
 
	}	
	
	TraceFunctLeave();		
}

</Script>
</HEAD>
<BODY onLoad="OnLoad();" id="idBody" name="idBody" class="sys-inlineform-bgcolor1">
	<Table name="idMainTable" id="idMainTable" cellspacing="0" cellpadding="0" border=0 class="MaxLayout">
		<TR>
			<TD class="padding6 padding3">
               <Table id="T1" name="T1" border=0 cellpadding="0" cellspacing="0" class="MaxLayout">
                    <TR>
                    	<TD class="padding5 valigntop">	
		                    <Fieldset id="F0TD0TR1TD0TR0T0" name="F0TD0TR1TD0TR0T0" class="padding3 padding4 padding6 padding7">
                                <Legend id="L0TD0TR1TD0TR0T0" name="L0TD0TR1TD0TR0T0" class="sys-font-body sys-color-body">
				                    Audio
			                    </Legend>
			                    <Table cellpadding=0 cellspacing=0 border=0 name="idContainer1" name="idContainer1" class="MaxLayout">
									<TR>
										<TD class="height5">										
										</TD>
									</TR>
									<TR>
										<TD>
											<Input type="radio" name="rdAS" id="optStd" checked>
											<Label id="LA0rdAS" name="LA0rdAS" For="optStd" class="sys-font-body sys-color-body">
												Standard quality
											</Label>
										</TD>
									</TR>
									<TR>
										<TD>
											<Input type="radio" name="rdAS" id="optHigh">
											<Label id="L0rdAS" name="L0rdAS" For="optHigh" class="sys-font-body sys-color-body">
												High quality (requires a high-speed Internet connection)
											</Label>
			                    	</TD>
									</TR>
									<TR>
										<TD class="height15">										
										</TD>
									</TR>
									<TR>
										<TD id="idbtn" name="idbtn" align="right" class="padding2">
#if 0			                    
                                <Div id="D3" name="D3">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </Div>
#endif
										   <Button name="btnATW" id="btnATW" onClick="Tuning();" class="sys-font-body sys-color-body" accesskey="T">   
										      Audio Tuning Wizard ....    
										   </Button>
										</TD>
									</TR>	
			                    </Table>            
			                </Fieldset>		                    
	                    </TD>
                    </TR>
                    <TR id="TR2TD0TR0T0" name="TR2TD0TR0T0">
	                    <TD id="TD0TR2TD0TR0T0" name="TD0TR2TD0TR0T0" class="padding5 valigntop">
		                    <Fieldset id="F0TD0TR2TD0TR0T0" name="F0TD0TR2TD0TR0T0" class="padding3 padding4 padding6 padding7">
			                    <Legend id="L0F0TD0TR2TD0TR0T0" name="L0F0TD0TR2TD0TR0T0" class="sys-font-body sys-color-body">
				                    Default screen view
			                    </Legend>
			                    <Table cellpadding=0 cellspacing=0 border=0 name="idContainer2" name="idContainer2" class="MaxLayout">
									<TR>
										<TD class="height5">										
										</TD>
									</TR>
									<TR>
										<TD>
											<Input type="radio" name="rdSS" id="optSS" checked>
											<Label id="LA0F0TD0TR2TD0TR0T0" name="LA0F0TD0TR2TD0TR0T0" For="optSS" class="sys-font-body sys-color-body">
												Scale to window
											</Label>
										</TD>
									</TR>
									<TR>
										<TD>
			                                <Input type="radio" name="rdSS" id="optAS">
											<Label id="LA1F0TD0TR2TD0TR0T0" name="LA1F0TD0TR2TD0TR0T0" For="optAS" class="sys-font-body sys-color-body">
												Actual size
											</Label>
										</TD>
									</TR>
									</Table>            
			                </Fieldset>		                    
	                    </TD>
                    </TR>
                    <TR>
						<TD class="height8">										
						</TD>
					</TR>
                    <TR id="TR3TD0TR0T0" name="TR3TD0TR0T0">
	                    <TD id="TD0TR3TD0TR0T0" name="TD0TR3TD0TR0T0" align="right">
	                        <Button id="btnOK" name="btnOK" Onclick="OnApply();window.close();" class="styBtnWidth sys-font-body sys-color-body" accesskey="O"><U>O</U>K</Button> 
	                        <Span id="idblankSpace1" name="idblankSpace1" class="width8"></Span>
                            <Button id="btnCancel" name="btnCancel" OnClick="window.close();" class="styBtnWidth sys-font-body sys-color-body" accesskey="C"><U>C</U>ancel</Button> 
                            <Span id="idblankSpace2" name="idblankSpace2" class="width8"></Span>
                            <Button id="btnApply" name="btnApply" Onclick="OnApply();" class="styBtnWidth sys-font-body sys-color-body" accesskey="A"><U>A</U>pply</Button>                        
	                    </TD>
                    </TR>
                </Table>
            </TD>
        </TR>
    </Table>
</BODY>
</HTML>