function top_menu_toggle( mode ){
	if( mode == 'min' ){
		$( ELEMENTS[ 'top_menu_max' ] ).hide();
		$( ELEMENTS[ 'top_menu_min' ] ).show();
	}else{
		$( ELEMENTS[ 'top_menu_max' ] ).show();
		$( ELEMENTS[ 'top_menu_min' ] ).hide();
	}
	set_cookie( 'menu_mode', mode, 1000 );
}

function top_menu_min_click( step ){
	head_item = $( '#top_menu_min_head_'+ step );
	body_item = $( '#top_menu_min_body_'+ step );
	$( '.head_a' ).removeClass().addClass( 'head' );
	$( '[id^=top_menu_min_body][id!=top_menu_min_body_'+ step +']' ).fadeOut( 500 );
	if( $( body_item ).css( 'display' ) == 'none' ){
		$( head_item ).removeClass().addClass( 'head_a' );
		$( body_item ).css( 'display', 'block' );
	}else{
		$( head_item ).removeClass().addClass( 'head' );
		$( body_item ).fadeOut( 500 );
	}
}


function pd_main_build_bookmark( obj_id, type ){
	inner_html = '';
	tmp_arr = BOOKMARKS[ 'main' ][ type ];
	for( z = 0; z < tmp_arr[ 'list' ].length; z++ ){
		bookmark_ttl = tmp_arr[ 'list' ][ z ];
		bookmark_src = tmp_arr[ 'src' ][ z ];
		if( bookmark_ttl == tmp_arr[ 'sel' ] ){
			inner_html += '<img src="'+ SITE_URL +'/img/pd_main_bookmark_'+ type +'_'+ bookmark_ttl +'_a.gif" border="0" />';
		}else{
			href_str = build_href_url_js( SITE_URL +'/'+ bookmark_src, 'pd_main_bookmark_sel( \''+ type +'\', \''+ z +'\' );pd_main_build_bookmark( \''+ obj_id +'\', \''+ type +'\' );' );
			inner_html += '<a href="'+ href_str +'"><img src="'+ SITE_URL +'/img/pd_main_bookmark_'+ type +'_'+ bookmark_ttl +'_p.gif" border="0" onmouseover="pd_main_bookmark_over( this, \''+ SITE_URL +'/img/pd_main_bookmark_'+ type +'_'+ bookmark_ttl +'_o.gif\' );" onmouseout="pd_main_bookmark_out( this );" /></a>';
		}
	}
	$( '#'+ obj_id ).html( inner_html );
}

function pd_main_bookmark_over( obj_item, btn_image ){
	$( obj_item ).attr( 'osrc', $( obj_item ).attr( 'src' ) ).attr( 'src', btn_image );
}

function pd_main_bookmark_out( obj_item ){
	$( obj_item ).attr( 'src', $( obj_item ).attr( 'osrc' ) );
}

function pd_main_bookmark_sel( type, sel_id ){
	closed_body = '#el_pd_main_'+ type +'_'+ BOOKMARKS[ 'main' ][ type ][ 'sel' ];
	BOOKMARKS[ 'main' ][ type ][ 'sel' ] = BOOKMARKS[ 'main' ][ type ][ 'list' ][ sel_id ];
	opened_body = $( '#el_pd_main_'+ type +'_'+ BOOKMARKS[ 'main' ][ type ][ 'list' ][ sel_id ] );
	opened_src = BOOKMARKS[ 'main' ][ type ][ 'src' ][ sel_id ];
	$( closed_body ).fadeOut( 100, 
		function(){ 
			$( opened_body ).fadeIn( 100,
				function(){
					if( $( opened_body ).html().length < 5 ){
						$( opened_body ).html( '<div class="body_out" id="el_pd_main_'+ type +'_'+ BOOKMARKS[ 'main' ][ type ][ 'list' ][ sel_id ] +'_body"><div class="body_in"><div class="loader"></div></div></div>' );
						$.ajax({	
							type: 'GET',
							url:	SITE_URL +'/'+ opened_src,
							success: function( data ){
								result = data.substr( 0, 1 ); 
								inner_html = data.substr( 1 );
								if( result == 1 ){
									$( opened_body ).html( inner_html );
								}else{
									$( opened_body ).html( '<div class="body_out" id="el_pd_main_'+ type +'_'+ BOOKMARKS[ 'main' ][ type ][ 'list' ][ sel_id ] +'_body"><div class="body_in"><br/><br/><br/><center>Извините, при попытке загрузить информацию, возникла ошибка.<br/>Повторите попытку позже</center><br/><br/><br/></div></div>' );
								}
							},
							error: function( XMLHttpRequest, textStatus ){
								$( opened_body ).html( '<div class="body_out" id="el_pd_main_'+ type +'_'+ BOOKMARKS[ 'main' ][ type ][ 'list' ][ sel_id ] +'_body"><div class="body_in"><br/><br/><br/><center>Извините, при попытке загрузить информацию, возникла ошибка.<br/>Повторите попытку позже</center><br/><br/><br/></div></div>' );
							}
						});
					}
				}
			); 
		}
	);
}


function pd_sub_tgl( part ){
	obj_item = $( '#el_pd_sub_'+ part );
	if( $( obj_item ).css( 'display' ) == 'none' ){
		$( '#el_pd_sub_'+ part +'_headX' ).hide( 300, function(){
			$( obj_item ).show( 500 );
		});		
		set_cookie( 'pd_sub_'+ part, 0, 1000 );
	}else{
		set_cookie( 'pd_sub_'+ part, 1, 1000 );
		obj_item_tmp = document.getElementById( 'el_pd_sub_'+ part +'_headX' );
		if( !obj_item_tmp ){
			inner_html = '<div id="el_pd_sub_'+ part +'_headX" class="headX" style="display:none;" onclick="pd_sub_tgl(\''+ part +'\');"><img src="'+ SITE_URL +'/img/pd_sub_head_arrow_dn.gif" width=20 height=30 class=tgl /><img src="'+ SITE_URL +'/img/pd_sub_head_'+ part +'.gif" class="head" /></div>';
			$( obj_item ).hide( 300, function(){
				$( obj_item ).after( inner_html );
				obj_item_tmp = document.getElementById( 'el_pd_sub_'+ part +'_headX' );
				$( obj_item_tmp ).show( 500 ).css( { 'FILTER' : 'alpha(opacity=60)', '-moz-opacity' : '0.6', 'opacity' : '0.6' } );
				pd_sub_hover( obj_item_tmp );
			} );
		}else{
			$( obj_item ).hide( 300, function(){
				$( obj_item_tmp ).show( 500 ).css( { 'FILTER' : 'alpha(opacity=60)', '-moz-opacity' : '0.6', 'opacity' : '0.6' } );
			} );
		}
	}
}

function pd_sub_hover( obj_item ){
	$( obj_item ).hover(
		function(){
			$( this ).css( { 'FILTER' : 'alpha(opacity=100)', '-moz-opacity' : '1', 'opacity' : '1' } );
		},
		function(){
			$( this ).css( { 'FILTER' : 'alpha(opacity=60)', '-moz-opacity' : '0.6', 'opacity' : '0.6' } );
		}
	);
}

