<?php
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# genearate header and footer
#
# !! be careful, this file must be saved under uft8 format, and display an e accentuated here : é
# ***************************************

function page_begining_simple() {
    $html = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Portaneo mobile</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport" content="width=320">
            <link href="../styles/mobile_css.css" rel="stylesheet" type="text/css" />
            <link href="../styles/mobile_css_widgets.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="../includes/ajax-mob-min.js"></script>
    </head>
    <body>';      
    return $html;
}

function page_begining() {
    $isCompatible = false;
    $ua = $_SERVER['HTTP_USER_AGENT']; 
    if  (( strpos($ua,'iPhone') != false )
        ||( strpos($ua,'iPod') != false )
        ||( strpos($ua,'Android') != false ) ) {
            $isCompatible = true;
    }
    //do not load the iscroll script if it's a smartphone application
    if (isset($_SESSION['smartphone'])) $isCompatible = false;
    
    $html = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Portaneo mobile</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
        if ($isCompatible) {
            $html .= '
            <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
            <meta name="apple-mobile-web-app-capable" content="yes" />
            <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
            <link href="../styles/mobile_css_compatible.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="../includes/iscroll.js?v3.6"></script>';
        }
        else {
            $html .= '
            <meta name="viewport" content="width=320">
            <link href="../styles/mobile_css.css" rel="stylesheet" type="text/css" />';
        }
        if (isset($_SESSION['smartphone'])) {
            $html .= '<link href="../styles/mobile_smartphone.css" rel="stylesheet" type="text/css" />';
        }
    $html .= '
    </head>
    <body>';
        
    return $html;
}

function generate_header($message='', $updateStatus='')
{
	global $islogin;
	global $selectedTab;
    $html = '';
    if (isset($_SESSION["smartphone"])) {  return $html;  }
	if (isset($islogin)) {
        $html.= '
        <div id="headerlogin">
            <a href="index.php"><img src="../../../../images/s.gif" width="130" height="40"></a>
        </div>';
	}
	else {
        $html.='
            <div class="header_name">'.$message.'</div>
            <div class="statusMessage"><span class="spanstatusmsg">'.lg("$updateStatus").'</span></div>
            <div id="header_search">
                <form method="get" action="search.php">
                    <input type="hidden" name="tab" value="'.$selectedTab.'" />
                    <input type="text" class="header_search_btn" name="search" value="'.lg("search").'" style="width: 80px;" />
                    <input type="image" src="../images/ico_search.gif" alt="search" width="16" height="16" />
                </form>
            </div>';
	}    
    return $html;
}

//$current can be "pages" - "network" - "notebook" - "group"
function generate_footer($current = '')
{
	global $islogin;      
    if (isset($_SESSION["smartphone"])) {
        return '';
    }
	if (isset($islogin)) {
		return '
		</div>
		</body>
		</html>';
	}
	else {
        $pages_style = ($current == "pages")         ?   "footer_options_img_sel"    :   "footer_options_img";
        $network_style = ($current == "network")     ?   "footer_options_img_sel"    :   "footer_options_img";
        $notebook_style = ($current == "notebook")   ?   "footer_options_img_sel"    :   "footer_options_img";
        $group_style = ($current == "group")         ?   "footer_options_img_sel"    :   "footer_options_img";
        
		$html  = '<div id="foot">
                    <div id="footer_logo"></div>
                    <div id="footer_options">
                        <a href="portal.php"><div class="'.$pages_style.'"><img src="../images/ico_pages.png"><br /><span class="footspan">'.lg("Pages").'</span></div></a>';
        if (__useNetwork)  
        $html .= '      <a href="network.php"><div class="'.$network_style.'"><img src="../images/ico_network.png"><br /><span class="footspan">'.lg("Network").'</span></div></a>';
        if (__useNetwork && __useNotebook)
        $html .= '      <a href="network_profil.php?id='.$_SESSION['user_id'].'&act=prof"><div class="'.$notebook_style.'"><img src="../images/ico_notebook.png"><br /><span class="footspan">'.lg("notebook").'</span></div></a>';
        if (__useNetwork && __useGroup)
        $html .= '      <a href="group.php"><div class="'.$group_style.'"><img src="../images/ico_group.png"><br /><span class="footspan">'.lg("groups").'</span></div><a/>';
        $html .= '  </div>
                 </div>
            </body>
        </html>';
        
        return $html;        
	}
}

function generate_footer_widget()
{
	return '
		</body>
		</html>';
}

function generate_warning($type,$txt,$link,$txt_link)
{
	switch ($type) {
		case 'alert':
			$img='../../../../images/ico_alert.gif';
			break;
		default:
			$img='../../../../images/ico_info.gif';
	}

	return'<div id="'.$type.'">
		<img src="../images/'.$img.'" width="16" height="16" style="vertical-align: middle;display: inline-block;"> 
		'.$txt.'<a href="'.$link.'">'.$txt_link.'</a>
		</div>';
}

function generate_statusform($script) {
    return '<div id="suboptions_notebook">
                 <form method="POST" action="scr_status.php">
                    <input type="hidden" value="'.$script.'" name="from" />
                    <input type="text" value="'.lg('myStatus').'" name="mystatus" />&nbsp;
                    <input type="submit" value="'.lg('envoyer').'" class="minibtn" />
                 </form>
            </div> ';
}

function defineHeader() {
    if (isset($_SESSION["smartphone"])) {
        return '';
    }    
    $username = formatString($_SESSION['longname'],15);
    $options = '<a href="network_profil.php?id='.$_SESSION['user_id'].'">'.ucfirst($username).'</a>';
    return $options;
}
?>