Report abuse

<?php
include(TEMPLATEPATH . '/twitter.php'); //load twitter integration
include(TEMPLATEPATH . '/simple_recent_comments.php'); //load recent comments script
include(TEMPLATEPATH . '/wp-pagenavi.php'); //load page navigation integration
$GLOBALS['cfCount'] = 0; //used to track the comment count for output



if ( function_exists('register_sidebar') ) {
   register_sidebar(array(
       'before_widget' => '<div class="clear"></div><div class="dividerDark"></div>',
       'after_widget' => '<div class="clear"></div>',
       'before_title' => '<h3>',
       'after_title' => '</h3>',
   ));
}

//this function is used as the callback/overriding function for wp_list_comments
//used so I can insert comment numbering
function custom_comments($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; 
	$GLOBALS['cfCount']++; //incriment the comment counter	
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	<div id="comment-<?php comment_ID(); ?>" class="comment-body">
		<div class="commentCount">
			<?php //echo $GLOBALS['cfCount']; ?>
		</div>
		<div class="comment-author vcard">
			<?php echo get_avatar($comment,$size='48'); ?>
			<?php printf(__('<cite class="fn">%s</cite> <span class="says">stated:</span>'), get_comment_author_link()) ?>
			<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
			<div class="clear"></div>
		</div>
		<?php if ($comment->comment_approved == '0') : ?>
			<em><?php _e('Your comment is awaiting moderation.') ?></em>
			<br />
		<?php endif; ?>
		
		<?php comment_text() ?>		
		<div class="reply">
			<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
		</div>
		<div class="dividerLight marg"></div>
	</div>
	<?php
}


//build out the markup for the web portfolio image page from image attachments
function build_web_portfolio_images()
{
	$wppath = get_bloginfo('template_directory');		
	
	$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
	$count = 1;
	$output = '';
	
	if (!is_array($attachments)) 
	{
		$image = get_bloginfo('template_directory')."/images/default_470_110_image.png";		
		$output = '<a href="'.$image.'" class="widePreviewImg"><img src="'.$image.'" alt="web preview" /></a>'.
		'<p class="webDesc">Upload an image via upload button (see docs for details) | <a href="#">View Website</a></p>';
		
		echo $output;
	}
	else
	{		
		foreach($attachments as $img)
		{
			$img = array_shift($attachments);
			$imagelink = wp_get_attachment_image_src($img->ID,'full');
			$imageTitle = $img->post_title;
			$imageDesc  = $img->post_content;
						
			
			$image = $imagelink[0];
			
			//get full size image from caption field - use default image if none set
			$imageFullSize	= ((strlen((string)$img->post_excerpt) > 0) ? $img->post_excerpt : $image);			
									
			$output .= '<a href="'.$imageFullSize.'" class="widePreviewImg"><img src="'.$image.'" alt="web preview" /></a>'.
			'<p class="webDesc">'.$imageTitle.' | <a href="'.$imageDesc.'">View Website</a></p>';			
		}		
		
		echo $output;
	}
}

//creates the grid of images used on the logo/print pages, with a rollover hover
function build_grid_images($print = true) {	
	$wppath = get_bloginfo('template_directory');		
	
	$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
	$count = 1;
	$output = '';

	if (!is_array($attachments)) 
	{
		$image = get_bloginfo('template_directory')."/images/default_150_150_image.png";		
		while($count <= 9)
		{			
			if($print)
			{
				echo '<div class="boxgrid captionfull'.(($count % 3 == 0) ? ' last' : '').'">'.
						'<img src="'.$image.'" alt="thumbnail" class="thumbnail"/>'.
						'<div class="cover boxcaption">'.
							'<h4>Logo Title</h4>'.
							'<p>At vero eos et accusamus et iusto.</p>'.
						'</div>'.
					'</div>';
				echo (($count % 3 == 0) ? '<div class="clear"></div>' : '');							
			}
			else
			{
				$output .= '<div class="boxgrid captionfull'.(($count % 3 == 0) ? ' last' : '').'">'.
								'<img src="'.$image.'" alt="thumbnail" class="thumbnail"/>'.
								'<div class="cover boxcaption">'.
									'<h4>Logo Title</h4>'.
									'<p>At vero eos et accusamus et iusto.</p>'.
								'</div>'.
							'</div>';
				$output.= (($count % 3 == 0) ? '<div class="clear"></div>' : '');
			}
			$count++;
		}
		
		if($print)
			return $output;
	}
	else
	{
		foreach($attachments as $img)
		{
			//echo wp_get_attachment_image_src($img->ID,'full');
			//$img = array_shift($attachments);
			$imagelink = wp_get_attachment_image_src($img->ID,'full');
			$imageTitle = $img->post_title;
			$imageDesc  = $img->post_content;
			$image = $imagelink[0];
			if($print)
			{
				echo '<div class="boxgrid captionfull'.(($count % 3 == 0) ? ' last' : '').'">'.
							'<img src="'.$image.'" alt="thumbnail" class="thumbnail"/>'.
							'<div class="cover boxcaption">'.
								'<h4>'.$imageTitle.'</h4>'.
								'<p>'.$imageDesc.'</p>'.
							'</div>'.
						'</div>';
					echo (($count % 3 == 0) ? '<div class="clear"></div>' : '');
			}			
			else
			{
				$output .= '<div class="boxgrid captionfull'.(($count % 3 == 0) ? ' last' : '').'">'.
							'<img src="'.$image.'" alt="thumbnail" class="thumbnail"/>'.
							'<div class="cover boxcaption">'.
								'<h4>'.$imageTitle.'</h4>'.
								'<p>'.$imageDesc.'</p>'.
							'</div>'.
						'</div>';
				
				$output.= (($count % 3 == 0) ? '<div class="clear"></div>' : '');
			}
			
			$count++;
		}			
			
		if($print)
			return $output;
	}
}

//get the sidebar images based on input from admin panel
function load_manual_sidebar_images()
{
	/* retrieve all admin options. */
	global $options;
	foreach ($options as $value) 
	{
		if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
	}
		
	if(strlen($bb_rotator_images)  <= 0)
	{
		echo '<p>Please set the information required in the admin panel for your images to display here. Read the notes under \'Sidebar rotator images\' section.</p>';
		return;
	}
	
	//process the information provided by user and buid markup	
	$directory = ABSPATH .'wp-content/themes/bigBrands/images/rotator';
	$pairs = explode("\n", $bb_rotator_images);
	$output = '';
	foreach($pairs as $pair)
	{
		if(strlen(trim($pair)) > 0)
		{			
			//echo 'mytwo: '.$image_details[2];
			$image_details = explode(',',$pair);
			$output .= '<a href="'.trim($image_details[1]).'" class="'.((trim(strtolower($image_details[2])) == 'active') ? 'active' : '').'"><img src="'.get_bloginfo('template_directory').'/images/rotator/'.trim($image_details[0]).'" alt="" /></a>';    		
		}
	}
	
	echo $output;
	//echo print_r($details_arr); 
}

//builds out the markup for the ad/images in the sidebar on all pages
//parses the files stored in bigBrands/rotator and automatically uses them
function auto_load_sidebar_images()
{		
	$directory = ABSPATH .'wp-content/themes/bigBrands/images/rotator';
    $results = array();    
    $handler = opendir($directory); 
    while ($file = readdir($handler)) {

        // if $file isn't this directory or its parent, 
        // add it to the results array
        if ($file != '.' && $file != '..')
            $results[] = $file;
    }    
    closedir($handler);


    if(sizeof($results) <= 0)    
    	echo '<h3>Please add images to the bigBrands/images/rotator folder you want to display here</h3>';    
    else
    {    
    	$output = '';	
    	foreach($results as $img_name)
    	{    		
    		$output .= '<img src="'.get_bloginfo('template_directory').'/images/rotator/'.$img_name.'" alt="ad image" />';    		
    	}
    	
    	echo $output;
    }
}

//get first post attachement if one exists, otherwise return the link to our default image
// usage blogFeatureImage(180,135);
// or whatever dimensions you want
// requirements: have tim thumb in your theme directory
function blogFeatureImage($width,$height, $print = true) {	
	$scriptpath = get_bloginfo('template_directory');		
	$mystring = get_bloginfo('template_directory');
	
	$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));

	if (!is_array($attachments)) 
	{
		$image = get_bloginfo('template_directory')."/images/defaultBlogFeature550x200.jpg";		
		if($print)
			echo '<img src="'.$scriptpath.'/scripts/timthumb.php?src='.stripPathToWordpressBase($image).'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=1" alt="Post thumbnail" class="blogFeatureimg"/>';
		else
			return '<img src="'.$scriptpath.'/scripts/timthumb.php?src='.stripPathToWordpressBase($image).'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=1" alt="Post thumbnail" class="blogFeatureimg"/>';
	}
	else
	{
		$img = array_shift($attachments);
		$imagelink = wp_get_attachment_image_src($img->ID,'full');
		$image = $imagelink[0];
		if($print)
			echo '<img src="'.$scriptpath.'/scripts/timthumb.php?src='.stripPathToWordpressBase($image).'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=1" alt="Post thumbnail"  class="blogFeatureimg"/>';
		else
			return '<img src="'.$scriptpath.'/scripts/timthumb.php?src='.stripPathToWordpressBase($image).'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=1" alt="Post thumbnail"  class="blogFeatureimg"/>';
	}
}

function get_popular_posts()
{
	global $wpdb;
	$result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
	$output = '';
	$has_comments = FALSE;
	if(sizeof($result) <= 0)
		return '<li>No comments on your posts yet...</li>';
		
	foreach ($result as $post) 
	{		
		setup_postdata($post);
		$postid = $post->ID;
		$title = $post->post_title;
		$commentcount = $post->comment_count;
		
		if ($commentcount != 0)
		{
			$has_comments = TRUE;
			$output.='<li><a href="'.get_permalink($postid).'" title="'.$title.'">'.substr($title, 0,65).'</a> '. $commentcount.' comment(s)</li>';		
		}		
	}
	
	if($has_comments)
		return $output;
	else
		return '<li>No comments on your posts yet...</li>';	
}


// takes a full path and returns only the wordpress install portion
// ie.
// full path = /home/username/public_html/wordpress/wp-content/images/test.jpg    or     http://domain.tld/wordpress/wp-content/images/test.jpg
// returns
// wordpress/wp-content/images/test.jpg
//this is necessary as I found that on different hosts depending on permissions that passing a full url as the src attribute to timthumb was blowing it up 
//so instead we pass a relative path of the wordpress install by stripping off everything before wp-content folder
function stripPathToWordpressBase($fullPath)
{		
	//get the location of wp-content
	$findme   = 'wp-content';
	$pos = strpos($fullPath, $findme);
	if($pos !== false)
	{		
		//strip off the path up until $pos		
		return $wpPathOnly = substr($fullPath, $pos);						
	}	
}

function curPageURL() {
	
	$pageURL = 'http';	
	if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
	
	$pageURL .= "://";	
	
	if ($_SERVER["SERVER_PORT"] != "80") 	
		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];	
	else	
		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
			
	return $pageURL;
}


//load legacy comments if older version of wordpress
add_filter('comments_template', 'legacy_comments');
function legacy_comments($file) {
	if ( !function_exists('wp_list_comments') ) 
		$file = TEMPLATEPATH . '/legacy.comments.php';
	return $file;
}

//contact form processing function
function processContactForm() {
	session_start();
	
	if ( !isset($_POST['contact_form_submitted']) ) return;
	
	/* retrieve all admin options. */
	global $options;
	foreach ($options as $value) 
	{
		if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
	}
	
	if(strlen($bb_contact_email) <= 0) wp_die('Error: Please set your contact email in bigBrands admin panel.'); 
	
	$name  = ( isset($_POST['name']) )  ? trim(strip_tags($_POST['name'])) : null;
	$email   = ( isset($_POST['email']) )   ? trim(strip_tags($_POST['email'])) : null;	
	$message = ( isset($_POST['message']) ) ? trim(strip_tags($_POST['message'])) : null;	
	$website = ( isset($_POST['website']) ) ? trim(strip_tags($_POST['website'])) : null;
	$company = ( isset($_POST['company']) ) ? trim(strip_tags($_POST['company'])) : null;
	$phone = ( isset($_POST['phone']) ) ? trim(strip_tags($_POST['phone'])) : null;	
	
	//set this to whatever you want to show in the 'FROM' section of your email
	$headers = 'From: '. get_option('blogname') .' <' . get_option('admin_email') . '>';
	

	if ( $name == '' ) wp_die('Error: please fill the required field (name).'); 
	if ( !is_email($email) ) wp_die('Error: please enter a valid email address.');
	if ( $message == '' ) wp_die('Error: please fill the required field (message).');

	//send email
	$output = "Name: ". $name . "\n" .
			  "Email: ". $email . "\n" .
			  "---------------------------------------------------------------\n".
			  "Website: " . $website . "\n" .
			  "Company: " . $company . "\n" .
			  "Phone: " . $phone . "\n\n";
			
	
	$output .= $message;			  
			  
	wp_mail((($pr_contact_email !== "") ? $bb_contact_email : get_settings('admin_email')), "Contact request from Wordpress user", $output, $headers, '');
	
	//set session for completion validation
	$_SESSION['contactComplete'] = 1;


	header('Location: ' . $_SERVER['HTTP_REFERER']);
	exit();
}
add_action('init', 'processContactForm');

$themename = "BigBrands";
$shortname = "bb";

$options = array (
	//new section
	array(	"name" => $themename." | Welcome to the admin page for the ".$themename." theme designed by <a href='http://chrisfay.net/'>Chris Fay</a>",
			"type" => "title"),
			
	array(	"type" => "open"),
				
	array(  "name" => "Logo image name",
			"desc" => "Insert the file name of the logo you want to display (logo should be uploaded to bigBrands/images/ folder) 342px x 88px",
            "id" => $shortname."_logo_url",
            "type" => "logo",
            "std" => "logo.jpg"),	
			
	array(  "name" => "Contact email address",
			"desc" => "Insert the email address you want to use for contact form submissions",
			"id" => $shortname."_contact_email",
			"type" => "input",
			"std" => ""),
			
	array(  "name" => "Testimonials category ID",
			"desc" => "Insert the testimonials category ID you created manually",
			"id" => $shortname."_testimonials_category_id",
			"type" => "inputThin",
			"std" => ""),	
			
	array(  "name" => "Page ID's to exclude",
		"desc" => "Insert the page ID's you want excluded from main nav (ie 7,8,9)",
		"id" => $shortname."_page_ids_exclude",
		"type" => "input",
		"std" => ""),
		
	array(  "name" => "Category ID's to exclude",
		"desc" => "Insert the category ID's you want excluded from blog roll (ie 7,8,9). Testimonial category auto-exluded so do not add this here.",
		"id" => $shortname."_cat_ids_exclude",
		"type" => "input",
		"std" => ""),
			
	array(  "name" => "Sidebar rotator images",
			"desc" => "Enter the file name and url separated by a comma - put each on new line. Place ',active' on the image to load first - see example. (<strong>place images in bigBrands/images/rotator 350px X 280px</strong>)<br />For example: ad1.png,http://somedomain.com,active",
			"id" => $shortname."_rotator_images",
			"type" => "textarea",
			"std" => "ad1.jpg,http://chrisfay.net\nad2.jpg,http://cjfay.com,active\nad3.jpg,http://cjfay.com\nad4.jpg,http://cjfay.com\n"),
	
	array(  "name" => "Google Analytics Code",
			"desc" => "Insert your Google Analytics code here",
			"id" => $shortname."_google_analytics",
			"type" => "textarea",
			"std" => ""),
			
	array(	"type" => "close"),
	
	//new section	
	array(	"name" => "Items you can hide/show",
			"type" => "title"),
	
	array(	"type" => "open"), //open the secion
	
	array(  "name" => "Enable autoloading of sidebar images?",
			"desc" => "Checking this box will override the rotator images specified for 'Sidebar rotator images' and autoload them from images/rotator folder without links.",
            "id" => $shortname."_enable_autorotator",
            "type" => "checkbox",
            "std" => FALSE),			
			
	array(  "name" => "Disable recent comments sidebar module?",
			"desc" => "Check this box if you would like to DISABLE the recent comments sidebar module?.",
            "id" => $shortname."_recentComments_disable",
            "type" => "checkbox",
            "std" => FALSE),
			
	array(  "name" => "Disable recent posts sidebar module?",
			"desc" => "Check this box if you would like to DISABLE the recent posts sidebar module?.",
            "id" => $shortname."_recentPosts_disable",
            "type" => "checkbox",
            "std" => FALSE),

    array(  "name" => "Disable popular posts sidebar module?",
			"desc" => "Check this box if you would like to DISABLE the popular posts sidebar module?.",
            "id" => $shortname."_popularPosts_disable",
            "type" => "checkbox",
            "std" => FALSE),
		
	array(	"type" => "close"),//close the secion	
);

function mytheme_add_admin() {

    global $themename, $shortname, $options;

    if ( $_GET['page'] == basename(__FILE__) ) {

        if ( 'save' == $_REQUEST['action'] ) {

                foreach ($options as $value) {
                    update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }

                foreach ($options as $value) {
                    if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }

                header("Location: themes.php?page=functions.php&saved=true");
                die;

        } else if( 'reset' == $_REQUEST['action'] ) {

            foreach ($options as $value) {
                delete_option( $value['id'] ); }

            header("Location: themes.php?page=functions.php&reset=true");
            die;

        }
    }

    add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');

}

function mytheme_admin() {

    global $themename, $shortname, $options;

    if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
    if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';

?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>

<form method="post">



<?php foreach ($options as $value) { 

	switch ( $value['type'] ) {
	
		case "open":
		?>
        <table width="100%" border="0" style="background-color:#e6e6e3; padding:10px;">
		

		<?php break;
		
		case "close":
		?>
		
        </table><br />


		<?php break;
		
		case "title":
		?>
		<table width="100%" border="0" style="background-color:#292a24; color:#fff;font-weight:bold; padding:5px 10px;"><tr>
        	<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
        </tr>


		<?php break;
		
		case 'input':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle" ><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>"/>				
			
        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;
		
		case 'inputThin':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><input style="width:100px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>"/>				
			
        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;

		case 'text':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><textarea style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>"><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td>
        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;				
		
		case 'textareasmall':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><textarea style="width:400px;height:100px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>"><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?> </textarea></td>
        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;
		
		case 'textarea':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:600px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo stripslashes($value['std']); } ?></textarea></td>

        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;
		
		case 'select':
		?>
        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
       </tr>

       <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
       </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php
        break;

		case "checkbox":
		?>
            <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
                <td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
                        <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
                        </td>
            </tr>

            <tr>
                <td><small><?php echo $value['desc']; ?></small></td>
           </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

        <?php 		break;
		
		case 'logo':
		?>

        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>"/>
			<!-- show the ad image -->
			<?php
				echo ((get_settings( $value['id']) != "") ? "<img src='".get_bloginfo('template_directory') . "/images/".get_settings( $value['id']) . "' alt='log image' />" : "");
			?>
			</td>
			
			
        </tr>

        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>

		<?php 
		break;
		
		case 'colorSchemes':
		?>
			 <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
                <td width="80%">
                        <input type="radio" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="blue" <? if(get_settings($value['id']) === "blue"){ echo " CHECKED"; }else{ echo ""; } ?> /> Blue <br />
						<input type="radio" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="purple"  <? if(get_settings($value['id']) === "purple"){ echo " checked"; }else{ echo ""; } ?> /> Purple<br />
						<input type="radio" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="green"  <? if(get_settings($value['id']) === "green"){ echo " checked"; }else{ echo ""; } ?> /> Green<br />
						<input type="radio" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="brown"  <? if(get_settings($value['id']) === "brown"){ echo " checked"; }else{ echo ""; } ?> /> Brown						                       
						</td>						
            </tr>

            <tr>
                <td><small><?php echo $value['desc']; ?></small></td>
           </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
		
		<?php
		break;
	

} 
}
?>

<!--</table>-->

<p class="submit">
<input name="save" type="submit" value="Save changes" />    
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post" action="">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>

<div class="adminOptionsAvailable" style="padding:15px;background:#eef3d6;">
<h3>Below are the admin variables and their syntax based on your configuration</h3>
<?php
	global $options;
	foreach ($options as $value) 
	{
		if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
		echo (($value['id'] != '')  ? '$'.$value['id'] . "= " . $$value['id'] . "<br \>" : '');		
	}
?>
</div>

<?php
}

add_action('admin_menu', 'mytheme_add_admin'); ?>