/**
 * Breadnav ausklappen
 * 
 * @author Holger Szüsz
 */
var breadIsMoving = false;

if ($.browser.name == 'msie' && $.browser.versionNumber == '6') {
	$('#breadnav').css({
		'filter' : 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src="/fileadmin/templates/img/shared//breadCrump_zu.png"',
		'background' : 'none'
	});
}

var BreadNav = {
	strTitleLastOpen: '',
	strTitleLastArrow: '',
	
	switchTo: function(strTitle, strTitleLiItem) {
		if(strTitleLiItem != this.strTitleLastArrow) {
			this.switchActiveArrow(strTitleLiItem);
		}
		
		if (strTitle != this.strTitleLastOpen) {
			var itemList = $('div[title="' + strTitle + '"]>div.scrollable>div.items').html();
			
			if ($('div[title="main"]').css('display') == 'none') {
				$('div[title="main"]>div.scrollable>div.items').html(itemList);
				
				BreadScroll.resetMargin('div[title="main"]');
				
				if (FlashResizer.headerType == 'headonly') {
					this.toggleBreadCrump();
				} else {
					this.toggleBreadCrumpWithFlash();
				}
				
				BreadScroll.checkScrolling('div[title="main"]');
				
				this.strTitleLastOpen = strTitle;
			} else {
				$('div[title="main"]>div.back').fadeOut(500);
				$('div[title="main"]>div.go').fadeOut(500);
				$('div[title="main"]>div.scrollable>div.items').fadeOut(500, function(){
					$('div[title="main"]>div.scrollable>div.items').html(itemList);
					
					BreadScroll.resetMargin('div[title="main"]');
					
					$('div[title="main"]>div.scrollable>div.items').fadeIn(500);
		
					BreadScroll.checkScrolling('div[title="main"]');
				});
				
				this.strTitleLastOpen = strTitle;
			}
		} else {
			if (FlashResizer.headerType == 'headonly') {
				this.toggleBreadCrump();
			} else {
				this.toggleBreadCrumpWithFlash();
			}
		}

	},
	
	switchActiveArrow: function(strTitleLiItem) {
		if(strTitleLiItem == 'current') {
			$('div#breadnav>ul>li[title="'+this.strTitleLastArrow+'"]').removeAttr('class');
			$('div#breadnav>ul>li:last').attr('class','active');
			this.strTitleLastArrow = $('div#breadnav>ul>li:last').attr('title');
			return;
		}
		
		$('div#breadnav>ul>li[title="'+this.strTitleLastArrow+'"]').removeAttr('class');
		$('div#breadnav>ul>li[title="'+strTitleLiItem+'"]').attr('class','active2');
		this.strTitleLastArrow = strTitleLiItem;
	},
	
	toggleBreadCrumpWithFlash: function() {
		if($('div[title="main"]').css('display') == 'none') {
			$('div#breadnav').css('background', 'none');
		} else {
			if ($.browser.name == 'msie' && $.browser.versionNumber == '6') {
				$('div#breadnav').css('background', 'url(fileadmin/templates/img/shared/breadCrump_zu.gif) left bottom no-repeat');
			} else {
				$('div#breadnav').css('background', 'url(fileadmin/templates/img/shared/breadCrump_zu.png) left bottom no-repeat');
			}
			this.switchActiveArrow('current');
		}
		
		if ($('#main').css('top') == '62px') {
//			$('div[title="main"]').toggle('slide', { direction: 'up' }, 1000);
			$('div[title="main"]').toggle();
			if (FlashResizer.wmodetransparent == 0 && FlashResizer.scaleFlash == 1) {
				$('#teaserflash').height($(window).height() - 283);
				if ($.browser.name != 'msie') {
					breadIsMoving = true;
					$('#main').animate({top: "190px"}, 0, function(){
						breadIsMoving = false;
						callExternalInterface(158);
						default_pos_main_offset = 128;
						resizeMainDiv();
					});
				} else {
					$('#main').css('top','190px');
					callExternalInterface(158);
					default_pos_main_offset = 128;
					resizeMainDiv();
				}
			}
		} else {
//			$('div[title="main"]').toggle('slide', { direction: 'up' }, 1000);
			$('div[title="main"]').toggle();
			if (FlashResizer.wmodetransparent == 0 && FlashResizer.scaleFlash == 1) {
				$('#teaserflash').height($(window).height() - 133);
				if ($.browser.name != 'msie') {
					breadIsMoving = true;
					$('#main').animate({top: "62px"}, 0, function(){
						breadIsMoving = false;
						callExternalInterface(0);
						default_pos_main_offset = 0;
						resizeMainDiv();
					});
				} else {
					$('#main').css('top','62px');
					callExternalInterface(0);
					default_pos_main_offset = 0;
					resizeMainDiv();
				}
			}
		}
	},
	
	toggleBreadCrump: function() {
		if($('div[title="main"]').css('display') == 'none') {
			$('div#breadnav').css('background', 'none');
		} else {
			if ($.browser.name == 'msie' && $.browser.versionNumber == '6') {
				$('div#breadnav').css('background', 'url(fileadmin/templates/img/shared/breadCrump_zu.gif) left bottom no-repeat');
			} else {
				$('div#breadnav').css('background', 'url(fileadmin/templates/img/shared/breadCrump_zu.png) left bottom no-repeat');
			}
			this.switchActiveArrow('current');
		}
		$('div[title="main"]').toggle('slide', { direction: 'up' }, 1000);
	}
}
