
$(document).ready(function(){
	
  $('form.contactform div.html a').toggle(function(){
	  pi_ShowForm();
	  return false;
    }, function(){
      pi_HideForm();
      return false;
    }
    
  );
  
  $("#content li:last-child").addClass('last');
  show_tab($('#tabs ul:eq(0) li:eq(0) a'));
  $('#tabs ul:eq(0) li:eq(0)').addClass('active');
  $('#tabs > ul a').click(function(e){
	  show_tab(this);
	  $(this).blur();
	  arec_cancel_event(e);
  });

  
  $('a[rel=pb]').each(function(){
	  
	  var img = new Image();
  	  img.src = $(this).attr('href');  
	  
	  $(this).css('cursor','help');
	  $(this).css('text-decoration','none');
	  $(this).css('border-bottom','1px dashed #007AAE');
	    $(this).click(function(){
	    	return false;
	    });
	    $(this).mouseover(function(){
	    	
	    	var top = ($(this).position().top+20);
	    	var left = $(this).position().left+$(this).width()+5;
	    	
	    	var coord = $(this).offset();
	    	
	    	var y = coord.top - $(window).scrollTop();
	    	if( y > $(window).height()/2){
	    		top = ($(this).position().top-5-img.height);
	    	};
	    	
	    	var x = coord.left - $(window).scrollLeft();
	    	if( x > $(window).width()/2){
	    		left = ($(this).position().left-5-img.width);
	    	};
	    	
	    	
	    	$(img).attr('style','border: 1px solid rgb(0,122,174); position: absolute; top: '+top+'px; left: '+left+'px;');
	    	$(img).attr('id','popup-image');
	    	$(document.body).append(img);
	    });
	    
	    $(this).mouseout(function(){
	        $('#popup-image').remove();
	    });
	  });
  
  
  $('a[rel=arec_back]').each(function(){
	 $(this).click(function(){
		 history.back();
		 return false;
	 });
  });
  
});


function show_tab(a){
	$('#tabs ul:eq(0) li').removeClass('active'); // all inactive
	$(a).parent().addClass('active'); // activate current tab
	  
	// hide all contents
	$('#tabs-content div').each(function(){
		  var id = $(this).attr('id');
		  if(id.substr(0,3) == 'tab')
            $(this).css('display','none'); 
	  });
	
	$($(a).attr('href')).css('display','block'); // show current content
	
	$($(a).attr('href')).click();	
}

function pi_ShowForm(){
  $('form.contactform div.optional').show('slow');
  $('form.contactform div.html a').text('Weniger Daten angeben? - Hier klicken');
}

function pi_HideForm(){
  $('form.contactform div.optional').hide('slow');
  $('form.contactform div.html a').text('Mehr Daten angeben? - Hier klicken');
}

function start_livezilla(){
	void(window.open('http://livezilla.it-easy.de/livezilla.php?intgroup=ZWFzeVdpbkFydA==&amp;hg=P0lULUVhc3k,TWlDTEFT&amp;reset=true','','width=473,height=600,left=0,top=0,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=yes'));
}


