/*
 * home.js
 *
 * @name        home
 * @package     www.foto-de-sign.de
 * @category    script
 * @author      Marcel Jänicke Software <mail@mj-software.net>
 * @copyright   © Marcel Jänicke Software, 2011 - Alle Rechte vorbehalten.
 * @since       19.11.2011
 * @modified    22.11.2011
 */
var scrolled = false;

function checkContent() {
	$(window).trigger("resize");
}

function animateOpacity() {
	var opacity = $(window).scrollTop() != 0 ? 0.1 : 1;
	$("#imprintRight, #imprintLeft").animate({
		opacity: opacity
	}, 300);
}

function addBookmark() {
	if(window.sidebar) { // Geckos wie FF
		window.sidebar.addPanel(document.title || location.href, location.href, "");
	} else if(window.external) { // IE
		window.external.AddFavorite(window.location.href, document.title || location.href)
	} else {
		alert("Hinweis:\nIhr Browser unterstützt leider nicht die Funktion zum Setzen eines Lesezeichens aus der Webseite heraus.");
	}
}

$(window).scroll(function () {
	if ($(window).scrollTop() != 0 && !scrolled) {
		scrolled = true;
		animateOpacity();
	} else if ($(window).scrollTop() == 0 && scrolled) {
		scrolled = false;
		animateOpacity();
	}
 });

$(window).resize(function() {
	if ($("#contactVisitcard").length > 0) {
		$("#contactVisitcard").css("right", ($(window).width() - $("#navigation").width()) / 2 + 20);
		$("#contactVitaBox").css("right", $(window).width() -$("#contactVisitcard").offset().left + 10);
	} else if ($("#imprintLeft").length > 0) {
		$("#imprintLeft").css("left", ($(window).width() - $("#navigation").width()) / 2 + 160);
		if (parseInt($("#imprintLeft").css("left")) < 160) {
			$("#imprintLeft").css("left", 160);
		}
		$("#imprintBottom").css("left", ($(window).width() - $("#navigation").width()) / 2 + 160);
		$("#imprintBottom").css("padding-right", ($(window).width() - $("#navigation").width()) / 2 + 160);
		if (parseInt($("#imprintBottom").css("left")) < 160) {
			$("#imprintBottom").css("left", 160);
		}
		$("#imprintBottom").css("top", $("#imprintLeft").offset().top +  $("#imprintLeft").height() + 80);
		$("#imprintRight").css("right", ($(window).width() - $("#navigation").width()) / 2 + 180);
	}
});
