/***************
 * Flash Navigation Handler
 ***************/
jumpTo = function (absoluteUrl) {
	var baseUrl = 'http://www.bartenbach.de';
	location.href = baseUrl + absoluteUrl;
}

/***************
 * MESSENGER
 ***************/
startMessengerConversation = function (uid) {
    Shadowbox.open({
        player:   'iframe',
        content: '/kommunikationstool/?tx_baagmessenger_pi2%5BuserId%5D=' + uid,
        width:    450,
        height:   575
    });
}

 /***************
  * CONTACT SINGLE
  ***************/
startPersonalMail = function (url) {
	 Shadowbox.open({
         player:   'iframe',
         content: url,
         width:    450,
         height:   555
     });
 }

/***************
 *  SHADOWBOX
 ***************/
Shadowbox.loadSkin('baag', 'fileadmin/templates/bartenbach_de/js/shadowbox/skin');
Shadowbox.loadLanguage('de-DE', 'fileadmin/templates/bartenbach_de/js/shadowbox/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'swf'], 'fileadmin/templates/bartenbach_de/js/shadowbox/player');

DD_roundies.addRule('#shadowbox_corner', '8px', true);

/***************
 *  BROWSER
 ***************/
var browser = navigator.userAgent.toLowerCase();
var isIE = ( (browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1) && (browser.indexOf("webtv") == -1));
var browserVersion = parseFloat( browser.substring( browser.indexOf('msie ') + 5 ) );


/***************
 *  JQUERY
 ***************/
$(document).ready(function() {
	/***************
	 *  GLOBAL
	 ***************/
	// NAVIGATION
	call('sendToActionScript', 100, 100);
	
	$('li.expandLeft ul.subnav').css('marginLeft','-135px');
	$(".nav ul ").css({display: "block",visibility: "hidden"});
	$(".nav li").hover(function(){
		$(this).children("a").css({"background-position" : "0px -16px"});
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show();
	},function(){
		$(this).children("a").css({"background-position" : "0px 0px"});
		$(this).find('ul:first').css({visibility: "hidden"});
	});


	// DISCUSSION TOGGLE CONTACTS
	$('div#box-discussion-contacts-list div').hide();
	$('div#box-discussion-contacts-list h6').click(function() {
		var nextDiv = $(this).next();
		var visibleSiblings = nextDiv.siblings('div:visible');

		if (visibleSiblings.length ) {
			$('div#box-discussion-contacts-list h6').removeClass("active");
			$(this).addClass('active');
			visibleSiblings.slideUp('slow', function() {
				nextDiv.slideToggle('fast');
			});
		} else {
			nextDiv.slideToggle('fast');
			$(this).toggleClass('active');

			nextDivPosition = nextDiv.position();
			scrollToPosition = nextDivPosition.top + 30;

			if (scrollToPosition > 85) $('#box-discussion-contacts')[0].scrollTo(scrollToPosition );
		}
	});


	// DISCUSSION SCROLLBAR
	$("div#box-discussion-contacts").jScrollPane({
		showArrows:true,
		scrollbarWidth: 7,
		dragMinHeight : 19,
		dragMaxHeight : 19
	});


	// NEWSTICKER
	$('#nautv-ticker').innerfade({
		speed: 750,
		timeout: 2000,
		containerheight: '21px'
	});
	
	$('#nautv-open').hide();
	
	$('a.nautv-openclose').toggle(function(){
		$('ul#nautv-ticker').slideUp(100,function(){
			$('div#nautv-open').slideDown(750,function(){
				$('a.nautv-openclose').addClass("open");
			});
		});
	},function(){
		$('a.nautv-openclose').removeClass("open")
		$('div#nautv-open').slideUp(750,function(){
			$('ul#nautv-ticker').slideDown(100);
		});
	});


	// MESSENGER SUBPAGES FIX
/*
	$("#box-discussion-contacts-list a[href='#']").each(function () {
		$(this).attr('href', 'javascript: return false;');
	});
*/
	$('#box-discussion-contacts-list div').each(function(){
        	if($(this).children('a').is("a[title^='Chat']")) {
        	} else {
                    $(this).prev().fadeTo(1, 0.5);
                }
	});


 	// SHADOWBOX
	Shadowbox.init();


 	// INTERNET EXPLORER BUG FIX
	if(isIE) {
		if(browserVersion == 6) {
			// IE6 PNG-FIX
			$("div#content-container").each(pngfix);
			$("p.person-quote").each(pngfix);
			$("p.quote-end").each(pngfix);
		}


		// HIDE VALUE BUTTON
		$(".tt-news_newslistbox-herunterladen").attr("value","");
		$(".jobs-herunterladen").attr("value","");
	}

	// CLEAR SEARCH INPUT ON FOCUS
	$("input#quicksearch").focus(function () {
		$(this).attr("value","");
	});

	// focus flash on mouseover
	$('#flash').bind('mouseover', function () {
		$('#flashcontent').focus();
	});

	$('#flashcontent').css('color', 'transparent');
	$('#flashcontent').css('font-size', '0px');

/*
	// SHOW CUSTOMER SELECT DROPDOWNS
	$("div#customer form").show();

	// TOOLTIP
	$("a.tooltip").bstip({
		forewrap:'',
		backwrap:'',
		color:'tooltipbox',
		opacity:1
	});
	$("p.tooltip a").bstip({
		forewrap:'',
		backwrap:'',
		color:'tooltipbox',
		opacity:1
	});
*/
});