<?php global $options;
 		foreach ($options as $value) {
			 if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); 
		}
	} ?>

<div id="sidebar">
<div id="searchform">		
		<form method="get" action="<?php bloginfo('home'); ?>/">
		<input name="s" type="text" class="inputs" id="s" value="<?php echo wp_specialchars($s, 1); ?>" size="32" />
		<input type="submit" class="go" value="SEARCH" />	     
		</form>
</div><!--searchform-->
<!--the twitter widget-->
<div id="twitter-entry">
<?php if ($apa_Twitter == ''){$apa_Twitter = 'mks6804';}?>
<?php require_once(ABSPATH . 'wp-includes/class-snoopy.php');
$tweet   = get_option("lasttweet");
$url  = 'http://twitter.com/statuses/user_timeline/' .$apa_Twitter. '.json?count=20';
if ($tweet['lastcheck'] < ( mktime() - 60 ) ) {
  $snoopy = new Snoopy;
  $result = $snoopy->fetch($url);
  if ($result) {
    $twitterdata   = json_decode($snoopy->results,true);
    $i = 0;
    while ($twitterdata[$i]['in_reply_to_user_id'] != '') {
      $i++;
    }
    $pattern  = '/\@([a-zA-Z]+)/';
    $replace  = '<a href="http://twitter.com/'.strtolower('\1').'">@\1</a>';
    $output   = preg_replace($pattern,$replace,$twitterdata[$i]["text"]); 
	$output = make_clickable($output);  
    $tweet['lastcheck'] = mktime();
    $tweet['data']    = $output;
    $tweet['rawdata']  = $twitterdata;
    $tweet['followers'] = $twitterdata[0]['user']['followers_count'];
    update_option('lasttweet',$tweet);
  } else {
    echo "Twitter API not responding.";
  }
} else {
  $output = $tweet['data'];
}
echo "<p>".$output."</p>";
?>
</div><!--twitter widget-->

<div id="adblock-big">
<a href="<?php echo $apa_ad300x250destination; ?>"><img src="<?php if ($apa_ad300x250image == ""){echo bloginfo('template_directory'). '/images/ad-blocks-big.jpg'; } else {echo $apa_ad300x250image; } ?>"  /></a>
</div><!--adblock-big-->

<?php include (TEMPLATEPATH . '/tabbed-container.php');?>

<div id="adblock-small">
<ul>
	<li><a href="<?php echo $apa_1_ad_destination; ?>"><img src="<?php if ($apa_1_ad_image == ""){echo bloginfo('template_directory'). '/images/1st-ad-blocks.jpg'; } else {echo $apa_1_ad_image; } ?>"/></a></li>
	<li><a href="<?php echo $apa_2_ad_destination; ?>"><img src="<?php if ($apa_2_ad_image == ""){echo bloginfo('template_directory'). '/images/2nd-ad-blocks.jpg'; } else {echo $apa_2_ad_image; } ?>"  /></a></li>
	<li><a href="<?php echo $apa_3_ad_destination; ?>"><img src="<?php if ($apa_3_ad_image == ""){echo bloginfo('template_directory'). '/images/3rd-ad-blocks.jpg'; } else {echo $apa_3_ad_image; } ?>"  /></a></li>
	<li><a href="<?php echo $apa_4_ad_destination; ?>"><img src="<?php if ($apa_4_ad_image == ""){echo bloginfo('template_directory'). '/images/4th-ad-blocks.jpg'; } else {echo $apa_4_ad_image; } ?>"  /></a></a></li>
</ul>
</div><!--adblock-small-->
	<?php if ( !function_exists('dynamic_sidebar')
		|| !dynamic_sidebar('sidebar') ) : ?>
	<?php endif; ?>
</div><!--sidebar-->