// JavaScript Document

/*
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |c|r|e|a|t|i|v|e|c|o|c|k|s|.at
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 *	Standardscripts | 15.09.2010
 *	http://www.creativecocks.at
 *	
 */
 
 // Form Handling - focus & blur
 
 $('input[type=text],textarea').focus(function () {
	 if(($(this).val() == "Name")||
	 	($(this).val() == "Email")||
		($(this).val() == "Ihre Nachricht")){
			
	 		$(this).val("");
	 }
 });
 
 $('input[type=text],textarea').blur(function () {
	if(this.value == ""){
		this.value = this.defaultValue;  
	}
 });
 
 // Contact Form Submit
 
 $('#contactform').submit(function() {

	if(($('#name').val() == " ")||
		($('#email').val() == " ")||
		($('#content').val() == " ")){
		$("#error").html("Fehler: Bitte füllen Sie alle Felder korrekt aus!").show();
		return false;
	}else {
		email = $('#email').val();
		filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(email)) {
  			return true;
		}else{
			$("#error").html("Fehler: Bitte füllen Sie alle Felder korrekt aus!").show();
		return false;
		}
	}
	 
 });
 
 $('#submit').click(function () {
 	$('#contactform').submit()
 });
 
 // backstretch
 
  $.backstretch("images/backstretch_bg.jpg");
  
 // google maps
 
 function initialize() {
    var myLatlng = new google.maps.LatLng(47.979341,16.274687);
	var myDown = new google.maps.LatLng(47.984341,16.274387);
    var myOptions = {
      zoom: 14,
      center: myDown,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var contentString = 
		'<div id="anfahrtinfo">'+
        '<h1>Udo Landauer</h1>'+
		'<p>Haidhofstrasse 108<br>2500 Baden<br>Austria</p><br>'+
        '<a href="http://goo.gl/maps/PWwe" target="_blank">Route berechnen</a></div>';
        
    var infowindow = new google.maps.InfoWindow({
        content: contentString,
		Height: 500
    });

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        title: 'Uluru (Ayers Rock)'
    });
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
	infowindow.open(map,marker);
  }
  
  // fancybox
  
  $(".picture").fancybox({
		'titleShow'     : false
	});

