$(document).ready(function() {

//Fehlermeldungen beim Kontaktformular entfernen
	$('.formbody p.error').click(function() {
  		$(this).fadeOut('slow', function(){ 
  			$(this).remove();
  		});
	});


//Gutscheinformular
$('.custom1-gen, .custom2-gen').hide();
$('#opt_39_0').click(function() {
	if($('#opt_39_0').is(':checked')) {
		$('.custom1-gen').fadeIn();
		} else {
		$('.custom1-gen').fadeOut();
	}
});
$('#opt_39_1').click(function() {
	if($('#opt_39_1').is(':checked')) {
		$('.custom2-gen').fadeIn();
		} else {
		$('.custom2-gen').fadeOut();
	}
});



/*Buchenlink
$(".buchen_link").click(function(event){
	event.preventDefault();
	var url=$(this).attr('href');
	requestCrossDomain(url, function(results) {
		$('.buchen_box').html(results);
	});
});*/

//Buchenlink
$('.buchen_box').hide();
$(".buchen_link").click(function(event){
	event.preventDefault();
	$('.buchen_box').fadeIn();
});



        $("#nachrichtenliste_container .image_container").corner("5px");
        $("#arrangementsliste_container .image_container").corner("5px");
        $("#step1").corner("5px");
        $("#step2").corner("5px");
        $("#step3").corner("5px");

function wochentag(tag){
	var wochentage=new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");
	if(tag>6){
		tag=0;
	}
	return wochentage[tag];
}

$(function() {
	$.wetter({
		location: 'attendorn, germany',
		unit: 'c',
		success: function(weather) {

			var datum=new Date();
			var heute=wochentag(datum.getDay());
			var morgen=wochentag(datum.getDay()+1);
			$("#wetter").append('<h5>Wetter - Attendorn</h5>');
			$("#wetter").append('<img src="'+weather.image+'" class="wetter_heute"/><p><strong>'+heute+':</strong><br /> '+weather.low+'° '+weather.units.temp+' - '+weather.high+'° '+weather.units.temp+'</p><hr class="clear" />');
			$("#wetter").append('<img src="'+weather.tomorrow.image+'" class="wetter_morgen"/><p><strong>'+morgen+':</strong><br /> '+weather.tomorrow.low+'° '+weather.units.temp+' - '+weather.tomorrow.high+'&deg '+weather.units.temp+'</p><hr class="clear" />');
		},
		error: function(error) {
			$("#wetter").html('<p>'+error+'</p>');
		}
	});
});
});

// Accepts a url and a callback function to run.
function requestCrossDomain( site, callback ) {

	// If no url was passed, exit.
	if ( !site ) {
		alert('No site was passed.');
		return false;
	}

	// Take the provided url, and add it to a YQL query. Make sure you encode it!
	var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml&callback=?';

	// Request that YSQL string, and run a callback function.
	// Pass a defined function to prevent cache-busting.
	$.getJSON( yql, cbFunc );

	function cbFunc(data) {
		// If we have something to work with...
		if ( data.results[0] ) {
			// Strip out all script tags, for security reasons.
			// BE VERY CAREFUL. This helps, but we should do more.
			data = data.results[0].replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');

			// If the user passed a callback, and it
			// is a function, call it, and send through the data var.
			if ( typeof callback === 'function') {
				callback(data);
			}
		}
		// Else, Maybe we requested a site that doesn't exist, and nothing returned.
		else throw new Error('Nothing returned from getJSON.');
	}
}
