function updatePos() {
  var offset = $('#contentbox').offset();
  $('#alogo').css("left", offset.left+76);
  $('#alogo').css("top", offset.top+27);
  $('#alogo').css("display", "block");
  $('#commpanel').css("left", offset.left+368);
  $('#commpanel').css("top", offset.top+420);
  $('#token').css("left", offset.left+3);
 }
 function logoanim() {
  $("#alogoimg").animate( { width:"1"}, 1200, "linear" ).animate( { width:"40"}, 1200, "linear", function(){
    logoanim();
  });
 }
 function getCurrSlide() {
  cc = 0; cr=0;
  //alert($('#after a.activeSlide').index());
  $('#after a').each(function () {
   if ($(this).attr("class") == "activeSlide") cr = cc;
   cc++;
  });
  return cr;
 }
 $(document).ready(function() {
  $('#btnslideshowleft').click(function () {
   $('#slideshow').cycle('pause');
   cl = $('#after a').length;
   cr = getCurrSlide();
   prevPic = (cr-1 >= 0 ? cr-1 : cl-1)
   $('#after a').eq(prevPic).click();
  });
  $('#btnslideshowright').click(function () {
   $('#slideshow').cycle('pause');
   cl = $('#after a').length;
   cr = getCurrSlide();
   nextPic = (cr+1 < cl ? cr+1 : 0);
   $('#after a').eq(nextPic).click();
  });
  
/*  $('#contentbox').hover(
   function () {
    updatePos();
    if ($('#content').css("display") == 'none') $('#commpanel').fadeTo(1000,0.7);
   }, 
   function () {updatePos();$('#commpanel').fadeOut(300);}
  );
  $('#commpanel').bind("mouseenter", function () {
    $(this).fadeIn(1000);
   }
  );*/
  
  $('#fullscrcurt').click(function () {
   $('#fullscrcurt').fadeOut(500);
  });

  $('#btnshowcontent').click(function () {
   if ($('#content').css("display") == 'none') {
    $('#content').fadeIn(300);
	$('#commpanel').fadeOut(300);
	var offset = $('#contentbox').offset();
    $('#token').css("left", offset.left+3);
	$('#token').fadeIn("slow");
	$('#slideshow').cycle('pause');
   } else {
    $('#token').fadeOut("slow");
    $('#content').fadeOut(300);
	$('#commpanel').fadeIn(1000);
	$('#slideshow').cycle('resume'); 
   }
  });
  
  $('#tokenbtn').click(function () {
   $('#btnshowcontent').click();
  });
  
  $('#langswitch').click(function () {
   var offsetlsf = $('#langswitch').offset();
   $('#langswitchform').css("left", offsetlsf.left-3);
   $('#langswitchform').css("top", offsetlsf.top-3);
   $('#langswitchform').slideDown(500);
  });
  
  var offset = $('#content').offset();
  $('#token').css("left", offset.left+3);
  
  $('div.accordionButton').eq(0).click();
  if ($('#content').css("display") == 'none') {
   updatePos();
   $('#commpanel').fadeIn(300);
   //$('#commpanel').fadeOut(2000);
  } else {
   $('#slideshow').cycle('pause');
  }
  
  logoanim();
  showtimer = window.setTimeout(updatePos, 300);
 });
