$(document).ready(function(){
$("#smallPictures img").click(function(){
$(this).clone().appendTo(".bigPicture").attr("width", "600").attr("height", "350").css("opacity", "0").animate({opacity: '1'}, 500);
});
$("#mainNavigation").click(function(){
$("#mainNavigation").animate({height:'215px'},800);
});
//Larger thumbnail preview 
$("ul.thumb li").hover(function() {
$(this).css({'z-index' : '10'});
$(this).find('img').addClass("hover").stop()
.animate({
marginTop: '-120px', 
marginLeft: '-160px', 
top: '50%', 
left: '50%', 
width: '300px', 
height: '197px',
padding: '0px' 
}, 200);
} , function() {
$(this).css({'z-index' : '0'});
$(this).find('img').removeClass("hover").stop()
.animate({
marginTop: '0', 
marginLeft: '0',
top: '0', 
left: '0', 
width: '128px', 
height: '84px', 
padding: '0px',
}, 400);
});
//Swap Image on Click
$("ul.thumb li a").click(function() {
var mainImage = $(this).attr("href"); //Find Image Name
$("#main_view img").attr({ src: mainImage });
return false;
});
$("a[rel=example_group]").fancybox({
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
 return '<span id="fancybox-title-over">' + title + '</span>';
}
});
$("img#start").hide();
$(".preload").hide();
$(window).load( function() {
$(".preload").fadeIn('1500');
});
$(".preload_references").hide();
$(window).load( function() {
$(".preload_references").fadeIn('1500');
$("#projectPictureGallery").css("backgroundColor", "#E4E4E4");
});
$("li#products").hover(function(){
$("img.products").css("z-index", "2");
$("img.products").stop().animate({
opacity: '1'
}, 1000);
}, function () {
$("img.products").css("z-index", "10");
$("img.products").stop().animate({
opacity: '0'
}, 1000);
});
$("li#service").hover(function(){
$("img.service").css("z-index", "2");
$("img.service").stop().animate({
opacity: '1'
}, 1000);
$(this).stop().animate({backgroundColor:"#E4ECEE"}, 750)
}, function () {
$("img.service").css("z-index", "10");
$("img.service").stop().animate({
opacity: '0'
}, 1000);
$(this).stop().animate({backgroundColor:"#FFFFFF"}, 750)
});
$("li#projects").hover(function(){
$("img.projects").css("z-index", "2");
$("img.projects").stop().animate({
opacity: '1'
}, 1000);
}, function () {
$("img.projects").css("z-index", "10");
$("img.projects").stop().animate({
opacity: '0'
}, 1000);
});
$("ul.withhover li a").hover(function() {
$(this).find("img").stop().animate({
opacity: '1',
}, 300)
}, function () {
$(this).find("img").stop().animate({
opacity: '.4',
}, 300)
});
$("ul.withhover li a").click(function() {
$(this).find("img").delay(700).animate({
opacity: '.4',
}, 300)
});
$("form#newsletterForm").hide();
$("div#openNewsletterForm a").attr("href", "javascript:void(0);");
$("div#openNewsletterForm").click(function() {
$(this).hide();
$("form#newsletterForm").show(500);
});
$("input#search").click(function(){$(this).val("")});
var i = 0;
var cindex = "";
var urlindex = [];
var urltemp = "";
var cindextemp = "";
var currentThis = "";
var maxLength = $(".fotothek > ul > li").length;
for ( i = 0; i < maxLength; i++ ) {
if ($(".fotothek > ul > li:eq("+i+") div > a").attr("href") === "javascript:void(0);") {
$(".fotothek > ul > li:eq("+i+")").addClass("nophoto");
} else {
urlindex[i] = $(".fotothek ul > li:eq("+i+") div a").attr("href");
$(".fotothek > ul > li:eq("+i+") div > a").attr("href", "javascript:void(0);");
}
}
function showLargeImage(cindex, currentThis) {
if (!$(currentThis).hasClass("active")) {
$(".fotothek li#prevImg, .fotothek li#nextImg").show();
if (cindex === 0) {
$(".fotothek li#prevImg").hide();
}
if (cindex === maxLength-1) {
$(".fotothek li#nextImg").hide();
}
$("#large").show();
$(".fotothek #large li.large").remove();
$(".fotothek li.active").removeClass("active");
$(currentThis).attr("class", "active");
$(currentThis).find("i.lens").removeClass("plus").addClass("minus");
$(currentThis).clone().appendTo(".fotothek div#large div.large ul").addClass("large").removeClass("active");
$(".fotothek #large li").find("a img").attr("src", urlindex[cindex]);
}
}
$(".fotothek > ul > li").click( function() {
if ( $(this).hasClass("nophoto") == false) {
cindex = $(this).index();
$("#service").html(cindex);
showLargeImage(cindex, this);
}
});
$(".fotothek li#nextImg").click( function() {
$(".fotothek li#prevImg, .fotothek li#nextImg").show();
if (cindex === maxLength-2) {
$(".fotothek li#nextImg").hide();
}
if (cindex < maxLength-2) {
$(".fotothek li#prevImg").show();
}
cindex++;
$("#service").html(cindex);
nextElement = $(".fotothek ul > li:eq(" + cindex + ")");
$(".fotothek #large li.large").remove();
$(".fotothek li.active").removeClass("active");
$(".fotothek li:eq("+ cindex +")").addClass("active");
$(nextElement).clone().appendTo(".fotothek div#large div.large ul").addClass("large").removeClass("active");
$(".fotothek #large li").find("a img").attr("src", urlindex[cindex]);
}
);
$(".fotothek li#prevImg").click( function() {
$(".fotothek li#prevImg, .fotothek li#nextImg").show();
if (cindex === 1 || cindex === 0) {
$(".fotothek li#prevImg").hide();
}
if (cindex > 0) {
$(".fotothek li#nextImg").show();
}
cindex--;
$("#service").html(cindex);
prevElement = $(".fotothek ul > li:eq(" + cindex + ")");
$(".fotothek #large li.large").remove();
$(".fotothek li.active").removeClass("active");
$(".fotothek li:eq("+ cindex +")").addClass("active");
$(prevElement).clone().appendTo(".fotothek div#large div.large ul").addClass("large").removeClass("active");
$(".fotothek #large li").find("a img").attr("src", urlindex[cindex]);
});
$(".fotothek #large div.large li div a img").live("click", function(){
$(this).parents("li").remove();
$("#large").hide();
$(".fotothek ul > li:eq(" + cindex + ")").removeAttr("class");
$(".fotothek ul > li:eq(" + cindex + ")").find("i.lens").removeClass("minus").addClass("plus");
});
});
