<?php
/**	*************************************************************************************************************
*	mod_olark_chat.php                                                                                           
*	-------------------------------------------------------------------------------------------------------------
*	@author     Mario Gleichmann                                                                                 
*	@package    Joomla                                                                                           
*	@version    1.1.1                                                                                            
*	@copyright  Copyright (C) 2009 Mario Gleichmann. All rights reserved.                                        
*	@mail       mgleich@orcas-internet.de                                                                        
*	@license    GNU/GPL, see LICENSE.php                                                                         
*	                                                                                                             
*	Joomla! is free software. This version may have been modified pursuant to the GNU General Public License, and
*	as distributed it includes or is derivative of works licensed under the GNU General Public License or other  
*	free or open source software licenses. See COPYRIGHT.php for copyright notices and details.                  
*/

defined('_JEXEC') or die('Direct Access to this location is not allowed.');

$sOlarkId=$params->get('olarkid', '');

$sSayText=(($params->get('say_text_DEFAULT', '0') == '1') ? JText::_("Type here and hit <enter> to chat") : $params->get('say_text', ''));
if($sSayText == "Type here and hit <enter> to chat")
	$sSayText="";

$sNotAvailableText=(($params->get('not_available_text_DEFAULT', '0') == '1') ? JText::_("Live Help: Offline") : $params->get('not_available_text', ''));
if($sNotAvailableText == "Live Help: Offline")
	$sNotAvailableText="";
$sOfflineMessage=(($params->get('offline_message_DEFAULT', '0') == '1') ? JText::_("Our live support feature is currently offline. Please try again later.") : $params->get('offline_message', ''));
if($sOfflineMessage == "Our live support feature is currently offline. Please try again later.")
	$sOfflineMessage="";
$sBusyText=(($params->get('busy_text_DEFAULT', '0') == '1') ? JText::_("Live Help: Unavailable") : $params->get('busy_text', ''));
if($sBusyText == "Live Help: Unavailable")
	$sBusyText="";
$sBusyMessage=(($params->get('busy_message_DEFAULT', '0') == '1') ? JText::_("All of our representatives are with other customers at this time. We will be with you shortly.") : $params->get('busy_message', ''));
if($sBusyMessage == "All of our representatives are with other customers at this time. We will be with you shortly.")
	$sBusyMessage="";

$sBeforeChatText=(($params->get('before_chat_text_DEFAULT', '0') == '1') ? JText::_("Click for Live Help") : $params->get('before_chat_text', ''));
if($sBeforeChatText == "Click for Live Help")
	$sBeforeChatText="";
$sInChatText=(($params->get('in_chat_text_DEFAULT', '0') == '1') ? JText::_("Live Help: Now Chatting") : $params->get('in_chat_text', ''));
if($sInChatText == "Live Help: Now Chatting")
	$sInChatText="";
$sWelcomeMsg=(($params->get('welcome_msg_DEFAULT', '0') == '1') ? JText::_("Questions? This window is your portal to live online support. We are around, send us a message.") : $params->get('welcome_msg', ''));
if($sWelcomeMsg == "Questions? This window is your portal to live online support. We are around, send us a message.")
	$sWelcomeMsg="";

$sPreChatMessage=(($params->get('pre_chat_message_DEFAULT', '0') == '1') ? JText::_("Hi, I am around, click 'start chatting' to contact me.") : $params->get('pre_chat_message', ''));
if($sPreChatMessage == "Hi, I am around, click 'start chatting' to contact me.")
	$sPreChatMessage="";
$sPreChatErrorText=(($params->get('pre_chat_error_text_DEFAULT', '0') == '1') ? JText::_("Please enter your name and email in case we get disconnected.") : $params->get('pre_chat_error_text', ''));
if($sPreChatErrorText == "Please enter your name and email in case we get disconnected.")
	$sPreChatErrorText="";
$sPreChatSubmit=(($params->get('pre_chat_submit_DEFAULT', '0') == '1') ? JText::_("Click here to start chatting") : $params->get('pre_chat_submit', ''));
if($sPreChatSubmit == "Click here to start chatting")
	$sPreChatSubmit="";

$sEmailBodyErrorText=(($params->get('email_body_error_text_DEFAULT', '0') == '1') ? JText::_("Complete all fields") : $params->get('email_body_error_text', ''));
if($sEmailBodyErrorText == "Complete all fields")
	$sEmailBodyErrorText="";
$sHablaNameInputText=(($params->get('habla_name_input_text_DEFAULT', '0') == '1') ? JText::_("<click here> and type your Name") : $params->get('habla_name_input_text', ''));
if($sHablaNameInputText == "<click here> and type your Name")
	$sHablaNameInputText="";
$sHablaOfflineEmailText=(($params->get('habla_offline_email_text_DEFAULT', '0') == '1') ? JText::_("<click here> and type your Email") : $params->get('habla_offline_email_text', ''));
if($sHablaOfflineEmailText == "<click here> and type your Email")
	$sHablaOfflineEmailText="";
$sHablaOfflineSubmitValue=(($params->get('habla_offline_submit_value_DEFAULT', '0') == '1') ? JText::_("Send") : $params->get('habla_offline_submit_value', ''));
if($sHablaOfflineSubmitValue == "Send")
	$sHablaOfflineSubmitValue="";
$sHablaOfflineBodyText=(($params->get('habla_offline_body_text_DEFAULT', '0') == '1') ? JText::_("We are offline, send us a message") : $params->get('habla_offline_body_text', ''));
if($sHablaOfflineBodyText == "We are offline, send us a message")
	$sHablaOfflineBodyText="";
$sHablaOfflineSentText=(($params->get('habla_offline_sent_text_DEFAULT', '0') == '1') ? JText::_("Thank you for your message. We will get back to you as soon as we can.") : $params->get('habla_offline_sent_text', ''));
if($sHablaOfflineSentText == "Thank you for your message. We will get back to you as soon as we can.")
	$sHablaOfflineSentText="";

$sAwayText=(($params->get('away_text_DEFAULT', '0') == '1') ? JText::_("Live Help: Unavailable") : $params->get('away_text', ''));
if($sAwayText == "Live Help: Unavailable")
	$sAwayText="";
$sSendText=(($params->get('send_text_DEFAULT', '0') == '1') ? JText::_("Send") : $params->get('send_text', ''));
if($sSendText == "Send")
	$sSendText="";
$sSendingText=(($params->get('sending_text_DEFAULT', '0') == '1') ? JText::_("sending") : $params->get('sending_text', ''));
if($sSendingText == "sending")
	$sSendingText="";

$nInline=$params->get('inline', '-1');

$nShowAway=$params->get('show_away', '-1');
$nShowAwayAsHeader=$params->get('show_away_as_header', '-1');

$nHideMinMaxButtons=$params->get('hide_min_max_buttons', '-1');
$nEnableButtons=$params->get('enable_buttons', '-1');
$nParseLinks=$params->get('parse_links', '-1');
$sUrlHandlerTargetWindow=(($params->get('url_handler_target_window_DEFAULT', '0') == '1') ? "_top" : $params->get('url_handler_target_window', ''));
if($sUrlHandlerTargetWindow == "_top")
	$sUrlHandlerTargetWindow="";
$sUrlLocalPattern=(($params->get('url_local_pattern_DEFAULT', '0') == '1') ? "document.domain" : $params->get('url_local_pattern', ''));
if($sUrlLocalPattern == "document.domain")
	$sUrlLocalPattern="";
$sUrlHandler=(($params->get('url_handler_DEFAULT', '0') == '1') ? "http://static.hab.la/js/html/url_handler.html" : $params->get('url_handler', ''));
if($sUrlHandler == "http://static.hab.la/js/html/url_handler.html")
	$sUrlHandler="";

$sDefaultFlashOffIcon=(($params->get('default_flash_off_icon_DEFAULT', '0') == '1') ? "http://static.hab.la/js/images/white.ico" : $params->get('default_flash_off_icon', ''));
if($sDefaultFlashOffIcon == "http://static.hab.la/js/images/white.ico")
	$sDefaultFlashOffIcon="";
$sDefaultFlashOnIcon=(($params->get('default_flash_on_icon_DEFAULT', '0') == '1') ? "http://static.hab.la/js/images/orange.ico" : $params->get('default_flash_on_icon', ''));
if($sDefaultFlashOnIcon == "http://static.hab.la/js/images/orange.ico")
	$sDefaultFlashOnIcon="";
$nFlashIcons=$params->get('flash_icons', '-1');

$nDisableGoogleAnalytics=$params->get('disableGoogleAnalytics', '-1');

$bNotSecure=strpos($_SERVER['SERVER_PROTOCOL'], "HTTPS") === false;
?>
<script type="text/javascript" src="http<?php if(!$bNotSecure) echo "s"; ?>://static.olark.com/js/wc.js"></script>
<script type="text/javascript">
tConfig=wc_config();
<?php
if($sSayText != "")
	echo "tConfig.vars[\"say_text\"]=\"$sSayText\";\n";

if($sNotAvailableText != "")
	echo "tConfig.vars[\"not_available_text\"]=\"$sNotAvailableText\";\n";
if($sOfflineMessage != "")
	echo "tConfig.vars[\"offline_message\"]=\"$sOfflineMessage\";\n";
if($sBusyText != "")
	echo "tConfig.vars[\"busy_text\"]=\"$sBusyText\";\n";
if($sBusyMessage != "")	
	echo "tConfig.vars[\"busy_message\"]=\"$sBusyMessage\";\n";

if($sBeforeChatText != "")
	echo "tConfig.vars[\"before_chat_text\"]=\"$sBeforeChatText\";\n";
if($sInChatText != "")
	echo "tConfig.vars[\"in_chat_text\"]=\"$sInChatText\";\n";
if($sWelcomeMsg != "")
	echo "tConfig.vars[\"welcome_msg\"]=\"$sWelcomeMsg\";\n";

if($sPreChatMessage != "")
	echo "tConfig.vars[\"pre_chat_message\"]=\"$sPreChatMessage\";\n";
if($sPreChatErrorText != "")
	echo "tConfig.vars[\"pre_chat_error_text\"]=\"$sPreChatErrorText\";\n";
if($sPreChatSubmit != "")
	echo "tConfig.vars[\"pre_chat_submit\"]=\"$sPreChatSubmit\";\n";

if($sEmailBodyErrorText != "")
	echo "tConfig.vars[\"email_body_error_text\"]=\"$sEmailBodyErrorText\";\n";
if($sHablaNameInputText != "")
	echo "tConfig.vars[\"habla_name_input_text\"]=\"$sHablaNameInputText\";\n";
if($sHablaOfflineBodyText != "")
	echo "tConfig.vars[\"habla_offline_body_text\"]=\"$sHablaOfflineBodyText\";\n";
if($sHablaOfflineEmailText != "")
	echo "tConfig.vars[\"habla_offline_email_text\"]=\"$sHablaOfflineEmailText\";\n";
if($sHablaOfflineSentText != "")
	echo "tConfig.vars[\"habla_offline_sent_text\"]=\"$sHablaOfflineSentText\";\n";
if($sHablaOfflineSubmitValue != "")
	echo "tConfig.vars[\"habla_offline_submit_value\"]=\"$sHablaOfflineSubmitValue\";\n";

if($sAwayText != "")	
	echo "tConfig.vars[\"away_text\"]=\"$sAwayText\";\n";
if($sSendText != "")	
	echo "tConfig.vars[\"send_text\"]=\"$sSendText\";\n";
if($sSendingText != "")	
	echo "tConfig.vars[\"sending_text\"]=\"$sSendingText\";\n";

if($nInline != "-1")
	echo "tConfig.setInline($nInline);\n";

if($nShowAway != "-1")
	echo "tConfig.vars[\"show_away\"]=$nShowAway;\n";
if($nShowAwayAsHeader != "-1")
	echo "tConfig.vars[\"show_away_as_header\"]=$nShowAwayAsHeader;\n";

if($nHideMinMaxButtons != "-1")
	echo "tConfig.vars[\"hide_min_max_buttons\"]=$nHideMinMaxButtons;\n";
if($nEnableButtons != "-1")
	echo "tConfig.vars[\"enable_buttons\"]=$nEnableButtons;\n";
if($nParseLinks != "-1")
	echo "tConfig.vars[\"parse_links\"]=$nParseLinks;\n";
if($sUrlHandlerTargetWindow != "")
	echo "tConfig.vars[\"url_handler_target_window\"]=\"$sUrlHandlerTargetWindow\";\n";
if($sUrlLocalPattern != "")
	echo "tConfig.vars[\"url_local_pattern\"]=\"$sUrlLocalPattern\";\n";
if($sUrlHandler != "")
	echo "tConfig.vars[\"url_handler\"]=\"$sUrlHandler\";\n";

if($sDefaultFlashOffIcon != "")
	echo "tConfig.vars[\"default_flash_off_icon\"]=\"$sDefaultFlashOffIcon\";\n";
if($sDefaultFlashOnIcon != "")
	echo "tConfig.vars[\"default_flash_on_icon\"]=\"$sDefaultFlashOnIcon\";\n";
if($nFlashIcons != "-1")
	echo "tConfig.vars[\"flash_icons\"]=$nFlashIcons;\n";

if($nDisableGoogleAnalytics != "-1")
	echo "tConfig.vars[\"disableGoogleAnalytics\"]=$nDisableGoogleAnalytics;\n";
?>
wc_init("<?php echo $sOlarkId; ?>", tConfig); 
</script>
