
function showCategoriesCam(data)
{
	 // Kategoriennavigation erzeugen
	 $.each(data.results, function(i,item){     
	     if(i == 0)
		 {
		 	$("#digipetsresourcesWebCam .digipetsresourcesWebCamNav").append('<li><a href="#" class="Select" name="'+item.uid+'"><span>'+item.subtitle+'</span></a></li>');
		 } else{
		 	
			$("#digipetsresourcesWebCam .digipetsresourcesWebCamNav").append('<li><a href="#" name="'+item.uid+'"><span>'+item.subtitle+'</span></a></li>');
		 }            
	 });
	 
	 // Navigationshandling
	 $("#digipetsresourcesWebCam .digipetsresourcesWebCamNav a").bind("click", function(e){
      	e.preventDefault();		

		$.each($("#digipetsresourcesWebCam .digipetsresourcesWebCamNav a"), function(i, item){				
				$(this).removeClass("Select");				
			});
		$(this).addClass('Select');
		
		// Galerieinhalt löschen
		$("#digipetsresourcesWebCam .digipetsresourcesWebCamObject").empty();
		
		// Neuer Galerieinhalt laden		
		loadRessourcesCam($(this).attr("name"), 0, 1,$("#digipetsresourcesWebCam").attr('name'));			
    
    }); //End of Click

}

function showRessourcesCam(data)
{
	$.each(data.results, function(i,item){
     
	 	
	    $resObj = '<a rel="prettyPhoto[webcamgallery]" href="' + item.email + '" title="' + item.title + '">';
		$resObj +=  ' <img src="'+item.link+'" alt="'+item.title+'" />';
		$resObj += '  <div class="StopFloatingForMyChilds"><div></div></div>';
		$resObj += '</a>';
		
		$("#digipetsresourcesWebCam .digipetsresourcesWebCamObject").append($resObj);	
		
		
		            
	 });
	 
		 $("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});
	
	 

}

function loadCategoriesCam(startingPoint)
{
	returnValue = 0;
	$.getJSON("index.php?eID=tx_digipetsresources&L="+digipetsLanguage+"&action=getCategories&startingPoint="+startingPoint+"&catType=0",    // Muss aktuelle Page als ID mitgeben für pid Parameter
        function(data){        
       		
			showCategoriesCam(data);
		 	loadRessourcesCam(data.results[0].uid,0,1,startingPoint);
        });
		
}

function loadRessourcesCam(category, startEl, anzEl, startingPoint)
{
	$.getJSON("index.php?eID=tx_digipetsresources&L="+digipetsLanguage+"&action=getRessources&startEl="+startEl+"&anzEl="+anzEl+"&category="+category+"&startingPoint="+startingPoint,  
        function(data){        
       		showRessourcesCam(data);
        });
	
}


$(document).ready(function(){
   
	startCategory = loadCategoriesCam($("#digipetsresourcesWebCam").attr('name'));   
    
	
  });