{include file="$gentemplates/$header_tpl"}

<div class="organizer">
	<h2>{$lang.organizer.homepage_management}</h2>

	{*if $form.err}
		<p class="error_msg">*&nbsp;{$form.err}</p>
	{/if*}

	<!-- main tabs -->	
	<div class="main_tabs">
		<div class="tab_block first {if $type eq 'layout'}active{/if}">
			<a href="{$seo_site_root}/organizer.php?sel=homepage_management&type=layout">{$lang.organizer.my_page_layout}</a>
		</div>
		<div class="tab_block {if $type eq 'page_styles'}active{/if}">
			<a href="{$seo_site_root}/organizer.php?sel=homepage_management&type=page_styles">{$lang.organizer.my_page_styles}</a>
		</div>
                <div class="tab_block {if $type eq 'change_styles'}active{/if}">
			<a href="{$seo_site_root}/organizer.php?sel=homepage_management&type=change_styles">{$lang.organizer.my_change_styles}</a>
		</div>
	</div>
	<!-- end main tabs -->		

	{if $type eq 'layout'}
		<div>
			<div id="home_div" class="{if !$carousel_vertical_dir}home_div_gorizont{else}home_div_vertic{/if}" style="width: 725px;">
				{include file="$gentemplates/organizer_home_small.tpl"}
			</div>	
		</div>	

	{elseif $type eq 'page_styles'}	
		<form action="{$seo_site_root}/organizer.php" method="POST" style="margin: 0px;" enctype="multipart/form-data">
			<input type="hidden" name="sel" value="save_home_colors">
			{foreach item=item from=$colors key=color}
				{if $color ne 'bg_picture' && $color ne 'bg_color' && $color ne 'bg_picture_path'}
					<div style="overflow:hidden; margin: 5px 0;">
						<div class="float_left" style="width: 400px;">
							{$lang.organizer[$color]}:
						</div>
						<div class="float_left">
							<input type="hidden" name="{$color}" id="{$color}_text" value="{$colors[$color]}" size="6">&nbsp;
						</div>
						<div id="{$color}_color" class="color_selector" onclick="pickColorPicker('{$color}', '{$colors[$color]}')">
							<div style="background-color: #{$colors[$color]};"></div>
						</div>
						{if $help[$color]}
						<div class="float_left color_help">
							<span onmouseover="ShowHelpDiv('help_{$color}');" onmouseout="HideHelpDiv('help_{$color}');">&nbsp;<b>?</b>&nbsp;</span>
						</div>	
						<div id="help_{$color}" style="display: none; position: absolute;">&nbsp;<img src="{$help[$color]}"></div>
						{/if}
					</div>
				{/if}
			{/foreach}
			<div>
				{$lang.organizer.big_bg}:
			</div>
			<div style="overflow:hidden; margin: 5px 0;">
				<div class="float_left">
					<input type="radio" name="bg_type" value="color" id="type_color" {if $colors.bg_picture_path eq ''}checked{/if}>&nbsp;
					<label for="type_color">{$lang.organizer.big_bg_color}</label>&nbsp;&nbsp;&nbsp;
					<input type="text" name="data[big_bg_color]" id='tdcolor_big_bg_text' value="{$colors.bg_color}" size="25">
				</div>
				<div id="tdcolor_big_bg_color" class="color_selector" onclick="pickColorPicker('tdcolor_big_bg', '{$colors.bg_color}')">
					<div style="background-color: #{$colors.bg_color};"></div>
				</div>
			</div>
			<div style="overflow:hidden; margin: 5px 0;">
				<div class="float_left">
                    <input type="radio" name="bg_type" value="image" id="type_image" {if $colors.bg_picture_path ne ''}checked{/if}>&nbsp;
    				<label for="type_image">{$lang.organizer.big_bg_image}</label>&nbsp;
    				<input type="file" name="bg_picture_path">&nbsp;
    				{if $colors.bg_picture_path ne ''}<a href="{$colors.bg_picture_path}" target="_blank">{$lang.button.view}</a>{/if}
                </div>
                <div class="float_left color_help">
				    <span onmouseover="ShowHelpDiv('help_{$color}');" onmouseout="HideHelpDiv('help_{$color}');">&nbsp;<b>?</b>&nbsp;</span>
				</div>	
				<div id="help_{$color}" style="display: none; position: absolute;">&nbsp;{$help.bg_picture}</div>
			</div>
			<p>
				<input type="submit" value="{$lang.button.save}">&nbsp;&nbsp;&nbsp;
				<input type="button" value="{$lang.button.restore}" onclick="document.location.href='{$seo_site_root}/organizer.php?sel=restore_home_colors&type=page_styles'">
			</p>
			</form>
               {elseif $type eq 'change_styles'}
                   <script>                       
                   {literal}

						function toggleDiv(divId) {
							$("#"+divId).toggle();
						}
						
						$(document).ready(function(){
							$(".my_theme_sq").click(function(){
								var my_bg_image = '{/literal}{$seo_site_root}{literal}/uploades/bg/Backgrounds_DP_1920x1200-'+this.id+'.jpg';
								var id_img=this.id;
								$('html').css('background-image', 'url('+my_bg_image+')');
								$(".my_theme_sq").css('border','1px solid black');
								$(this).css('border','1px solid red');
								$("#myid_img").val(id_img);
									
								$.ajax({
									type: "POST",
									url: "organizer.php",
									data: "sel=save_home_colors&ajax=1&bg_img="+this.id,
									success: function(theme_color){
										//var theme_color = $.parseJSON(msg);

										$("#bg_content_color_color").css('background-color', '#'+theme_color.bg_content_color);     
										$("#bg_content_color_text").val(theme_color.bg_content_color);
											
										$("#main_text_color_color").css('background-color', '#'+theme_color.main_text_color);     
										$("#main_text_color_text").val(theme_color.main_text_color);
											
										$("#home_menu_color").css('background-color', '#'+theme_color.home_menu);     
										$("#home_menu_text").val(theme_color.home_menu);
											
										$("#link_color").css('background-color', '#'+theme_color.link);     
										$("#link_text").val(theme_color.link);
										 
										$("#tabs_block_border_color").css('background-color', '#'+theme_color.tabs_block_border);     
										$("#tabs_block_border_text").val(theme_color.tabs_block_border);  
									},
									dataType: 'json'
								});                          
							});
							$("#tile_bg").click(function(){
							   var thisCheck = $(this);
							   if (thisCheck.is(':checked')){
									$('html').css('background-repeat','repeat');
									$('html').css('background-attachment','scroll');
								}
								else{
									$('html').css('background-repeat','no-repeat');
									$('html').css('background-attachment','fixed');
								}    
							});
						})
                   {/literal}
                   </script>
                   <form action="{$seo_site_root}/organizer.php" method="POST" style="margin: 0px;" enctype="multipart/form-data">
                   <h3>{$lang.organizer.my_change_styles}</h3>
                          
                   {section name = mySection start = 0 loop = 10 step = 1}              
                        <div {if $colors.mybg_img == $smarty.section.mySection.index}style="border:1px solid red;"{/if} id="{$smarty.section.mySection.index}" class="my_theme_sq  my_theme_cust{$smarty.section.mySection.index}">
                        </div>
                   {/section}
                   <div style="float:left;">
                   <input type="button" value="{$lang.organizer.change_bg_image}" onclick="toggleDiv('change_bg_image');$('#change_design').css('display', 'none');">
                   <input type="button" value="{$lang.organizer.change_design}" onclick="toggleDiv('change_design');$('#change_bg_image').css('display', 'none');">
                   </div>
                   <br><br>
                   <div id="change_bg_image" style="display:none;float:left;padding-right:20px;">
                       
                            <input type="hidden" name="sel" value="save_home_colors">
                            <div style="padding-top: 30px;">                          
                            <input type="checkbox" name="bg_type" value="image" id="type_image" >&nbsp;
                            {$lang.organizer.big_bg_image}
                            <input type="file" name="bg_picture_path" onchange="$('#my_bg_image').css('border','double 4px black');$('#my_bg_image').css('background','#E6E1E1');$('#my_bg_image').text('')">&nbsp;
                            <br><br>
                            {$lang.organizer.img_text}
                            <br><br>
                            <div id="my_bg_image" class="my_bg_image">
                            {$lang.organizer.no_bg_img}

                            </div> 
                            <label><input name="tile_bg" id="tile_bg" type="checkbox" {if $colors.bg_tile eq '1'}checked{/if}> {$lang.organizer.tile_bg}</label>
                            <div style="width:50px;padding-top:40px;"><input type="submit" value="{$lang.button.save}"></div>
                       
                       </div>
                   </div>
                   <div id="change_design" style="float:left;display:none;">
                       <input type="hidden" value="my" name="sel1">
                       <div style="padding-top: 30px;">
						   
                      {*comment for save_theme_color*}
					  
                      <div class="div_head">{$lang.organizer.background}<div id="bg_content_color_color" style="background-color:#{$colors.bg_content_color};" class="my_change" onclick="pickColorPicker('bg_content_color', '#{$colors.bg_content_color}','my')">
                      <input id="bg_content_color_text" type="hidden" size="6" value="{$colors.bg_content_color}" name="bg_content_color">
                      
                      </div></div> 
                      
                       <div class="div_head">{$lang.organizer.main_texts}<div id="main_text_color_color" style="background-color:#{$colors.main_text_color};" class="my_change" onclick="pickColorPicker('main_text_color', '#{$colors.main_text_color}','my')">
                        <input id="main_text_color_text" type="hidden" size="6" value="{$colors.main_text_color}" name="main_text_color">
                       </div ></div>
                       
                       <div class="div_head">{$lang.organizer.headlines}<div id="home_menu_color" style="background-color:#{$colors.home_menu};" class="my_change" onclick="pickColorPicker('home_menu', '#{$colors.home_menu}','my')">
                      <input id="home_menu_text" type="hidden" size="6" value="{$colors.home_menu}" name="home_menu">
                       </div></div>
                       
                       <div class="div_head">{$lang.organizer.links}<div id="link_color" style="background-color:#{$colors.link};" class="my_change" onclick="pickColorPicker('link', '#{$colors.link}','my')">
                        <input id="link_text" type="hidden" size="6" value="{$colors.link}" name="link">       
                       </div></div>
                       
                       <div class="div_head">{$lang.organizer.active_tabs}<div id="tabs_block_border_color" style="background-color:#{$colors.tabs_block_border};" class="my_change" onclick="pickColorPicker('tabs_block_border', '#{$colors.tabs_block_border}','my')">
                      <input id="tabs_block_border_text" type="hidden" size="6" value="{$colors.tabs_block_border}" name="tabs_block_border">
                       </div></div><div></div>
					   
					   {*/comment for save_theme_color*}
					   
                       {foreach item=item from=$colors key=color}
                        {if $color ne 'bg_picture_path' && $color ne 'bg_picture'&& $color ne 'link' && $color ne 'main_text_color' && $color ne 'tabs_block_border' && $color ne 'bg_content_color' && $color ne 'home_menu'}    
                            <input type="hidden" name="{$color}" id="{$color}_text" value="{$colors[$color]}" size="6">&nbsp;
                        {/if}
                      {/foreach}
                      <div>
                     <div style="width:50px;padding-top:60px;padding-left:9px;"><input type="submit" value="{$lang.button.save}"></div>
                     </form>
					 
					 {*save_color_theme
					 					 
					 <form enctype="multipart/form-data" style="margin: 0px;" method="POST" action="/organizer.php">
					  <input type="hidden" id="myid_img" value="" name="myid_img">
					  
                      <input type="hidden" value="save_color_theme" name="sel">                      
                       <div style="padding-top: 30px;">
                      <div class="div_head">{$lang.organizer.background}<div id="bg_content_color_color" style="background-color:#{$colors.bg_content_color};" class="my_change" onclick="pickColorPicker('bg_content_color', '#{$colors.bg_content_color}','my')">
                      <input id="bg_content_color_text" type="hidden" size="6" value="{$colors.bg_content_color}" name="bg_content_color">
                      
                      </div></div> 
                      
                       <div class="div_head">{$lang.organizer.main_texts}<div id="main_text_color_color" style="background-color:#{$colors.main_text_color};" class="my_change" onclick="pickColorPicker('main_text_color', '#{$colors.main_text_color}','my')">
                        <input id="main_text_color_text" type="hidden" size="6" value="{$colors.main_text_color}" name="main_text_color">
                       </div ></div>
                       
                       <div class="div_head">{$lang.organizer.headlines}<div id="home_menu_color" style="background-color:#{$colors.home_menu};" class="my_change" onclick="pickColorPicker('home_menu', '#{$colors.home_menu}','my')">
                      <input id="home_menu_text" type="hidden" size="6" value="{$colors.home_menu}" name="home_menu">
                       </div></div>
                       
                       <div class="div_head">{$lang.organizer.links}<div id="link_color" style="background-color:#{$colors.link};" class="my_change" onclick="pickColorPicker('link', '#{$colors.link}','my')">
                        <input id="link_text" type="hidden" size="6" value="{$colors.link}" name="link">       
                       </div></div>
                       
                       <div class="div_head">{$lang.organizer.active_tabs}<div id="tabs_block_border_color" style="background-color:#{$colors.tabs_block_border};" class="my_change" onclick="pickColorPicker('tabs_block_border', '#{$colors.tabs_block_border}','my')">
                      <input id="tabs_block_border_text" type="hidden" size="6" value="{$colors.tabs_block_border}" name="tabs_block_border">
                       </div></div><div></div>
					   
					   <input type="submit" value="SaveColorTheme">
					   </form>
		 
					 /save_color_theme*}
					 
                    </div>
	{/if}

	{if $banner.right}
	<div style="float: left;">
	{$banner.right}
	</div>
	{/if}	  
</div>

{if $type eq 'layout'}
{literal}
<script type="text/javascript">
function HighLight(section, state) {
	if (document.getElementById('section_'+section)) {
		if (state == 1) {
			setElementOpacity('section_'+section, 0.4);
		} else {
			setElementOpacity('section_'+section, 1.0);
		}
	}
	return;
}

function setElementOpacity(sElemId, nOpacity)
{

  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);

  if (!elem || !opacityProp) return; // error

  if (opacityProp=="filter")  // Internet Explorer 5.5+
  {
    nOpacity *= 100;

    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
  }
  else
    elem.style[opacityProp] = nOpacity;
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') {
    return 'opacity';
  } else if (typeof document.body.style.MozOpacity == 'string') {
    return 'MozOpacity';
  } else if (typeof document.body.style.KhtmlOpacity == 'string') {
    return 'KhtmlOpacity';
  } else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) {
    return 'filter'
  } else {
  	return false;
  }
}

var req = null;

function InitXMLHttpRequest() {
	// Make a new XMLHttp object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
}
</script>
{/literal}
{elseif $type eq 'page_styles' || $type eq 'change_styles'}
{literal}
<script type="text/javascript">
function pickColorPicker(id, color, param){
        param = param || '';
	$('#'+id+'_color').ColorPicker({
		color: color,
		onShow: function (cp) {
			$(cp).fadeIn(300);
			return false;
		},
		onHide: function (cp) {
			$(cp).fadeOut(300);
			return false;
		},
		onSubmit: function(hsb, hex, rgb, el) {
                    if(param == 'my')
                        $('#'+id+'_color').css('backgroundColor', '#'+hex);
                    else      
			$('#'+id+'_color div').css('backgroundColor', '#'+hex);
			$('#'+id+'_text').val(hex);
			$(el).val(hex);
			$(el).ColorPickerHide();
		}
	});
	$('#'+id+'_color').ColorPickerShow();
}
function ShowHelpDiv(div_id) {
	document.getElementById(div_id).style.display = 'inline';
	return;
}
function HideHelpDiv(div_id) {
	document.getElementById(div_id).style.display = 'none';
	return;
}

</script>
{/literal}
{/if}
{include file="$gentemplates/$footer_tpl"}