//-------------------------------------------
// Accordion navigation
//-------------------------------------------

$(document).ready(function() {
	
	// open external links in new window
	$("a.link-external").attr('target', '_blank');

	$('#nav-losninger h3').click(function() {
		$(this).next('.child').slideToggle('fast').siblings('.child:visible').slideUp('fast');
	});

	$('#nav-losninger li.parent').click(function() {
		// $(this).bind('click', 'expando')
		$(this).toggleClass('on').children('.child').slideToggle('fast');
	});

	$('#nav-losninger a#nav-active + ul.child').each(function(){
		$(this).show();
	});
	
	// Make sure we cancel the overlapping LI click for children and grandchildren
	$('#nav-losninger li a').click(function(e){
		if ($(this).parent().attr('class').match(/^parent/) !== null) {
			$(this).parent().unbind('click');
		} else {
			$(this).parent().parent().parent().unbind('click');
		}
	});
	
	
	// remove border on last LI
	$('ul#nav li:last-child').addClass('nav-end');

	// adjust height of links
	$('#section-home td.nav').each(function(){
		var $this = $(this);
		var a = $('ul#nav li a', $this);
		var h = $this.height()/a.length;
		a.css('height', (Math.floor(h) + 6) + 'px');
		a.css('font-size', '0.87em');
		
	});
	
	// set background and hover on parent LI
	$('#nav-losninger li a#nav-active').each(function(){
		$(this).parent('li').addClass('active');

		$(this).siblings('ul').addClass('mask');
	});

	
	$('#nav-losninger li a').mouseover(function(){
		// $(this).parent().css('background-image', 'url(/images/ui/bkg-hdr-plus.gif)');
		if ($(this).attr('id') !== 'nav-active') $(this).parent().toggleClass('over');
		$(this).siblings('ul').addClass('mask');
	});
	$('#nav-losninger li a').mouseout(function(){
		// $(this).parent().css('background-image', 'url(/images/ui/bkg-hdr-minus.gif)');
		if ($(this).attr('id') !== 'nav-active') $(this).parent().toggleClass('over');
	});
	
	$('#nav-losninger li a#nav-active').unbind('mouseover mouseout');

	// prevent copy from page elements
	// $('.col2, .col3').bind('contextmenu',function(e){
	// 	alert('contextmenu called');
	// 	e.preventDefault();
	// });
	// 
	// $('.col2, .col3').bind('onselect',function(e){
	// 	alert('onselectstart called');
	// 	e.preventDefault();
	// });
	
});

//-------------------------------------------
// Status bar function
//-------------------------------------------

function statusText(msg) {
  window.status = msg;
  return true;
}

//-------------------------------------------
// Open window function
//-------------------------------------------

function openWin(id) {
  self.name = "opener";
  remote = open("partnere_popup.php?id=" + id, "partnere", "status=0,scrollbars=1,resize=1,toolbar=0,width=750,height=400");
}


