var $j = jQuery.noConflict();

function resize() {
		var d_width = document.body.offsetWidth;
		
		if ( d_width < 950 ) {
			$j("#description").fadeOut("slow");
			$j("#description2").css('left', 15 );
		} else {
			$j("#description2").css('left', d_width / 2 - 150 );
			$j("#description").show();
		}
}

$j(document).ready( function() {
		$j("#linkImprint").click( function(){ showImprint() });
		$j("#linkRegister").click( function() { showRegistration() } );
		$j("#linkTerms").click( function() { showTerms() });
		$j("#logo").click( function() { goHome() } );
		
		var url = window.location.search;
		if ( url.search(/register/) != -1 ) {
			showRegistration();
		}
});

function showImprint() {
			$j('#imprint').load('/imprint.seam');
			
			$j("#description").fadeOut("slow");
			$j("#description2").fadeOut("slow");
			$j("#homelogo").fadeOut("slow");
			$j("#advertisement").fadeOut("slow");
			$j("#loginBox").fadeOut("slow");
			$j("#register").hide("slow");
			$j("#terms").hide("slow");
			
			$j("#imprint").show("slow");
			
			window.setTimeout( "locateHQ()", 2000 );
}

function showRegistration() {
			$j('#register').load('/registerForm.seam');
			
			$j("#description").fadeOut("slow");
			$j("#description2").fadeOut("slow");
			$j("#loginBox").fadeOut("slow");
			$j("#advertisement").fadeOut("slow");
			$j("#imprint").hide("slow");
			$j("#terms").hide("slow");
			
			$j("#homelogo").show("slow");
			$j("#register").show("slow");
}

function showTerms() {
			$j('#terms').load('/terms.seam');
			
			$j("#description").fadeOut("slow");
			$j("#description2").fadeOut("slow");
			$j("#loginBox").fadeOut("slow");
			$j("#advertisement").fadeOut("slow");
			$j("#imprint").hide("slow");
			$j("#register").hide("slow");
			
			$j("#homelogo").show("slow");
			$j("#terms").show("slow");
}

function locateHQ() {
	var hq =  new GLatLng( 49.9996, 8.699153 );
	map.setCenter( hq , 17 );
	map.addOverlay( new GMarker( hq ) );
	map.setMapType( G_HYBRID_MAP );
}

function goHome() {
	$j("#imprint").hide("slow");
	
	$j("#homelogo").show("slow");
	$j("#advertisement").show("slow");
	$j("#loginBox").show("slow");
	$j("#description").show("slow");
	$j("#description2").show("slow");
	
	$j("#terms").hide("slow");
	$j("#register").hide("slow");
	
	window.setTimeout( "setUserCenter(); setStandardMapType();", 2000 );
}

function setStandardMapType() {
	map.setMapType( G_NORMAL_MAP );
}

function resizeHandler() {
	resize();
}