var form_error_mark_border  = "1px solid #5b4300";
var form_error_reset_border = "1px solid #b39d61";

function form_error_mark(field)
{
  field.style.border = form_error_mark_border;
  field.focus();
}

function form_error_reset(field)
{
  field.style.border = form_error_reset_border; 
}

function check_email(email)
{
  /* valid chars for email */
  var emailchars="@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZaöüAÖÜ+-_.0123456789~";
  var emailchars_res = true;
  for(i=0; i<email.length; i++) 
  { 
    emailchars_res && (emailchars.indexOf(email.charAt(i))!=-1) 
  }
  
  /* check length, @, .@, !.xxxxx  */
  email_res = ( emailchars_res &&
                email.length >= 6 &&
                email.search('@') >= 1 &&
                email.lastIndexOf('.') > email.search('@') &&
                email.lastIndexOf('.') >= email.length-5
          	   )
  return email_res;
}

/* jquery */
$(document).ready(function() {
   
   // fancybox
   $("[rel=fancy]").fancybox({
	  'titlePosition' : 'inside',
	  'transitionIn' : 'elastic',
	  'transitionOut' : 'elastic'
  });
  
  // picfading
  $(".picfade").divFader();
  

  // topmeldung
  $("#topmeldunglink").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

  
  $("#topmeldung").css('display','block');
  $("#topmeldunglink").fancybox().trigger('click');        
  
  $(".meldunglink").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
    });

 
 });


/* jQuery divFader */
(function($) { $.fn.divFader = $.fn.divFader = function(delay)
  {
    delay = delay || 8000;
    initFader = function(el)
    {
      stopFader(el);
      el.items = $("div", el);
      el.items.not(":eq(0)").hide().end();
      el.currentitem = 0;
      startFader(el);
    };

   startFader = function(el) { el.tickfn = setInterval(function() { doTick(el) }, delay) };
   stopFader = function(el) { clearInterval(el.tickfn); };

   pauseFader = function(el) { el.pause = true; };
   resumeFader = function(el) { el.pause = false; };
   doTick = function(el)
   {
     if(el.pause) return;
     el.pause = true;
	 $(el.items[el.currentitem]).css("z-index", "2");
     $(el.items[el.currentitem]).fadeOut(1400,
       function() {
         $(this).hide();
      }
    );
	
    el.currentitem = ++el.currentitem % (el.items.size());
    $(el.items[el.currentitem]).css("z-index", "1");
	$(el.items[el.currentitem]).fadeIn(1600, function() { el.pause = false; } );

   };

   this.each( function() { if(this.nodeName.toLowerCase()!= "div") return; initFader(this); } )
   .hover( function() { pauseFader(this); }, function() { resumeFader(this); } );

   return this;
  };
})(jQuery);

