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 lenght, @, .@, !.xxxxx  */
  email_res = ( emailchars_res &&
                email.length >= 6 &&
                email.search('@') >= 1 &&
                email.lastIndexOf('.') > email.search('@') &&
                email.lastIndexOf('.') >= email.length-5
          	   )
			   
  return email_res;
}

var form_error_mark_border  = "1px solid #fe0125";
var form_error_reset_border = "1px solid #1f2849";

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; 
}



/*
 * Slideshow
 */

   function run_once(slideobj) {
     time = parseInt( (196+(parseInt(slideobj.position().left)-4)) * (8190/195));
     slideobj.animate({left:'-192'},time,'linear',function() {
       $(this).children("img:first").insertAfter($(this).children("img:last"));
	   $(this).css('left','3px');
	   run_once(slideobj);
     });
   }
   
   function show_img(file,path,left,top) {
	 $('#imgzoom').css('display','none');
	 $('#imgzoom').children('img:first').attr('onLoad','');
	 $('#imgzoom').children('img:first').attr('src','/images/trans.gif');
	 $('#imgzoom').children('img:first').attr('onLoad','show_img_loaded('+left+','+top+');');
	 $('#imgzoom').children('img:first').attr('src',path+file);
   }

   function show_img_loaded(left,top) {
   	 if($('#imgzoom').width() > 50 && $('#imgzoom').children('img:first').attr('src') != '/images/trans.gif') 
	  {
	   w=parseInt($(document).width());
	   if($(".slideshow").length!=0) { minl=parseInt($(".slideshow").offset().left); } else { minl=0; }
	   if(left<minl) left=minl;
	   if(left+imgw+20>w) left=w-(imgw+20);
	   if(top<0) top=0;
	   if(left<0) left=0;
	   $('#imgzoom').css('top',top+'px').css('left',left+'px').fadeIn(200);
	   $('#imgzoom').click(function() { $('#imgzoom').fadeOut(100); });
	   $('.zoomclose').click(function() { $('#imgzoom').click() });
	  }
   }

var imgw=0;
var imgh=0;
$(document).ready(function() {
   
   if($(".slidebox").length!=0) {
     imgw=512;
     imgh=342;
     slideobj=$(".slidebox");
	 slideobj.children("img")
	   .mouseover(function() { slideobj.stop(true, false); })
	   .mouseout(function() { run_once(slideobj); })
	   .click(function() { show_img(/([^/]+)$/.exec($(this).attr('src'))[1],'/images/slideshow/big/',parseInt($(this).offset().left),parseInt($(this).offset().top)-imgh-24); });
     run_once(slideobj);
   }
   
   if($(".ansprechpartner").length!=0) {
     imgw=192;
     imgh=184;
     $(".ansprechpartner").click(function() { show_img(/([^/]+)$/.exec($(this).attr('src'))[1],'/images/ansprechpartner/big/',parseInt($(this).offset().left-imgw+75),parseInt($(this).offset().top)-imgh+80); });
   }
   
});