// JavaScript Document
$(document).ready(function() {
						   
	
	
	$(".thumb").hover( img_over, img_out ).click( img_click );
	
	$("#left_model").click( left_model );
	$("#right_model").click( right_model );
						   


	$("#left").click(function (){
		breite = $("#scrolldiv").width();
		standpunkt = $("#scrolldiv").css("marginLeft").replace(/px/, "").replace(/-/, "");
		rest = standpunkt;
		if(rest <= 810){mleft = 0}
		if(rest > 810){mleft = standpunkt - 810}
			$("#scrolldiv").animate({ 
			marginLeft: '-'+mleft+'px'
			 }, 500 );
	});
	
	$("#right").click( function (){
		
		breite = Number($("#scrolldiv").width());
		standpunkt = Number($("#scrolldiv").css("marginLeft").replace(/px/, ""));
		rest = Number(breite + standpunkt);
		if(rest < 1620){mleft = rest - 810 - standpunkt; }
		if(rest > 1620){mleft = 810 - standpunkt; }+
			$("#scrolldiv").animate({ 
			marginLeft: '-'+mleft+'px'
			 }, 500 );
	});
	
	
	$("#fotos").click( function (){
    
	
	$.ajax({
				type: 'POST',
				url: '/ajax/fotos.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#fotos").addClass("hover");
						$(".ueb2_unt").css({visibility:"hidden"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	
	$("#beschreibung").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/beschreibung.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#beschreibung").addClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	$("#details").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/detail.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#details").addClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	$("#honorar").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/honorar.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#honorar").addClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	$("#buchen,.buchen").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/buchen.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#buchen").addClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	$("#abo,.abo").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/abo.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$("#abo").addClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	$("#abo_bestellung").click( function (){
		$.ajax({
				type: 'POST',
				url: '/ajax/abo_bestellung.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
	});
	
	
});


function left_model(){
	breite = Number($("#scrolldiv_model").width());
	standpunkt = Number($("#scrolldiv_model").css("marginLeft").replace(/px/, "").replace(/-/, ""));
	rest = standpunkt;
	if(rest <= 810){mleft = 0}
	if(rest > 810){mleft = standpunkt - 810}
		$("#scrolldiv_model").animate({ 
        marginLeft: '-'+mleft+'px'
         }, 500 );
}
function right_model(){
	
	breite = Number($("#scrolldiv_model").width());
	standpunkt = Number($("#scrolldiv_model").css("marginLeft").replace(/px/, ""));
	rest = Number(breite + standpunkt);
	if(rest < 1620){mleft = rest - 810 - standpunkt; }
	if(rest >= 1620){mleft = 810 - standpunkt; }
		$("#scrolldiv_model").animate({ 
        marginLeft: -mleft+'px'
         }, 500 );
}



function img_over() {
    if ($(this).hasClass("active")) return;
    $(this).stop().animate({opacity: 1}, "fast");
}
function img_out() {
    if ($(this).hasClass("active")) return;
    $(this).stop().animate({opacity: 0.5}, "slow");
}


function img_click() {
    $(".active").fadeTo(0, 0.5).removeClass("active");
    $(this).fadeTo(0, 1.0).addClass("active");
	
	$.ajax({
				type: 'POST',
				url: '/ajax/fotos.php',
				data: 'id='+this.id,
				success: function(result) {
					if(result != "false") {
						$("#scrolldiv_model").css({marginLeft:0+'px'});
						$("#scrolldiv_model").html(result);
						$(".navi_unten").css({visibility:"visible"});
						$(".navi_unten a").removeClass("hover");
						$("#fotos").addClass("hover");
						$(".ueb2_unt").css({visibility:"hidden"});
					} 
				}
		  })
}

function bestell()
{
		$.ajax({
				type: 'POST',
				url: '/ajax/abo_bestellung.php',
				data: '',
				success: function(result) {
					if(result != "false") {
						
						$("#scrolldiv_model").html(result);
						$(".navi_unten a").removeClass("hover");
						$(".ueb2_unt").css({visibility:"visible"});
						$("#scrolldiv_model").css({marginLeft:'0px'});
					} 
				}
		  })
};
	

