function getContent( name ) {
	$("#mainContent").load("?c="+name, {}, function() { 
			$('#main').fadeIn("fast");
			scrollTo('#mainContent');
		});	
}

function getContentInto( divName, content ) {
	var target = "#" + divName;
	$(target).load("?c="+content, {}, function() {
			$(target).fadeIn("fast");
		});	
}

function scrollTo( t ) {
	var target = $( t );
	if (target.length) {
		var top = target.offset().top;
		$('html,body').animate({scrollTop: top}, "fast");
	}
}

function sendNewsletter() {
	var email = $('#email').val();

	if( validateEmail( email ) ) {
		$( '#newsletter' ).load( "mail.php?email=" + email, {}, function () {
		} );
	} else {
		alert( email + " ist keine Email Adresse!" );
	}
}

function sendFanMap() {
	var first = $('#firstname').val();
	var postal = $('#postalcode').val();
	var country = $('#country').val();

	if( first != null && postal != null ) {
		$( '#joinAsFan' ).load( "fanmap.php?first=" + first + "&postal=" + postal + "&country=" + country, {}, function () {
		} );
	}
	else {
		alert( "Bitte gib Deinen Vor-, PLZ und Land an!" );
	}
}

function validateEmail( email ) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ 
	return email.match(re) ;
}

function switchLogo() {
	if( $('#logo').hasClass('logo1') )
        	$('#logo').removeClass('logo1').addClass('logo2');
	else
		$('#logo').removeClass('logo2').addClass('logo1');
}

function getURLParameter(name) {
    return unescape(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}

$(document).ready(function() {
	var par = getURLParameter('m');
	if( par != 'null' )
		getContent(par);
});

