/*
* Beroobi
* standard.js
*
* Author: Holger M. Stangl 
* Date: Februar 2009
*/

function setElementSize(id_dom, width, height)
{
 var element = document.getElementById(id_dom);
 if(width) element.width = width;
 if(height) element.height = height; 
}


$(document).ready(function() {
		
	$.fn.colorbox.settings.bgOpacity = "0.9";
	$("a[rel='lightbox']").colorbox({transition:"fade"});
	
	/* LIST TEASERBOX LASTCHILD */
	$('div.containerList .contentBox').each(function() {
		$(this).find('div.teaserBoxA:last').prev().prev().addClass('lastChild');
		$(this).find('div.teaserBox:last').addClass('lastChild').end();
	});
	
	
	$('div.containerDetail .infoBox').each(function() {
		if ( !$('#paginationDetail').find('div')[0] ) {
		if ( $(this).next().not('class="textBox"') ) { 
			$(this).css('padding-bottom','5px');
		}
		}
	});
	
	
	
	
	
	$('ul.navigationBottom').each(function() {
		$(this).find('li:last').addClass('lastChild');
	});
	
	
	/* NAVIGATION MAIN */
	$('ul.navigationA li a').hover( 
		function() {
			var navB = $(this).parent().find('ul.navigationB');
			navB.prev().addClass('hover');
			navB.find('li:first').addClass('firstChild');
			navB.find('li:last').addClass('lastChild');
			navB.show();
		},
		function() {
			var navB = $(this).parent().find('ul.navigationB');
			navB.prev().removeClass('hover');
			navB.hide();
		}
	);
	
	$('ul.navigationB').hover( 
		function() {
			$(this).prev().addClass('hover');
			$(this).find('li:first').addClass('firstChild');
			$(this).find('li:last').addClass('lastChild');
			$(this).show();
		},
		function() {
			$(this).prev().removeClass('hover');
			$(this).hide();
		}
	);
	
	
	/* TOOL TIP GLOSAR */
	$('span.glosaryTerm').hover( 
		function() { 
			$(this).prev().show(); 
			var toolTipHeight = $(this).prev().height();
			//console.log( "ToolTipHeight: "+toolTipHeight );/**/
			toolTipHeight = toolTipHeight + 9;
			$(this).prev().css("margin-top","-"+toolTipHeight+"px"); 
		},
		function() { 
			$(this).prev().hide(); 
		}
	);
	
	$('.toolTip').hover(
		function() { $(this).show(); },
		function() { $(this).hide(); }
	);
	
	
	
	/* TOOL TIP FRIEND BOX */
	$('span.friendBox').hover( 
		function() { $(this).find('span').show(); },
		function() { $(this).find('span').hide(); }
	);
	
	$('span.friendBoxToolTip').hover(
		function() { $(this).show(); },
		function() { $(this).hide(); }
	);
	
	
	/* TOOL TIP MYBEROOBIS */
	$('.myBeroobiBox').hover( 
		function() { $(this).find('.myBeroobiToolTip').show(); },
		function() { $(this).find('.myBeroobiToolTip').hide(); }
	);
	
	$('.myBeroobiToolTip').hover(
		function() { $(this).show(); },
		function() { $(this).hide(); }
	);		
	
	/* LOGIN BOX */
	$('#loginBox a:last').css('font-weight', 'normal');
	$('#loginBox a:last').attr('title','Kennwort vergessen?');	
	
	/* BUDDYLISTDEL PROMT */
	$('.delBuddy').css('cursor','pointer');					
	$('.delBuddy').click(function(){ $(this).parent().next().toggle();});
	$('.delBuddyPromtHide').click(function(){ $('.delBuddyPromt').hide(); });	
	
	/* BUDDYLISTADD PROMT */
	$('.buddyAdd').css('cursor','pointer');	
	$('.buddyAdd').click(function(){ $(this).parent().next().toggle(); });
	$('.buddyAddPromtHide').click(function(){ $('.buddyAddPromt').hide(); });

	/* BUDDYLISTADD PROMT FORUM */
	$('.buddyAddForum').css('cursor','pointer');	
	$('.buddyAddForum').click(function(){ $('.buddyAddPromt').next().toggle(); });
	$('.buddyAddPromtHide').click(function(){ $('.buddyAddPromt').hide(); });	
	
	$(':radio').checkize({
		checked:"fileadmin/templates/images/icon_checkbox_act.png",
		unchecked:"fileadmin/templates/images/icon_checkbox.png"
	});
	$(':checkbox').checkize({
		checked:"fileadmin/templates/images/icon_checkbox_act.png",
		unchecked:"fileadmin/templates/images/icon_checkbox.png"
	});		

	$("img[src*='fileadmin/templates/ext/mm_forum/tmpl/img/beroobi/topic_pinned.png']")
		.attr('alt','Dieses Thema ist gepinned')
		.attr('title','Dieses Thema ist gepinned');

	$('input.submit').each(function() {
		$(this).hover( function() {
			$(this).css("color","#FF9B1E");
			$(this).css("cursor","pointer");
		},
		function() {
			$(this).css("color","#F56E00");
			$(this).css("cursor","default");
		});
	});	
	
	//Forum
	$(".forumBoxImage img[src*='icon_forum_post.gif']")
		.attr('alt', 'Themen ohne neue Antworten')
		.attr('title', 'Themen ohne neue Antworten');
	$(".forumBoxImage img[src*='icon_forum_open.gif']")
		.attr('alt', 'Keine Themen')
		.attr('title', 'Keine Themen');		
	$('.forumBoxInfo a:first-child').each(function(){
		$(this).attr('title', 'Zum letzten Beitrag')
	});	
	
	
	// Body Height
  	if($.browser.msie && $.browser.version == 6 ){
    	$('#containerMain').css('height', $('body').height()-275 );
    } else {
    	$('#containerMain').css('min-height', $('body').height()-275 );
  	}
  	
  	

});

//Forum Adminpanel Toggle
function toggleDisplay(id){
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = '';
		document.getElementById('img-expand').style.display = 'none';
		document.getElementById('img-collapse').style.display = 'block';
	} else {
		document.getElementById(id).style.display = 'none';
		document.getElementById('img-expand').style.display = 'block';
		document.getElementById('img-collapse').style.display = 'none';
	}
}

function openWindowText(moduleType, id)  {
//alert('type:' + moduleType + ' id:' + id);
    var width = 400;
    var height = 500;
    var windowName = 'window' + moduleType;

    if (moduleType == "audioplayer") {
        var destination = "index.php?id=706&uid=" + id + "&src=tx_lfberoobiaudios_assets";
    } else if (moduleType == "videoplayer") {
        var destination = "index.php?id=706&uid=" + id + "&src=tx_lfberoobivideos_assets";
    } else if (moduleType == "interview_audio") {
        var destination = "index.php?id=706&uid=" + id + "&src=tx_lfberoobiaudiointerview_items";
    } else if (moduleType == "interview_video") {
        var destination = "index.php?id=706&uid=" + id + "&src=tx_lfberoobividoeinterview_items";
    }
    
    var host = 'http://' + location.host;
//alert(host+'/'+destination);    
    fs = window.open(host+'/'+destination, windowName, 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,location=no');
    fs.resizeTo(width, height);
    fs.focus();
}
	
// jQuery LightBox
/*
$(function(){
	$.Lightbox.construct({
		text: {
			close: 'Schließen',	
			image: '',
			of: '',
			closeInfo: '',
			download: '',
			help: {
				close: 'Schließen',
				interact: ''
			}
		},
		opacity: 0.75,
		speed: 300,
		padding: 1,
		auto_resize: true,
		show_linkback: false,
		download_link: false,
		show_info: true,
		show_extended_info: false
	});

});
*/


