<?

function dispHome(){

//echo 'test'.$_SESSION["WEEZ"]." CRYPTAGE MD5 : ".md5($_SESSION["WEEZ"]) ;

$str	= '

    <div id="main_body">
    <div class="top_box">
    <object width="790" height="168"><param name="movie" value="http://www.dailymotion.com/flash/dmwall/dmwall.swf?feed=/eptv&cols=9&rows=2&slide=0&brand=none"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed width="790" height="168" wmode="transparent" allowscriptaccess="always" src="http://www.dailymotion.com/flash/dmwall/dmwall.swf?feed=/eptv&cols=9&rows=2&slide=0&duration=30&brand=none" type="application/x-shockwave-flash" /></object>
    </div>
    <!-- main body -->
    	<div id="left_side">
            <div id="newsbox">
                <h1><img alt="" src="images/puce.png" /> <strong>Br&egrave;ves</strong></h1>
                <ul>';
								
	$str .=dispHomeNews();

	$str .= '
            </ul></div>
	    </div>

        <div id="right_side">
            <div class="rightbox">
                <h1><img alt="" src="images/puce.png" /><strong>Edito</strong></h1>
                ';
		
	$str .= dispHomeEdito();	

	$str .= '
            </div>
            <div class="rightbox">
                <h1><img alt="" src="images/puce.png" /> <strong>Derni&egrave;res vid&eacute;o</strong></h1>
                ';
						
	$str .= dispHomeLastVideos();

	$str .='
            </div>
			<div class="rightbox">
                <h1><img alt="" src="images/puce.png" /> <strong>Derni&egrave;res photos</strong></h1>
               ';
						
	$str .= dispHomeLastPhotos();

	$str .='
            </div>
        </div>
        <div class="clr">&nbsp;</div>
    </div>
</div>
';


echo $str;
}




function dispHomeNews(){

	$str = '';

	if ($_SESSION["user_right"] >= $GLOBALS["PRIV_GUEST"] ) {	
		$result = getLastNews(2);
	}
	else if ($_SESSION["user_right"] >= $GLOBALS["GUEST"] ) {	
		$result = getLastNews(1);	
	}
	else {
		$result = getLastNews(0);	
	}
	
	if (mysql_num_rows($result)){
		while ($news = mysql_fetch_array($result)) {


// DISP NEWS TITLE BY TENDU
			$str .= dispWhenTendu($news["news_tendu"]);
			
			$str .= '
                	<li>
                    	<h2><strong>
				'.$news["news_title"].'
				</strong>';

// DISP NEWS CONTENT BY TENDU	
			$str .= dispWhenTendu($news["news_tendu"]);


			$str .= '
				<span class="news_date"> - '.$news["news_date"].'</span></h2>
                        <p class="news_text">'.$news["news_comment"].'</p>
                        <p class="news_separator"><br /><img alt="" src="images/corner_20.png" /><br /></p>
                    </li>';
		}
	}

	return ($str);
}

function dispHomeEdito(){

	$result = getLastEdito();
	if (mysql_num_rows($result)){
		$edito = mysql_fetch_array($result);    
  	}
	
	$str	= '
		<ul>
			<li>'.$edito["edito_title"].'</li>
			<li><img id="logo_edito" alt="" src="images/edito_logo.png" />'.$edito["edito_comment"].'</li>
		</ul>';

	return ($str);
}

function dispHomeLastVideos(){


	if ($_SESSION["user_right"] >= $GLOBALS["PRIV_GUEST"] ) {	
		$result = getLastVideosByTendu(2);
	}
	else if ($_SESSION["user_right"] >= $GLOBALS["GUEST"] ) {	
		$result = getLastVideosByTendu(1);
	}
	else {
		$result = getLastVideosByTendu(0);
	}

	$str = '<ul>';


	if (mysql_num_rows($result)){
		for ($cpt = 0; $cpt < 10 && ($video = mysql_fetch_array($result)); $cpt++) {
			

// DISP LAST VIDEOS BY TENDU
			$str .= dispWhenTendu($video["video_tendu"]);

			$str .= '
		
				&nbsp;<li><a href="' . $video["video_path"] . ' " class="texte_link"' . '>'.$video["video_name"].'</a>
			    </TD>
				<TD>';
			
			if ($video["video_path_daily"]) {
			$str .= '&nbsp;&nbsp;&nbsp;<a href=\'public/dailymotion.php?q='.$video["video_path_daily"].'\' onclick="return popitup(this, \'EPTV\')" >
			<img class="daily_preview" src=\'../images/daily.png\' height="18" border=0></a>';
			}	
			$str .= '&nbsp;&nbsp;&nbsp;<strong>'.$video["video_size"].' Mo</strong>';
		}
		$str .= '</ul>';
	}

	$str .= '
		</small>
	';

	return ($str);
}

function dispHomeLastPhotos(){


	if ($_SESSION["user_right"] >= $GLOBALS["PRIV_GUEST"] ) {	
		$result = getLastPhotosByTendu(2);
	}
	else if ($_SESSION["user_right"] >= $GLOBALS["GUEST"] ) {	
		$result = getLastPhotosByTendu(1);
	}
	else {
		$result = getLastPhotosByTendu(0);
	}

	$str = '<ul>';


	if (mysql_num_rows($result)){
		for ($cpt = 0; $cpt < 10 && ($photo = mysql_fetch_array($result)); $cpt++) {
			

// DISP LAST PHOTOS BY TENDU
			$str .= dispWhenTendu($photo["photo_tendu"]);

			$str .= '<li><a href="index.php?section=PhotosShow&action='.$photo["photo_path"].'" class="texte_link"';
			
			if ($photo["photo_comment"]) {
			$str .= 'ONMOUSECLICK="popitup(\'<font>'.$photo["photo_comment"].'</font>\', \'#d3d3df\')"';
		}
			$str .= '>'.$photo["photo_name"].'</a>&nbsp;';
				if ($_SESSION["user_right"] >= $GLOBALS["PRIV_GUEST"] && photo_img_path != 0) {
                        	$str .= '<a href="http://www.eptv.fr/"'.$photo["photo_img_path"].'" class="texte_link" >(zip)</a>';
                        	}
			$str .= '';
			$str .=	'&nbsp;&nbsp;&nbsp;<strong>'.$photo["photo_size"]. ' Img</strong>
				</li>
			';
		}
			$str .= '</ul>';
	}

	$str .= '
		</small>
	';

	return ($str);
}

?>
