<?php 
include_once($this->path . '/pages/default_settings.php');

$title = $tname;
$catArray = array();
$ccNumbers = array();
foreach(explode('||',$tsettings) as $val) {
	$expl = explode('::',$val);
	$settings[$expl[0]] = $expl[1];
	if(substr($expl[0], 0, 8) == 'cat-name') {
		$cc = get_cat_name(intval(substr($expl[0], 9)));
		array_push ($catArray,$cc);
		array_push ($ccNumbers, 0);
	}
}
?>
<style type="text/css">
#tl<?php echo $id; ?> .timeline_line {
 	width: <?php echo $settings['line-width']; ?>px;
} 

#tl<?php echo $id; ?> .t_line_view {
 	width: <?php echo $settings['line-width']; ?>px;
} 
 
#tl<?php echo $id; ?> .t_line_m {
	width: <?php echo ((int)$settings['line-width'])/2-2; ?>px;
}
 
#tl<?php echo $id; ?> .t_line_m.right {
	left: <?php echo ((int)$settings['line-width'])/2-1; ?>px;
	width: <?php echo ((int)$settings['line-width'])/2-1; ?>px;
}
 
#tl<?php echo $id; ?> .t_node_desc {
	background:  <?php echo $settings['node-desc-color']?>;
}

#tl<?php echo $id; ?> .item h2,
#content #tl<?php echo $id; ?> .item h2 {
	font-size: <?php echo $settings['item-header-font-size']?>px;
	color: <?php echo $settings['item-header-font-color']?>;
	line-height: <?php echo $settings['item-header-line-height']?>px;
	
	<?php switch($settings['item-header-font-type']) {
	case 'regular' : echo '
	font-weight:normal;
	font-style:normal;'; break;
	
	case 'thick' : echo '
	font-weight:100;
	font-style:normal;'; break;
	
	case 'bold' : echo '
	font-weight:bold;
	font-style:normal;'; break;
	
	case 'bold-italic' : echo '
	font-weight:bold;
	font-style:italic;'; break;
	
	case 'italic' : echo '
	font-weight:normal;
	font-style:italic;'; break;} ?>
} 

 
#tl<?php echo $id; ?> .item {
 	width: <?php echo $settings['item-width']; ?>px;
	height: <?php echo $settings['item-height']; ?>px;
	background:<?php echo $settings['item-back-color']; ?> url(<?php echo $settings['item-background']; ?>) repeat; 
	font-size: <?php echo $settings['item-text-font-size']?>px;
	color: <?php echo $settings['item-text-font-color']?>;
	line-height: <?php echo $settings['item-text-line-height']?>px;
	
	<?php switch($settings['item-text-font-type']) {
	case 'regular' : echo '
	font-weight:normal;
	font-style:normal;'; break;
	
	case 'thick' : echo '
	font-weight:100;
	font-style:normal;'; break;
	
	case 'bold' : echo '
	font-weight:bold;
	font-style:normal;'; break;
	
	case 'bold-italic' : echo '
	font-weight:bold;
	font-style:italic;'; break;
	
	case 'italic' : echo '
	font-weight:normal;
	font-style:italic;'; break;} ?>
	
	<?php if($settings['shadow'] == 'show') {
	echo '
	-moz-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	-webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	box-shadow: 0px 0px 6px rgba(0,0,0,0.5);';
	}
	else {
	echo '
	-moz-box-shadow: 0 0 0 #000000;
	-webkit-box-shadow: 0 0 0 #000000;
	box-shadow: 0 0 0 #000000;';
	} ?>
 }
<?php if($settings['shadow'] == 'on-hover') {
echo '
#tl'. $id . ' .item:hover {
	-moz-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	-webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	box-shadow: 0px 0px 6px rgba(0,0,0,0.5);;
}';
} ?>

#tl<?php echo $id; ?> .item_open h2,
#content #tl<?php echo $id; ?> .item_open h2 {
	font-size: <?php echo $settings['item-open-header-font-size']?>px;
	color: <?php echo $settings['item-open-header-font-color']?>;
	line-height: <?php echo $settings['item-open-header-line-height']?>px;
	
	<?php switch($settings['item-open-header-font-type']) {
	case 'regular' : echo '
	font-weight:normal;
	font-style:normal;'; break;
	
	case 'thick' : echo '
	font-weight:100;
	font-style:normal;'; break;
	
	case 'bold' : echo '
	font-weight:bold;
	font-style:normal;'; break;
	
	case 'bold-italic' : echo '
	font-weight:bold;
	font-style:italic;'; break;
	
	case 'italic' : echo '
	font-weight:normal;
	font-style:italic;'; break;} ?>
} 

#tl<?php echo $id; ?> .item_open {
 	width: <?php echo $settings['item-open-width']; ?>px;
	height: <?php echo $settings['item-height']; ?>px;
	background:<?php echo $settings['item-open-back-color']; ?> url(<?php echo $settings['item-open-background']; ?>) repeat; 
 	font-size: <?php echo $settings['item-open-text-font-size']?>px;
	color: <?php echo $settings['item-open-text-font-color']?>;
	line-height: <?php echo $settings['item-open-text-line-height']?>px;
	
	<?php switch($settings['item-open-text-font-type']) {
	case 'regular' : echo '
	font-weight:normal;
	font-style:normal;'; break;
	
	case 'thick' : echo '
	font-weight:100;
	font-style:normal;'; break;
	
	case 'bold' : echo '
	font-weight:bold;
	font-style:normal;'; break;
	
	case 'bold-italic' : echo '
	font-weight:bold;
	font-style:italic;'; break;
	
	case 'italic' : echo '
	font-weight:normal;
	font-style:italic;'; break;} ?>
	
	<?php if($settings['shadow'] == 'show' || $settings['shadow'] == 'on-hover') {
	echo '
	-moz-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	-webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.5);
	box-shadow: 0px 0px 6px rgba(0,0,0,0.5);';
	}
	else {
	echo '
	-moz-box-shadow: 0 0 0 #000000;
	-webkit-box-shadow: 0 0 0 #000000;
	box-shadow: 0 0 0 #000000;';
	} ?>
 }
 
 
 
 #tl<?php echo $id; ?> .item .con_borderImage{
 	border-bottom: <?php echo $settings['item-image-border-width']; ?>px solid <?php echo $settings['item-image-border-color']; ?> ; 
 }
 
 #tl<?php echo $id; ?> .item_open .con_borderImage{
 	border-bottom: <?php echo $settings['item-open-image-border-width']; ?>px solid <?php echo $settings['item-open-image-border-color']; ?> ; 
 }

#tl<?php echo $id; ?> .item_open_cwrapper {
 	width: <?php echo $settings['item-open-width']; ?>px;
}

#tl<?php echo $id; ?> .item_open .t_close:hover {
	background:<?php echo $settings['button-hover-color']; ?>;
}

#tl<?php echo $id; ?> .timeline_open_content {
	padding:<?php echo $settings['item-open-content-padding']; ?>px;
}



</style>


<?php 
if($settings['read-more'] == 'whole-item') {
	$read_more = "'.item'";
}
else if ($settings['read-more'] == 'button') {
	$read_more = "'.read_more'";
}
else {
	$read_more = "'.none'";
}
?>

<!-- BEGIN TIMELINE -->
<div id="tl<?php echo $id; ?>" class="timeline <?php if($settings['line-style'] == 'dark') echo 'darkLine'; if($settings['nav-style'] == 'dark') echo 'darkNav'?>">

<?php
if ($titems != '') {
	$imge_height = $settings['item-width']*125/200;
	$imge_open_height = $settings['item-open-width']*155/490;
	$explode = explode('||',$titems);
	$itemsArray = array();
	foreach ($explode as $it) {
		$ex2 = explode('::', $it);
		$key = substr($ex2[0],0,strpos($ex2[0],'-'));
		$subkey = substr($ex2[0],strpos($ex2[0],'-')+1);
		$itemsArray[$key][$subkey] = $ex2[1];
	}
	foreach ($itemsArray as $key => $arr) {
		$num = substr($key,4);
		if($settings['cat-type'] == 'categories') {
			$index = array_search($arr['categoryid'],$catArray);
			$ccNumbers[$index]++;
			$arr['dataid'] = ($ccNumbers[$index] < 10 ? '0'.$ccNumbers[$index] : $ccNumbers[$index]).'/'.$arr['categoryid'];
		}
		if($arr['start-item']) {
			$start_item = $arr['dataid'];
			
		}
	?>




		<div class="item" data-id="<?php echo $arr['dataid']; ?>"<?php if($arr['node-name'] && $arr['node-name'] != '') echo ' data-name="'.$arr['node-name'].'"'; ?> data-description="<?php echo substr($arr['item-title'],0,30); ?>">
			<a href="#" class="image_rollover_bottom">
			<img class="con_borderImage" src="<?php echo $this->url . 'timthumb/timthumb.php?src=' . $arr['item-image'] . '&w='.$settings['item-width'].'&h='.$settings['item-image-height']; ?>" alt=""/>
			</a>
			<h2><?php echo $arr['item-title']; ?></h2>
			<span><?php echo $arr['item-content']; ?></span>
			<?php if ($settings['read-more'] == 'button') { echo '<div class="read_more" data-id="'.$arr['dataid'].'">Read more</div>'; } ?>
		</div>
		<div class="item_open" data-id="<?php echo $arr['dataid']; ?>">
		
			<?php if ($arr['item-open-image'] != '') {?>
			<img class="con_borderImage" src="<?php echo $this->url . 'timthumb/timthumb.php?src=' . $arr['item-open-image'] . '&w='.$settings['item-open-width'].'&h='.$settings['item-open-image-height']; ?>" alt=""/>
			<div class="timeline_open_content" style="height: <?php echo $open_content_height;?>px">
			
			<?php } else { ?>
			<div class="timeline_open_content <?php if($arr['desable-scroll']) echo ''; else echo 'scrollable-content'; ?>" style="height: <?php echo intval($settings['item-height']) - 2*intval($settings['item-open-content-padding']); ?>px">
			<?php } ?>
			
			<?php if ($arr['item-open-title'] != '') { ?><h2><?php echo $arr['item-open-title']; ?></h2><?php } ?>
			<?php echo $arr['item-open-content']; ?>
			</div>
		</div>
<?php
	}
}
?>
</div> <!-- END TIMELINE -->

<input type="hidden" id="ctimeline-preview-start-item" value="<?php echo $start_item; ?>" />

