
$(document).ready(function() 
{
	

/************************************************ Scrollbalkne */
	var pane = $('.scroll-pane');
	pane.jScrollPane(
		{
			hijackInternalLinks: false,
			showArrows: false,
			animateScroll: true,
			autoReinitialise: false
		}
	);
	var api = pane.data('jsp');
	

	var pane2 = $('#content .inner');
	pane2.jScrollPane(
		{
			hijackInternalLinks: false,
			showArrows: true,
			animateScroll: true,
			autoReinitialise: true
		}
	);
	var api2 = pane2.data('jsp');



	  $('.ContentUpButton').live('click',function(){
		  
		  api2.scrollBy(0,-100);
		  return false;
	  });
	  $('.ContentDownButton').live('click',function(){
		  
		  api2.scrollBy(0,100);
		  return false;
	  });
		

	


/************************************************ Right-Side */

	$('.cat').click(function(){
		
		var tmp_kat=($(this).attr("cat"));
		$('#katAuswahl .active').removeClass('active');
		$(this).addClass('active');
		
		$('#namensListe').slideUp();
		$.ajax({
				type: "POST",
				url: "ajax_getPhotographers.php",
				data: "cat=" + tmp_kat,
				success: function(data) {
					$("#personenListe").html(data);
				}
			});
			return false;
		});	



	$('.portfolioLink').live('click',function()
			{
		
				var tmp_user=($(this).attr("person"));
				var tmp_cat=($(this).attr("cat"));
			
				 
				 $(this).parent().parent().siblings().slideUp('fast',function(){
					 $(this).parent().parent().siblings().addClass('hidden');
				 });
				 
				 $('#katAuswahl').slideUp('fast',function(){
					 $('.personDetails1').slideUp('fast');
					 $('.personDetails2').slideDown('fast');
				 });
			
				$.ajax({
						type: "POST",
						url: "ajax_getPhotographersPics.php",
						data: "cat=" + tmp_cat+"&user="+tmp_user,
						success: function(data) {
							api.getContentPane().append($(data));
							api.reinitialise();
							
						}
					});
				
				$("#bilderListe").fadeIn('slow',function(){
					$('.backButton').fadeIn('fast',function(){
						
						
						if ( $(".thumb:first").length > 0 ) {
							$('.thumb:first').click();
							$('.upButton').fadeIn();
							$('.downButton').fadeIn();
						}
					});
				});
				return false;
			 }
	);
	
	$('.changeCat').live('click',function(){
		
		tmp_cat=($(this).attr("cat"));
		tmp_user=($(this).attr("user"));
		
		loadThumbnails(tmp_cat,tmp_user);
		$(this).addClass('active');
		
		/*Signatur des About-Links bzw. Works-Links manipulieren*/
		var newUrl1="about.php?user="+tmp_user+"&cat="+tmp_cat+"&showVita=true";
		$(this).siblings(".aboutLink").attr({'href':newUrl1});
		
		var newUrl2="about.php?user="+tmp_user+"&cat="+tmp_cat+"&showPublished=true";
		$(this).siblings(".publishedLink").attr({'href':newUrl2});

		
		return false;
	});
	
	function loadThumbnails(tmp_cat,tmp_user) {
		
		$(".person .active").removeClass('active');
		$('.upButton').fadeOut();
		$('.downButton').fadeOut();
		$("#bilderListe").fadeIn();
		
		$.ajax({
			type: "POST",
			url: "ajax_getPhotographersPics.php",
			data: "cat=" + tmp_cat+"&user="+tmp_user,
			success: function(data) {
			
				api.getContentPane().html($(data));
				api.reinitialise();
				$('.thumb:first').click();
				api.scrollToElement($('.thumb:first'));
				
				if ( $(".thumb:first").length > 0 ) {
					$('.thumb:first').click();
					$('.upButton').fadeIn();
					$('.downButton').fadeIn();
				}
			}
		});
		
		
		
		
		return false;
		};

	

	

	$('.thumb').live('click',function(){
		
		$('#content').html("");
		
			var tmp_atr=($(this).attr("atr"));
			var tmp_person=($(this).attr("person"));
	
			var tmp_pic_id=($(this).attr("pic"));
			var tmp_pic_name=($(this).attr("name"));
			var tmp_altText=($(this).attr("alt"))
			
			var tmp_path="pictures/"+tmp_person+"/"+tmp_pic_name;
			var tmp_id="pic_"+tmp_pic_id;

			
			var tmp_next_id=($(this).next().next().attr("pic")); 
			var tmp_prev_id=($(this).prev().prev().attr("pic")); 
			
			var html="";
			//html+="<div class='picHolder'>";
			
			html+="<div class='picHolder2 hide'>";

			
			if(tmp_atr!='first') html+="<a href='#thumb_"+tmp_prev_id+"' class='goPrev changePic' pic='"+tmp_pic_id+"' target_pic='"+tmp_prev_id+"' accesskey='p' title='Previous (Accesskey:p)'></a>";
			
			html+="<img  src='"+tmp_path+"' pic='"+tmp_pic_id+"' id='"+tmp_id+"' class='grBild' />";
			
			if(tmp_atr!='last')  html+="<a href='#thumb_"+tmp_prev_id+"' class='goNext changePic' pic='"+tmp_pic_id+"' target_pic='"+tmp_next_id+"' accesskey='n' title='Next (Accesskey:n)'></a>";
			
			html+="<div class='clear'></div><div class='add2pdf' ><span><a picPath='"+tmp_path+"'  href='#'>ADD TO YOUR PDF</a><br />"+tmp_altText+"</span></div>";
			html+="</div>";
			//html+="</div>";		
			
			
			$.loadImages([tmp_path], function(){
				$('#content').html(html);
				$('.picHolder2').fadeIn('slow');
			});
			
			
			$('.showThumb').removeClass('showThumb');
			$('#thumb_'+tmp_pic_id).addClass('showThumb');
			
			$('#secMenu .jspPane').focus().focusout(); //For IE7
			
			
			
			return false;
	});
	

	
	  $(".personUnten").mouseover(function() {
		  
		  var tmp_user_id=".p"+($(this).attr("person"));
		    $(tmp_user_id).css('color','#000');
		  //alert(tmp_user_id);
		  }).mouseout(function(){
			  var tmp_user_id=".p"+($(this).attr("person"));
			  $(tmp_user_id).css('color','#fff');
		  });
	  
	  $(".personUnten").click(function(){
		
		 // alert(($(this).attr("id")));
		  	var tmp_user=$(this).attr("person");
		  	var tmp_cat=$(this).attr("firstCat");
		  	
		  	$('#katAuswahl').slideUp('fast');
		  	$('#namensListe').slideUp('fast');
			$.ajax({
					type: "POST",
					url: "ajax_getPhotographers.php",
					data: "cat=" + tmp_cat+"&user="+tmp_user,
					success: function(data) {
						$("#personenListe").html(data);
						$('.personDetails1').slideUp('fast');
						$('.personDetails2').slideDown('fast');
					}
			});

			$.ajax({
					type: "POST",
					url: "ajax_getPhotographersPics.php",
					data: "cat=" + tmp_cat+"&user="+tmp_user,
					success: function(data) {
						api.getContentPane().append($(data));
						api.reinitialise();
					}
			});
			$("#bilderListe").fadeIn('slow',function(){
				$('.backButton').fadeIn('fast',function(){
					if ( $(".thumb:first").length > 0 ) {
						$('.thumb:first').click();
						$('.upButton').fadeIn();
						$('.downButton').fadeIn();
					}
				});
			});
		
			return false;
			
	  });
	  
	  
	  
	  $('.upButton').live('click',function(){
		  api.scrollBy(0,-68);
		  return false;
	  });
	  $('.downButton').live('click',function(){
		  api.scrollBy(0,68);
		  return false;
	  });


/************************************************ gr-Bild */

		
		$('a.changePic').live(
			'click',
			function()
			{
				
				var targetId="#thumb_"+$(this).attr("target_pic"); 
				$(targetId).click();
				api.scrollToElement(targetId);
				$('.jspPane').focus(); //For IE7
				return false;
			}
		);
		
		$('.add2pdf a').live('click',function(){
			
			var tmp_pic_path=($(this).attr("picPath"));
			
			$.ajax({
				type: "POST",
				url: "setPdf.php",
				data: "pic=" + tmp_pic_path,
				success: function(data) {
					$('.add2pdf a').html("DAS BILD WURDE VORGEMERKT").fadeOut(3000);
				},
				error:function(){
					$('.add2pdf a').html("DAS BILD KONNTE NICHT VORGEMERKT WERDEN");
				}
			});
			return false
		});
		
		$(window).resize(function(){
			api.reinitialise();
		});

		
/************************************************ beta */
		
	  $('#deepLink').click(function(){
		 var cat=($(this).attr("cat"));
		 var user=($(this).attr("user"));
		 var pic_id=($(this).attr("pic_id"));
		 var pic_name=($(this).attr("pic_name"));

			$.ajax({
				type: "POST",
				url: "getPhotographers.php",
				data: "cat=" + cat+"&user="+user,
				success: function(data) {
					$("#personenListe").html(data);
				}
			});
			$('#namensListe').slideUp();
			$('#katAuswahl').slideUp('fast',function(){
				 $('.personDetails1').slideUp('fast');
				 $('.personDetails2').fadeIn('fast');
			 });
			
			$.ajax({
				type: "POST",
				url: "getPhotographersPics.php",
				data: "cat=" + cat+"&user="+user,
				success: function(data) {
					api.getContentPane().append($(data));
					api.reinitialise();
				}
			});
			
			$("#bilderListe").fadeIn('slow',function(){
				$('.backButton').fadeIn('fast',function(){
					$('#thumb_'+pic_id).click();
					api.scrollToElement($('#thumb_'+pic_id));
					$('.upButton').fadeIn();
					$('.downButton').fadeIn();
					
				});
			});
			
			
			return false;
		});
	  
	  
/************************************************ Slide About-Us */
	
	  var nextpic=function(){  
		  var dur=3000;
		 if ($(".showThis").next().attr("src") != undefined){ //letztes Bild?
			  $(".showThis").removeClass('showThis').fadeOut('slow').next().addClass('showThis').fadeIn(dur);
		 }
		  else{
			  $(".showThis").removeClass('showThis').fadeOut(dur);
			  $(".aboutSlide").first().fadeIn(dur).addClass('showThis');
			  
		  }
		  window.setTimeout(nextpic, 4000);  // and set duration here
		};
	  
	  if ($(".aboutSlide").attr("src") != undefined){ //About-Slide vorhanden?
		  
		  $(".aboutSlide").first().fadeIn('slow').addClass('showThis');
		  window.setTimeout(nextpic, 4500);  // and set duration here
	  }
	  


/************************************************ Slide About-Us */
	
	  var nextpic2=function(){ 
				var dur=3000;
				
				 if ($(".showThis").next().attr("src") != undefined){ //letztes Bild?
					  $(".showThis").removeClass('showThis').fadeOut(dur).next().addClass('showThis').fadeIn(dur);
				 }
				  else{
					  $(".showThis").removeClass('showThis').fadeOut(dur);
					  $(".publishedSlider").first().fadeIn(dur).addClass('showThis');
					  
				  }
				  window.setTimeout(nextpic2, 4000);  // and set duration here
	  };
 
	 //if ($(".publishedSlider").attr("src") != undefined){ //About-Slide vorhanden?
	  if ( $('.publishedSlider').size()>1  ){ //About-Slide vorhanden?
	   
		 	var alte_hoehe=$('#col1').css('height');
		 	alte_hoehe=parseInt(alte_hoehe.substr(0,alte_hoehe.length-2));

		 	var neue_hoehe=alte_hoehe-10;;
		 	neue_hoehe+="px";
		 	$('#col1').css('height',neue_hoehe);
			api2.reinitialise();

		 $('.publishedSlider').each(function(index) {
			    $('p').first().append($(this));
			   
			  });
		 
		 $(".publishedSlider").first().fadeIn('slow').addClass('showThis');
		  window.setTimeout(nextpic2, 4500);  // and set duration here
		
	 }
	  else
	  {
		  $(".publishedSlider").first().fadeIn('slow').addClass('showThis');
	  }
 
 $('#secMenu .jspPane').focus(); //For IE7

 });
		  
	  




