/*
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |c|r|e|a|t|i|v|e|c|o|c|k|s|.at
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 *	lichtblau_js.css
 *	javascript // 22.06.2010
 *	http://www.lichtblau.com
 *	
 */

/***************************
	LENI SOUND
***************************/

 function playSound() {
 document.getElementById("dummy").innerHTML=
 "<embed src=\"images/wauwau.wav\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
 }

 
/***************************
	INPUT CHANGE
***************************/


function inputchange() {
	if(document.loginform.username.value == ""){
		document.loginform.username.value = "Benutzername";
		document.loginform.username.className = "text-input";
	}
	if(document.loginform.password.value == ""){
		document.loginform.password.value = "Password";
		document.loginform.password.className = "text-input";
	}
	if(document.contactform.name.value == ""){
		document.contactform.name.value = "Name";
	}
	if(document.contactform.mail.value == ""){
		document.contactform.mail.value = "E-Mail";
	}
	if(document.contactform.telefon.value == ""){
		document.contactform.telefon.value = "Telefon";
	}
	if(document.contactform.betreff.value == ""){
		document.contactform.betreff.value = "Betreff";
	}
	if(document.contactform.nachricht.value == ""){
		document.contactform.nachricht.value = "Ihre Nachricht";
	}
	
}

/***************************
	SLIDESHOW
***************************/

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',4000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
		
}

// Image Slide Show 2

function slideShow2() {

	//Set the opacity of all images to 0
	$('#gallery2 a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery2 a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery2 .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery2 .caption').css({width: $('#gallery2 a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery2 .content').html($('#gallery2 a:first').find('img'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery2()',4000);
	
}

function gallery2() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery2 a.show')?  $('#gallery2 a.show') : $('#gallery2 a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery2 a:first') :current.next()) : $('#gallery2 a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery2 .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery2 .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	$('#gallery2 .content').html(caption);
		
}

/***************************
	UNTERMENU
***************************/

function untermenuchange(wat) {
	document.getElementById('amenu1').className = 'invisible';
	document.getElementById('amenu2').className = 'invisible';
	document.getElementById('amenu3').className = 'invisible';
	document.getElementById('amenu4').className = 'invisible';
	document.getElementById('amenu5').className = 'invisible';
	document.getElementById('amenu6').className = 'invisible';
	document.getElementById(wat).className = 'untermenu';
}

/***************************
	GOOGLE MAPS
***************************/

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		var markerpos = new GLatLng(48.096154, 16.277297);
		var marker = new GMarker(markerpos);
		map.setCenter(new GLatLng(48.076154, 16.277297), 14);
		GEvent.addListener(marker, "click", function() {
        var html = "<div class='lageplaninfo'><b>Versicherungsbüro Lichtblau</b><br />Johannesstraße 25<br />2344 Maria Enzersdorf<br /><a href='http://maps.google.de/maps?daddr=Johannesstra%C3%9Fe+25,+2344+Maria+Enzersdorf&geocode=3371268293612202208,48.727534,8.850089&dirflg=&saddr=&f=d&hl=de&dq=SOTEC&sll=48.096156,16.277293&sspn=0.01158,0.033023&cid=48727534,8850089,11535059465088755623&ie=UTF8&ll=51.248163,11.887207&spn=7.635285,20.76416&z=6&om=0' target='_blank'><u>Route berechnen</u></a></div>";
        marker.openInfoWindowHtml(html);
      });
      map.addOverlay(marker);
      GEvent.trigger(marker, "click");
	  map.removeMapType(G_HYBRID_MAP);
	  map.addControl(new GMapTypeControl());
	  map.addControl(new GSmallMapControl());
	  marker.openInfoWindowHtml(info);
	  map.addControl(new GOverviewMapControl());
      }
    }
	
/***************************
	MAIL VALDIATION
***************************/

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/);
	return pattern.test(emailAddress);
	}
	
	
