<?php

load_theme_textdomain('default');

if ( function_exists('register_sidebar') )
    register_sidebars(2, array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3 class="widgettitle">',
        'after_title' => '</h3>',
    ));

$etoyaplus= array();
global $etoyaplus;

global $update_result_text;

// $etoyaplus= get_option('etoyaplus');

$etoyaplus= unserialize( get_option('etoyaplus') );
// print_r($etoyaplus);

etoyaplus_default_settings();

function etoyaplus_default_settings ()
{
global $etoyaplus;

if ( empty( $etoyaplus['body_bgimage'] ) )
	$etoyaplus['body_bgimage']= get_stylesheet_directory_uri().'/images/fon/body_bg1.jpg';

if ( empty( $etoyaplus['body_bgrepeat'] ) )
	$etoyaplus['body_bgrepeat']= 'repeat-x';

if ( empty($etoyaplus['body_bgcolor']) )
	$etoyaplus['body_bgcolor']= '#9999CC';

if ( empty($etoyaplus['body_color']) )
	$etoyaplus['body_color']= '#000000';

if ( !isset( $etoyaplus['page_topmargin'] ) )
	$etoyaplus['page_topmargin']= '20';
else
	$etoyaplus['page_topmargin']= (int)$etoyaplus['page_topmargin'];

if ( empty( $etoyaplus['header_bgimage'] ) )
	$etoyaplus['header_bgimage']= get_stylesheet_directory_uri().'/images/fon/header_bg1.gif';

if ( empty( $etoyaplus['header_bgrepeat'] ) )
	$etoyaplus['header_bgrepeat']= 'repeat-x';

if ( !isset( $etoyaplus['headerimg_topmargin'] ) || $etoyaplus['headerimg_topmargin']=='' )
	$etoyaplus['headerimg_topmargin']= '6';

if ( empty( $etoyaplus['horiz_pages_menu'] ) )
	$etoyaplus['horiz_pages_menu']= 'yes';

if ( empty( $etoyaplus['horiz_menu_list_pages'] ) )
	$etoyaplus['horiz_menu_list_pages']= '';

if ( empty( $etoyaplus['horiz_menu_align'] ) )
	$etoyaplus['horiz_menu_align']= 'left';

if ( empty( $etoyaplus['horiz_menu_order'] ) )
	$etoyaplus['horiz_menu_order']= 'ID';

if ( empty( $etoyaplus['horiz_menu_button_bgimage'] ) )
	$etoyaplus['horiz_menu_button_bgimage']= get_stylesheet_directory_uri().'/images/fon/button_bg1.gif';

if ( empty( $etoyaplus['horiz_menu_button_bgcolor'] ) )
	$etoyaplus['horiz_menu_button_bgcolor']= 'NO';  // '#FFFF99';

if ( empty( $etoyaplus['horiz_menu_bgimage'] ) )
	$etoyaplus['horiz_menu_bgimage']= get_stylesheet_directory_uri().'/images/fon/horiz_menu_bg1.jpg';

if ( empty( $etoyaplus['horiz_menu_button_height'] ) )
	$etoyaplus['horiz_menu_button_height']= '24';

if ( empty( $etoyaplus['horiz_menu_button_width'] ) )
	$etoyaplus['horiz_menu_button_width']= 'NO';

if ( empty( $etoyaplus['horiz_menu_bgcolor'] ) )
	$etoyaplus['horiz_menu_bgcolor']= '#FFFFCC';	

if ( !isset($etoyaplus['header_image']) )
	define('HEADER_IMAGE', '%s/images/hdrimg_df.jpg'); // %s is theme dir uri
else
	define('HEADER_IMAGE', $etoyaplus['header_image']);

if ( !isset($etoyaplus['header_image_width']) )
{
	define('HEADER_IMAGE_WIDTH', 848);
	$etoyaplus['header_image_width']= 848;
}
else
	define('HEADER_IMAGE_WIDTH', $etoyaplus['header_image_width']);

if ( !isset($etoyaplus['header_image_height']) )
{
	define('HEADER_IMAGE_HEIGHT', 160);
	$etoyaplus['header_image_height']= 160;
}
else
	define('HEADER_IMAGE_HEIGHT', $etoyaplus['header_image_height']);

define('HEADER_TEXTCOLOR', 'e0e0e0');

if ( empty( $etoyaplus['blogname_visible'] ) )
	$etoyaplus['blogname_visible']='yes';

if ( empty( $etoyaplus['blog_descr_visible'] ) )
	$etoyaplus['blog_descr_visible']='yes';

if ( !isset($etoyaplus['page_width']) )
	$etoyaplus['page_width']= 860;

if ( empty( $etoyaplus['page_bgimage'] ) )
	$etoyaplus['page_bgimage']= get_stylesheet_directory_uri().'/images/fon/page_bg1.jpg';

if ( empty( $etoyaplus['page_bgrepeat'] ) )
	$etoyaplus['page_bgrepeat']= 'repeat-y';

if ( empty($etoyaplus['page_bgcolor']) )
	$etoyaplus['page_bgcolor']= '#FFFFF0';

if ( empty( $etoyaplus['info_bgcolor'] ) )
	$etoyaplus['info_bgcolor']= 'NO';

if ( empty( $etoyaplus['info_bgimage'] ) )
	$etoyaplus['info_bgimage']= get_stylesheet_directory_uri().'/images/fon/info_bg_sidebar_right_1.jpg ';

if ( empty( $etoyaplus['info_bgrepeat'] ) )
	$etoyaplus['info_bgrepeat']= 'repeat-y';

if ( empty( $etoyaplus['content_margin'] ) )
	$etoyaplus['content_margin']= '0';

if ( empty( $etoyaplus['sidebar_margin'] ) )
	$etoyaplus['sidebar_margin']= '0';

if ( empty( $etoyaplus['post_bgcolor'] ) )
	$etoyaplus['post_bgcolor']= 'NO';

if ( empty( $etoyaplus['post_bgimage'] ) )
	$etoyaplus['post_bgimage']= get_stylesheet_directory_uri().'/images/fon/post_bg1.gif';

if ( empty( $etoyaplus['post_bgrepeat'] ) )
	$etoyaplus['post_bgrepeat']= 'repeat';


if ( empty( $etoyaplus['post_title_bgcolor'] ) )
	$etoyaplus['post_title_bgcolor']= 'NO';

if ( empty( $etoyaplus['post_title_bgimage'] ) )
	$etoyaplus['post_title_bgimage']= get_stylesheet_directory_uri().'/images/fon/post_title_bg1.jpg';

if ( empty( $etoyaplus['post_title_bgrepeat'] ) )
	$etoyaplus['post_title_bgrepeat']= 'no-repeat';

if ( empty( $etoyaplus['post_title_color'] ) )
	$etoyaplus['post_title_color']= '#000000';

if ( empty( $etoyaplus['post_color'] ) )
	$etoyaplus['post_color']= '#000000';

if ( empty( $etoyaplus['post_bottom_bgimage'] ) )
	$etoyaplus['post_bottom_bgimage']= get_stylesheet_directory_uri().'/images/fon/post_bottom_bg1.jpg';

if ( empty( $etoyaplus['post_bottom_bgrepeat'] ) )
	$etoyaplus['post_bottom_bgrepeat']= 'no-repeat';

if ( empty( $etoyaplus['post_date_fmt'] ) )
	$etoyaplus['post_date_fmt']= get_option('date_format').' '.get_option('time_format');

if ( !isset($etoyaplus['sidebar_bok']) )
	$etoyaplus['sidebar_bok']= 'yes';

if ( !isset($etoyaplus['sidebar_niz']) )
	$etoyaplus['sidebar_niz']= 'no';

if ( !isset($etoyaplus['widget_niz_width']) )
	$etoyaplus['widget_niz_width']= '183';

if ( !isset($etoyaplus['widget_niz_align']) )
	$etoyaplus['widget_niz_align']= 'left';

if ( !isset($etoyaplus['widget_niz_bgcolor']) )
	$etoyaplus['widget_niz_bgcolor']= '#e0e0f0';

if ( !isset($etoyaplus['sidebar_side']) )
	$etoyaplus['sidebar_side']= 'right';

if ( !isset($etoyaplus['widget_title_color']) )
	$etoyaplus['widget_title_color']= '#000066';

if ( !isset($etoyaplus['sidebar_width']) )
	$etoyaplus['sidebar_width']= 240;

if ( !isset($etoyaplus['content_width']) )
	$etoyaplus['content_width']= 600;

if ( !isset($etoyaplus['content_bgrepeat']) )
	$etoyaplus['content_bgrepeat']= 'no-repeat';

if ( empty( $etoyaplus['content_bgcolor'] ) )
	$etoyaplus['content_bgcolor']= 'NO';

if ( !isset($etoyaplus['content_align']) )
	$etoyaplus['content_align']= 'left';

if ( empty( $etoyaplus['footer_bgcolor'] ) )
	$etoyaplus['footer_bgcolor']= 'NO';

if ( empty( $etoyaplus['footer_bgimage'] ) )
	$etoyaplus['footer_bgimage']= get_stylesheet_directory_uri().'/images/fon/footer_bg1.gif';

// if ( empty( $etoyaplus['footer_bgrepeat'] ) )
	$etoyaplus['footer_bgrepeat']= 'repeat-x';

if ( empty( $etoyaplus['footer_vpos'] ) )
	$etoyaplus['footer_vpos']= '-37';

if ( empty( $etoyaplus['footer_color'] ) )
	$etoyaplus['footer_color']= '#000000';

if ( empty( $etoyaplus['footer_rss_links'] ) )
	$etoyaplus['footer_rss_links']= 'yes';

if ( empty( $etoyaplus['txt_comments'] ) )
	$etoyaplus['txt_comments']= __('comments');
	
if ( empty( $etoyaplus['txt_add_your_comment'] ) )
	$etoyaplus['txt_add_your_comment']= __('Leave a comment');

if ( empty( $etoyaplus['txt_commenter_wrote'] ) )
	$etoyaplus['txt_commenter_wrote']= __('wrote');

if ( empty( $etoyaplus['comment_date_fmt'] ) )
	$etoyaplus['comment_date_fmt']= get_option('date_format').' '.get_option('time_format');

if ( empty( $etoyaplus['comments_popup'] ) )
	$etoyaplus['comments_popup']= 'no';

if ( empty( $etoyaplus['footer_txt'] ) )
	$etoyaplus['footer_txt']= '&copy; '.date('Y ').get_option('blogname');

if ( empty( $etoyaplus['link_color'] ) )
	$etoyaplus['link_color']= '#0000FF';

if ( empty( $etoyaplus['post_link_color'] ) )
	$etoyaplus['post_link_color']= '#006666';

if ( empty( $etoyaplus['sidebar_link_color'] ) )
	$etoyaplus['sidebar_link_color']= '#000099';

if ( empty( $etoyaplus['post_link_underline'] ) )
	$etoyaplus['post_link_underline']= 'none';

if ( empty( $etoyaplus['show_gravatars'] ) )
	$etoyaplus['show_gravatars']= 'no';

// -- end of default settings
}

function admin_header_style() {
echo "<style type=\"text/css\">\r\n";
echo '#headimg {background: #c0c0c0 url('; header_image(); echo ') no-repeat;';
echo 'height:', HEADER_IMAGE_HEIGHT, 'px;';
echo 'width:', HEADER_IMAGE_WIDTH, "px; }\r\n";

echo '#headimg h1 a, headimg h1 a:visited {color:#'; header_textcolor(); echo ';}';
echo '#desc {color:#'; header_textcolor(); echo ';}';

echo '</style>';

}


function eto_opposite_side($side) {
	if ($side=='left') return 'right';
	elseif ($side=='right') return 'left';
	else return '';
}

function header_style() {
global $etoyaplus;

echo "\r\n<style type=\"text/css\">\r\n";

echo "body {";
if ( $etoyaplus['body_bgcolor']!='NO' )
echo "background-color: ",$etoyaplus['body_bgcolor'],'; ';
if ( $etoyaplus['body_bgimage']!='NO' )
{
echo "background-image: url(", $etoyaplus['body_bgimage'], '); ';
echo "background-repeat: ", $etoyaplus['body_bgrepeat'], '; ';
}

if ( $etoyaplus['body_bgcolor']=='NO' && $etoyaplus['body_bgimage']=='NO' )
echo "background:none; ";

if ( $etoyaplus['body_color']!='NO' )
echo "color: ",$etoyaplus['body_color'],'; ';

echo "} \r\n";

echo "#page {width: $etoyaplus[page_width]px; margin: $etoyaplus[page_topmargin]px auto;";
if ( $etoyaplus['page_bgcolor']!='NO' )
echo "background-color: ",$etoyaplus['page_bgcolor'],'; ';

if ( $etoyaplus['page_bgimage']!='NO' )
{
echo "background-image: url(", $etoyaplus['page_bgimage'], '); ';
echo "background-repeat: ", $etoyaplus['page_bgrepeat'], ';';
}

if ( $etoyaplus['page_bgcolor']=='NO' && $etoyaplus['page_bgimage']=='NO' )
echo "background:none; ";
echo "} \r\n";

echo "#header {";
if ( $etoyaplus['header_bgcolor']!='NO' )
echo "background-color: ",$etoyaplus['header_bgcolor'],'; ';
if ( $etoyaplus['header_bgimage']!='NO' )
{
echo "background-image: url(", $etoyaplus['header_bgimage'], '); ';
echo "background-repeat: $etoyaplus[header_bgrepeat]; ";
}

if ( $etoyaplus['header_bgcolor']=='NO' && $etoyaplus['header_bgimage']=='NO' )
echo "background:none; ";
echo "} \r\n";

echo '#headerimg {';

if ( $etoyaplus['header_image']!='NO' )
{
	echo 'background: url('; header_image(); echo ') no-repeat; ';
}
echo 'height:', HEADER_IMAGE_HEIGHT, 'px; ';
echo 'width:', HEADER_IMAGE_WIDTH, "px;}\r\n";

if ( $etoyaplus[headerimg_topmargin]!=0 ) {
	echo "#header_top {height: $etoyaplus[headerimg_topmargin]px; width:100%;}\r\n"; 
}

echo '#headerimg h1 a{color:#'; header_textcolor(); echo "}\r\n";

if ( 'blank' == get_header_textcolor() ) { 

echo "#header h1 {display: none;}\r\n";
echo "#description {display: none;}\r\n";

} else {

echo '#header h1 a{color: #'; header_textcolor(); echo "}\r\n";
echo '#description {color: #'; header_textcolor(); echo "}\r\n";
}

if ( $etoyaplus['horiz_menu_align']!='center' )
{
echo "#header ul {text-align: $etoyaplus[horiz_menu_align];}\r\n";
echo "#header ul li {float: $etoyaplus[horiz_menu_align]; ";
echo "}\r\n";
}
else
{
echo "#horiz_menu { text-align:center; }\n";
echo "#header ul { margin:0 auto;}\n";
echo "#header ul li {display: inline;}\n";
echo "#header ul li a {display: inline-block; text-align:center; overflow:hidden; }";
}

echo "#horiz_menu {";
if ( $etoyaplus['horiz_menu_bgcolor']!='NO' )
	echo "background-color: $etoyaplus[horiz_menu_bgcolor]; ";
if ( $etoyaplus['horiz_menu_bgimage']!='NO' )
	echo "background-image: url($etoyaplus[horiz_menu_bgimage]);";
echo "}\r\n";

echo '#header ul li a, #header ul li a:visited {';
if ( $etoyaplus['horiz_menu_button_bgcolor']!='NO' )
	echo "background-color: $etoyaplus[horiz_menu_button_bgcolor]; ";

if ( $etoyaplus['horiz_menu_button_bgimage']!='NO' ) {
	echo "background-image: url(", $etoyaplus['horiz_menu_button_bgimage'], '); ';
	echo "background-repeat: repeat-x; ";
	echo " height:", $etoyaplus['horiz_menu_button_height'], "px;";
	echo " line-height:", $etoyaplus['horiz_menu_button_height'], "px;";
}

if ( $etoyaplus['horiz_menu_button_width']!='NO' ) {
	echo " width:", $etoyaplus['horiz_menu_button_width'], "px;";
	echo " text-align: center;";
}

if ( $etoyaplus['page_bgcolor']=='NO' && $etoyaplus['page_bgimage']=='NO' )
	echo "background:none; ";
echo "} \r\n";

echo '#info {width:', $etoyaplus['page_width'], 'px; ';

if ( $etoyaplus['info_bgcolor']!='NO' )
	echo "background-color: ",$etoyaplus['info_bgcolor'],'!important;';

if ( $etoyaplus['info_bgimage']!='NO' ) {
	echo "background-image: url(", $etoyaplus['info_bgimage'], '); ';
	echo "background-repeat: ", $etoyaplus['info_bgrepeat'];
}

if ( $etoyaplus['info_bgcolor']=='NO' && $etoyaplus['info_bgimage']=='NO' )
	echo "background:none; ";

echo "} \r\n";

echo "#content {width: $etoyaplus[content_width]px; overflow-x:hidden; float:".eto_opposite_side($etoyaplus['sidebar_side'])."; ";

if ( $etoyaplus['content_margin']!='0') {
	echo "margin-".eto_opposite_side($etoyaplus['sidebar_side']).": ".$etoyaplus['content_margin']."px; ";
}

if ( $etoyaplus['content_bgcolor']!='NO' )
	echo "background-color: ",$etoyaplus['content_bgcolor'],'; ';

if ( $etoyaplus['content_bgimage']!='NO' ) {
	echo "background-image: url(", $etoyaplus['content_bgimage'], '); ';
	echo "background-repeat: ", $etoyaplus['content_bgrepeat'], '; ';
}

if ( $etoyaplus['content_bgcolor']=='NO' && $etoyaplus['content_bgimage']=='NO' )
echo "background:none; ";

if ( $etoyaplus['content_align']!='NO' )
echo "text-align: ",$etoyaplus['content_align'],'; ';

echo "} \r\n";


echo ".post {";
if ( $etoyaplus['post_bgcolor']!='NO' )
echo "background-color: ",$etoyaplus['post_bgcolor'],'; ';

if ( $etoyaplus['post_bgimage']!='NO' )
{
echo "background-image: url(", $etoyaplus['post_bgimage'], '); ';
echo "background-repeat: ", $etoyaplus['post_bgrepeat'], '; ';
}
echo "} \r\n";

echo "h2.posttitle, h2.pagetitle {";
if ( $etoyaplus['post_bgimage']!='NO' )
{
echo "background-image: url(", $etoyaplus['post_title_bgimage'], '); ';
echo "background-repeat: ", $etoyaplus['post_title_bgrepeat'], '; ';
}
echo "} \r\n";

if ( $etoyaplus['post_color']!='NO' )
echo ".entry {color: $etoyaplus[post_color]} \r\n";

if ( $etoyaplus['post_title_color']!='NO' )
echo "h2.pagetitle, h2.posttitle, h2.posttitle a, h2.posttitle a:visited {color: $etoyaplus[post_title_color]} \r\n";

echo ".post_bottom {";
if ( $etoyaplus['post_bottom_bgimage']!='NO' )
{
echo "height:40px; background-image: url(", $etoyaplus['post_bottom_bgimage'], '); ';
echo "background-repeat: ", $etoyaplus['post_bottom_bgrepeat'], '; ';
}
echo "} \r\n";

echo "#sidebar {width: $etoyaplus[sidebar_width]px; overflow-x:hidden; float:$etoyaplus[sidebar_side]; ";

if ( $etoyaplus['sidebar_margin']!='0') {
	echo "margin-$etoyaplus[sidebar_side]: $etoyaplus[sidebar_margin]px; ";
}

echo "}\r\n";

if ( $etoyaplus['widget_title_color']!='NO' )
echo ".widget h3 {color: $etoyaplus[widget_title_color]}\r\n";

echo "#footer {";

if ( $etoyaplus['footer_bgcolor']!='NO' )
	echo "background-color: ",$etoyaplus['footer_bgcolor'],'; ';

if ( $etoyaplus['footer_bgimage']!='NO' ) {
	echo "background-image: url(", $etoyaplus['footer_bgimage'], '); ';
	echo "background-repeat: repeat-x;"; //, $etoyaplus['footer_bgrepeat'];
}

if ( $etoyaplus['footer_color']!='NO' )
echo "color: ",$etoyaplus['footer_color'],'; ';

if ( $etoyaplus['footer_vpos']!='NO' )
{
echo "background-position: 0 ", $etoyaplus['footer_vpos'], 'px; ';
}

if ( $etoyaplus['body_bgcolor']=='NO' && $etoyaplus['body_bgimage']=='NO' )
echo "background:none; ";
echo "} \r\n";

if ( $etoyaplus['link_color']!='NO' )
echo 'a, a:visited {color:',$etoyaplus['link_color'],"}\r\n";

if ( $etoyaplus['post_link_color']!='NO' )
echo '.entry a, .entry a:visited {color:',$etoyaplus['post_link_color'],"}\r\n";

if ( $etoyaplus['post_link_underline']=='underline' )
echo ".entry a, .entry a:visited {text-decoration: underline}\r\n";

if ( $etoyaplus['sidebar_link_color']!='NO' )
echo '#sidebar a, #sidebar a:visited {color:',$etoyaplus['sidebar_link_color'],"}\r\n";

echo "#sidebar_niz li.widget { width:$etoyaplus[widget_niz_width]px; ";

if ( $etoyaplus['widget_niz_bgcolor']!='NO' )
echo 'background: ',$etoyaplus['widget_niz_bgcolor'],"; ";

echo 'text-align: ',$etoyaplus['widget_niz_align'],"; ";

echo "}\r\n";
?>

</style>

<?php }

if ( function_exists('add_custom_image_header') ) {
add_custom_image_header('header_style', 'admin_header_style');
}


function etoyaplus_add_admin() {
	add_theme_page(__('Theme Settings'), __('&quot;Eto-Ya +&quot; Settings'), 'manage_options', basename(__FILE__), 'etoyaplus_settings');
}

// -- this functions simplifies output of background-repeat variants
function etoyaplus_bgrepeat_variants($div)
{
	global $etoyaplus;
	$rpv= array( 'repeat'=> __('horiz., vert.'), 'repeat-x'=>__('horiz.'), 'repeat-y'=>__('vert.'), 'no-repeat'=>'no' );
	echo __('Repeat').': &nbsp; ';
	foreach ($rpv as $k=>$v)
	{
		echo ' &nbsp; ', $v, '<input type="radio" ';
		if ( $k==$etoyaplus[$div.'_bgrepeat'] )
		{
			echo ' checked="checked"' ;
		}
		echo ' name="etoyaplus_'.$div.'_bgrepeat" value="', $k, '" />';
	}
}
// -- end of etoyaplus_bgrepeat_variants

//

// --  this functions outputs the colorpicker for an element
function etoyaplus_color_variants($div)
{
global $etoyaplus;
echo '<input type="text" name="etoyaplus_',$div,'" id="etoyaplus_',$div,'" size="7" value="',$etoyaplus[$div],'" style="background:',$etoyaplus[$div],'" ';

if ( substr($etoyaplus[$div],1,2)<='66' && substr($etoyaplus[$div],3,2)<='66' &&
	substr($etoyaplus[$div],5,2)<='66' )
		echo ' style="color:#FFFFFF" ';

echo "/> <a href=\"javascript:void(0);\" onclick=\"javascript:color_table('etoyaplus_$div');\">".__('select')."</a> &nbsp; <a href=\"javascript:void(0);\" onclick=\"javascript:skryt_piker('etoyaplus_$div');\">[Х]</a> &nbsp; <a href=\"javascript:void(0);\" onclick=\"javascript:document.getElementById('etoyaplus_$div').value='NO'\">".__('no')."</a> <div id=\"colors_etoyaplus_$div\" class=\"piker\"></div>";
}

function etoyaplus_settings()
{
global $etoyaplus;
global $update_result_text;

if ( 'POST'==$_SERVER['REQUEST_METHOD'] )
{	
//	print_r($_POST);
	
	$update_result_text= '';

	if ( $_POST['delete_eto_ya_plus_settings']=='yes' )
	{
		delete_option('etoyaplus');
		unset($etoyaplus);
		global $etoyaplus;
				$etoyaplus= array();
		etoyaplus_default_settings();
		$update_result_text= __('Theme options have been reset to default.');
	}
	elseif ( !empty($_FILES['etoyaplus_importing']['name']) )
	{	
		if ( !eregi('.+\.txt$', $_FILES['etoyaplus_importing']['name'], $price_ext) )
		{
			$update_result_text= __('Theme settins file must have .txt extention.');
		}
		else
		{
			 $update_result_text= serialize($_FILES);
			
			$new_etoyaplus= unserialize(file_get_contents($_FILES['etoyaplus_importing']['tmp_name']));

			print_r($new_etoyaplus);

			foreach ($new_etoyaplus as $nk=>$nv)
				$etoyaplus[$nk]= htmlspecialchars(trim(stripslashes($nv)));
			update_option ( 'etoyaplus', serialize($etoyaplus) );
			$update_result_text= __('Theme settings have been imported from the file').
				' '.htmlspecialchars($_FILES['etoyaplus_importing']['name']);
		}
	}
	else
	{
		$new_etoyaplus= array();
		foreach ( $_POST as $k=>$v )
		{
			if ( ereg('^etoyaplus_([a-z0-9_]+)', $k, $r) )
			{
				$new_etoyaplus[$r[1]]= htmlspecialchars(trim(stripslashes($v)));
			}
			if ( $new_etoyaplus[$r[1]]=='' )
			{
				unset( $new_etoyaplus[$r[1]] );
			}
	
		}
		
		update_option ( 'etoyaplus', serialize($new_etoyaplus) );
	
		$etoyaplus= unserialize( get_option('etoyaplus') );
		$update_result_text= __('Theme settings updated.');
	}
}


if ( $_GET['eypact']=='export' )
{
	$exportstr= get_option('etoyaplus');
	header("Content-Type: application/octet-stream;");
	header('Content-Disposition: attachment; filename=eyp-settings-'.date('YmdHis').'-'.str_replace('.','-',$_SERVER['HTTP_HOST']).'.txt');
	header ('Accept-Ranges: bytes');
	header ('Content-Length: '.strlen($exportstr));

	echo($exportstr);
	die();
}

if ( 'POST'== $_SERVER['REQUEST_METHOD'] )
{
	echo '<div id="message" class="updated fade"><p><strong>'.$update_result_text.'</strong></p></div>';
}

?>
<div class="wrap">
<div id="icon-themes" class="icon32"><br /></div><h2 style="margin-top:10px"><?php _e('Customize the Eto-Ya plus theme'); ?> &nbsp; <span>(<a href="http://plus.eto-ya.com/"><?php _e('Visit Theme Site'); ?></a>)</span></h2>

<form method="post" enctype="multipart/form-data" action="http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" id="nastrojki_eto_ya_plus">
<div class="wrap2"><h3><?php _e('Import from theme options file'); ?></h3>
<p><?php _e('If you like to apply theme options from a file saved earlier,<br />please select a file on your computer:'); ?><br /> <input type="file" name="etoyaplus_importing" />
&nbsp; <input type="submit" name="etoyaplus_import_submit" value="<?php _e('Upload and Apply'); ?>" />
</p>
</div>
<div class="wrap2"><h3><?php _e('Body Settings (General Background)'); ?></h3>
<p><?php _e('Background color'); ?> <?php etoyaplus_color_variants('body_bgcolor') ; ?></p>

<p><?php _e('Background image'); ?> (http://...)<input type="text" id="etoyaplus_body_bgimage" name="etoyaplus_body_bgimage" size="45" value="<?php echo $etoyaplus['body_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_body_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('body'); ?>
</p>

<p><?php _e('Main text color'); ?> <?php etoyaplus_color_variants('body_color'); ?> </p>

</div>

<div class="wrap2"><h3><?php _e('Page Settings'); ?></h3>
<p><?php _e('Page width'); ?>: <input type="text" name="etoyaplus_page_width" size="6" value="<?php echo $etoyaplus['page_width']; ?>" /> px </p>

<?php _e('Page background color'); ?> <?php etoyaplus_color_variants('page_bgcolor') ; ?>

<p><?php _e('Page background image'); ?> (http://...)<input type="text" id="etoyaplus_page_bgimage" name="etoyaplus_page_bgimage" size="45" value="<?php echo $etoyaplus['page_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_page_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('page'); ?>
</p>

<p><?php _e('Page distance from the top of the window'); ?>:  <input type="text" id="etoyaplus_page_topmargin" name="etoyaplus_page_topmargin" size="6" value="<?php echo $etoyaplus['page_topmargin']; ?>" /> <?php _e('px (integer, sample: 10, 0, 25)'); ?></p>

</div>

<div class="wrap2"><h3><?php _e('Header Settings'); ?></h3>

<p><?php _e('Header background image'); ?> (http://...)<input type="text" name="etoyaplus_header_bgimage" size="45" value="<?php echo $etoyaplus['header_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_header_bgimage').value='NO'"><?php _e('no'); ?></a><br />

<?php etoyaplus_bgrepeat_variants('header'); ?>

&nbsp; &nbsp; &nbsp;
<?php _e('Header background color'); ?> <?php etoyaplus_color_variants('header_bgcolor') ; ?> </p>

<p><?php _e('Header image width'); ?>: <input type="text" id="etoyaplus_header_image_width" name="etoyaplus_header_image_width" size="6" value="<?php echo $etoyaplus['header_image_width']; ?>" /> px
&nbsp; &nbsp; &nbsp;
<?php _e('Header image height'); ?>: <input type="text" name="etoyaplus_header_image_height" size="6" value="<?php echo $etoyaplus['header_image_height']; ?>" /> px </p>

<p><?php _e('Header image'); ?> (http://...)<input type="text" name="etoyaplus_header_image" size="45" value="<?php echo $etoyaplus['header_image']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_header_image').value='NO'"><?php _e('no'); ?></a><br />
<small><i><?php _e('If empty then the image from &quot;Custom Header&quot; submenu is used'); ?></i></small>
</p>

<p><?php _e('Show blog name'); ?>: &nbsp; <?php _e('Yes'); ?> <input type="radio" name="etoyaplus_blogname_visible" <?php if ( $etoyaplus['blogname_visible']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp;
<?php _e('No'); ?> <input type="radio" name="etoyaplus_blogname_visible" <?php if ( $etoyaplus['blogname_visible']=='no' ) echo 'checked="checked"'; ?> value="no" /> &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<?php _e('Show blog description'); ?>: &nbsp; <?php _e('Yes'); ?> <input type="radio" name="etoyaplus_blog_descr_visible" <?php if ( $etoyaplus['blog_descr_visible']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp;
<?php _e('No'); ?> <input type="radio" name="etoyaplus_blog_descr_visible" <?php if ( $etoyaplus['blog_descr_visible']=='no' ) echo 'checked="checked"'; ?> value="no" /> &nbsp;
</p>

<p><?php _e('Header image distance from the top of the page'); ?> <input type="text" id="etoyaplus_headerimg_topmargin" name="etoyaplus_headerimg_topmargin" size="6" value="<?php echo $etoyaplus['headerimg_topmargin']; ?>" /> <?php _e('px (integer, sample: -10, 0, 15)'); ?></p>
</div>

<div class="wrap2"><h3><?php _e('Horizontal pages menu under the header'); ?></h3>
<p><?php _e('Horizontal pages menu'); ?>: &nbsp; <?php _e('Show'); ?> <input type="radio" name="etoyaplus_horiz_pages_menu" <?php if ( $etoyaplus['horiz_pages_menu']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp; <?php _e('No'); ?> <input type="radio" name="etoyaplus_horiz_pages_menu" <?php if ( $etoyaplus['horiz_pages_menu']=='no' ) echo 'checked="checked"'; ?> value="no" /></p>

<p><?php _e('Horizontal pages menu alignment'); ?>: &nbsp; <?php _e('Left'); ?><input type="radio" name="etoyaplus_horiz_menu_align" <?php if ( $etoyaplus['horiz_menu_align']=='left' ) echo 'checked="checked"'; ?> value="left" /> &nbsp;
<?php _e('Right'); ?><input type="radio" name="etoyaplus_horiz_menu_align" <?php if ( $etoyaplus['horiz_menu_align']=='right' ) echo 'checked="checked"'; ?> value="right" /> &nbsp;

<?php _e('Center'); ?><input type="radio" name="etoyaplus_horiz_menu_align" <?php if ( $etoyaplus['horiz_menu_align']=='center' ) echo 'checked="checked"'; ?> value="center" />
</p>

<p><?php _e('Horizontal menu background color'); ?> <?php etoyaplus_color_variants('horiz_menu_bgcolor') ; ?></p>

<p><?php _e('Horizontal menu background image'); ?> (http://...)<input type="text" id="etoyaplus_horiz_menu_bgimage" name="etoyaplus_horiz_menu_bgimage" size="45" value="<?php echo $etoyaplus['horiz_menu_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_horiz_menu_bgimage').value='NO'"><?php _e('no'); ?></a>
</p>

<p><?php _e('Background color of horiz. menu links'); ?> <?php etoyaplus_color_variants('horiz_menu_button_bgcolor') ; ?> </p>

<p><?php _e('Background image of horiz. menu links'); ?> (http://...)<input type="text" id="etoyaplus_horiz_menu_button_bgimage" name="etoyaplus_horiz_menu_button_bgimage" size="45" value="<?php echo $etoyaplus['horiz_menu_button_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_horiz_menu_button_bgimage').value='NO'"><?php _e('no'); ?></a></p>

<p><?php _e('Horizontal menu button height'); ?> <input type="text" id="etoyaplus_horiz_menu_button_height" name="etoyaplus_horiz_menu_button_height" size="2" value="<?php echo $etoyaplus['horiz_menu_button_height']; ?>" />px &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_horiz_menu_button_height').value='NO'"><?php _e('no'); ?></a>
&nbsp; &nbsp; &nbsp; &nbsp;

<?php _e('Horizontal menu button width'); ?> <input type="text" id="etoyaplus_horiz_menu_button_width" name="etoyaplus_horiz_menu_button_width" size="2" value="<?php echo $etoyaplus['horiz_menu_button_width']; ?>" />px &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_horiz_menu_button_width').value='NO'"><?php _e('no'); ?></a></p>

<p><?php _e('List page IDs to show in the horiz. menu'); ?>:
<input type="text" id="etoyaplus_horiz_menu_list_pages" name="etoyaplus_horiz_menu_list_pages" size="30" value="<?php echo $etoyaplus['horiz_menu_list_pages']; ?>" /><br />
<small><?php _e('Leave empty to show all. Or write: <b>include=1,4,5</b> (where 1, 4 и 5 are IDs of pages shloud be in horiz. menu),<br /> or <b>exclude=1,3,7</b> (then pages 2, 3 и 7 are not shown in horiz. menu).'); ?></small></p>

<p><?php _e('Sort horiz. menu links'); ?>:<br /> <?php _e('By page ID'); ?><input type="radio" name="etoyaplus_horiz_menu_order" <?php
if ( $etoyaplus['horiz_menu_order'] == 'ID' ) echo ' checked="checked"';
?>
value="ID">
&nbsp; <?php _e('By menu order'); ?><input type="radio" name="etoyaplus_horiz_menu_order"
<?php
if ( $etoyaplus['horiz_menu_order'] == 'menu_order' ) echo ' checked="checked"';
?>
value="menu_order">
&nbsp; <?php _e('By post title'); ?><input type="radio" name="etoyaplus_horiz_menu_order"
<?php
if ( $etoyaplus['horiz_menu_order'] == 'post_title' ) echo ' checked="checked"';
?>
value="post_title">
</p>

</div>

<div class="wrap2"><h3><?php _e('Main Part Settings (Info Block)'); ?></h3>
<p><?php _e('Info block background color'); ?> <?php etoyaplus_color_variants('info_bgcolor') ; ?> </p>

<p><?php _e('Info block background image'); ?> (http://...)<input type="text" id="etoyaplus_info_bgimage" name="etoyaplus_info_bgimage" size="45" value="<?php echo $etoyaplus['info_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_info_bgimage').value='NO'"><?php _e('no'); ?></a><br />

<?php etoyaplus_bgrepeat_variants('info'); ?>
</p>
</div>

<div class="wrap2"><h3><?php _e('Content Block Settings'); ?></h3>
<p><?php _e('Content block width'); ?>: <input type="text" name="etoyaplus_content_width" size="6" value="<?php echo $etoyaplus['content_width']; ?>" /> px</p>

<p><?php _e('Content block background color'); ?> <?php etoyaplus_color_variants('content_bgcolor') ; ?> </p>

<p><?php _e('Content block background image'); ?> (http://...)<input type="text" id="etoyaplus_content_bgimage"  name="etoyaplus_content_bgimage" size="45" value="<?php echo $etoyaplus['content_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_content_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('content'); ?> </p>

<p><?php _e('Content block distance from the vertical page border'); ?> <?php echo $etoyaplus['content_margin']; ?>px </p>

<p><?php _e('Text alignment'); ?>: &nbsp;
<?php
$tmp= array('left'=>__('left'), 'right'=>__('right'), 'center'=>__('center'), 'justify'=>__('justify'), 'NO'=>'no');
foreach ($tmp as $k=>$v)
{
	echo '&nbsp; ',$v,'<input type="radio"  name="etoyaplus_content_align" value="',$k,'" id="',$k,'" ';
	if ( $etoyaplus['content_align']==$k )
	echo ' checked="checked" ';
	echo ' />';
}
?>
</p>

</div>

<div class="wrap2"><h3><?php _e('Post Settings'); ?></h3>
<p><?php _e('Post title background image'); ?> (http://...)<input type="text" id="etoyaplus_post_title_bgimage"  name="etoyaplus_post_title_bgimage" size="45" value="<?php echo $etoyaplus['post_title_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_post_title_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('post_title'); ?> </p>

<p><?php _e('Post background image'); ?> (http://...)<input type="text" id="etoyaplus_post_bgimage"  name="etoyaplus_post_bgimage" size="45" value="<?php echo $etoyaplus['post_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_post_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('post'); ?> </p>

<p><?php _e('Post bottom background image'); ?> (http://...)<input type="text" id="etoyaplus_post_bottom_bgimage"  name="etoyaplus_post_bottom_bgimage" size="45" value="<?php echo $etoyaplus['post_bottom_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_post_bottom_bgimage').value='NO'"><?php _e('no'); ?></a><br />
<?php etoyaplus_bgrepeat_variants('post_bottom'); ?> </p>

<p><?php _e('Post title color'); ?> <?php etoyaplus_color_variants('post_title_color'); ?> </p>

<p><?php _e('Post text color'); ?> <?php etoyaplus_color_variants('post_color'); ?> </p>

<p><?php _e('Post date and time format'); ?> <input type="text" id="etoyaplus_post_date_fmt"  name="etoyaplus_post_date_fmt" size="20" value="<?php echo $etoyaplus['post_date_fmt']; ?>" /> (<a href="http://codex.wordpress.org/Formatting_Date_and_Time"><?php _e('more info'); ?></a>)</p>

</div>

<div class="wrap2"><h3><?php _e('Sidebar Settings (Sidebar 1)'); ?></h3>
<p><?php _e('Show sidebar?'); ?> &nbsp; <?php _e('Yes'); ?> <input type="radio" name="etoyaplus_sidebar_bok" <?php if ( $etoyaplus['sidebar_bok']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp; <?php _e('No'); ?> <input type="radio" name="etoyaplus_sidebar_bok" <?php if ( $etoyaplus['sidebar_bok']=='no' ) echo 'checked="checked"'; ?> value="no" />
&nbsp; &nbsp; &nbsp; &nbsp;
<?php _e('Sidebar location'); ?>: &nbsp; <?php _e('left'); ?> <input type="radio" name="etoyaplus_sidebar_side" <?php if ( $etoyaplus['sidebar_side']=='left' ) echo 'checked="checked"'; ?> value="left" /> &nbsp; <?php _e('right'); ?> <input type="radio" name="etoyaplus_sidebar_side" <?php if ( $etoyaplus['sidebar_side']=='right' ) echo 'checked="checked"'; ?> value="right" /></p>

<p><?php _e('Sidebar width'); ?>: <input type="text" name="etoyaplus_sidebar_width" size="6" value="<?php echo $etoyaplus['sidebar_width']; ?>" /> px
&nbsp; &nbsp; &nbsp; &nbsp;
<?php _e('Sidebar distance from the vertical page border'); ?>: <input type="text" name="etoyaplus_sidebar_margin" size="6" value="<?php echo $etoyaplus['sidebar_margin']; ?>" /> px </p>

<p><?php _e('Widget titles color'); ?> <?php etoyaplus_color_variants('widget_title_color') ; ?></p>

</div>

<div class="wrap2"><h3><?php _e('Bottom Menu Settings (Sidebar 2)'); ?></h3>
<p><?php _e('Show bottom sidebar?'); ?> &nbsp; <?php _e('Yes'); ?> <input type="radio" name="etoyaplus_sidebar_niz" <?php if ( $etoyaplus['sidebar_niz']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp; <?php _e('No'); ?> <input type="radio" name="etoyaplus_sidebar_niz" <?php if ( $etoyaplus['sidebar_niz']=='no' ) echo 'checked="checked"'; ?> value="no" />
&nbsp; &nbsp; &nbsp; &nbsp;
<?php _e('Bottom sidebar widgets width'); ?>: <input type="text" name="etoyaplus_widget_niz_width" size="6" value="<?php echo $etoyaplus['widget_niz_width']; ?>" /> px</p></p>

<p><?php _e('Text alignment in bottom sidebar widgets'); ?> &nbsp; <?php _e('left'); ?> <input type="radio" name="etoyaplus_widget_niz_align" <?php if ( $etoyaplus['widget_niz_align']=='left' ) echo 'checked="checked"'; ?> value="left" /> &nbsp; <?php _e('right'); ?> <input type="radio" name="etoyaplus_widget_niz_align" <?php if ( $etoyaplus['widget_niz_align']=='right' ) echo 'checked="checked"'; ?> value="right" /> &nbsp; <?php _e('center'); ?> <input type="radio" name="etoyaplus_widget_niz_align" <?php if ( $etoyaplus['widget_niz_align']=='center' ) echo 'checked="checked"'; ?> value="center" /></p>

<p><?php _e('Bottom sidebar widgets background color'); ?>
<?php etoyaplus_color_variants('widget_niz_bgcolor') ; ?></p>

</div>

<div class="wrap2"><h3><?php _e('Footer'); ?></h3>
<p><?php _e('Footer background color'); ?> <?php etoyaplus_color_variants('footer_bgcolor') ; ?> </p>

<p><?php _e('Footer background image'); ?> (http://...)<input type="text" id="etoyaplus_footer_bgimage" name="etoyaplus_footer_bgimage" size="45" value="<?php echo $etoyaplus['footer_bgimage']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_footer_bgimage').value='NO'"><?php _e('no'); ?></a>
</p>
<p><?php _e('Footer background image vertical position'); ?> <input type="text" id="etoyaplus_footer_vpos" name="etoyaplus_footer_vpos" size="6" value="<?php echo $etoyaplus['footer_vpos']; ?>" /> <?php _e('px (integer, sample: -10, 0, 15)'); ?>
</p>

<p><?php _e('Text color in a footer'); ?>: <?php etoyaplus_color_variants('footer_color'); ?> </p>

<p><?php _e('Show links to RSS'); ?>: 
&nbsp; <?php _e('yes'); ?><input type="radio" name="etoyaplus_footer_rss_links" <?php if ( $etoyaplus['footer_rss_links']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp; <?php _e('no'); ?><input type="radio" name="etoyaplus_footer_rss_links" <?php if ( $etoyaplus['footer_rss_links']=='no' ) echo 'checked="checked"'; ?> value="no" /></p>

</div>

<div class="wrap2"><h3><?php _e('Texts'); ?></h3>
<p><?php _e('Replacement for the &quot;Leave a Comment&quot;'); ?>: <input type="text" name="etoyaplus_txt_add_your_comment" size="30" value="<?php echo $etoyaplus['txt_add_your_comment']; ?>" />
</p>

<p><?php _e('Replacement for the &quot;Comments&quot;'); ?>: <input type="text" name="etoyaplus_txt_comments" size="30" value="<?php echo $etoyaplus['txt_comments']; ?>" /></p>

<p><?php _e('Replacement for the &quot;wrote&quot;'); ?>: <input type="text" name="etoyaplus_txt_commenter_wrote" size="30" value="<?php echo $etoyaplus['txt_commenter_wrote']; ?>" />&nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_txt_commenter_wrote').value='NO'"><?php _e('no'); ?></a></p>

<p><?php _e('Footer text'); ?>: <input type="text" name="etoyaplus_footer_txt" size="30" value="<?php echo $etoyaplus['footer_txt']; ?>" /> &nbsp; <a href="javascript:void(0);" onclick="javascript:document.getElementById('etoyaplus_footer_txt').value='NO'"><?php _e('no'); ?></a></p>

</div>

<div class="wrap2"><h3><?php _e('Commenting'); ?></h3>
<p><?php _e('Show gravatars'); ?>: 
&nbsp; <?php _e('left'); ?><input type="radio" name="etoyaplus_show_gravatars" <?php if ( $etoyaplus['show_gravatars']=='left' ) echo 'checked="checked"'; ?> value="left" /> &nbsp; <?php _e('right'); ?><input type="radio" name="etoyaplus_show_gravatars" <?php if ( $etoyaplus['show_gravatars']=='right' ) echo 'checked="checked"'; ?> value="right" /> &nbsp; <?php _e('no'); ?><input type="radio" name="etoyaplus_show_gravatars" <?php if ( $etoyaplus['show_gravatars']=='no' ) echo 'checked="checked"'; ?> value="no" /></p>
<p><?php _e('Comment date and time format'); ?> <input type="text" id="etoyaplus_comment_date_fmt"  name="etoyaplus_comment_date_fmt" size="20" value="<?php echo $etoyaplus['comment_date_fmt']; ?>" /> (<a href="http://codex.wordpress.org/Formatting_Date_and_Time"><?php _e('more info'); ?></a>)</p>
<p><?php _e('Comments popup'); ?>: 
&nbsp; <?php _e('yes'); ?><input type="radio" name="etoyaplus_comments_popup" <?php if ( $etoyaplus['comments_popup']=='yes' ) echo 'checked="checked"'; ?> value="yes" /> &nbsp; <?php _e('no'); ?><input type="radio" name="etoyaplus_comments_popup" <?php if ( $etoyaplus['comments_popup']=='no' ) echo 'checked="checked"'; ?> value="no" /></p>

</div>

<div class="wrap2"><h3><?php _e('Links Color'); ?></h3>
<p><?php _e('Default links color'); ?>: <?php etoyaplus_color_variants('link_color') ; ?> </p>

<p><?php _e('Underline links in posts?'); ?>

<?php _e('Yes'); ?> <input type="radio" name="etoyaplus_post_link_underline" <?php if ( $etoyaplus['post_link_underline']=='underline' ) echo 'checked="checked"'; ?> value="underline" /> &nbsp; <?php _e('No'); ?> <input type="radio" name="etoyaplus_post_link_underline" <?php if ( $etoyaplus['post_link_underline']=='none' ) echo 'checked="checked"'; ?> value="none" />
&nbsp; &nbsp; &nbsp;
<?php _e('Link color in posts'); ?>: <?php etoyaplus_color_variants('post_link_color') ; ?> </p>

<p><?php _e('Links color in a sidebar'); ?>: <?php etoyaplus_color_variants('sidebar_link_color') ; ?> </p>

</div>

<input type="hidden" value="no" id="delete_eto_ya_plus_settings" name="delete_eto_ya_plus_settings" />
<p><small><?php _e('If you like to name this set of theme options, write the name here'); ?>:
<input type="text" name="etoyaplus_setting_name" value="<?php echo $etoyaplus['setting_name'] ; ?>" /></small>
</p>
<p><input type="submit" class="submit_button" value="<?php _e('Apply Settings'); ?>" /> &nbsp; &nbsp; &nbsp; &nbsp;

<input type="button" onclick="javascript:really_reset()" class="submit_button" value="<?php _e('Reset All Theme Settings'); ?>" />
</p>
</form>

<p><?php _e('You may save (export) theme settings into the text file in your computer, and import them from this file in future.'); ?> <a href="themes.php?page=functions.php&amp;eypact=export&amp;noheader=1"><?php _e('Click here to export options'); ?></a>.<br /><small><?php _e('You can create you own collection of settings for this theme.'); ?></small></p>

<p><?php _e('The following image files are included in this theme'); ?>:<br /><small>
<?

$dir=opendir( dirname(__FILE__).'/images/fon' );

while ( $file= readdir($dir) )
{
	if ( $file!='.' && $file!='..')
	{	
		$file2= get_stylesheet_directory_uri().'/images/fon/'.$file;
		echo '<a href="'.$file2.'">', $file, '</a> &nbsp; &nbsp; ';

	}
};

?>
</small></p>

</div>
<?
}


function etoyaplus_admin_header()
{
?>
<style type="text/css" title="">
.wrap2 {background: #fff; border: 1px solid #ccc; clear: both; margin: 15px 0; padding: 1em;}
.wrap2 h3 {margin:0}
.submit_button {font-weight:bold; border:3px double #ccc;}
input.color_select {background-color:inherit; line-height:3px;}
.sample_color {width:220px; height:20px; float:left; margin-bottom:2px}
.piker {border:solid 1px #ccc; padding:1px;width:400px; margin-top:2px; display:none;}
.piker a {float:right; width:50px}
.piker table {border-collapse:collapse; clear:both}
.piker table td {height:15px; width:10px; border:solid 1px #fff;}
h2 span {font-size:12px; font-weight:normal; font-style:normal}
</style>

<script language="javascript" type="text/javascript">
// <![CDATA[

function pokaz_piker(input_id)
{
	document.getElementById('colors_'+input_id).style.display='block';
}

function skryt_piker(input_id)
{
	document.getElementById('colors_'+input_id).style.display='none';
}

function color_table(input_id)
{
var colcode= Array('00','33','66','99','CC','FF');
var i,j,k,n;
n=0;

var str ='<!-- <div class="sample_color" id="sample_color_'+input_id+'"> </div> --><table>';

for (i=0;i<6;i++ )
for (j=0;j<6;j++ )
for (k=0;k<6;k++ )
{
	zvet= '#'+colcode[k]+colcode[j]+colcode[i];
	if (n%36==0) str += '<tr>';
	 str += '<td style="background:'+zvet+'" '+' onclick="javascript:vc(\''+zvet+'\', \''+input_id+'\')"></td>';
	if (n%36==35)  str += '</tr>';
	n++;
}
str +='</table>';
document.getElementById('colors_'+input_id).innerHTML= str;
pokaz_piker(input_id);
}

function vc(zvet, input_id)
{
document.getElementById(input_id).value= zvet;
document.getElementById(input_id).style.backgroundColor= zvet;

if ( zvet.substring(1,2)<'66' &&  zvet.substring(3,2)<'66' &&  zvet.substring(5,2)<'66')
	document.getElementById(input_id).style.color= '#FFFFFF';
else
	document.getElementById(input_id).style.color= '#000000';

}

function really_reset()
{
if (confirm('<?php _e('Are you really going to reset all settings?\nDefault settings being applied.'); ?>') )
{
	document.getElementById('delete_eto_ya_plus_settings').value='yes';
	document.getElementById('nastrojki_eto_ya_plus').submit();
}
}

// ]]>
</script>
<?
}

if ( strpos($_SERVER['REQUEST_URI'], 'themes.php?page=function') ) {
	add_action('admin_head', 'etoyaplus_admin_header');
}

add_action('admin_menu', 'etoyaplus_add_admin');

?>