// jas for bcsvaja
var $j = jQuery.noConflict();
function theRotator() {
	//Set the opacity of all images to 0
	$j('div#top-banner ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$j('div#top-banner ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($j('div#top-banner ul li.show')?  $j('div#top-banner ul li.show') : $j('div#top-banner ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $j('div#top-banner ul li:first') :current.next()) : $j('div#top-banner ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$j(document).ready(function($j){
	theRotator();
	//theMarkup();
	//$j("#menu ul li:last, #subnavi ul li:last").each(function(){
	//	$j("a", this).addClass("last");  
	//});
	$j("#primary .children").hide();
	$j("#primary .gallery_but").hover(function() { $j('.children', this).show(); },function() { $j('.children', this).hide(); });
	
	$j("img.f_img").hover(
	 function()
	 {
	  this.src = this.src.replace("rep_","ico_");
	 },
	 function()
	 {
	  this.src = this.src.replace("ico_","rep_");
	 }
	);
	
	(function (){
		var odd=1;
		$j('.gtr').each(function(index) {
			if(odd == 1){odd=2;}else{odd=1;}
			$j(this).addClass('odd'+odd);
			//alert(index + ': ' + $(this).text());
		});
	})();
	
	(function (){
	var opened;
	$j('div.info_wide').hide(); 
	  $j('div.info_mini').click(function(e) {
	  
		var id = $j(this).attr('rel');
		$j('div#showinfo_'+id+'.info_mini').hide();
		$j('div#infow_'+id+'.info_wide').show('fast');

		$j('div#infow_'+opened+'.info_wide').removeClass('opened');
		$j('div#infow_'+opened+'.info_wide').hide();
		$j('div#showinfo_'+opened+'.info_mini').show('fast');
		opened=id;
		$j('div#infow_'+opened+'.info_wide').addClass('opened');
		//$j('div#infow_'+id+'.info_wide').addClass('opened');
		return false;
	  });  
	  $j('span.closeinfo').click(function(e) {
		var id = $j(this).attr('rel');
		$j('div#infow_'+id+'.info_wide').hide('fast');
		$j('div#showinfo_'+id+'.info_mini').show('fast');
		$j('div#infow_'+opened+'.info_wide').removeClass('opened');
		opened=0;
		return false;
	 });
	})();
	(function (){
	var opened;
	$j('div.dtable').hide(); 
	  $j('div.glegue_single').click(function(e) {
		//
		var id = $j(this).attr('rel');
		$j('div#lbut_'+id+'.glegue_single').hide();
		$j('div#legue_'+id+' .dtable').show('fast');

		$j('div#legue_'+opened+' .dtable').removeClass('opened');
		$j('div#legue_'+opened+' .dtable').hide();
		$j('div#lbut_'+opened+'.glegue_single').show('fast');
		opened=id;
		$j('div#legue_'+opened+'.dtable').addClass('opened');
		return false;
	  });  
	  $j('span.closeinfo').click(function(e) {
		var id = $j(this).attr('rel');
		$j('div#legue_'+id+' .dtable').hide('fast');
		$j('div#lbut_'+id+'.glegue_single').show('fast');
		$j('div#legue_'+opened+' .dtable').removeClass('opened');
		opened=0;
		return false;
	 });
	 })();
	 
	 $j(".ngg-galleryoverview a").each(function (arr){  
		if ($j(this).attr("title").substr(0,5)=="Video"){
		  var thereltag = $j(this).attr("rel").substr(0,22);
		  $j(this).attr("rel", thereltag + ";width=512;height=348;");
		  $j(this).attr("href",$j(this).children("div").children("div").children("img").attr("title")+'&hl=en&fs=1&rel=0&autoplay=1');
		  var thesrctag = $j(this).children("img").attr("src");
		  $j(this).children("img").attr("src",thesrctag);
		}
	  });
	  
	  Shadowbox.init();
});


