<?php // Display this loop for pages
if (is_page()) { ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<span class="postvedio posticon"></span>
  <h2 class="post-title page-tit">
    <?php the_title(); ?>
  </h2>
<div class="post" id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
  <div class="post-content">
    <?php the_content(); ?>
    <?php wp_link_pages( array( 'before' => '<div id="pagination"><span class="pages">' . __( 'Pages', 'MCL' ) . '</span>', 'after' => '</div>', 'link_before' => '<span class="page-link">', 'link_after' => '</span>' ) ); ?>
  </div>
</div>

<!--post-->

<?php endwhile; endif; ?>
<?php // Display this loop for single blog posts
} elseif (is_single()) { ?>

<div style="display:none">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php setPostViews(get_the_ID()); ?>

  <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
 <?php
$attachments = get_children(array
('post_parent' => get_the_ID(),
 'post_type' => 'attachment',
 'post_mime_type' => 'image',
 'orderby' => 'menu_order'));
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(150,150) );
} elseif ($attachments) {
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments);
    echo wp_get_attachment_image($first_attachment->ID);
} else {
	$table = "wp_posts";
	if($table_prefix !='' || $table_prefix != ''){
		$table = $table_prefix."posts ";
	}
	$row = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $table . " WHERE id =".get_the_ID()));
	$row = explode('||',$row['post_excerpt']);
	if(preg_match('/(png|jpg|jpeg|gif|bmp)$/iUs',$row[1]) == true){
		echo '<img class="thumb" src="'.$row[1].'" alt=" " height="150" width="150" />';
	}elseif ( $MHGOZ_Options->get('checkbox_custom_no_photo')){
		echo '<img class="thumb" src="'.$MHGOZ_Options->get('site_no_photo').'" alt=" " height="150" width="150" />';
 	}else{
	    echo '<img class="thumb" src="'. get_template_directory_uri().'/theme-files/img/no-img/post-thumb.png" height="150" width="150" />';
	}
}
?>
  </a>



  <h1 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    <?php the_title(); ?>
    </a></h1>
  <?php the_content(); ?>

</div>

<?php 

$get_the_excerpt = explode('||',get_the_excerpt());
$get_the_excerpt = $get_the_excerpt[0]; // link
$get_the_img = $get_the_excerpt[1]; // img

	
?>

<!--[if IE 9]>
<style>
.ifreamm{
	height:900px;
	width:100%
}
</style>
<![endif]-->

<iframe  src="<?php echo $get_the_excerpt; ?>" width="100%" height="100%"  ALIGN="top" HSPACE="0" VSPACE="0" frameborder="0" class="ifreamm"></iframe>
<?php endwhile; endif; ?>

<!-- Search -->

<?php // Display this loop for search results
} elseif (is_search()) { ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
  <div class="post-img"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php
$attachments = get_children(array
('post_parent' => get_the_ID(),
 'post_type' => 'attachment',
 'post_mime_type' => 'image',
 'orderby' => 'menu_order'));
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(150,150) );
} elseif ($attachments) {
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments);
    echo wp_get_attachment_image($first_attachment->ID);
} else {
	$table = "wp_posts";
	if($table_prefix !='' || $table_prefix != ''){
		$table = $table_prefix."posts ";
	}
	$row = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $table . " WHERE id =".get_the_ID()));
	$row = explode('||',$row['post_excerpt']);
	if(preg_match('/(png|jpg|jpeg|gif|bmp)$/iUs',$row[1]) == true){
		echo '<img class="thumb" src="'.$row[1].'" alt=" " height="150" width="150" />';
 	}else{
	    echo '<img class="thumb" src="'. get_template_directory_uri().'/theme-files/img/no-img/post-thumb.png" height="150" width="150" />';
	}
}
?>
    </a> </div>
  <div class="post-right">
    <h2 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
      <?php the_title(); ?>
      </a></h2>
    <em class="meta">
    <?php _e( 'بتاريخ : ', 'MCL' ) ?>
    <?php the_time(get_option('date_format')); ?>
    <?php _e( ',فى قسم : ', 'MCL' ) ?>
    <?php the_category(', '); ?>
    <?php _e( ', التعليقات : ', 'MCL' ) ?>
    <?php comments_popup_link( __( 'لا توجد تعليقات', 'MCL' ), __( 'تعليق واحد', 'MCL' ), __( '% تعليق', 'MCL' ) ); ?>
    </em>
    <p class="post-content"><?php echo substr(strip_tags(get_the_content()),0,500); ?></p>
    <p class="read-more"><a href="<?php the_permalink() ?>" title="الموضوع بالكامل">
      <?php _e('تابع الموضوع', 'MCL'); ?>
      </a></p>
  </div>
</div>


<?php endwhile;?>
<div class="pagination"><?php pagination('«', '»'); ?></div>

<?php else : ?>


<p class="notfound">
  <?php _e( 'عفوا .. لا يوجد نتائج لبحثك ..', 'MCL' ); ?>
</p>
<?php endif; ?>
<?php // Display this loop for the blog
} else { ?>

<?php $count = 0; ?>
<?php if( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); $count++; ?>
<?php do_action( 'bp_before_blog_post' ) ?>
<div class="post">
  <div class="post-img"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
   <?php
$attachments = get_children(array
('post_parent' => get_the_ID(),
 'post_type' => 'attachment',
 'post_mime_type' => 'image',
 'orderby' => 'menu_order'));
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(150,150) );
} elseif ($attachments) {
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments);
    echo wp_get_attachment_image($first_attachment->ID);
} else {
	$table = "wp_posts";
	if($table_prefix !='' || $table_prefix != ''){
		$table = $table_prefix."posts ";
	}
	$row = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $table . " WHERE id =".get_the_ID()));
	$row = explode('||',$row['post_excerpt']);
	if(preg_match('/(png|jpg|jpeg|gif|bmp)$/iUs',$row[1]) == true){
		echo '<img class="thumb" src="'.$row[1].'" alt=" " height="150" width="150" />';
 	}else{
	    echo '<img class="thumb" src="'. get_template_directory_uri().'/theme-files/img/no-img/post-thumb.png" height="150" width="150" />';
	}
}
?>
    </a> </div>
  <div class="post-right">
    <h2 class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
      <?php the_title(); ?>
      </a></h2>
    <em class="meta">
    <?php _e( 'بتاريخ : ', 'MCL' ) ?>
    <?php the_time(get_option('date_format')); ?>
    <?php _e( ',فى قسم : ', 'MCL' ) ?>
    <?php the_category(', '); ?>
    <?php _e( ', التعليقات : ', 'MCL' ) ?>
    <?php comments_popup_link( __( 'لا توجد تعليقات', 'MCL' ), __( 'تعليق واحد', 'MCL' ), __( '% تعليق', 'MCL' ) ); ?>
    </em>
    <p class="post-content"><?php echo substr(strip_tags(get_the_content()),0,500); ?></p>
    <p class="read-more"><a href="<?php the_permalink() ?>" title="الموضوع بالكامل">
      <?php _e('تابع الموضوع', 'MCL'); ?>
      </a></p>
  </div>
</div>
<!--.post-->

<?php do_action( 'bp_after_blog_post' ) ?>
<?php endwhile;
		endif; ?>
<div class="pagination"><?php pagination('«', '»'); ?></div>

<?php // Close the main pages/blog 'if' statement
} ?>