<div id="webPhone">
<div id="phone1" class="phone1FlashWrapper">
	<div id="phone1FlashObject" style="visibility:hidden;"></div>
</div>

<!-- Welcome popup -->
<div id="phoneSettingsDialog" style="display:none;">
	<div class="phoneFrameUpper">
		<div class="welcome-content">
			<span>To enable access click allow and remember.<br> This will authorise use of your microphone.</span><br>
		</div>
	</div>
	<div class="phoneFrameLower"></div>
</div>

<!-- UpgradeFlash popup -->
<div id="phoneGeneralPanelWrapper" style="display:none;">
	<div class="phoneFrameUpper" style="background: none repeat scroll 0 0 #FFFFFF; height: 159px; margin-top: -14px; padding: 20px; width: 334px;">
		<div class="flashNeededBody" style="position:relative; z-index:99999999">
			Important! - Requires a newer version of Adobe Flash Player. 
			Click the link below and follow the instructions to install the latest Flash Player. 
			If your browser is Google Chrome, you will need to update Chrome to the latest version.
			<br /><br />
			<a href="https://www.adobe.com/go/getflashplayer" target="_blank">
				<img src="https://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
			</a>
		</div>
	</div>
	<div class="phoneFrameLower"></div>
</div>

<!-- UpgradeFlash popup -->
<div id="phoneGeneralPanelTemplate" class="phoneGeneralPanel" style="display:none;">
	<div class="phoneFrameUpper">
		<div class="phoneBody"></div>
	</div>
	<div class="phoneFrameLower"></div>
</div>

<div id="phoneIMPanel" class="phoneGeneralPanel" style="display:none;">
	<div class="phoneFrameUpper">
		<div class="phoneBody" style="position:relative; z-index:99999999">
			To:<br /><div><img src="<?php echo $this->siteBaseUrl ?>images/webphone/dial-box.png" /><input id="phoneIMTo" style="position:relative; left:-152px; top: -13px; width:145px; border:0px;" value="tel:" /></div>
			Message:<br /><div><img src="<?php echo $this->siteBaseUrl ?>images/webphone/dial-box.png" /><input id="phoneIMMessage" style="position:relative; left:-152px; top: -13px; width:145px; border:0px;" value="test <?php echo date("r") ?>" /></div>
			<div id="sendButton" class="sendButton phoneButton Green"><a href="#"><span>Send</span></a></div>

		</div>
	</div>
	<div class="phoneFrameLower"></div>
</div>

<?php 	if(  $this->SIPgwMode == 'sip-rtmp' ) : ?>
<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.phone.js"></script>
<?php 	else : ?>
<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/atmail/phone/swfobject.js"></script>
<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/atmail/phone/phoneCore.js?<?php echo rand() ?>"></script>
<?php $row = $this->selectedSIPAccount;
//Zend_Registry::get('log')->debug( "\n" . print_r($row, true) . "\n" . __METHOD__ . ' #' . __LINE__ . ": \$row \n");
 ?>
<script type="text/javascript">
$phone = new Phone({ //N.B. $phone is also used for UI stuff, but only defined, set and accessed in this UI layer, NOT internally within $.phone
	authToken : '<?php echo md5($row['Account'] . $row['AuthorizationName'] . $row['Password']) ?>',
	pid : '<?php echo $this->selectedSIPAccount['id'] ?>',
	serviceType : '<?php echo $this->selectedSIPAccount['Type'] ?>',
	serviceName : '<?php echo $this->selectedSIPAccount['Provider'] ?>',
	userId : '<?php echo $this->selectedSIPAccount['UserId'] ?>',
	phoneNumber : '<?php echo $this->selectedSIPAccount['PhoneNumber'] ?>',
	displayName : '<?php echo $this->selectedSIPAccount['DisplayName'] ?>',
	debug: false,
	uiMainMode:'hidden', 
	SIPServerType:'<?php echo $this->SIPServerType ?>',
    cssStyleTheme: '<?php echo $this->UserSettings["cssStyleTheme"]; ?>'
})

$phone.sipMode = function()
{
	return "<?php echo Zend_registry::get('config')->global['SIPType']; ?>"
}

var appBaseUrl = "<?php echo $this->appBaseUrl ?>";
var siteBaseUrl = "<?php echo $this->siteBaseUrl ?>";
var moduleBaseUrl = "<?php echo $this->moduleBaseUrl ?>";
var cssStyleTheme = "<?php $this->UserSettings['cssStyleTheme'] ?>";
var SIPgwMode = "<?php $this->SIPgwMode ?>";

</script>
<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/atmail/phone/phoneUI.js?<?php echo rand() ?>"></script>
<?php 	endif ?>

<script type="text/javascript">

//wrapper functions because flash calls these methods in the root scope (bound to Atmail common methods)
<?php 	if( $this->SIPgwMode == 'sip-rtmp' ) : ?>

function onCreationComplete(e) { 			$phone.flashInstantiated(e) }
function onPropertyChange(e) { 				$phone.onPropertyChange(e) }
function onCallback(e) { 					$phone.onConnectorCallback(e) }
function onShowingSettings(e) { 			$phone.onShowSettings(e) }

<?php else : ?>
// Flash connector methods
function flashVersionSufficient() { return swfobject.hasFlashPlayerVersion("11.1.102") }

//flash calls this method once instantiated so that phone can continue
function flashInstantiatedCallback(e) 					{ $phone.flashInstantiated(e); 					}

//wrapper functions because flash calls these methods in the root scope
function notifyFlashReady(e) 							{ $phone.glueNotifyFlashReady() 					}
function notifyConnected() 								{ $phone.glueNotifyRTMPConnected() 					}
function notifyRegisterRequired(SIPLoginProgressState)  { $phone.glueNotifySIPLoginProgress( SIPLoginProgressState ) }
function notifyRegistered(sipObject) 					{ $phone.glueNotifySIPLoginSuccess(sipObject)				}
function notifyCloseConnection() 						{ $phone.glueNotifyLostRTMPConnection() 			}
function notifyCall(caller,callerName) 					{ $phone.glueInvited( caller, callerName) 			}
function notifyError(error) 							{ $phone.glueNotifyError(error) 					}
function notifyCost(cost) 								{ $phone.glueNotifyCost(cost) 						}
function notifyBalance(balance) 						{ $phone.glueNotifyBalance(balance) 				}

//for notify events that fall outside the main ones
function notify(call, sipObject) 						{ $phone.glueNotify(call, sipObject)		}

function notifyCallbackHold(call,isHold) 				{ $phone.glueNotifyCallbackHold(call,isHold) }
function notifyVideoFormat(call) 						{ $phone.glueNotifyVideoFormat(call) 		}
function notifyMessage(messageObject, sipObject) 		{ $phone.glueNotifyMessage(messageObject, sipObject) }
function notifyAddCall(call) 							{ $phone.glueNotifyAddCall(call) 			}
function notifyRemoveCall(call) 						{ $phone.glueNotifyRemoveCall(call) 		}
function notifyVersion(version) 						{ $phone.glueNotifyVersion(version) 		}
function notifyAgc(agc)									{ $phone.glueNotifyAgc(agc)					}
function notifySubscription(subscribeObject,sipObject)	{ $phone.glueNotifySubscription(subscribeObject,sipObject) }

function notifyXcapResponse(body)						{ $phone.glueNotifyXcapResponse(body) }


function addLogMessage(message) 						{ $phone.addLogMessage(message) 			}

<?php 	endif ?>
</script>
</div>
