$(document).ready(function() {
	var slideShowTime = 6000;
	slideShowTimeFade = 4000;
	contactForm();
	socialBookmarks();
        /*var actualURL = document.URL;
        actualURL.search(/aktuelles.html/);
        if (actualURL.search(/aktuelles.html/)!=-1) {
            $(".news-catmenu news-catmenu-NO:first-child").addClass("news-catmenu-ACT");
           
        }
        */
	if (parseInt($('#eyecatcher IMG').size()) >= 2) {
        $("#eyecatcher IMG").css({opacity:0.0});
		$('#eyecatcher IMG:first-child').addClass("active").css({opacity:1});
		setInterval( "slideSwitch()",  slideShowTime);
	}

        if(parseInt($("#showroom-left-content .csc-textpic-imagecolumn li img").size()) >=2) {
            $("#showroom-left-content .csc-textpic-imagecolumn img").css({opacity:0.0});
            $("#showroom-left-content .csc-textpic-imagecolumn li:first-child").addClass("active");
            $("#showroom-left-content .csc-textpic-imagecolumn .active img").css({opacity:1});
            if (jQuery.browser.msie && parseInt(jQuery.browser.version)) {
               //$("#showroom-left-content .csc-textpic-imagecolumn .active img").css({width:"550px" });
            }
            setInterval( "categorySwitch()",  slideShowTime);
            
        }
});
function slideSwitch() {
	
    var $active = $('#eyecatcher IMG.active');
	$active.next().length == 0 ? $next = $('#eyecatcher IMG:first-child'): $next = $active.next();
	$active.addClass('last-active');
	$next.css({opacity : 0.0}).addClass('active').animate({opacity: 1.0},slideShowTimeFade, function () {
		$active.removeClass('active last-active');
	});
    
}
function categorySwitch() {
    
    var $active = $("#showroom-left-content .csc-textpic-imagecolumn li.active");
	$active.next().length == 0 ? $next = $('#showroom-left-content .csc-textpic .csc-textpic-imagecolumn li:first-child'): $next = $active.next();
	$active.addClass('last-active');
        $next.children("img").css({opacity : 0.0}).parent().addClass('active').children("img").animate({opacity: 1.0},slideShowTimeFade, function () {
		$active.removeClass('active last-active');
	});

}


function contactForm() {
	$("#content-top #mailform").parent().hide();
	$("#content-top #mailform").parent().before("<a href='#' id='contact-link'>Kontaktieren Sie uns</a>");
	$("#contact-link").toggle(	function () {
											$("#contact-link").text("Schließen");
											//$("#content-bottom").css({marginTop: "-10px"});
											$("#content-bottom").animate({marginTop: "+=70"});
											}, 
									function () {
												$("#contact-link").text("Kontaktieren Sie uns");
												$("#content-bottom").animate({marginTop: "-=70"});
												}
									);
	$("#contact-link").click(function () {
		$("#mailform").parent().slideToggle("slow"); 
		this.blur();
		return false;
	});
}

function socialBookmarks() {

	var sbHtml = '<a href="http://www.facebook.com/sharer.php?u='+encodeURI(location)+'&t='+encodeURI(document.title)+'" title="Auf Facebook ver&ouml;ffentlichen: '+document.title+'"><img src="fileadmin/templates/images/socialbookmarks/sb_bw_fb.jpg" alt="Facebook-icon" /></a><a href="http://www.linkedin.com/shareArticle?mini=true&url='+encodeURI(location)+'&title='+encodeURI(document.title)+'&summary={articleSummary}&source={articleSource}" title="Auf LinkedIn ver&ouml;ffentlichen: '+document.title+'" ><img src="fileadmin/templates/images/socialbookmarks/sb_bw_in.jpg" alt="LinkedIn-Logo" /></a><a href="http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURI(location)+'&title='+encodeURI(document.title)+'" title="Als Google-Bookmark speichern: '+document.title+'"><img src="fileadmin/templates/images/socialbookmarks/sb_bw_gg.jpg" alt="Google-Bookmark-Logo" /></a><a href="http://twitter.com/home?status='+encodeURI(location)+'" title="Diese Seite twittern: '+document.title+'"><img src="fileadmin/templates/images/socialbookmarks/sb_bw_tw.jpg" alt="Twitter-Logo" /></a><a href="https://www.xing.com/app/user?op=share&url='+encodeURI(location)+';title='+encodeURI(document.title)+'" title="Auf XING empfehlen: '+document.title+'"><img src="fileadmin/templates/images/socialbookmarks/sb_bw_xg.jpg" alt="XING-Logo" /></a><a href="http://www.sidenstein.com/rss.xml" title="Sidenstein Medien GmbH - Aktuelles (RSS 2.0)"><img src="fileadmin/templates/images/socialbookmarks/sb_bw_rss.jpg" alt="RSS-Feed-Logo" /></a>';
	var actualLocation = window.location.href

	//if (actualLocation.indexOf("sidwebsite-relaunch") > -1) {
		$("#all").append('<div id="socialbookmarks"></div>');
		$("#socialbookmarks").append(sbHtml);
	//}
	$("#socialbookmarks img").mouseenter(function () {
		if (this.oldSrc === undefined) {
			this.oldSrc = $(this).attr("src");
			this.newSrc = this.oldSrc.replace("bw_","");
		}
		
		$(this).stop(true,true).fadeOut(function() {
			$(this).attr("src",this.newSrc);
			$(this).fadeIn();
		});
	});
	$("#socialbookmarks img").mouseleave(function() {
		$(this).stop(true,true).attr("src",this.oldSrc);
		//$(this).stop(true,true).fadeOut(function() {	
		//	$(this).fadeIn();
		//});
	});
	/*if (actualLocation.indexOf("sidwebsite-relaunch/filmproduktion.html") > -1 || actualLocation.indexOf("sidwebsite-relaunch/interaktive-medien.html") > -1) {
		$("#all").append('<div id="socialbookmarks" style="margin-top: 20px !important;"></div>');
		$("#socialbookmarks").append(sbHtml);
	}
	*/
}

