// JavaScript Document
var ActiveMenu = "";

function showItems(value) { //value 'A', 'B', 'C'
	//$('#content').hide('fast');
	for (var i=0;i<$('#profilfa_content').find('.imgholder').length;i++){
		$('#profilfa_content').find('.imgholder').show('fast');
	}
	$('#profilfa_content').find('.profilfa_content>a').click(
		function() {
			//adatok betöltése a profilfa_content div-be
			//$('#profilfa_content').find('.imgholder>a>img').hide('fast');
						
		}
	);
}

function getMainContent(value) {
	if (value != '') {
		$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
		$.get(value, function(data) {
			pageTracker._trackPageview(value);
			$('#profilfa_content_main').html(data);
			setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true);",200);
		});
	}
}

function setAlmenu(value) { //value = false; document ready-ben a bal oldali menut aktiválja
/*TODO: unbind*/
	if (value) {
		$('#elemek').find('.item_1_szoveg').bind('click', 
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
		$('#elemek').find('.item_2_szoveg').bind('click', 
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
		$('#elemek').find('.item_1_1_szoveg').bind('click',
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									//setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
									setTimeout("$('#termek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true);",200);
								}
							);
						});
					}
				);
			}
		);
		$('#back').bind('click',
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
		$('#back2').bind('click',
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
									//setTimeout("$('#termek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
		$('#profilfa_content_main .termek_prev').bind('click',
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#termek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
		$('#profilfa_content_main .termek_next').bind('click',
			function() {
				var element = $(this).attr('refhtml');
				//pageTracker._trackPageview(element);
				$('#profilfa_content_main').fadeOut('slow',
					function() {
						$('#profilfa_content_main').show();
						$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
						$.get(element, function(data) {
							$('#profilfa_content_main').hide('fast', function() {$('#profilfa_content_main').html(data);});
							$('#profilfa_content_main').fadeIn('slow',
								function() {
									setTimeout("$('#termek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
								}
							);
						});
					}
				);
			}
		);
	} else {
		$('#navcontainer').find('.submenu').find('a').bind('click',
			function() {
				$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
				$.get($(this).attr('refhtml'), function(data) {
					$('#profilfa_content_main').html(data);
					setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
				});
			}
		);
	}
}


$(document).ready(
	function() {
		setAlmenu(false);
		
		$('#fooldal').hover(
			function() {
				$(this).attr('src','../img/felso_menu_aktiv_03.jpg');
			},
			function() {
				$(this).attr('src','../img/felso_menu_03.jpg');
			}
		);

		$('#elerhetosegeink').hover(
			function() {
				$(this).attr('src','../img/felso_menu_aktiv_04.jpg');
			},
			function() {
				$(this).attr('src','../img/felso_menu_04.jpg');
			}
		);

		$('#maintext').jqm({ajax: '../elerhetosegeink.html', trigger: '#elerhetosegeink'});

		$('#fooldal').bind('click',
			function() {
				window.location.href = $(this).attr('refhtml');
			}
		);

		$('#vissza').bind('click', 
			function() {
				$('#'+ActiveMenu).parent().find('ul').BlindUp('slow');
				$('#profilfa_menu_left_upper').BlindDown('slow');
				$('#'+ActiveMenu).css('color', '#9d0804');
				$('#vissza').BlindUp('slow', 
					function() {
						$('#separator').toggle();
					});
				ActiveMenu = '';
			}
		);
		
		$('#left_menu1').bind('click', 
			function() {
				if ((ActiveMenu != '')&&(ActiveMenu!='left_menu1') ){
					$('#'+ActiveMenu).parent().find('ul').BlindUp('slow');
				}
				if (ActiveMenu != 'left_menu1') {
					$('#profilfa_menu_left_upper').BlindUp('slow');
					$('#separator').toggle();
				}
				$('#left_menu1').parent().find('ul').BlindDown('slow');
				$('#'+ActiveMenu).css('color', '#9d0804');
				ActiveMenu = 'left_menu1';
				$('#'+ActiveMenu).css('color', '#c9b885');
				$('#left_menu1').css('marginTop', '10px');
				if ($('#left_menu1').css('display') == 'block') {
					$('#vissza').show();
					$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
					$.get('A1/oldalA1.html',function(data) {
						$('#profilfa_content_main').html(data);
						setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
						if ($('#profilfa_content').css('display') == 'none') {
							$('#profilfa_content').slideOut('fast');
						}
					});
				}
			});
		$('#left_menu2').bind('click', 
			function() {
				if ((ActiveMenu != '')&&(ActiveMenu!='left_menu2') ){
					$('#'+ActiveMenu).parent().find('ul').BlindUp('slow');
				}
				if ((ActiveMenu == 'left_menu1') || ((ActiveMenu == '') && ($('#profilfa_menu_left_upper').css('display') == 'none'))) {
					$('#profilfa_menu_left_upper').BlindDown('slow');
					$('#separator').toggle();
					$('#left_menu1').css('marginTop', 'auto');
				}
				$('#left_menu2').parent().find('ul').BlindDown('slow');
				$('#'+ActiveMenu).css('color', '#9d0804');
				ActiveMenu = 'left_menu2';
				$('#'+ActiveMenu).css('color', '#c9b885');
				if ($('#left_menu2').css('display') == 'block') {
					$('#vissza').hide();
					$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
					$.get('A2/oldalA2.html',function(data) {
						$('#profilfa_content_main').html(data);
						setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
						if ($('#profilfa_content').css('display') == 'none')
							$('#profilfa_content').slideOut('fast');
					});
				}
			});
		$('#left_menu3').bind('click', 
			function() {
				if ((ActiveMenu != '')&&(ActiveMenu!='left_menu3') ){
					$('#'+ActiveMenu).parent().find('ul').BlindUp('slow');
				}
				if ((ActiveMenu == 'left_menu1') || ((ActiveMenu == '') && ($('#profilfa_menu_left_upper').css('display') == 'none'))) {
					$('#profilfa_menu_left_upper').BlindDown('slow');
					$('#separator').toggle();
					//alert($('#left_menu1').css('marginTop'));
					$('#left_menu1').css('marginTop', 'auto');
				}
				$('#left_menu3').parent().find('ul').BlindDown('slow');
				$('#'+ActiveMenu).css('color', '#9d0804');
				ActiveMenu = 'left_menu3';
				$('#'+ActiveMenu).css('color', '#c9b885');
				if ($('#left_menu3').css('display') == 'block') {
					$('#vissza').hide();
					$('#profilfa_content_main').html('<img class="ajaxloader" src="../img/ajax_loader.gif" />');
					$.get('A3/oldalA3.html',function(data) {
						$('#profilfa_content_main').html(data);
						setTimeout("$('#elemek').jScrollPane({scrollbarWidth:8, scrollbarMargin:0});setAlmenu(true)",200);
						if ($('#profilfa_content').css('display') == 'none')
							$('#profilfa_content').slideOut('fast');
					});
				}
			});
		getMainContent('../cegtortenet.html');
	}
);

