    m_pHTTP                    = new TIdHTTP(this);
    m_pHTTP->ConnectTimeout    = 30000;
    m_pHTTP->Request->BasicAuthentication = true;

    m_lCCTV       = 0;


    String sStreamIP;
    if (m_pHTTP->Connected()) m_pHTTP->Disconnect();

	try{
		teCCTVID->Text    = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][1];
		teLocation->Text  = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][2];
		teNo->Text		  = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][0];
		btLock->Hint	  = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][5];
		AnsiString sStr   = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][3];
		edCtrl->Text	  = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][5];
		edCommStatus->Text= cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][4];
        sStreamIP         = pCCTVList->Items[cxGTV1->DataController->FocusedRecordIndex]->StreamIP;
		edRow->Text       = IntToStr(cxGTV1->DataController->FocusedRecordIndex);
		teWeb->Text       = cxGTV1->DataController->Values[cxGTV1->DataController->FocusedRecordIndex][7];

        if (teWeb->Text == "1") {
            Panel1->Visible        = false;
            Panel2->Visible        = true;
			SpeedButton9->Enabled  = false;
            SpeedButton14->Enabled = false;

			m_pHTTP->Request->Username = "admin";
			m_pHTTP->Request->Password = "admin";
		} else if (teWeb->Text == "2") {
			Panel1->Visible        = false;
			Panel2->Visible        = true;
            SpeedButton9->Enabled  = true;
            SpeedButton14->Enabled = true;

			m_pHTTP->Request->Username = "Admin";
			m_pHTTP->Request->Password = "1234";
		} else {
            Panel1->Visible = true;
            Panel2->Visible = false;
        }

		AnsiString sStr1 = "rtsp://" + sStreamIP + "/" + sStr;
		if(AX != NULL){
		   delete AX;
		   AX      = NULL;
           m_lCCTV = 0;
		}
		AX	= new TAcesTechXPlayer2(this);
		AX->URL    = sStr1;
		AX->Parent = Panel8;
		AX->Align  = alClient;
		m_lCCTV    = AX->Connect();
	}catch(...){
		if(AX != NULL){
		   delete AX;
		   AX     = NULL;
           m_lCCTV= 0;
		}
		MessageDlg("CCTV가 표출 가능한 상태가 아닙니다.", mtConfirmation, TMsgDlgButtons() << mbOK, 0);
	}

void __fastcall TCCTVCtrlF::SpeedButton10MouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y)
{
    if (m_lCCTV == 0)        return;

    AnsiString sCommand;
    AnsiString para;
	AnsiString sSpd;

	// cxTrackBar1->Min = 0, cxTrackBar1->Max = 6;
	
	if (teWeb->Text == "2") {
		sSpd = IntToStr(10 + (cxTrackBar1->Position * 15));
	}
	else {
		sSpd = IntToStr(cxTrackBar1->Position);
	}

    int iRow;
    int iTag = ((TSpeedButton *)Sender)->Tag;

    if (edRow->Text.Length() != 0) {
       iRow = StrToInt(edRow->Text);
    } else {
       return;
    }

    switch (iTag)
    {
		case 1:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendpandirection=4";
			}
			else {
				// sanyo camera
				para = "opecmd.cgi?ope=51&cmd=4&p_speed=" +sSpd;               	//Left
			}
			break;
		case 2:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendpandirection=6";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=5&p_speed=" +sSpd;               	//Right
			}
			break;
		case 3:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendpandirection=2";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=2&p_speed=" +sSpd;               	//Up
			}
			break;
		case 4:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendpandirection=8";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=7&p_speed=" +sSpd;               	//Down
			}
			break;
		case 5:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendfz=1";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=9&z_speed=" +sSpd;               	//ZommIn
			}
			break;
		case 6:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendfz=2";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=10&z_speed="+sSpd;               	//ZoomOut
			}
			break;
		case 7:
			if (teWeb->Text == "2") {
				return;
			}
			else {
				return;           	                                            //Focusin
			}
			break;
		case 8:
			if (teWeb->Text == "2") {
				return;
			}
			else {
				return;           	                                            //FocusOut
			}
			break;
		case 9:
			if (teWeb->Text == "2") {
				return;
			}
			else {
				para = "opecmd.cgi?ope=49&action=2";                           	//AutoFocus
			}
			break;
	}
	try {
		if (teWeb->Text == "2") {
			sCommand = "http://" + pCCTVList->Items[iRow]->sIP + para;
		} else {
			sCommand = "http://" + pCCTVList->Items[iRow]->sIP + "/cgi-bin/" + para;
		}
		m_pHTTP->Get(sCommand);
		fnWriteDebug(sCommand, 33333);
	} catch (Exception &e) {
	}
}

void __fastcall TCCTVCtrlF::SpeedButton10MouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y)
{
    if (m_lCCTV == 0)        return;

    AnsiString sCommand;
    AnsiString para;
	int iRow;
    int iTag = ((TSpeedButton *)Sender)->Tag;

	if (iTag > 6) return;

	if (edRow->Text.Length() != 0) {
	   iRow = StrToInt(edRow->Text);
	} else {
	   return;
	}

	switch (iTag)
	{
		case 1:
		case 2:
		case 3:
		case 4:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendstop=1";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=12&p_speed=0";               		//Left, Right, Up, Down
			}
			break;
		case 5:
		case 6:
			if (teWeb->Text == "2") {
				para = "/vb.htm?sendstop=2";
			}
			else {
				para = "opecmd.cgi?ope=51&cmd=11&z_speed=0";                    //ZommIn, ZoomOut
			}
			break;
		case 7:
			if (teWeb->Text == "2") {
				return;
			}
			else {
				return;           	                                            //Focusin
			}
			break;
		case 8:
			if (teWeb->Text == "2") {
				return;
			}
			else {
				return;           	                                            //FocusOut
			}
			break;
	}

	try {
		if (teWeb->Text == "2") {
			sCommand = "http://" + pCCTVList->Items[iRow]->sIP + para;
		} else {
			sCommand = "http://" + pCCTVList->Items[iRow]->sIP + "/cgi-bin/" + para;
		}
		m_pHTTP->Get(sCommand);
	} catch (Exception &e) {
	}
}


