// all code specifically for bcframeset

// onresize commented out to see if loading issue while resizing are still occuring in Toronto
// Continue to looking for reason of this code line here.
//window.onresize = memorizeWindow;
	/*
	 for ie screenLeft & screenTop are the x, y points of content window
	 go to x=0, y=0 to be able to find out the size of toolbars and left border
	*/
	
//*********************************************************************************
//
// < CONSTANTS>
//
//*********************************************************************************

var SAFARIMOBILE_LAYOUT_UPDATE_TIMER = 500; 	// time in ms at which code will periodically update iphone/ipad layout to hide navigation bar if needed

//*********************************************************************************
//
// < / CONSTANTS>
//
//*********************************************************************************
	
//*********************************************************************************
//
// <GLOBAL VARIABLES>
//
//*********************************************************************************

var ieOffSetX = 0; // size of IE toobars include upper border
var TBLRieOffSetX = 0; // size of taskbar if located at left or right of the screen
var TBTBieOffSetY = 0; // size of the taskbar if located at top or bottom of screen
var ieOffSetY = 0; // size of left border
var statusBarHeight = 0; // size of the statusbar
var taskBarStatus = 0; // 1 = taskbar on left or right - 2 = taskbar on top or bottom

var newX = 0;
var newY = 0;
var newWidth = 0;
var newHeight = 0;

var winCONSOLE = undefined;
var bArchive = true, bwinConsoleOpened = false;

var initBCFretries=0;

// if true enables code that will auto hide safari mobile (iphone/ipad) url bar 
var bHideUrlBar = true;


// defines safari Mobile current orientation, possible values = "profile" (portrait) or "landscape"
var safariMobileCurOrientation = ""; 

// define the UI state before the update
var oldScrollXValue = 0;
var oldSafariMobileCurOrientation = "";

//*********************************************************************************
//
// < / GLOBAL VARIABLES>
//
//*********************************************************************************

// THIS FUNCTION WILL BE CALLED ONLY IF PHONEGAP IS USED
// Aim is to dynamically load the phonegap.js and phonegapcallback.js libraries in the frameset document

function createJsNode ( head, jsfile)
{
if(head) {
	var node = document.createElement('script');
	if(node) {
		node.setAttribute('language','javascript');
		node.setAttribute('type','text/javascript');
		node.setAttribute('charset', 'utf-8');
		node.setAttribute('src',jsfile);
		//node.onload = 
		head.appendChild(node);
		}
	}
}

function loadPhoneGapLib()
{
var docHead = document.getElementsByTagName('head').item(0);
if(docHead)
	{
	createJsNode ( docHead, "../../phonegap.js");
	createJsNode ( docHead, "js/phonegapcallback.js");
	}
}


//
//
//	SAFARI MOBILE (IPHONE/IPAD) SPECIFIC FUNCTIONS
//

// works only for Ipad for now
// returns true if console is visible on screen

function isSafariConsoleEnabled()
{
if(bIpad) {		
		var w = window.innerHeight;
		// if console visible safari window height is 640 (landscape) or 896 (portrait) pixels, otherwise 690/946
		if((w == 640) || (w == 896)) return true;
		return false;
		}
return false;
}

function initSafariMobileFrameset()
{
addEventListener("load", function() { setTimeout(updateSafariMobileLayout, 0); }, false);
var ort = getSafariMobileOrientation();
if(safariMobileCurOrientation != ort) safariMobileCurOrientation = ort;
if(bIphone) return 'rows = "416"';
// Ipad case
if(ort == "profile") {
		if(bSafariConsole == true) return 'rows = "'+IPAD_PORTRAIT_HEIGHT+'"';
		return 'rows = "'+IPAD_PORTRAIT_HEIGHT_BIG+'"';
		}
else {
		if(bSafariConsole == true) return 'rows = "'+IPAD_LANDSCAPE_HEIGHT+'"';
		return 'rows = "'+IPAD_LANDSCAPE_HEIGHT_BIG+'"';
		}
}

function initAndroidMobileFrameset()
{
addEventListener("load", function() { setTimeout(updateAndroidMobileLayout, 0); }, false);
return 'rows = 455';
}


function setUrlBarAutoHideEnabledStatus ( enabled )
{
bHideUrlBar = enabled;
}
           

function safariMobileLayoutResize( display )
{
if((display == null) || (display == undefined)) return;
var r = display.resize.toString();
if(r.indexOf("ERROR_INIT") != -1) return;

display.resizeWanted = true;
display.resize();
}


function setIpadSafariControlFrameWidth( width )
{
if(bIpad == false) return;
if(width == undefined) return;
if(width < 0) return;
if(width == gIpadControlFrameWidth) return;

gIpadControlFrameWidth = width;
if(DEBUGON == true) console.log("gIpadControlFrameWidth set to: " + gIpadControlFrameWidth);
}


function setIpadSafariFramesetLayout( )
{
var fr = document.getElementById("clientFrameset");
if(fr)
	{
	var cont = null, ctrl = null, doc = null, ifr = null, ipaddiv = null, nContentWidth;
	
	if(self) {
		cont = self.content;
		ctrl = self.control;
		}

    if((cont == null) || (ctrl == null)) return;
	
	doc = cont.document;
	if(doc) {
		//ipaddiv = doc.getElementById('ipaddiv');
		ifr = doc.getElementById('contfrm');
		}
		
	//if(ipaddiv && ipaddiv.style) {
		if(top && (top.orientation != undefined)) {
			var h, w;
			if((top.orientation != 0) && (top.orientation != 180)) {
				// landscape
				h = (bSafariConsole?IPAD_LANDSCAPE_HEIGHT:IPAD_LANDSCAPE_HEIGHT_BIG);
				w = IPAD_LANDSCAPE_WIDTH;
			} else {
				h = (bSafariConsole?IPAD_PORTRAIT_HEIGHT:IPAD_PORTRAIT_HEIGHT_BIG);
				w = IPAD_PORTRAIT_WIDTH;
			}
			nContentWidth = w - gIpadControlFrameWidth;
			if(ui == CONTROL_FRAME_PLACE_RIGHT) fr.cols = nContentWidth + "," + gIpadControlFrameWidth;
			else fr.cols = gIpadControlFrameWidth + "," + nContentWidth;
			//ipaddiv.style.width = nContentWidth + "px";
			if(ifr && ifr.style) ifr.style.width = nContentWidth + 'px';
			//ipaddiv.style.height = h + "px";
			if(ifr && ifr.style) ifr.style.height = h + "px";
			fr.rows = h;
			cont.innerHeight = h;
			ctrl.innerHeight = h;
			if (top.content && top.content.document && top.content.document.body && top.content.document.body.style) {
				top.content.document.body.style.height = h + "px";
				top.content.document.body.style.width = nContentWidth + "px";
			}
			if (top.control && top.control.document && top.control.document.body && top.control.document.body.style) {
				top.control.document.body.style.height = h + "px";
				top.control.document.body.clientHeight = h;//gIpadControlFrameWidth;
				top.control.document.body.scrollHeight = h;//gIpadControlFrameWidth;
				top.control.document.body.offsetHeight = h;//gIpadControlFrameWidth;
				top.control.document.body.style.width = gIpadControlFrameWidth + "px";
				top.control.document.body.clientWidth = gIpadControlFrameWidth;
				top.control.document.body.scrollWidth = gIpadControlFrameWidth;
				top.control.document.body.offsetWidth = gIpadControlFrameWidth;
			}
			if (cont.document && cont.document.documentElement) {
				cont.document.documentElement.clientHeight = h;
				cont.document.documentElement.clientWidth = nContentWidth;
				cont.document.documentElement.scrollHeight = h;
				cont.document.documentElement.scrollWidth = nContentWidth;
			}
			if (ctrl.document && ctrl.document.documentElement) {
				ctrl.document.documentElement.clientHeight = h;
				ctrl.document.documentElement.scrollHeight = h;
				ctrl.document.documentElement.offsetHeight = h;
				ctrl.document.documentElement.clientWidth = gIpadControlFrameWidth;
				ctrl.document.documentElement.scrollWidth = gIpadControlFrameWidth;
				ctrl.document.documentElement.offsetWidth = gIpadControlFrameWidth;
			}
		cont.innerWidth = nContentWidth;
		ctrl.innerWidth = gIpadControlFrameWidth;
		if ((oldSafariMobileCurOrientation != safariMobileCurOrientation) && (oldScrollXValue <= 128)) window.scrollTo(0,0);
		if (cont.setDivSize) cont.setDivSize();			
			}
		/*ipaddiv.style.overflow = "auto";
		}*/
	
	//@@@ DEBUG
	if(DEBUGON == true) {
		var strDebug = 'setIpadSafariFramesetLayout() => orient=' + top.orientation + ' frameset cols=' + fr.cols + ' rows=' + fr.rows;
		//if(ipaddiv && ipaddiv.style) strDebug += ' / ipaddiv.style.width=' + ipaddiv.style.width + ' ipaddiv.style.height=' + ipaddiv.style.height + ' ipaddiv.style.overflow=' + ipaddiv.style.overflow;
		if(ifr && ifr.style) strDebug += ' / ifr.style.width=' + ifr.style.width + ' ifr.style.height=' + ifr.style.height + ' ifr.style.overflow=' + ifr.style.overflow;
		strDebug += (cont?' / content iW=' + cont.innerWidth + ' iH=' + cont.innerHeight:' / content : null');
		strDebug += (ctrl?' / control iW=' + ctrl.innerWidth + ' iH=' + ctrl.innerHeight:' / control: null');
		console.log(strDebug);
			
		strDebug = "";
		strDebug += ((cont && cont.document && cont.document.body)?' content body styleW: ' + cont.document.body.style.width + ',  clientW=' + cont.document.body.clientWidth + ', offsetW:' + cont.document.body.offsetWidth  + ', scrollW:' + cont.document.body.scrollWidth + ' | styleH: ' + cont.document.body.style.height + ', clientH=' + cont.document.body.clientHeight + ', offsetH:' + cont.document.body.offsetHeight + ', scrollH:' + cont.document.body.scrollHeight:'content body : null');
		console.log(strDebug);
		strDebug = ((ctrl && ctrl.document && ctrl.document.body)?' / control body styleW: ' + ctrl.document.body.style.width + ', clientW=' + ctrl.document.body.clientWidth+ ', offsetW:' + ctrl.document.body.offsetWidth  + ', scrollW:' + ctrl.document.body.scrollWidth + ' | styleH: ' + ctrl.document.body.style.height + ', clientH=' + ctrl.document.body.clientHeight + ', offsetH:' + ctrl.document.body.offsetHeight  + ', scrollH:' + ctrl.document.body.scrollHeight:'control body : null');	
		console.log(strDebug);
		strDebug = ((cont && cont.document && cont.document.documentElement)?' cont document.documentElement styleW: ' + cont.document.documentElement.style.width + ', clientW=' + cont.document.documentElement.clientWidth + ', offsetW:' + cont.document.documentElement.offsetWidth  + ', scrollW:' + cont.document.documentElement.scrollWidth + ' | styleH: ' + cont.document.documentElement.style.height + ', clientH=' + cont.document.documentElement.clientHeight + ', offsetH:' + cont.document.documentElement.offsetHeight + ', scrollH:' + cont.document.documentElement.scrollHeight:'cont.document.documentElement null');
		console.log(strDebug);
		strDebug = ((ctrl && ctrl.document && ctrl.document.documentElement)?' ctrl document.documentElement styleW: ' + ctrl.document.documentElement.style.width + ', clientW=' + ctrl.document.documentElement.clientWidth + ', offsetW:' + ctrl.document.documentElement.offsetWidth  + ', scrollW:' + ctrl.document.documentElement.scrollWidth + ' | styleH: ' + ctrl.document.documentElement.style.height + ', clientH=' + ctrl.document.documentElement.clientHeight + ', offsetH:' + ctrl.document.documentElement.offsetHeight + ', scrollH:' + ctrl.document.documentElement.scrollHeight:'ctrl.document.documentElement null');				
		console.log(strDebug);
		strDebug = ((top && top.document && top.document.documentElement)?' top document.documentElement clientW=' + top.document.documentElement.clientWidth+ ', offsetW:' + top.document.body.offsetWidth  + ', scrollW:' + top.document.body.scrollWidth + ' | clientH=' + top.document.documentElement.clientHeight + ', offsetH:' + top.document.body.offsetHeight  + ', scrollH:' + top.document.body.scrollHeight:'top.document.documentElement null');
		console.log(strDebug);
		}
	}
}


var bIpadDivSizeInited = false;

function updateSafariMobileLayout()
{
var strDebug, orient;

if(bIpad && !bIpadDivSizeInited) {
	setIpadSafariFramesetLayout();
	bIpadDivSizeInited = true;
	}		

orient = getSafariMobileOrientation();

if(top.innerWidth != safariMobileCurrentWidth)
	{
    if(bIpad) {
		if(orient == "profile") safariMobileCurrentWidth = IPAD_PORTRAIT_WIDTH;
		else safariMobileCurrentWidth = IPAD_LANDSCAPE_WIDTH;
		setIpadSafariFramesetLayout();
		}
	else safariMobileCurrentWidth = top.innerWidth;
	if(DEBUGON == true) console.log('updateSafariMobileLayout() => top.innerWidth=' + top.innerWidth + ' W=' + safariMobileCurrentWidth + ' H=' + safariMobileCurFrameHeight);
	}

var iH = top.innerHeight, ctl = null, cont = null;
if(self) {
	ctl = self.control;
	cont = self.content;
	}

if(safariMobileCurFrameHeight != iH) {

    if(bIpad) {
		if(orient == "profile") {
				if(bSafariConsole == true) safariMobileCurFrameHeight = IPAD_PORTRAIT_HEIGHT;
				else safariMobileCurFrameHeight = IPAD_PORTRAIT_HEIGHT_BIG;
				}
		else {
				if(bSafariConsole == true) safariMobileCurFrameHeight = IPAD_LANDSCAPE_HEIGHT;
				else safariMobileCurFrameHeight = IPAD_LANDSCAPE_HEIGHT_BIG;
				}	
		setIpadSafariFramesetLayout();
		}
	else safariMobileCurFrameHeight = iH;
	
	if(ctl) {
		if(bIphone) {
			// height = 396 is when green active phone call bar is present
			// height = 416 is when only safari url bar is hidden and not active phone call ~ full screen mode
			if((iH == 396) || (iH == 416)) safariMobileLayoutResize(ctl.gDisplay);
			}
		else {
			safariMobileLayoutResize(ctl.gDisplay);
			}
		}

	if(ctl.innerWidth != gIpadControlFrameWidth) ctl.innerWidth = gIpadControlFrameWidth;
	
	//@@@DEBUG
	if(DEBUGON == true) {
		strDebug = 'updateSafariMobileLayout() => iH=' + iH + ' W=' + safariMobileCurrentWidth + ' H=' + safariMobileCurFrameHeight + ' Orient=' + safariMobileCurOrientation;
		strDebug += ' content W=' + cont.innerWidth + ' control W=' + ctl.innerWidth;			
		console.log(strDebug);
		}
	}

if(bHideUrlBar && bIphone) {

	// hide help button on "i will dial in" pane if not enough space (green bar present)...
	if(ctl && ctl.document) {
		var el = ctl.document.getElementById('DIhelpButton');
		if(el && el.style) {
			
			if(safariMobileCurFrameHeight == 396) el.style.visibility = "hidden";
			else {
				var eldiv = ctl.document.getElementById('IphoneVoicePanelDialInDiv');
				if(eldiv && eldiv.style && (eldiv.style.visibility == "visible")) el.style.visibility = "visible";
				else el.style.visibility = "hidden";
				}
			}
		}
		
	// Auto hide safari mobile url bar..
	window.scrollTo(0,1);
	}
	oldScrollXValue=window.scrollX;
	oldSafariMobileCurOrientation = safariMobileCurOrientation;		
}

function updateAndroidMobileLayout()
{
    if(bHideUrlBar) {
		var control = null, display = null;
		if(self) {
			if(self.control) control = self.control;
			if(self.content) content = self.content;
		}
		/*
		if(control && control.gDisplay) display = control.gDisplay;
		if (display && display.ContentFrameVisible) {
		    if (console && console.log)
			    console.log('updateAndroidMobileLayout(): do not hide url bar for content frame.')
		    return;
		}
		*/
		window.scrollTo(0,1);
	}
}

//
//
//	END OF SAFARI MOBILE (IPHONE/IPAD) FUNCTIONS
//


// Event handler when device orientation changes (iPhone, Ipad, ...)

function orientationChangeHandler()
{	
var event = null;
if(arguments.length > 0) event = arguments[0];
if(event) {
	if(bIphone || (top.isAndroid && top.isAndroid())) {
		// IPHONE ORIENTATION CHANGE HANDLER
		var control = null, display = null, content = null;
		if(self) {
			if(self.control) control = self.control;
			if(self.content) content = self.content;
			}
		//Android: TBD
		if(control && control.gDisplay && !(top.isAndroid && top.isAndroid()))	display = control.gDisplay;

		if(control && content && display) {

			var ort = getSafariMobileOrientation();

			if(content.centerSlideMgrLoadingScreen) content.centerSlideMgrLoadingScreen();

			if(display.ContentFrameVisible)
				{
				// content frame currently visible
				if(ort == "profile") {
					// reset warning message as we moved back to portrait mode
					if(content.gblandscapeModeWarningDisplayed == true) content.landscapeModeWarning(false);
					// and auto switch to control frame as requested by click on toggle icon
					if(content.gbToggleLSClick == true) {
						content.gbToggleLSClick = false;
						display.ShowCurrentFrame();
						}
					else { window.scrollTo(0,1); }
					}
				else {
				    window.scrollTo(0,1);
					}
				}
			else {
				// control frame currently visible
				if(ort == "landscape")  {
					// landscape mode => not supported on control frame => display content frame
					display.ShowCurrentFrame();
					}
				}
			}
		}
	else if (bIpad){
		// IPAD ORIENTATION CHANGE HANDLER
		setIpadSafariFramesetLayout();
		safariMobileLayoutResize();
		}
    else {
		// Other ORIENTATION CHANGE HANDLER
		if (console && console.log)
		    console.log('orientationChangeHandler: You device is not supported. top.orientation=' + top.orientation);
	}
}
};


window.onorientationchange = orientationChangeHandler;


function initBCF()
{
// if Internet explorer is used
if (window.screenLeft && window.screenTop)
	{
	try
		{
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight);
		ieOffSetX = window.screenLeft;
		ieOffSetY = window.screenTop;

		if (screen.availWidth < screen.width)
			{
			// Task bar should be located at left or right of the screen
			TBLRieOffSetX = (screen.width - screen.availWidth);
			taskBarStatus = 1;
			}
		if (screen.availHeight < screen.height)
			{
			// Task bar should be located at top or bottom the screen
			TBTBieOffSetY = (screen.height - screen.availHeight);
			taskBarStatus = 2;
			}

		// To correct the bug of IE 6 that is not able to fit avail height and avail width
		// with taskbar, the case of taskbar on the left is managed.
		if (taskBarStatus == 1)
			{
			// if UA_IE6 = 512
			if (gClientUserAgent & 512)
				window.moveTo(TBLRieOffSetX,0);
			else
				window.moveTo(0,0);
			}
		else if (taskBarStatus == 2)
			{
			window.moveTo(0,0);
			}
		window.resizeTo(screen.availWidth,screen.availHeight);
		}
	catch(err)
		{
		initBCFretries++;
		if(initBCFretries < 4)	setTimeout('initBCF()',500);
		}
	}
}


function coordinatesXY(coordinates)
{
if (coordinates && (coordinates == "x" || coordinates == "y"))
	{
	if  (window.screenLeft && window.screenTop)
		{
		if (coordinates == "x")
			{
			if (taskBarStatus == 1)
				{
				if (gClientUserAgent & 2) // IE7
					return (window.screenLeft);
				else
					return (window.screenLeft - ieOffSetX);
				}
			return (window.screenLeft - ieOffSetX);
			}
		else if (coordinates == "y")
			{
			return (window.screenTop - ieOffSetY);
			}
		}

	if (window.screenX && window.screenY)
		{
		if (coordinates == "x")
			return  window.screenX;
		else if (coordinates == "y")
			return  window.screenY;
		}
	}
}


function windowSize(widthHeight)
{
if (widthHeight && (widthHeight == "w" || widthHeight == "h"))
	{
	if (window.outerWidth && window.outerHeight)
		{
		if (widthHeight == "w")
		return window.outerWidth;
		else if (widthHeight == "h")
		return window.outerHeight;
		}

	if (document.documentElement && (document.documentElement && document.documentElement.clientHeight))
		{
		if (widthHeight == "w")
			{
			if (taskBarStatus == 1)
				{
				if (gClientUserAgent & 2) // IE7
					return (document.documentElement.clientWidth+ieOffSetX*3);
				else
					return (document.documentElement.clientWidth+(ieOffSetX*3));
				}

			return (document.documentElement.clientWidth+(ieOffSetX*3));

			}
		else if (widthHeight == "h")
			{
			if (isPopupEnabled())
				{
				// if UA_IE7 = 2
				if (gClientUserAgent & 2)
					return (document.documentElement.clientHeight+statusBarHeight+ieOffSetY);
				else
					return (document.documentElement.clientHeight+ieOffSetY+(ieOffSetX*2));
				}
			else
				{
				return (document.documentElement.clientHeight+statusBarHeight+ieOffSetY);
				}
			}
		}
	}
}


function memorizeWindow(arg)
{
newX = coordinatesXY("x");
newY = coordinatesXY("y");
if (arg=="display")
	{
	if (window.screenLeft && window.screenTop)
		{
		window.moveTo(0,0);
		ieOffSetY = window.screenTop;
		window.moveTo(newX,newY);
		}
	}
newX = coordinatesXY("x");
newY = coordinatesXY("y",arg);
newWidth = windowSize("w");
newHeight = windowSize("h");

newX = (newX == undefined) ? correctBugIe6FxLinux() : newX;
}


function correctBugIe6FxLinux()
{
newX = 0;
newY = 0;
newWidth = screen.availWidth;
newHeight = screen.availHeight;
return true;
}


function openWinConsole()
{
if(bwinConsoleOpened == true) return;
bwinConsoleOpened = true;
winCONSOLE = null;
//@@@ APBC-MERGE, code for different console window path
var path = '/bc/winconsole.html';
if (bPhoneGap && top.isAndroid && top.isAndroid()) path = './winconsole.html';
if(bArchive) path = './winconsole.html?player=1';
if(bPhoneGap != true)
winCONSOLE = window.open(path, 'BCwinConsole', "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no");;
}


// For start.html to get the lang parameter CR 24366
function GetLang()
{
var args = new URLParamObj();
args.Init();
var l = args.GetParam('lang');
delete args;
return (l != null)?l:"en";
}



/**
 ** Phonegap device orientation changed event handler
 **/

function updateOrientation(evt) 
{
var ot = "landscape";
if((evt.orientation == 0) || (evt.orientation == 180)) ot = "profile";
if(safariMobileCurOrientation != ot) {
		safariMobileCurOrientation = ot;
		if(DEBUGON) debug.log("updateOrientation: safariMobileCurOrientation = " + ot );
		}
orientationChangeHandler(evt);
}

			
function loadComplete()
{
if (top.isAndroid && top.isAndroid())
{
	iAndroidWidth =self.innerWidth;
	iAndroidHeight = self.innerHeight;
	//Add height of browser url bar to available height
	//Android 2.1
	if (iAndroidHeight == 399)	iAndroidHeight = 455;
	//Android 2.2 and 2.3
	if (iAndroidHeight == 401)	iAndroidHeight = 455;
	bAndroidSoftKeyboard = false;
	if (DEBUGON == true && console && console.log)
		console.log('loadComplete(): iAndroidWidth=' + iAndroidWidth + ', iAndroidHeight=' + iAndroidHeight);
}
checkDomain(2);
var u,sSearch = "",sProtocol = "http://",uiUrl = "./indexframes.html";

// on Phonegap, device orientation change event doesn't trigger onorientationchange event but orientationChanged event...
if(bPhoneGap == true) {
	//DEBUGON = true;
	document.addEventListener('orientationChanged', updateOrientation, false);
	}
	
// getting query string from doc url
u = document.location;
if(u)
	{
	sSearch = u.search;
	sProtocol = u.protocol + "//";
	}
if(sSearch == "") { alert('Invalid client start URL!'); return; }


var args = new URLParamObj();
args.Init();

if (DEBUGON == true && bPhoneGap == true && console && console.log)
	console.log("loadComplete(): self.innerWidth=" + self.innerWidth + ",self.innerHeight=" + self.innerHeight);

var bWinConsole = args.GetParam('winconsole');
if(args.GetParam('player') == undefined) bArchive = false;

if(bWinConsole == 1) openWinConsole();

if(args.GetParam('tdulevel') == undefined)	sSearch += '&tdulevel=0';
if(args.GetParam('loglevel') == undefined)	sSearch += '&loglevel=2';

//@@@ APBC-MERGE START
if(bArchive == false)
	{
	// code for fullscreen managment
	sBi = args.GetParam('bi');
	if (sBi != "")
		{
		oBrowser = new browserId();
		if (oBrowser.Init(sBi) == null)
			{
			delete oBrowser;
			oBrowser = null;
			alert('Mandatory URL bi query string parameter is missing!');
			return;
			}
		}

	if(DEBUGON == true && bPhoneGap != true)
		uiUrl = "./debug.html";
	}
//@@@ APBC-MERGE END

gClientUserAgent = getClientUserAgent();

initBCF();

// if Internet explorer is used
	if (window.screenLeft && window.screenTop)
		statusBarHeight = (screen.height-(document.documentElement.clientHeight + ieOffSetY + TBTBieOffSetY));

if(((gClientUserAgent & UA_IPAD) == 0) && ((gClientUserAgent & UA_IPHONE) == 0)) memorizeWindow();
// end of code for fullscreen managment


// building client UI url on conference server and add content server name to query string
uiUrl = uiUrl + sSearch + "&ui=" + ui;

delete args;

// loading client UI into control frame
if(!window.opera && document.frames)
	{
	document.frames['control'].location = uiUrl;
	document.frames['content'].location.reload();
	}
else
	{
	if(document.getElementById)
		{
		var f=document.getElementById('control');
		if(f) f.src = uiUrl;
		f=document.getElementById('content');
		//Android: ignore reloading
		if(f && f.location && f.location.reload && !((top.isAndroid && top.isAndroid()))) f.location.reload();
		}
	}
}

// CR 25882 Fix for IE6
function frmsetResize()
{
if(isIE6())
	{
	if(top && top.content && top.content.updateIframeSize)
		{
		var w,h;
		if (self.innerHeight) // all except Explorer
			{
			w = self.innerWidth;
			h = self.innerHeight;
			}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
			{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
			}
		else if (document.body) // other Explorers
			{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
			}
		top.content.updateIframeSize( w - CONTROL_FRAME_WIDTH, h);
		}
	}
if (top.isAndroid && top.isAndroid())
{
if (DEBUGON == true && console && console.log)
	console.log("frmsetResize(): self.innerWidth=" + self.innerWidth + ",self.innerHeight=" + self.innerHeight);
	// Android: when soft keyboard popup, the size is 320x253 or 320x183 and it scrolls control frame.
    if (top.control && top.control.gDisplay){
		var bSoftKeyboard = bAndroidSoftKeyboard;
		bAndroidSoftKeyboard = self.innerHeight<iAndroidHeight;
		/*
		if (bAndroidSoftKeyboard && console && console.log)
				console.log('frmsetResize(): soft keyboard shows.');
		*/
		/*
		if (bSoftKeyboard && !bAndroidSoftKeyboard &&
			!top.control.gDisplay.ContentFrameVisible){
				console.log('frmsetResize(): soft keyboard hides, resize');
				top.control.gDisplay.resizeWanted = true;
				top.control.gDisplay.resize();
		}
		*/
	}
}
}
