        <article class="post post_<?php echo $post -> ID; ?>">
            <?php if(is_single() || is_page()) { ?>
            <div class="row">
                <div class="twelve columns">
                    <div class="single-header">
                        <?php  

                            $top_url = home_url(); /*the default value*/

                            if(get_post_type($post -> ID) == 'post'){
                                $category_tax = 'category';    
                            } elseif(get_post_type( $post -> ID) == 'portfolio') {
                                $category_tax = 'portfolio-category';   
                            } elseif (get_post_type( $post -> ID) == 'page') {
                                $category_tax = '';   
                            }
                 
                            if(get_post_type($post -> ID) == 'post' || get_post_type($post -> ID) == 'portfolio'){
                                $categories = wp_get_post_terms($post -> ID, $category_tax );
                                
                                if (!empty($categories)) {
                                    
                                    foreach ($categories as $category) {
                                        $categ = get_term($category, $category_tax );
                                        $top_url = get_category_link($category);
                                        break;    
                                    }
                                    
                                    
                                    //$cat = __('in','cosmotheme').' '.   $cat;   
                                }
                            }
                            
                        ?>
                        <a href="<?php echo $top_url; ?>" class="single-header-explorebtn"><i class="icon-th explore-btn"></i></a>
                        <div class="single-header-nav-container">
                            <ul class="single-header-nav">
                                <li class="single-nav right"><?php if ( get_next_post() ) { next_post_link( '%link' , '<i class="icon-chevron-right"></i>' ); } else {echo '<a class="inactive" href="JavaScript:void(0)"><i class="icon-chevron-right"></i></a>'; } ?></li>
                                <li class="single-nav left"><?php if ( get_previous_post() ) { previous_post_link( '%link' , '<i class="icon-chevron-left"></i>' ); } else {echo '<a class="inactive" href="JavaScript:void(0)" ><i class="icon-chevron-left"></i></a>'; } ?></li>
                            </ul>
                        </div>
                        <div style="clear:both"></div>
                    </div>
                </div>
            </div>
            <?php } ?>
            <div class="row single-content-all-top">

            <?php
                //while( have_posts () ){
                    //the_post();
                    $post_id = $post -> ID;
                    if (is_single()) {
                        $template = 'single';
                    } elseif(is_page()) {
                        $template = 'page';
                    } elseif(is_home() || is_front_page()) { $template = 'single';}                      
                   
                    $zoom = false; 
                    
                    if( options::logic( 'blog_post' , 'enb_featured' ) ){
                        if ( has_post_thumbnail( $post_id ) && get_post_format( $post_id ) != 'video' ) {
                            $src_       = image::thumbnail( $post_id , $template , 'full' );
                            $caption    = image::caption( $post_id );
                            $zoom       = true;
                        }
                    } 
            ?>  
                      
            <div class="twelve columns">
                <div class="single-content-title-container">
                    <h2 class="single-content-title"><?php the_title(); ?></h2>
                    <?php if(strlen(trim($post->post_excerpt))){ ?>
                    <div class="subtitle">
                        <?php echo apply_filters('the_excerpt', $post->post_excerpt); ?>
                    </div>
                    <?php } ?>  
                </div>
            </div>


            <?php
                $layout = meta::get_meta( $post ->ID , 'layout' );
                if ( isset($layout['type']) && $layout['type'] == 'full' ) {
                    $nr_columns = ' twelve '; 
                } elseif(isset($layout['type']) && $layout['type'] != 'full') { 
                    if (is_single() || is_page()) {
                        $nr_columns = ' nine '; 
                    }else{
                        $nr_columns = ' twelve '; 
                    }
                } elseif(!isset($layout['type'])){ 
                    if( options::get_value( 'layout' , $template ) == 'full'){ /*if from general settings is set full width*/
                        $nr_columns = ' twelve ';
                    }else{
                        $nr_columns = ' nine ';    
                    }
                    
                }
                if (meta::logic( $post , 'settings' , 'meta' )) {
                    $content_class = ' nine ';
                } else { $content_class = ' twelve  '; }
            ?> 

            <?php if(is_single() || is_page()) { layout::side( 'left' , $post_id , 'single'); } ?>

            <div class="<?php echo $nr_columns; ?> columns">
                <?php

                    if( options::logic( 'blog_post' , 'enb_featured' ) ){
                        if ( has_post_thumbnail( $post_id ) && (get_post_format( $post_id ) != 'video'  && get_post_format( $post_id ) != 'gallery' ) ) {
                            if(options::logic( 'blog_post' , 'resize_method_image' ) == 'resize') {
                                $src = image::thumbnail( $post_id , $template , 'tmedium' );
                            }else{
                                $src = image::thumbnail( $post_id , $template , 'tmedium_cropped' );
                            }
                            $caption = image::caption( $post_id );
                ?> 
                            <div class="featimg">
                                     <a href="<?php echo $src_[0]; ?>" title="" class="featimg-hover" rel="prettyPhoto-<?php echo $post_id; ?>">
                                        <span class="featimg-hover-more" ></span>
                                    </a>      
                                    <?php
                                        echo '<img src="' . $src[0] . '" alt="' . $caption . '" >';
                                        if( options::logic( 'blog_post' , 'enb_lightbox' ) && $zoom  ){
                                    ?>

                                    <?php
                                        }
                                    if (options::logic('styling', 'stripes')) { ?>
                                        <div class="stripes">&nbsp;</div><!--Must put height equal to image-->
                                    <?php } ?>
                            </div>
                <?php
                        }
                    }                                  
                ?> 
                <?php if(get_post_format($post->ID)=="gallery" ) {
                        
                        
                        /* for gallery posts we will show a slidedhow if there are more than 1 images  */
                        ob_start();
                        ob_clean();
                        post::get_post_img_slideshow( $post -> ID );
                        $single_slideshow = ob_get_clean();
                        

                        if(isset($single_slideshow) && strlen($single_slideshow)){
                            echo '<div class="featimg">'.$single_slideshow.'</div>';
                        }
                        
                    }elseif( get_post_format( $post_id ) == 'video' ){

                        $video_format = meta::get_meta( $post_id , 'format' );
                    ?>
                        <div class="videos">
                            <div class="embedded_videos">    
                            <?php
                                $format=$video_format;
                                if( isset( $format['video'] ) && !empty( $format['video'] ) && post::isValidURL( $format['video'] ) ){
                                    $vimeo_id = post::get_vimeo_video_id( $format['video'] );
                                    $youtube_id = post::get_youtube_video_id( $format['video'] );
                                    $video_type = '';
                                    if( $vimeo_id != '0' ){
                                        $video_type = 'vimeo';
                                        $video_id = $vimeo_id;
                                    }

                                    if( $youtube_id != '0' ){
                                        $video_type = 'youtube';
                                        $video_id = $youtube_id;
                                    }

                                    if( !empty( $video_type ) ){
                                        echo post::get_embeded_video( $video_id , $video_type );
                                    }

                                }else if( isset( $video_format["feat_url"] ) && strlen($video_format["feat_url"])>1){

                                    $video_url=$video_format["feat_url"];
                                    if(post::get_youtube_video_id($video_url)!="0")
                                    {
                                        echo post::get_embeded_video(post::get_youtube_video_id($video_url),"youtube");
                                    }
                                    else if(post::get_vimeo_video_id($video_url)!="0")
                                    {
                                        echo post::get_embeded_video(post::get_vimeo_video_id($video_url),"vimeo");
                                    }
                                }else if(isset( $video_format["feat_id"] ) && strlen($video_format["feat_id"])>1){
                                    echo do_shortcode('[video mp4="'.wp_get_attachment_url($video_format["feat_id"]).'" width="610" height="443"]');
                                    //echo post::get_local_video( urlencode(wp_get_attachment_url($video_format["feat_id"])));
                                }
                            ?>
                                                                    
                            <?php    
                                if(isset($video_format['video_ids']) && !empty($video_format['video_ids'])){
                                    foreach($video_format["video_ids"] as $videoid){
                                        if( isset( $video_format[ 'video_urls' ][ $videoid ] ) ){
                                            $video_url = $video_format[ 'video_urls' ][ $videoid ];
                                            if( post::get_youtube_video_id($video_url) != "0" ){
                                                echo post::get_embeded_video( post::get_youtube_video_id( $video_url ), "youtube" );
                                            }else if( post::get_vimeo_video_id( $video_url ) != "0" ){
                                                echo post::get_embeded_video( post::get_vimeo_video_id( $video_url ) , "vimeo" );
                                            }
                                        }
                                        else echo post::get_local_video( urlencode(wp_get_attachment_url($videoid)));
                                    }
                                }    
                            ?>
                            </div>
                     </div>
                    <?php                                     
                    } 

                    ?>
                <div class="single-content-all">
                    <div class="row">
                        <?php if (meta::logic( $post , 'settings' , 'meta' ) ){ ?>
                        <div class="three columns">
                            <ul class="post-meta">
                                <?php 
                                    if((is_single() && meta::logic( $post , 'settings' , 'meta' )) || (meta::logic( $post , 'settings' , 'meta' ) && get_post_type() == 'portfolio')){
                                        echo post::get_source($post_id);
                                        echo post::get_services($post_id);
                                        echo post::get_client($post_id);
                                    }
                                ?> 
                                <?php                         
                                    if( meta::logic( $post , 'settings' , 'meta' ) ){
                                        post::meta( $post ); 
                                    }
                                ?>
                                <li>
                                    <i class="icon-user"></i>
                                    <?php _e('by ', 'cosmotheme'); ?><a href="<?php echo get_author_posts_url( $post->post_author ); ?>"><?php  the_author(); ?></a>
                                </li>
                            </ul>
                        </div>
                        <?php } ?>
                        <div class="<?php echo $content_class; ?> columns">
                            <div class="excerpt <?php if(!meta::logic( $post , 'settings' , 'meta' )) { echo 'excerpt_margin'; } ?>">
                                <?php 
                                    if( get_post_format( $post_id ) == 'audio' ){
                                        $audio = new AudioPlayer(); 
                                        echo $audio->processContent( post::get_audio_file( $post_id ) );
                                    }
                                    if( get_post_format( $post_id ) == 'image' ){
                                        $image_format = meta::get_meta( $post_id , 'format' );
                                        if(isset($image_format['images']) && is_array($image_format['images'])){
                                            echo "<div class=\"attached_imgs_gallery\">";
                                            foreach($image_format['images'] as $index=>$img_id){
                                                $caption = image::caption( $img_id );
                                                $thumbnail= wp_get_attachment_image_src( $img_id, 'thumbnail');
                                                $full_image=wp_get_attachment_url($img_id);
                                                $url=$thumbnail[0];
                                                $width=$thumbnail[1];
                                                $height=$thumbnail[2];

                                                echo "<div class=\"attached_imgs_gallery-elementm\">";
                                                ?>
                                                <a href="<?php echo $full_image; ?>" title="<?php echo $caption;  ?>" rel="prettyPhoto[gallery_<?php echo $post_id?>]"><?php echo "<img alt=\"\" src=\"$url\" width=\"$width\" height=\"$height\">"; ?></a>
                                            <?php
                                                echo "</div>";

                                            }     
                                            echo '<div class="clear"></div>';  
                                            echo "</div>";                            
                                        }  
                                    }
                                ?>
                                <?php
                                    if( get_post_format( $post_id ) == 'link' ){
                                        echo post::get_attached_file( $post_id );
                                    }
                                ?>                                  
                                <?php echo apply_filters('the_content', $post->post_content); ?>
                                <div class="pagenumbers">
                                <?php wp_link_pages(array('before' => '<p>Pages:','after' => '</p>', 'next_or_number' => 'number'));  ?>
                                </div>
                                
                            </div>

                            <?php get_template_part('social-sharing'); ?>
                            <?php 
                                if(is_single() && options::logic( 'blog_post' , 'show_similar' )){
                                    /* related posts */
                                    get_template_part( 'related-posts' ); 
                                }
                            ?>                    
                            <?php
                                /* comments */
                                if( comments_open($post_id) ){
                            ?>
                                <?php        
                                        if( options::logic( 'general' , 'fb_comments' ) ){
                                            ?>
                                            <div id="comments">
                                                <h3 id="reply-title"><?php _e( 'Leave a reply' , 'cosmotheme' ); ?></h3>
                                                <p class="delimiter">&nbsp;</p>
                                                <fb:comments href="<?php the_permalink(); ?>" num_posts="5" width="430" height="120" reverse="true"></fb:comments>
                                            </div>
                                            <?php
                                        }else{
                                            // if (is_single() || is_page()) {
                                                comments_template( '', true );
                                            // }else{
                                            //     //global $wp_query;
                                            //     $wp_query = new WP_Query(array('p' => $post_id));

                                            //     while( $wp_query->have_posts() ) { 
                                            //         $wp_query->the_post();
                                            //         comments_template( '', true );
                                            //     }
                                                    
                                            // }
                                        }
                                ?>   

                            <?php    
                                }
                            ?>
                        </div>
                    </div>
                </div>                
            </div>
            <?php if(is_single() || is_page()){ layout::side( 'right' , $post_id , 'single' ); } ?>

            </div>
        </article>