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;
}

var form_error_mark_border  = "1px solid #000000";
var form_error_reset_border = "1px solid #777777";

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; 
}

/* cre8ives.de : fotoframe */
$(document).ready(function() {
   $("img.foto").each( function() { 
   var w=$(this).width();
   var h=$(this).height();
   d=$("<div class='fotoframe'>").css({'display': 'block', 'width' : (w+10+16)+'px', 'height' : (h+10+16)+'px', 'position' : 'relative'});
   frame1=$("<div style='height:35px;width:69px;position:absolute;' class='png_fotoframe1'>").append("<img src='/images/fotoframe1.png' style='height:35px;width:69px;'/>");
   frame1b=$("<div style='height:"+(h+10)+"px;width:69px;position:absolute;' class='png_fotoframe1'>").append("<img src='/images/fotoframe1.png' style='height:"+(h+10)+"px;width:69px;'/>");
   frame2=$("<div style='height:35px;width:"+(w+10)+"px;position:absolute;' class='png_fotoframe2'>").append("<img src='/images/fotoframe2.png' style='height:35px;width:"+(w+10)+"px;' />");
      
   lt = $("<div class='lt' style='position:absolute;top:0px;left:0px;width:14px;height:14px;overflow:hidden;'>").append(frame1.clone().css({"top":"0px","left":"-14px"})).appendTo(d);
   rt = $("<div class='rt' style='position:absolute;top:0px;left:"+(w+6)+"px;width:20px;height:14px;overflow:hidden;'>").append(frame1.clone().css({"top":"0px","left":"-29px"})).appendTo(d);
   rb = $("<div class='rb' style='position:absolute;top:"+(h+6)+"px;left:"+(w+6)+"px;width:20px;height:20px;overflow:hidden;'>").append(frame1.clone().css({"top":"-15px","left":"-29px"})).appendTo(d);
   lb = $("<div class='lb' style='position:absolute;top:"+(h+6)+"px;left:0px;width:14px;height:20px;overflow:hidden;'>").append(frame1.clone().css({"top":"-15px","left":"-14px"})).appendTo(d);
      
   lc = $("<div class='lc' style='position:absolute;top:14px;left:0px;width:14px;height:"+(h-8)+"px;overflow:hidden;'>").append(frame1b.clone().css({"top":"-6px","left":"0px"})).appendTo(d);
   rc = $("<div class='rc' style='position:absolute;top:14px;left:"+(w+6)+"px;width:20px;height:"+(h-8)+"px;overflow:hidden;'>").append(frame1b.clone().css({"top":"-6px","left":"-49px"})).appendTo(d);
     
   ct = $("<div class='ct' style='position:absolute;top:0px;left:14px;width:"+(w-8)+"px;height:14px;overflow:hidden;'>").append(frame2.clone().css({"top":"0px","left":"-6px"})).appendTo(d);
   cb = $("<div class='cb' style='position:absolute;top:"+(h+6)+"px;left:14px;width:"+(w-8)+"px;height:20px;overflow:hidden;'>").append(frame2.clone().css({"top":"-15px","left":"-6px"})).appendTo(d);

   
   zoomtag=$(this).next("img['.zoom']");
   d.insertBefore(this);
   $(this).appendTo(d).css({'cursor':'pointer','cursor':'hand'});
   $(zoomtag).appendTo(d);

   });
});

/* lightbox plugin */
$(document).ready(function() {
	$('a[rel*="lightbox"]').lightBox({
		txtImage: 'Bild',
		txtOf: 'von'
	}
	);
});

$(document).ready(function() {
	
	/* Suchformular */
	var $sucheInputs = $('#suche input');
	sucheInput0Val = "Name oder Branche";
	$sucheInputs.eq(0)
		.val(sucheInput0Val)
		.focusin(function(){ if ($(this).val() == sucheInput0Val) { $(this).val(""); } })
		.focusout(function(){ if ($.trim($(this).val()) == "") { $(this).val(sucheInput0Val); } });
	sucheInput1Val = "Ort oder Stadt";
	$sucheInputs.eq(1)
		.val(sucheInput1Val)
		.focusin(function(){ if ($(this).val() == sucheInput1Val) { $(this).val(""); } })
		.focusout(function(){ if ($.trim($(this).val()) == "") { $(this).val(sucheInput1Val); } });

	// change 'QT' on submit, depends on 'View'
	$('#suche').submit(function(e){
	 if($("#suche input[@name='View']:checked").val() == '8') 
			$("#suche input[name='QT']").val('18');
	 else	$("#suche input[name='QT']").val('');
	});
	
});

/* check flash */
(function ($) {
	if (typeof $.flash === "undefined" || !$.flash) {
		var flash = false;
		$.extend(flash);
	}
	
	var flashSupported = function (p) {
		if (window.ActiveXObject) {
			$.flash = false;
			for (i = 0; i < p.actx.length; i++) {
				try {
					new ActiveXObject(p.actx[i]);
					$.flash = true;
				} catch (e) {}	
			}
		} else {
			$.each(navigator.plugins, function () {
				if (this.name.match(p.plugin)) {
					$.flash = true;
					return false;
				} else {
					$.flash = false;
				}
			});
		}
	};
	
	flashSupported({
		actx: ["ShockwaveFlash.ShockwaveFlash", "ShockwaveFlash.ShockwaveFlash.3", "ShockwaveFlash.ShockwaveFlash.4", "ShockwaveFlash.ShockwaveFlash.5", "ShockwaveFlash.ShockwaveFlash.6", "ShockwaveFlash.ShockwaveFlash.7", "ShockwaveFlash.ShockwaveFlash.8", "ShockwaveFlash.ShockwaveFlash.9", "ShockwaveFlash.ShockwaveFlash.10"],
		plugin: /flash/gim
	});

})(jQuery);


/* swap images fadeIn/Out */
function swapFrontBackCover() {
	$("#swfbuch-menubox").children('div:eq(0)').children('div:eq(1)').fadeIn('2000');
	$("#swfbuch-menubox").children('div:eq(0)').children('div:eq(0)').fadeOut('2000', function() 
		{ 
			$e1=$(this);
			$e2=$(this).next();
			$e1.remove().insertAfter($e2); window.setTimeout("swapFrontBackCover()",5000); 
		});
}

/* ready */
$(document).ready(function(){
 if(jQuery.flash) {
 	$("#swfbuch-menubox").append('<object type="application/x-shockwave-flash" data="/swf/simag-buch.swf" width="178" height="198" id="swfbuch" style="z-index:1;" class="hand"><param NAME="wmode" VALUE="transparent"><param name="menu" value="FALSE" /><param name="src" value="/swf/simag-buch.swf" /></object>');
 } 
 else 
 {
	$("#swfbuch-menubox").append('<div style="position:relative;display:block;width:178px;height:198px;"><div id="book-front" style="position:absolute;display:block;width:178px;height:198px;"><img src="/images/book-front-noflash-simag.gif" alt="Das BLAUE Telefon- und Branchenbuch" /></div><div id="book-back" style="display:none;position:absolute;width:178px;height:198px;"><img src="/images/book-back-noflash-simag.gif" alt="Das BLAUE Telefon- und Branchenbuch" /></div></div>');
	window.setTimeout("swapFrontBackCover()",5000);
 }

 /* $('a[@rel*=lightbox]').lightBox(); */
});
 

