<?php
include("includes/site_info.php");
include('session_handler.inc');

$latest_blog_query=mysql_query("SELECT UNIX_TIMESTAMP(blg_datetime) as blgdate, blg_id, blg_mood, blg_title, blg_message, blg_tags, blg_picture, blg_ext, mem_userid, mem_username FROM blogs LEFT JOIN members ON (blg_userid=mem_userid) WHERE blg_approved='Y' and blg_private='N' order by blg_datetime desc limit 10",$link) or die(mysql_error());
$latest_blog_count = mysql_num_rows($latest_blog_query);

$latest_note_query=mysql_query("SELECT UNIX_TIMESTAMP(art_datetime) as artdate, art_id, art_title, art_message, art_tags, art_picture, art_ext, mem_userid, mem_username FROM articles LEFT JOIN members ON (art_userid=mem_userid) WHERE art_approved='Y' and art_private='N' order by art_datetime desc",$link) or die(mysql_error());
$latest_note_count = mysql_num_rows($latest_note_query);
?>
<div id="top_panel" class="darkpink_row_back">
	<?php include ("panel_top_main.php"); ?>
</div>

<script type="text/javascript">
jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery("#search_thought").submit(function(){
	 	jQuery('#loading').show();
	 	jQuery('#right_loading_m').show();
		
		var q = jQuery("#q").val();
		
		q=jQuery.trim(q);
		
		jQuery("#q").val(q);

		var str = jQuery(this).serialize();
	
		window.location.hash = "search?tab=thought&" + str;
		window.location.reload(true);
/*		location.href="#search?tab=thought&" + str;
		jQuery.get('search.php?'+str, function(data) {
 		jQuery('#loading').hide();	
	 	jQuery('#right_loading_m').hide();
		jQuery("#main_content").fadeIn('slow');
 		jQuery('#main_content').html(data);
		});
*/			
		return false;
    });
});

  </script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#FF0000; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Search</div>
						<div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
						<div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
				</tr>
				<tr>
					<td><form name="search_thought" id="search_thought" style="padding:0; margin:0; border:0;">
							<table width="100%" border="0" cellspacing="0" cellpadding="5">
								<tr>
									<td align="center"><input type="text" size="40" name="q" id="q" class="grey_12_xb"/>
										<label>
										<input name="type" type="radio" value="blog" checked="checked" />
										Blogs</label>
										<label>
										<input name="type" type="radio" value="note" />
										Notes</label>
										<input name="init" type="submit" class="button" id="init" value="Search"/></td>
								</tr>
							</table>
						</form></td>
				</tr>
				<?php
					if ($latest_blog_count>0){ ?>
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Latest Blogs</div>
						<div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
						<div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
				</tr>
				<tr>
					<td><div class="left">
							<table border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb" width="100%" align="center">
								<?php 
			$i=1;
			while ($blog = mysql_fetch_object($latest_blog_query) ) {
			if(file_exists($SITE_MAIN_ROOT."/members/".$blog->mem_username."/blog/".$blog->blg_picture."_small.".$blog->blg_ext)){ $image=$SITE_MAIN_WWW_ROOT."/members/".$blog->mem_username."/blog/".$blog->blg_picture."_small.".$blog->blg_ext ;}  else {$image="$CONST_LINK_ROOT/images/icon-post.gif";}
			if ($i>1) $tr='<tr class="solid_line_separator"><td colspan="4"><img src="images/spacer.gif" height="3"/></td></tr>'; else $tr='';
			?>
								<?=$tr?>
								<tr>
									<td width='50px' align='left' valign="top"><a href='#mshowblog?tab=thought&bid=<?=$blog->blg_id?>&uID=<?=$blog->mem_userid?>' onclick="javascript: callpage(this.href);" rel="subpage_link"><img src='<?=$image?>' title='<?=$blog->blg_title?>' border="0" class="img_b_p3"/></a></td>
									<td width='100px' align='left' valign="top"><a href='#mshowblog?tab=thought&bid=<?=$blog->blg_id?>&uID=<?=$blog->mem_userid?>' onclick="javascript: callpage(this.href);" rel="subpage_link"><b>
										<?=$blog->blg_title?>
										</b></a><br>
										<span class="lightgrey_10">
										<?php if ($blog->blg_mood) echo "Mood: ".$blog->blg_mood."<br />";?>
										By <?=ucwords($blog->mem_username)?>
										<br />
										<?=date("d M'y h:ia",$blog->blgdate)?>
										</span></td>
									<td align='justify' valign="top"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($blog->blg_message,0,450)));
				if (strlen (strip_tags($blog->blg_message))>450) $short_msg_text.="...";
				echo $short_msg_text;
				?></td>
								</tr>
								<?php
    $i++;
	}
	?>
							</table>
						</div></td>
				</tr>
				<?php
				}
				?>
				<?php
					if ($latest_note_count>0){ ?>
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#FF00FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Latest Notes</div>
						<div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
						<div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
				</tr>
				<tr>
					<td><div class="left">
							<table border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb" width="100%" align="center">
								<?php 
			$i=1;
			while ($article = mysql_fetch_object($latest_note_query) ) {
			if(file_exists($SITE_MAIN_ROOT."/members/".$article->mem_username."/article/".$article->art_picture."_small.".$article->art_ext)){ $image=$SITE_MAIN_WWW_ROOT."/members/".$article->mem_username."/article/".$article->art_picture."_small.".$article->art_ext ;}  else {$image="$CONST_LINK_ROOT/images/icon-post.gif";}
			if ($i>1) $tr='<tr class="solid_line_separator"><td colspan="4"><img src="images/spacer.gif" height="3"/></td></tr>'; else $tr='';
			?>
								<?=$tr?>
								<tr>
									<td width='50px' align='left' valign="top"><a href='#mshownote?tab=thought&aid=<?=$article->art_id?>&uID=<?=$article->mem_userid?>' onclick="javascript: callpage(this.href);" rel="subpage_link"><img src='<?=$image?>' title='<?=$article->art_title?>' border="0" class="img_b_p3"/></a></td>
									<td width='100px' align='left' valign="top"><a href='#mshownote?tab=thought&aid=<?=$article->art_id?>&uID=<?=$article->mem_userid?>' onclick="javascript: callpage(this.href);" rel="subpage_link"><b>
										<?=$article->art_title?>
										</b></a><br>
										<span class="lightgrey_10">
										By <?=ucwords($article->mem_username)?>
										<br />
										<?=date("d M'y h:ia",$article->artdate)?>
										</span></td>
									<td align='justify' valign="top"><?php 
				$short_msg_text=strip_tags(stripslashes(substr($article->art_message,0,450)));
				if (strlen (strip_tags($article->art_message))>450) $short_msg_text.="...";
				echo $short_msg_text;
				?></td>
								</tr>
								<?php
    $i++;
	}
	?>
							</table>
						</div></td>
				</tr>
				<?php
				}
				?>
			</table></td>
	</tr>
</table>
