var Accommodation = function($){
	/**
	 * private methods and variables
	 */
	var priv = {
		accoId : -1,
		currentAccoIndex : 0,
		selectedPhotoId : -1,
		photoCarousel : null,
		
		initFavoriteLogic : function() {	
		    //test wether this is a favorite
		    var $favorite = $('#favorite');
		  
		    
		    //bind the click event for the trigger 	
		    $favorite.bind("click",
		        function(evt){	
					//test for add or removal of the favo
					
					
					//prevent event bubbling
					return false;
				}
		    );
		}
		
	
	};
	
	/**
	 * public methods
	 */
	return {	
	    
	    aspnetHidPhoto : '',
		
		thumbnailHighlight : function(photoIndex){
		    $('#selected-img-' + photoIndex).removeClass('unselected-img');
		    $('#caption-' + photoIndex).show();
		   	priv.selectedPhotoId = photoIndex;
		},
		thumbnailClick : function(newPhotoIndex, imgurl, url, index){
			
		    var $bigPhoto = $('div.gallery img.big-photo' + index);
		    var photoParam = '&sumphotoId='+newPhotoIndex;
		    
		    $('#selected-img-' + priv.selectedPhotoId).addClass('unselected-img');
		    $('#selected-img-' + priv.selectedPhotoId + '-sec').addClass('unselected-img');
		    $('#caption-' + priv.selectedPhotoId).hide();
		    $('#caption-' + priv.selectedPhotoId + '-sec').hide();
		    
		    priv.selectedPhotoId = newPhotoIndex;
		    
		    $('#selected-img-' + newPhotoIndex).removeClass('unselected-img');
		    $('#selected-img-' + newPhotoIndex + '-sec').removeClass('unselected-img');
		    $('#caption-' + newPhotoIndex).show();
			$('#caption-' + newPhotoIndex + '-sec').show();
		    
		    //update the link
		    $bigPhoto.parent().attr('href', url);
		    
		    //first show the loader by setting the background to a blank image
		    $bigPhoto.attr('src','http://www.webprodie.nl/admin/images/loading.gif');
		       
		    //now preload the new image
            var tmpImg = new Image();
            //now define the onload action
            tmpImg.onload = function(){
            $bigPhoto.attr('src', tmpImg.src);
			$bigPhoto.parent().attr('href', 'http://www.webprodie.nl/admin/user/uniekewinkels/fotoviewer.php?KeepThis=true&TB_iframe=true&height=500&width=700&id='+newPhotoIndex);
				
            };
		   tmpImg.src = 'http://www.webprodie.nl/admin/incs/thumb.php?img=../..' + imgurl;
		},
		
        
        
		
		
		
		

		OnReady	: function(){
		    
		
		  
            
            var summaryCarousel = new PCarousel2({"listItem" : $("#gallery-list").get(0), "direction" : "vertical", "continues" : true});
           
			$("#gallery-list li").bind("click", 
                function(evt){
                    //only do when photoCarousel is not locked for movement
                    if(summaryCarousel.IsLocked()){
                       
					   return;
                    }
                    
                    //determine move direction
                    //first determine position on screen
                    var self = this;
                    var pos = 0;
                    $(summaryCarousel.GetItemsInView()).each(
                        function(index){
                            if($(this).attr("rel") == $(self).attr("rel")){
                                pos = index;
                            }
                        }
                    );
                                                     
                    if(pos < Math.floor(summaryCarousel.GetNumberOfItemsInView()/2)){
                        summaryCarousel.Prev();
                    }
                    else if(pos >= (summaryCarousel.GetNumberOfItemsInView()/2)){
                        summaryCarousel.Next();
                    }
                }
            );
            
            
          
            
            
            
            
		}
	}
}(jQuery);
