$(document).ready(function(){	
	
	$("a[href=#kontakt]").click(function(){
		$("form#contact").show();
	});
	
	$("a.close").click(function(){
		$("form#contact").hide();
	});
	
	$("form#contact").draggable({delay:0.3});
	
	$("a[rel='lightbox']").lightBox({
		imageLoading:images.loading,
		imageBtnPrev:images.prev,
		imageBtnNext:images.next,
		imageBtnClose:images.close,
		imageBlank:images.blank,
		txtImage: 'Foto',
		txtOf: 'von'
	});
	
	$("h3 img").mouseover(function(e){
		$("div.imagesize")
			.css("top",(parseInt(e.pageY)+20)+"px")
			.css("left",(parseInt(e.pageX)+20)+"px")
			.show()
			.children("img").attr("src",$(this).attr("alt"))
			.next(".title").text($(this).attr("class"));
	}).mousemove(function(e){
		$("div.imagesize")
			.css("top",(parseInt(e.pageY)+20)+"px")
			.css("left",(parseInt(e.pageX)+20)+"px");
	}).mouseout(function(e){
		$("div.imagesize").hide();
	});
	
	var conveyor = $(".content-conveyor", $("#sliderContent")),
	item = $(".item", $("#sliderContent"));

	$(".accordion").accordion({
		navigation:true,
		autoHeight:false,
		event:"mouseover"
	});

	var maxVal = (item.length * parseInt(item.css("height"))) - parseInt($(".viewer", $("#sliderContent")).css("height"));
	//config
	var sliderOpts = {
		orientation: "vertical",
		value: maxVal,
		max: maxVal,
		slide: function(e, ui){
			conveyor.css("top", "-" + (maxVal-ui.value) + "px");
		}
	};
	//create slider
	$("#slider").slider(sliderOpts);
	
	$("#contact").validate({
		highlight: function(element, errorClass){
			$(element).addClass(errorClass).mouseover(function(e){
				if($(this).hasClass("email")){
					$("div.pflicht").text(pflichtfeld.email);}
				else{
					$("div.pflicht").text(pflichtfeld.text);}
				$("div.pflicht")
					.css("top",(parseInt(e.pageY)-33+getScrollY())+"px")
					.css("left",(parseInt(e.pageX)-39)+"px")
					.show();
			}).mousemove(function(e){
				$("div.pflicht")
					.css("top",(parseInt(e.clientY)-33+getScrollY())+"px")
					.css("left",(parseInt(e.clientX)-39)+"px");
			}).mouseout(function(){
				$("div.pflicht").hide();
			});
	  	},
	  	unhighlight: function(element, errorClass, validClass){
	  		$(element).removeClass(errorClass).mouseover(function(){
				$("div.pflicht").hide();
			}).mousemove(function(){
				$("div.pflicht").hide();
			});			 	
	  	},			  				  						
		errorPlacement: function(error, element){}											
	});
	
});

function getScrollY(){
	var scrOfY = 0;
	if(typeof(window.pageYOffset) == 'number'){
		/* Für Netscape */
		scrOfY = window.pageYOffset;
	}else if(document.body && document.body.scrollTop){
		/* Für DOM */
		scrOfY = document.body.scrollTop;
	}else if(document.documentElement && document.documentElement.scrollTop){
		/* Für IE6 */
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}
