<?php
if(!isset($_GET['page'])) {
	if(!function_exists("show_article_breadcrumbs")) {
		function show_article_breadcrumbs($parent_id){
			$display_bread = false;
			$ret = "";
			$newparent = $parent_id;
			$root = $newparent;
			$i=0;
			$go_up = true;
			$query = "SELECT * FROM main_article_categ WHERE cat_id = '$parent_id'";
			$res = mysql_query ($query);
			$line = mysql_fetch_array($res);
			${"root$i"}=$line["title_en"];
			${"friendly$i"}=$line["friendly_url"];
			${"link$i"}=$line["cat_id"];
			if($line['is_root'] == 1) {
				$go_up = false;
				$display_bread = true;
			}
			while($go_up && $root>0){
				$newparent=$line["parent_id"];
				$query = "SELECT * FROM  main_article_categ WHERE cat_id = '$newparent'";
				$result = mysql_query ($query);
				$line = mysql_fetch_array($result);
				$i++;
				${"root$i"}=$line["title_en"];
				${"friendly$i"}=$line["friendly_url"];
				${"link$i"}=$line["cat_id"];
				$root=$newparent;
				
				if($line['is_root'] == 1) {
					$display_bread = true;
					${"root$i"} = "[home]" . stripslashes(trim($line["title_en"]));
					$go_up = false;
				}
			}
			for($j=($i);$j>=0; $j = $j-1){
				if($j>=0){
					if($j != $i) $ret .= '<strong> &raquo; </strong>';
					$class= "blue";
					if(strpos(${"root$j"},"[home]") !== false) {
						${"root$j"} = str_replace("[home]", "", ${"root$j"});
						$class = "blue_home";
					}
					
					$ret .= '<a href="articles/'.${"friendly$j"} . ".html" .'" class="' . $class . '">' . ${"root$j"} . '</a>';
				}
				
			}
			
			if($display_bread) return $ret;
			else return false;
		}
	}
	
	$query = "SELECT * FROM  main_article WHERE article_id = '$middle_article_id' AND active='yes'";
	//echo $query;
	$result = @mysql_query ($query);
	if($result && mysql_num_rows($result)>0) {
		$line = mysql_fetch_assoc($result);
		$parent_id = $line['parent_id'];
	}
	
	$breads = show_article_breadcrumbs($parent_id);
	if($breads) {
	?>
	<div id="article_breadcrumbs" itemprop="breadcrumb">
		<?php
		echo $breads;
		?>
	</div>
	<?php
	}
}

/* Social Media plugin **********/
/*$sm_class_overload = "sm-categ";
include(dirname(__FILE__) . "/../sm/sm.php");*/
/***************************/

ob_start();
?>

	<?php 
	//print_r($_REQUEST);
	$query = "SELECT * FROM  main_article WHERE article_id = '$middle_article_id' AND active='yes'";
	//echo "<br/>$query";
	$result = mysql_query ($query) or die("<b>$query</b>".mysql_error());
	if($result && mysql_num_rows($result)>0) {
		$line = mysql_fetch_array($result);
		if(trim($line["url"]) != ""){
			$ahref = return_link_article('article_', $line['_blank'], $line['url'], $line['friendly_url'], $line["article_id"]);
			?>
			<div class="article_list_title_link">
				<p class="article_list_title_link">
					<a class="article_class" href="<?php  echo $ahref['link'];?>" target="<?php  echo $ahref['target'];?>"><span><?php  echo $line["title_en"];?></span></a>
				</p>
			</div>
			<?php 
		}
		else {
			$show_title = ($line["active_title_en"] == "yes") ? true : false;
			$article_title = stripslashes(trim($line["title_en"]));
			if($article_title == "") $show_title = false;
			
			$article_description = stripslashes(trim($line["title_en"]));
			
			if (!isset($article_locale_description) || $article_description != ""){ 
				$article_title = stripslashes($line["title_en"]);
				$article_description = stripslashes(trim($line["description_en"]));
			}
			if($show_title) {
				?>
				<div class="article_list_title">
					<h1 class="article_list_title"><span><?php  echo $article_title; ?></span></h1>
				</div>
				<?php
			}
			?>
			<div class="article_description_container">
				<div class="article_description">
					<?php  
					if(!is_dir("../general")) {
						$article_description = str_replace("../images/", "images/", $article_description);
					}
					echo $article_description; 
					?>
				</div>
			</div>
			<?php 
		}
	}
	?>

<?php
$_art_content = ob_get_contents();
ob_end_clean();

$_art_full_url = $protocol . str_replace('//', '/', ($_SERVER['HTTP_HOST'] . "/" . $_SERVER['REQUEST_URI']));
$_art_content = str_replace('#{FULL_URL}', $_art_full_url . '#', $_art_content);
echo $_art_content;
?>