/*
 * Copyright (c) 1999-2008 VidSoft Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only according to the terms and conditions 
 * of a separate license agreement with VidSoft Inc.
 *
 *
 * This software is provided as an programming example only 
 * and is not intended for production use. 
 * It is especially not tested to work properly under all foreseeable circumstances.
 * The programmer using these example has to make appropriate modifications 
 * in order to adapt the software to its intended usage.
 *
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL VIDSOFT GMBH OR ITS EMPLOYEES
 * AND CONTRACTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * THE FOREGOING LIMITATIONS, EXCLUSIONS AND DISCLAIMERS SHALL 
 * APPLY TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, 
 * EVEN IF ANY REMEDY FAILS  ITS ESSENTIAL PURPOSE.
*/

/* ############################# error codes ############################## */
	//	Identifier 	 					Value	Description 
	var	VCWRET_OK 						= 0;	// Success 
	var	VCWRET_ERROR 					= 1;	// Generic error 
	var	VCWRET_NO_COM_SERVER 			= 101;	// VidConference COM server not available 
	var	VCWRET_INVALID_STATE 			= 102;	// Action not available in current state 
	var	VCWRET_COM_INIT_FAIL 			= 107;	// VidConference returns error initializing 
	var	VCWRET_MODE_UNAVAILABlE 		= 108;	// The control cannot be initialized in the requested mode 
	var	VCWRET_COM_SERVER_RUNNING 		= 109;	// VidConference already running, close before initializing (state ST_RUN_MULTIPLE). 
	var	VCWRET_UNSUPPORTED_TYPE 		= 110;	// The data type is not supported. 
	var	VCWRET_INVALID_MODE 			= 201;	// Action not available in current mode 
	var	VCWRET_CALL_EXCEEDS_LIMIT 		= 208;	// Call exceeds the max. number of participants/connections in a conference 
	var	VCWRET_OBJ_ALREADY_LISTED 		= 301;	// Object already in list. 
	var	VCWRET_OBJ_EXCEEDS_LIMIT 		= 302;	// Maximum number of objects exceeded. 
	var	VCWRET_INTERNAL_COM_ERROR 		= 306;	// Error accessing client object. Details see HRESULT or error code (i.e. VBScript ErrObject). 
	var	VCWRET_NULL_POINTER 			= 401;	// NULL pointer. 
	var	VCWRET_OBJ_UNKNOWN 				= 403;	// The object is not assigned to or known by this master control. 
	var	VCWRET_INDEX_OUT_OF_RANGE 		= 501;	// Index out of range. 
	var	VCWRET_INVALID_PARAM 			= 503;	// Invalid device group. 
	var	VCWRET_NOT_INITIALIZED 			= 504;	// Control is not initialized. 
	var	VCWRET_INVALID_PATH 			= 602;	// Invalid path, file name or directory. 
	var	VCWRET_OUT_OF_MEMORY 			= 603;	// Insufficient memory. 
	var	VCWRET_PERFTEST_DONE 			= 703;	// All tests for this performance test level are already performed. 
	var	VCWRET_CHANNEL_EXISTS 			= 802;	// Channel already exists 
	var	VCWRET_INVALID_UUID 			= 803;	// String is not a valid UUID 
	var	VCWRET_CHANNEL_UNKNOWN 			= 804;	// Channel ID is not registered 
	var	VCWRET_MSG_SIZE_ERROR 			= 1003;	// Message(s) too large (maximum length of 65,535 bytes exceeded) 
	var	VCWRET_AV_IS_ON 				= 1102;	// ActivateAV() was called before. 
	var	VCWRET_DEVICE_ERROR 			= 1103;	// Device error(s). Check the properties AudioPlaybackState, AudioCaptureState, VideoPlaybackState and VideoCaptureState. 
	var	VCWRET_NOT_SUPPORTED 			= 1201;	// The feature is not supported 
	var	VCWRET_ALREADY_LOGGED_ON 		= 1300;	// Already logged on to a server 
	var	VCWRET_ACCOUNT_UNKNOWN 			= 1303;	// Account does not exist 
	var	VCWRET_NO_PASSWORD 				= 1304;	// Empty password and no stored password was found. 
	var	VCWRET_NOT_LOGGED_ON 			= 1401;	// Not logged on 
	var	VCWRET_NETWORK_ERROR 			= 1503;	// No network 
	
/* #######  Control Modes for Initialize and CurrentMode ######### */
    var MODE_UNKNOWN					= 0;	// instance is not initialized.
    var MODE_MASTER						= 1;	// in Master Mode.
    var MODE_SLAVE						= 2;	// in Slave Mode.
    var MODE_MASTER_SUSPENDED			= 3;	// Master Mode was suspended.
    var MODE_SERVER_CONNECTOR			= 4;	// in Server Connector Mode.
    
 /* #######  Control States for Status ######### */   
    var ST_NOT_CONNECTED				= 0;	// VidConference COM Server not available. Occurs only for the wrapper control. Cause: VidConference not installed or COM Interface not registered.
    var ST_NOT_INITIALIZED				= 1;	// System was not initialized.
    var ST_READY						= 2;	// System successfully initialized.
    var ST_INCOMING_CALL_PROCEEDING		= 3;	// An incoming call is pending.
    var ST_OUTGOING_CALL_PROCEEDING		= 4;	// An outgoing call is pending.
    var ST_IN_CONFERENCE				= 5;	// System is busy in a conference.
    var ST_IN_CALL_PROC_WHILE_IN_CONF	= 6;	// Incoming call pending while in conference.
    var ST_OUT_CALL_PROC_WHILE_IN_CONF	= 7;	// Incoming call pending while in conference.
    var ST_CLIENT_IDLE					= 8;	// Registered as Client-Mode control but not used.
    var ST_CLIENT_BUSY					= 9;	// Registered as Client-Mode and used.
    var ST_TEST_PERFORMANCE				= 10;	// Performance testing in progress. This state can only be reached from ST_READY and returns to ST_READY when the test is finished.
    var ST_RUN_MULTIPLE					= 11;	// Another Instance is running. Quit all instances and reload the control.

/* ####### Device Groups for methods GetDeviceName(), GetDeviceIndex(), SetDeviceIndex() ##### */
   var DG_AUDIO_RECORDING				= 1;	// Audio recording device(s)
   var DG_AUDIO_PLAYBACK				= 2;	// Audio playback device(s)
   var DG_VIDEO_CAPTURE					= 3;	// Video capture device(s)

/* #######  Dialog IDs Used in context of the method ShowVideoSourceDialog  ######### */  
   var VRC_SOURCEDLG					= 16;	// Video source dialog
   var VRC_PROPPAGE						= 32;	// Video property page

/* #######  Echo Filter Modes for the methods GetEchoHandlingMode() and SetEchoHandlingMode ########## */
   var ECHO_FLT_NONE					= 0;	// No echo filter
   var ECHO_FLT_AES						= 1;	// Acoustic echo suppression (available based on license)
   var ECHO_FLT_AEC						= 2;	// Acoustic echo cancellation (available on Windows XP and newer)

function error_alert(component, errno){
     alert(component + " returned error: " + Master.GetErrorDescription(errno));
}

function trace_alert(msg){
    if(trace!=0)   alert(msg);
}

/*
* help function for separating behaviour and structure providing cross-browsing functionality. 
* 
* obj...Object on which event occurs
* evType... Type of the Event
* fn... Function to be called for the Event
*
* example:
* addEvent(window, 'load', myFunction);
* -> equal to: window.onload=myFunction
*    problem with window.onload explained here: http://www.sitepoint.com/article/structural-markup-javascript
* -> equal to: <body onload="javascript:myFunction()">
*/
function AddEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
		return true;
	}else{
		if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} else {
			return false;
		}
	}
}




