jQuery(function() {
  jQuery('.error').hide();
  jQuery('input.text-input').css({backgroundColor:"#FFFFFF"});
  jQuery('input.text-input').focus(function(){
    jQuery(this).css({backgroundColor:"#FFDDAA"});
  });
  jQuery('input.text-input').blur(function(){
    jQuery(this).css({backgroundColor:"#FFFFFF"});
  });

  jQuery(".button").click(function() {
		// validate and process form
		// first hide any error messages
    jQuery('.error').hide();
		
	  var mailto = jQuery("input#mailto").val();
		if (mailto == "") {
      jQuery("label#mailto_error").show();
      jQuery("input#mailto").focus();
      return false;
    }
		var sender = jQuery("input#sender").val();
		if (sender == "") {
      jQuery("label#sender_error").show();
      jQuery("input#sender").focus();
      return false;
    }
		var from = jQuery("input#from").val();
		if (from == "") {
      jQuery("label#from_error").show();
      jQuery("input#from").focus();
      return false;
    }
	var subject = jQuery("input#subject").val();    
	var id = jQuery("input#id").val();	
	var lang = jQuery("input#lang").val();	
		
	var dataString = 'mailto='+ mailto + '&from=' + from + '&sender=' + sender + '&subject=' + subject+ '&id=' + id + '&lang=' + lang;
		
	jQuery.ajax({
      type: "POST",
      url: "/helper/send.php",
      data: dataString,
      success: function() {
        jQuery('#sendmail_form').html("<div id='message'></div>");
        jQuery('#message').html("<h2>Article sent to " + mailto + "!</h2>")
        .hide()
        .fadeIn(1500, function() {
        });
      }
     });
    return false;
	});
});

jQuery().ready(function() {
  jQuery('#sendmail').jqm({trigger: 'a.sendmailtrigger'});
});

var min=8;
var max=18;

function increaseFontSize() {
   var p = document.getElementsByTagName('text');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('text');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }  
}

var jQuerydate = new Date();
var jQuerytime = jQuerydate.getTime();
jQuery(document).ready(function() {


	jQuery(".commentsWrite").click(function () {
      jQuery("#commentWriteForm").slideDown(150,function(){
      });
    });
    
	jQuery(".commentsRead").click(function () {
      jQuery("#commentsListing").slideDown(500,function(){
      });
    });    

	
	// Tabs
	jQuery('#tabs').tabs();
	jQuery('#tabs-ar').tabs();	
	
	/* datepicker 
		1. bind datepicker to the ids datestart/ dateend
	*/
	jQuery("#datestart").datepicker({ dateFormat: 'dd.mm.yy' });
	jQuery("#dateend").datepicker({ dateFormat: 'dd.mm.yy' });
	
	
	//animation for topics en
	jQuery('.animation_left a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#animation-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-299);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#animation-container').width()-299;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/299; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 299);
			jQuery('#animation-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/299 + 1; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');
			jQuery('#animation-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.animation_right a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#animation-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-299);
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#animation-container').width()-299;
		if(jQuerywidth > (jQueryleftpixel*-1)){
			var jQuerynewclass =(jQueryleftpixel*-1)/299 + 2; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');

			jQuery('#animation-container').animate({left:(jQueryleftpixel-299)+'px'}, 1000);
		}else{
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').animate({left:'0px'}, 1000);			
		}
	});
	
	//animation for topics ar
	jQuery('.animation_left_ar a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#animation-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-299);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#animation-container').width()-299;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/299; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 299);
			jQuery('#animation-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/299 + 1; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');
			jQuery('#animation-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.animation_right_ar a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#animation-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-299);
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#animation-container').width()-299;
		if(jQuerywidth > (jQueryleftpixel*-1)){
			var jQuerynewclass =(jQueryleftpixel*-1)/299 + 2; 
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').addClass(jQuerynewclass+'_t');

			jQuery('#animation-container').animate({left:(jQueryleftpixel-299)+'px'}, 1000);
		}else{
			jQuery('#animation-container').removeClass();
			jQuery('#animation-container').animate({left:'0px'}, 1000);			
		}
	});
		
	//animation for menu en (topics)
	
	jQuery('.menu_en_left a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#menu-en-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-325);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-en-container').width()-325;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/325; 
			jQuery('#menu-en-container').removeClass();
			jQuery('#menu-en-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 325);
			jQuery('#menu-en-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/325 + 1; 
			jQuery('#menu-en-container').removeClass();
			jQuery('#menu-en-container').addClass(jQuerynewclass+'_t');
			jQuery('#menu-en-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.menu_en_right a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#menu-en-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * 325;
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-en-container').width()-325;
		if(jQuerywidth > (jQueryleftpixel)){
			var jQuerynewclass =(jQueryleftpixel)/325 + 2; 
			jQuery('#menu-en-container').removeClass();
			jQuery('#menu-en-container').addClass(jQuerynewclass+'_t');

			jQuery('#menu-en-container').animate({left:(-1*jQueryleftpixel-325)+'px'}, 1000);
		}else{
			jQuery('#menu-en-container').removeClass();		
			jQuery('#menu-en-container').addClass('1_t');
			jQuery('#menu-en-container').animate({left:'0px'}, 1000);			
		}
	});	
	
	//animation for menu en (authors)
	jQuery('.menu_en_author_left a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#menu-en-author-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-325);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-en-author-container').width()-325;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/325; 
			jQuery('#menu-en-author-container').removeClass();
			jQuery('#menu-en-author-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 325);
			jQuery('#menu-en-author-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/325 + 1; 
			jQuery('#menu-en-author-container').removeClass();
			jQuery('#menu-en-author-container').addClass(jQuerynewclass+'_t');
			jQuery('#menu-en-author-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.menu_en_author_right a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#menu-en-author-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * 325;
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-en-author-container').width()-325;
		if(jQuerywidth > (jQueryleftpixel)){
			var jQuerynewclass =(jQueryleftpixel)/325 + 2; 
			jQuery('#menu-en-author-container').removeClass();
			jQuery('#menu-en-author-container').addClass(jQuerynewclass+'_t');

			jQuery('#menu-en-author-container').animate({left:(-1*jQueryleftpixel-325)+'px'}, 1000);
		}else{
			jQuery('#menu-en-author-container').removeClass();		
			jQuery('#menu-en-author-container').addClass('1_t');
			jQuery('#menu-en-author-container').animate({left:'0px'}, 1000);			
		}
	});	
	
	//animation for menu ar (topics)
	
	jQuery('.menu_ar_left a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#menu-ar-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-325);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-ar-container').width()-325;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/325; 
			jQuery('#menu-ar-container').removeClass();
			jQuery('#menu-ar-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 325);
			jQuery('#menu-ar-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/325 + 1; 
			jQuery('#menu-ar-container').removeClass();
			jQuery('#menu-ar-container').addClass(jQuerynewclass+'_t');
			jQuery('#menu-ar-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.menu_ar_right a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#menu-ar-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * 325;
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-ar-container').width()-325;
		if(jQuerywidth > (jQueryleftpixel)){
			var jQuerynewclass =(jQueryleftpixel)/325 + 2; 
			jQuery('#menu-ar-container').removeClass();
			jQuery('#menu-ar-container').addClass(jQuerynewclass+'_t');

			jQuery('#menu-ar-container').animate({left:(-1*jQueryleftpixel-325)+'px'}, 1000);
		}else{
			jQuery('#menu-ar-container').removeClass();		
			jQuery('#menu-ar-container').addClass('1_t');
			jQuery('#menu-ar-container').animate({left:'0px'}, 1000);			
		}
	});	
	
	//animation for menu ar (authors)
	jQuery('.menu_ar_author_left a').bind('click.slide_left', function(){
		// aktuelle position
		var jQuerycurrent = jQuery('#menu-ar-author-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * (-325);
		}else{
			var jQueryleftpixel = 0;
		}
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-ar-author-container').width()-325;
		if((jQueryleftpixel*-1)>0){	
			var jQuerynewclass =(jQueryleftpixel*-1)/325; 
			jQuery('#menu-ar-author-container').removeClass();
			jQuery('#menu-ar-author-container').addClass(jQuerynewclass+'_t');
			var jQuerynewleft = plus(jQueryleftpixel, 325);
			jQuery('#menu-ar-author-container').animate({left:jQuerynewleft+'px'}, 1000);
		}else{
			var jQuerynewclass =(jQuerywidth)/325 + 1; 
			jQuery('#menu-ar-author-container').removeClass();
			jQuery('#menu-ar-author-container').addClass(jQuerynewclass+'_t');
			jQuery('#menu-ar-author-container').animate({left:(-jQuerywidth)+'px'}, 1000);
		}
	});
	
	jQuery('.menu_ar_author_right a').bind('click.slide_right', function(){											   
		var jQuerycurrent = jQuery('#menu-ar-author-container').attr('class').replace('_t','');
		// aktuelle position
		if(parseInt(jQuerycurrent)>0){
			var jQueryleftpixel = (jQuerycurrent-1) * 325;
		}else{
			var jQueryleftpixel = 0;
		}
		
		// gesamtbreite
		var jQuerywidth = jQuery('#menu-ar-author-container').width()-325;
		if(jQuerywidth > (jQueryleftpixel)){
			var jQuerynewclass =(jQueryleftpixel)/325 + 2; 
			jQuery('#menu-ar-author-container').removeClass();
			jQuery('#menu-ar-author-container').addClass(jQuerynewclass+'_t');

			jQuery('#menu-ar-author-container').animate({left:(-1*jQueryleftpixel-325)+'px'}, 1000);
		}else{
			jQuery('#menu-ar-author-container').removeClass();		
			jQuery('#menu-ar-author-container').addClass('1_t');
			jQuery('#menu-ar-author-container').animate({left:'0px'}, 1000);			
		}
	});	
		
	jQuery('a.lightbox1').lightBox();
	jQuery('a.lightbox2').lightBox();	
	jQuery('a.lightbox3').lightBox();
	jQuery('a.lightbox4').lightBox();	
	jQuery('a.gallery').lightBox();	
	
});


function plus(zahl1, zahl2)
{
	zahl1 = parseInt(zahl1);
	zahl2 = parseInt(zahl2);
	return zahl1 + zahl2;
}

