{* Smarty template for chat_index.php *}
{include file = "includes/header.tpl"}

{if $smarty.get.close}
    <script type = "text/javascript">
    <!--
        window.close();
    //-->
    </script>
{/if}


{if (isset($T_CHATROOMS_ID))}
    <script type = "text/javascript">
    <!--
        setInterval("makeAjaxRequest('ask_chat.php?chatrooms_ID={$T_CHATROOMS_ID}','special_get_request','chat')",2500);
        document.onload=setTimeout("setFocus()",2000);
    -->
    </script>
{/if}

<script type = "text/javascript">
<!--
    if (top.sideframe) top.sideframe.changeTDcolor('chat_a');      
//-->
</script>

{*-------------------------------End of Part 1: initialization etc-----------------------------------------------*}






{*-------------------------------Part 2: Modules List ---------------------------------------------*}
{if (isset($T_SHOW_ROOMS_LIST))}
{**moduleRoomsList: Show the list of rooms*}
    {capture name = "moduleRoomsList"}
                            <tr><td class = "moduleCell">

                            {capture name = 't_public_rooms_code'}
                                                <table border = "0" width="100%">
                                {if $smarty.session.s_type != 'student'}
                                                    <tr><td>
                                                            <a href = "chat/chat_room_options.php?new_public_room=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._NEWPUBLICROOM}', new Array('300px', '100px'))" class = "innerTable"><img src = "images/16x16/add2.png" alt = "{$smarty.const._NEWPUBLICROOM}" title = "{$smarty.const._NEWPUBLICROOM}" border = "0" style = "vertical-align:middle"/></a>&nbsp;
                                                            <a href = "chat/chat_room_options.php?new_public_room=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._NEWPUBLICROOM}', new Array('300px', '100px'))" class = "innerTable" style = "vertical-align:middle">{$smarty.const._NEWPUBLICROOM}</a></td></tr>
                                                    <tr><td>&nbsp;</td></tr>
                                {/if}       
                                {section name = 'public_rooms_list' loop = $T_PUBLIC_ROOMS}
                                    {if $T_PUBLIC_ROOMS[public_rooms_list].active}
                                        {capture name = 't_assign'}<img src = "images/16x16/trafficlight_green.png" alt = "{$smarty.const._DEACTIVATE}" title = "{$smarty.const._DEACTIVATE}" border = "0">{/capture}
                                                    <tr><td width="40%"><span class = "counter">{$smarty.section.public_rooms_list.iteration}.</span>&nbsp;<a href = "chat/chat_index.php?chatrooms_ID={$T_PUBLIC_ROOMS[public_rooms_list].id}" title="{$T_PUBLIC_ROOMS[public_rooms_list].name}">{$T_PUBLIC_ROOMS[public_rooms_list].name|eF_truncate:25:"...":true}</a></td>
                                    {else}
                                        {capture name = 't_assign'}<img src = "images/16x16/trafficlight_red.png" alt = "{$smarty.const._ACTIVATE}" title = "{$smarty.const._ACTIVATE}" border = "0"/>{/capture}
                                                    <tr><td width="40%"><span class = "counter">{$smarty.section.public_rooms_list.iteration}.</span>&nbsp;<span title="{$T_PUBLIC_ROOMS[public_rooms_list].name}">{$T_PUBLIC_ROOMS[public_rooms_list].name|eF_truncate:25:"...":true}</span></td>
                                    {/if}
                                                        <td>[(#filter:timestamp-{$T_PUBLIC_ROOMS[public_rooms_list].create_timestamp}#), {$T_PUBLIC_ROOMS[public_rooms_list].num_of_users_in_room} {$smarty.const._PARTICIPANTS}]</td>
                                    {if $T_PUBLIC_ROOMS[public_rooms_list].users_LOGIN == $smarty.session.s_login}
                                                        <td><a class = "deleteLink" href = "chat/chat_index.php?id={$T_PUBLIC_ROOMS[public_rooms_list].id}&delete=1"><img src = "images/16x16/delete.png" alt = "{$smarty.const._DELETE}" title = "{$smarty.const._DELETE}" border = "0"/></a>
                                                            <a class = "activateLink" href = "chat/chat_index.php?id={$T_PUBLIC_ROOMS[public_rooms_list].id}&activate=1">{$smarty.capture.t_assign}</a>
                                        {if $T_PUBLIC_ROOMS[public_rooms_list].active}
                                                            <a class = "inviteLink" href = "forum/new_message.php?chat_invite={$T_PUBLIC_ROOMS[public_rooms_list].id}" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._INVITEUSERS}', new Array('600px', '400px'))"><img src = "images/16x16/user1_into.png" alt = "{$smarty.const._INVITEUSERS}" title = "{$smarty.const._INVITEUSERS}" border = "0"/></a> </td>
                                        {/if}
                                    {/if}
                                                        <td>{if (isset($T_PUBLIC_ROOMS[public_rooms_list].exit))}<a class = "exitLink" href = "chat/chat_index.php?logout=1&chatrooms_ID={$T_PUBLIC_ROOMS[public_rooms_list].id}"><img src = "images/16x16/arrow_left_blue.png" alt = "{$smarty.const._EXIT}" title = "{$smarty.const._EXIT}" border = "0"/></a>{/if}</td>
                                                    </tr>

                                {sectionelse}
                                                    <tr><td class = "emptyCategory">{$smarty.const._NOROOMSFOUND}</td></tr>
                                {/section}
                                                </table>

                            {/capture}

                            {capture name = 't_private_rooms_code'}
                                                <table border = "0" width="100%">
                                                    <tr><td><a href = "chat/chat_room_options.php?new_private_room=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._NEWPRIVATEROOM}', new Array('300px', '100px'))" class = "innerTable"><img src = "images/16x16/add2.png" alt = "{$smarty.const._NEWPRIVATEROOM}" title = "{$smarty.const._NEWPRIVATEROOM}" border = "0" style = "vertical-align:middle"/>&nbsp;<span style = "vertical-align:middle">{$smarty.const._NEWPRIVATEROOM}</span></a></td></tr>
                                                    <tr><td>&nbsp;</td></tr>
                                {section name = 'private_rooms_list' loop = $T_PRIVATE_ROOMS}
                                    {if $T_PRIVATE_ROOMS[private_rooms_list].active}
                                        {capture name = 't_assign'}<img src = "images/16x16/trafficlight_green.png" alt = "{$smarty.const._DEACTIVATE}" title = "{$smarty.const._DEACTIVATE}" border = "0"/>{/capture}
                                                    <tr><td width="40%"><span class = "counter">{$smarty.section.private_rooms_list.iteration}.</span>&nbsp;<a href = "chat/chat_index.php?chatrooms_ID={$T_PRIVATE_ROOMS[private_rooms_list].id}" title="{$T_PRIVATE_ROOMS[private_rooms_list].name}">{$T_PRIVATE_ROOMS[private_rooms_list].name|eF_truncate:25:"...":true}</a></td>
                                    {else}
                                        {capture name = 't_assign'} <img src = "images/16x16/trafficlight_red.png" alt = "{$smarty.const._ACTIVATE}" title = "{$smarty.const._ACTIVATE}" border = "0"/>{/capture}
                                                    <tr><td width="40%"><span class = "counter">{$smarty.section.private_rooms_list.iteration}.</span>&nbsp;<span title="{$T_PRIVATE_ROOMS[private_rooms_list].name}">{$T_PRIVATE_ROOMS[private_rooms_list].name|eF_truncate:25:"...":true}</span></td>
                                    {/if}
                                                        <td>[(#filter:timestamp-{$T_PRIVATE_ROOMS[private_rooms_list].create_timestamp}#), {$T_PRIVATE_ROOMS[private_rooms_list].num_of_users_in_room} {$smarty.const._PARTICIPANTS}]</td>
                                    {if $T_PRIVATE_ROOMS[private_rooms_list].users_LOGIN == $smarty.session.s_login}
                                                        <td><a class = "deleteLink" href = "chat/chat_index.php?id={$T_PRIVATE_ROOMS[private_rooms_list].id}&delete=1"><img src = "images/16x16/delete.png" alt = "{$smarty.const._DELETE}" title = "{$smarty.const._DELETE}" border = "0"/></a>
                                                            <a href = "chat/chat_index.php?id={$T_PRIVATE_ROOMS[private_rooms_list].id}&activate=1">{$smarty.capture.t_assign}</a>
                                        {if $T_PRIVATE_ROOMS[private_rooms_list].active}
                                                            <a class = "inviteLink" href = "forum/new_message.php?chat_invite={$T_PRIVATE_ROOMS[private_rooms_list].id}" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._INVITEUSERS}', new Array('600px', '400px'))"><img src = "images/16x16/user1_into.png" alt = "{$smarty.const._INVITEUSERS}" title = "{$smarty.const._INVITEUSERS}" border = "0"/></a> </td>
                                        {/if}
                                                        </td>
                                    {/if}
                                                        <td>{if (isset($T_PRIVATE_ROOMS[private_rooms_list].exit))}<a href = "chat/chat_index.php?logout=1&chatrooms_ID={$T_PRIVATE_ROOMS[private_rooms_list].id}"><img src = "images/16x16/arrow_left_blue.png" alt = "{$smarty.const._EXIT}" title = "{$smarty.const._EXIT}" border = "0"/></a>{/if}</td>
                                                    </tr>

                                {sectionelse}
                                                    <tr><td class = "emptyCategory">{$smarty.const._NOROOMSFOUND}</td></tr>
                                {/section}
                                                </table>
                            {/capture}

                            {capture name = 't_options_code'}
                                        <table border = "0" width="100%">
                                            <tr><td>
                                                <span class = "counter">1.</span> <a href = "chat/chat_room_options.php?past_messages=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._SHOWPASTCOVERSATIONS}', new Array('600px', '300px'))">{$smarty.const._SHOWPASTCOVERSATIONS}</a> 
                                            </td></tr>
                                        </table>
                            {/capture}

                                <table width = "100%" align = "left" valign = "top" border = "0">
                                    <tr><td>
                                        {eF_template_printInnerTable title=$smarty.const._PUBLICROOMS data=$smarty.capture.t_public_rooms_code image='/32x32/users1.png'}
                                    </td></tr>
                                    <tr><td>
                                        {eF_template_printInnerTable title=$smarty.const._PRIVATEROOMS data=$smarty.capture.t_private_rooms_code image='/32x32/users2.png'}
                                    </td></tr>
                                    <tr><td>
                                        {eF_template_printInnerTable title=$smarty.const._OPTIONS data=$smarty.capture.t_options_code image='/32x32/gears.png'}
                                    </td></tr>
                                </table>  

                            </td></tr>
    {/capture}
{/if}

{if isset($T_SHOW_ROOM)}
{**moduleShowRoom: Show the room*}
    {capture name = "moduleShowRoom"}
                            <tr><td class = "moduleCell" >
							{assign var = 't_show_side_menu' value = true}
							{assign var = "room_title" value = $T_ROOM_TITLE|eF_truncate:30:"...":true}
							{assign var = "title" value ='&nbsp;&raquo;&nbsp;'|cat:$room_title}
                            {capture name = 't_input_code'}
                                    <table border = "0">
                                {if $smarty.get.standalone}
                                        <tr><td align = "center">{$smarty.const._ROOM}: <span class = "boldFont">{$T_ROOM_TITLE}</span></td></tr>
                                {/if}
                                        <tr>
                                            <form name = "chat_form" action = "javascript:sendMessage(document.chat_form.chat_message.value,'{$T_CHATROOMS_ID}');" method = "post">
                                            <td nowrap>{$smarty.const._MESSAGE}: <input type = "text" name = "chat_message" size = "40" valign = "middle" onpaste = "javascript: document.chat_form.submit.disabled = false;" onKeyup = "javascript:enableButton();" onMouseup = "javascript:enableButton();"/>
                                                <input type = "submit" name = "submit" value = "{$smarty.const._SEND}"  class = "flatButton"/>
                                                <input type = "hidden" name = "hidden_chat_room_id" value = "{$T_CHATROOMS_ID}"/>
                                            </td>
                                            </form>    
                                            <td>
                                                <a href = "chat/smilies.php" onclick = "eF_js_showDivPopup('{$smarty.const._SMILIES}', new Array('250px', '150px'))" target = "POPUP_FRAME"><img src = "images/smilies/icon_smile.gif" border = "0"/></a>
                                            </td>
                                        </tr>
                                    </table>
                            {/capture}

                            <script type="text/javascript">
                            {literal}
                            <!--
                                /*The user navigated away from the page, so log him out*/
                                function chat_logout() 
                                {
                            {/literal}
                                    logout_window = window.open("chat/chat_room_options.php?logout=1&chatrooms_ID={$T_CHATROOMS_ID}", "chat_logout", "scrollbars=no, resizable=no, toolbar=no, menubar=no, status=no, location=no, height=5, width=5");
                            {literal}
                                    logout_window.blur();
                                }

                                /*Resize the windows so that the new one appears below the parent window*/
                                function resizeChild() 
                                {
                                    parent_width  = parent.document.body.clientWidth; 
                                    parent_height = parent.document.body.clientHeight; 
                            {/literal}
                                    new_window    = window.open('chat/chat_index.php?chatrooms_ID={$T_CHATROOMS_ID}&standalone=1', 'standalone', 'resizable=yes, scrollbars=yes, width='+parent_width+', height=150'); 
                            {literal}
                                    parent.resizeTo(parent_width, parent_height - 50); 
                                    parent.moveTo(1, 1); 
                                    new_window.moveTo(1, parent_height - 50);
                                }
                            //-->
                            {/literal}
                            </script>
				<script language="JavaScript">
				 {literal}
				<!--
				function resize_iframe()
				{

					var height=window.innerWidth;//Firefox
					if (document.body.clientHeight)
					{
						height=document.body.clientHeight-100;//IE
					}
					//resize the iframe according to the size of the
					//window (all these should be on the same line)
					document.getElementById("glu").style.height=parseInt(height-
					document.getElementById("glu").offsetTop-8)+"px";
				}

				// this will resize the iframe every
				// time you change the size of the window.
				window.onresize=resize_iframe; 

				//Instead of using this you can use: 
				//	<BODY onresize="resize_iframe()">


				//-->
				 {/literal}
				</script>

                                    <table border = "0" width = "100%" style="height:100%;" cellpadding = "2">
                                     <tr><td>
                                            {$smarty.capture.t_input_code}
                                        </td></tr>
                                        <tr>
						<td valign = "top" style="height:100%;">
							<iframe name = "test" frameborder = "no" style="border: 1px solid #DDDDDD; " scrolling="auto" id="glu" width="100%" onload="resize_iframe()" src = "chat/blank.php" />{$smarty.const._SORRYNEEDIFRAME}</iframe>
						</td>
					</tr>
   
                                    </table>   

                            </td></tr>
    {/capture}
{/if}

{if isset($T_SHOW_ROOM)}
    {capture name = "sideRoomOptions"}  
                            {capture name = 't_functions_code'}
                                    <table>                                
                                        <tr><td><span class = "counter">{counter}.</span> <a href = "chat/chat_index.php?logout=1">{$smarty.const._EXITCHAT}</a></td></tr>
                                        {*<tr><td><span class = "counter">{counter}.</span> <a href = "javascript:void(0)" onclick = "resizeChild()">{$smarty.const._ADJUSTTOPAGE}</a></td></tr>*}
                                {if $smarty.session.s_type != 'student'}
                                        <tr><td><span class = "counter">{counter}.</span> <a href = "chat/chat_room_options.php?new_public_room=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._CREATEPUBLICROOM}', new Array('300px', '100px'))" >{$smarty.const._CREATEPUBLICROOM}</a></td></tr>
                                {/if}
                                        <tr><td><span class = "counter">{counter}.</span> <a href = "chat/chat_room_options.php?new_private_room=1" target = "POPUP_FRAME" onclick = "eF_js_showDivPopup('{$smarty.const._CREATEPRIVATEROOM}', new Array('300px', '100px'))" >{$smarty.const._CREATEPRIVATEROOM}</a></td></tr>
                                        <tr><td><span class = "counter">{counter}.</span> <a href = "chat/chat_index.php">{$smarty.const._GOTOCHATROOMSLIST}</a></td></tr>
                                    </table>    
                            {/capture}

                                            {assign var = 't_rooms_span' value = '<span id = "rooms_list"></span>'}
                                            {eF_template_printSide title=$smarty.const._OPENROOMS data=$t_rooms_span id = 'open_rooms'}
                                            {eF_template_printSide title=$smarty.const._OPTIONS data=$smarty.capture.t_functions_code id = 'functions_list'}
                                            {assign var = 't_users_span' value = '<span id = "users_list"></span>'}
                                            {eF_template_printSide title=$smarty.const._OTHERUSERSINROOM data=$t_users_span id = 'other_users'}
                                            <span id = "notice"></span>
    {/capture}
{/if}


{*----------------------------End of Part 2: Modules List------------------------------------------------*}



{*-----------------------------Part 3: Display table-------------------------------------------------*}
{if $T_USER == 'professor'}
    {assign var = "home_title" value = '<a class = "titleLink" href ="professor.php?ctg=control_panel">'|cat:$smarty.const._HOME|cat:'</a>'}
{elseif $T_USER == 'administrator'}
    {assign var = "home_title" value = '<a class = "titleLink" href ="administrator.php?ctg=control_panel">'|cat:$smarty.const._HOME|cat:'</a>'}
{else}
    {assign var = "home_title" value = '<a class = "titleLink" href ="student.php?ctg=control_panel">'|cat:$smarty.const._HOME|cat:'</a>'}
{/if}

<table class = "mainTable">
    <tr>
        <td style = "vertical-align: top;">
            <table class = "centerTable">
                <tr class = "topTitle">
                    <td colspan = "2" class = "topTitle">                               {*Header*}
                        {$home_title}&nbsp;&raquo;&nbsp;<a class = "titleLink"  href ="javascript:void(0)" onclick = "location.reload()">{$smarty.const._CHAT}</a>
                    </td>         
               </tr>
{if $T_MESSAGE}
                <tr class = "messageRow">
                    <td colspan = "2">{eF_template_printMessage message=$T_MESSAGE type=$T_MESSAGE_TYPE}</td>        {*Display Message, if any*}
                </tr>
{/if}
{if $T_SEARCH_MESSAGE}
                <tr class = "messageRow">
                    <td colspan = "2">{eF_template_printMessage message=$T_SEARCH_MESSAGE}</td>        {*Display Search Message, if any*}
                </tr>                                        
{/if}                                    

{if ($T_OPERATION == 'control_panel')}        {*Pages with 2-column layout*}
{*LEFT MAIN COLUMN*}
                <tr>
                    <td class = "leftColumn" id = "leftColumn">
                        <table class = "leftColumnData">
                        </table>
                    </td>
{*RIGHT MAIN COLUMN*}
                    <td class = "rightColumn" id = "rightColumn">
                        <table class = "rightColumnData">
                        </table>
                    </td>
                </tr>
{else}                                                                          {*Pages with single-column layout*}
{*SINGLE MAIN COLUMN*}
                <tr>
                    <td class = "singleColumn" id = "singleColumn">
                        <table class = "singleColumnData" height = "100%">
                                {$smarty.capture.moduleShowRoom}
                                {$smarty.capture.moduleRoomsList}
                        </table>
                    </td>
                </tr>
{/if}
            </table>

        </td>
{*RIGHT SIDE MENU*}
{if isset($T_SHOW_ROOM) && !$smarty.get.standalone}
        <td class = "sideMenu" id = "sideMenu">
            {$smarty.capture.sideRoomOptions}
        </td>
{/if}
    </tr>
{if $T_SHOWFOOTER}
    {include file = "includes/footer.tpl"}
{/if}
</table>

{*-----------------------------End of Part 3: Display table-------------------------------------------------*}

{*-----------------------------Part 4: Finalization data etc-------------------------------------------------*}
{include file = "includes/closing.tpl"}

</body>
</html>
