$(document).ready(function(){

	$('#mod-multi').accordion({
		header: 'h3',
		alwaysOpen: true,
		selectedClass: 'open',
		fillSpace: true
	});
	$('#accordion').accordion({
		header: 'h3',
		alwaysOpen: true,
		selectedClass: 'open',
		fillSpace: true
		/*@cc_on @if (@_jscript_version < 5.7) ,animated: false @end @*/ /* e|vo 090213 detecting IE6, which is @_jscript_version 5.6 */
		/*event: "mouseover"*/	
	});
	
	$("#mod-multi h3").hover(function(){
		if (!$(this).hasClass("open")) {
			$(this).addClass("hover");	
		}		
	}, function(){
		$(this).removeClass("hover");
	});
	
	//alert(($.browser.version==6 && $.browser.msie==true))
	/*if ( !($.browser.version==6 && $.browser.msie==true)) {
		$(function(){
			$.Lightbox.construct({
				show_linkback:	false,
				show_info:		true,
				download_link: false,
				files: {
					css: {
						lightbox:'styles/jquery.lightbox.css'
					},
					images: {
						prev:		'img/lightbox-prev.png',
						next:		'img/lightbox-next.png',
						loading:	'img/lightbox-load.gif'
					}
				},
				text: {
					image:		'Foto',
					of:			'von',
					close:		'Schlie&szlig;en',
					closeInfo:	'You can also click anywhere outside the image to close.',
					help: {
						close:		'Klicken um zu schlie&szlig;en',
						interact:	'' //Hover to interact
					}
				},
				opacity:			0.8
			});
		});
	}*/
	
	$('#input-search').example('Hier Suchbegriff eingeben');
	$('#search_query').example('Bitte hier den Suchbegriff eingeben');
	
	$('#ticker').newsTicker();
	
	$('#gal').jScrollPane({showArrows:false, scrollbarWidth:0, scrollbarMargin:0, animateTo:true});
	// hide scroll arrows if there are just 9 or less images
	if ($("#gal img").size() <= 9) {
		$("a#btn-scroll-up, a#btn-scroll-dw").css("visibility", "hidden");	
	}

	// this initialises the scrollBy and scrollTo links.
	$('.btn-scroll').bind(
		'click',
		function() {
			$('#gal')[0].scrollBy(parseInt($(this).attr('rel')));
			return false;
		}
	);


	
	/* FILME */
	$('.topic-1 .mod-movdet .cont > div').jScrollPane({scrollbarWidth:9, showArrows:true});
	$('.topic-1 .mod-movdet > ul').tabs();

	/* DVD */
	$('.topic-2 .mod-movdet .cont > div').jScrollPane({scrollbarWidth:9, showArrows:true});
	$('.topic-2 .mod-movdet > ul').tabs();
	/*$('.topic-2 ul#ticker').liScroll();*/

	$('.topic-3 #mod-game .cont').jScrollPane({scrollbarWidth:9, showArrows:true});
	$('.topic-4 #mod-news-item .cont').jScrollPane({scrollbarWidth:9, showArrows:true});
	$('.topic-5 #mod-stars-item .cont').jScrollPane({scrollbarWidth:9, showArrows:true});

	$('#mod-dump-items').jScrollPane({scrollbarWidth:9, showArrows:true});

	/* GAMES */
	$('form:not(#search_bar)').jqTransform();
	
	//$(document).pngFix();
	/*$.ifixpng('../img/pixel.gif');
	$('#content').ifixpng()*/
	
	var maxLength = 40;
	var obj = $(".topic-0 .mod-lightbox h3");
	if (obj.text().length > maxLength) {
		obj.text(obj.text().substring(0, maxLength - 3) + "...");
	}
	
	
	/* NAVIGATION */
	$("#nav-main > li").hover(function(){		
		$("ul", this).show();
	},function(){
		$("ul", this).hide();
	});
	$("#nav-main li ul").hover(function(){		
		$(this).prev("a").addClass("hover");
	},function(){
		$(this).prev("a").removeClass("hover");		
	});
});


// this funxtion changes all ajxlinks marked tags to jquery loaders..
// Sample_: a href="ajax3games_snip2.html" tgt="searchresult" id="page-next" class="ajxlinks"
// loads File ajax3games_snip2.html to Div searchresult 
// calls itself to generate new ajx links... schould not be called twice on the same object ! so be carefull with multiple targets on one page, menus and so on.
function createajxlinks() {
	$('.ajxlinks').each(function() {
		if ($(this).attr('href') != '') {
		
		$(this).attr('click',$(this).attr('href'));
		$(this).removeAttr('href');
		$(this).css('cursor','pointer');
		$(this).unbind('click');
		$(this).click(function() {
			$('#'+$(this).attr('tgt')).html('<img style="border: none !important; margin-top:225px; margin-left:225px;" class="loading" src="/export/system/modules/at.dmc.mn.templates/resources/styles/img/lightbox-load.gif">');
			$('#'+$(this).attr('tgt')).load($(this).attr('click'),function() {
				createajxlinks();
			});
		})
		
		}
	})
}
