
var waitTime = 9000;
var fadeTime = 1000;
var p = null;


function init(ck)
{
	// group trippled lists
  $('ul.groupedList.triple').groupListElement({groupClassName: 'li_grp', size : 3, fadeSpeed: 500});
	
  $('#Slides1 ul').groupListElement({groupClassName: 'li_grp', size : 3, fadeSpeed: 500});
  $('#Slides2 ul').groupListElement({groupClassName: 'li_grp', size : 3, fadeSpeed: 500});
  $('#Slides3 ul').groupListElement({groupClassName: 'li_grp', size : 3, fadeSpeed: 500});

  // group fifth lists
  $('ul.groupedList.fifth').groupListElement({groupClassName: 'li_grp', size : 5, fadeSpeed: 500});
  

  $('#FlagsLegend').before('<div class="contentHr map"></div>');


  // init slider(s)
  var startSlide = 1;
  // Get slide number if it exists
  if (window.location.hash) {
	  startSlide = window.location.hash.replace('#','');
  }


  $(function(){
      $('#slides').slides({
	  preload: false,
	  start: startSlide,
	  animationComplete: function(current){
	    // Set the slide number as a hash
	    window.location.hash = '#' + current;
	  },
		//generatePagination: true,
	  generateNextPrev: true
      });


      $('.slide_enabled').slides({
	  preload: false,
	  start: startSlide,
	  animationComplete: function(current){
	    // Set the slide number as a hash
	    window.location.hash = '#' + current;
	  },
		//generatePagination: true,
	  generateNextPrev: true
      });

      $('#Slides1').slides({
	  preload: false,
	  start: startSlide,
	  animationComplete: function(current){
	    // Set the slide number as a hash
	    window.location.hash = '#' + current;
	  },
		//generatePagination: true,
	  generateNextPrev: true
      });
      $('#Slides2').slides({
	  preload: false,
	  start: startSlide,
	  animationComplete: function(current){
	    // Set the slide number as a hash
	    window.location.hash = '#' + current;
	  },
		//generatePagination: true,
	  generateNextPrev: true
      });
      $('#Slides3').slides({
	  preload: false,
	  start: startSlide,
	  animationComplete: function(current){
	    // Set the slide number as a hash
	    window.location.hash = '#' + current;
	  },
		//generatePagination: true,
	  generateNextPrev: true
      });
  });
	initLang(ck);
	initIntro();

}

function initIntro()
{

	p = $('div#PageBody.home');

	// load the animation background
	p.css({'background-position':'0px 0px'});
	p.css('background-image', 'url(assets/images/content_bg_animation.jpg)');

	// let the initial Background load first
	window.setTimeout(step1, 6000); 

}

function step1()
{

	// reset
	p.css({'background-position':'0px 0px'});
	
	// animate
	p.
	stop().
	animate({backgroundPosition:'-974px 0px'}, fadeTime);

	$('h1.headliner, a.contentButton').
	stop().
	animate({'color':'#111'}, fadeTime);

	// switch in between
	window.setTimeout(stateB, fadeTime*0.6);
	
	// wait an cycle
	window.setTimeout(step2, waitTime);

}

function step2()
{

	// animate
	p.
	stop().
	animate({backgroundPosition:'-1948px 0px'}, fadeTime);

	$('h1.headliner, a.contentButton').
	stop().
	animate({'color':'#fff'}, fadeTime);

	
	// switch in between
	window.setTimeout(stateA, fadeTime*0.6);
	
	// wait an cycle
	window.setTimeout(step1, waitTime);
	
}


function stateB ()
{
$('a.contentButton').addClass('blk');

}

function stateA ()
{
$('a.contentButton').removeClass('blk');
}


function cmapSelect(tgt, text, av) {
	$m = $('#Map img');
	//$m.hide(0);

	if(!av) dir = 'map';
	else dir = 'map_av';

	$m.attr('src', 'assets/images/'+dir+'/'+tgt+'.gif');
	//$m.fadeIn('fast');
	
	var txt = "";
	switch(tgt)
	{
		case 'none': txt="Wählen Sie ein Land:"; break;
		case 'at': txt="Österreich"; break;
		case 'cz': txt="Tschechien"; break;
		case 'sk': txt="Slowakei"; break;
		case 'hu': txt="Ungarn"; break;
		case 'ro': txt="Rumänien"; break;
	}
	if(text) txt = text;
	$('#MapLegend').hide();
	$('#MapLegend').html(txt);
	$('#MapLegend').fadeIn();

}

function initLang(ck)
{

	switch(ck)
	{
	case 'de':
		$('.next').html('mehr');
		$('.prev').html('mehr');
		break;
	case 'ro':
		$('.next').html('mai mult');
		$('.prev').html('mai mult');
		break;
	case 'sk':
		$('.next').html('viac');
		$('.prev').html('viac');
		break;
	default:
		$('.next').html('more');
		$('.prev').html('more');
		break;
	}
		
}

