                                                                                                                                // JavaScript Document

/* Following functions are found in this javascript file using JQuery version jquery-1.3.2:

		** gets rid of last comma in tags
		** shorten neighborhood description
		
Last Updated: 01/19/10
Author: RR

*/

// Gallery Pagination



var pageSize = 10; // number of images displayed on page
var imagesParent = ".galleryImgItem li"; // HTML container where the the image are found
var nextButton = "#nextBtn"; // class or id of the Next button
var previousButton = "#preBtn"; // class or id of the Previous button
var paginationNumberContainer = ".galPaginate"; // container for page numbers
var pageNumberAnchor = true; // this will create page number links inside "paginationNumberContainer" element. false will turn the function off



var numberOfImages = $(imagesParent).length; 

function dispPage(pageNum){	
try{
	var listItems = $(imagesParent);
	var pageMax = Math.ceil($(imagesParent).length / pageSize);
	
	
	// checks for images
	if(listItems.length > 0){
		$(listItems).hide();
		for(i=((pageSize*pageNum) - pageSize);i<pageSize*pageNum; i++){
			   if(listItems[i]!=undefined)
					$(listItems[i]).show();  
		}
				
		
		// functions next and previous buttons
			$(nextButton).unbind().click(function(){  
				pageNum = parseFloat(pageNum);								
				dispPage(pageNum+1);
				return false;
			});
			
			$(previousButton).unbind().click(function(){
				pageNum = parseFloat(pageNum);	
				dispPage((pageNum)-1);
				return false;
			});
			
			
		
		// display of next and previous buttons
	 	if(pageNum == 1){
			$(previousButton).hide();
			$(nextButton).show();

		}else if(pageNum == pageMax){
			$(nextButton).hide();
			$(previousButton).show();
			
		}else{					
			$(previousButton).show();
			$(nextButton).show();
		}

	}else{ // if no images listed
		
		$(nextButton).hide();
		$(previousButton).hide();
	}
	
	
	
	
	
	// creating pagination numbers links
	if(!!pageNumberAnchor){
		for(x=1; x<pageMax+1;x++){
			$(paginationNumberContainer).append("<a href='javascript:;' rel='"+x+"'>"+x+"</a>");			
		}
		pageNumberAnchor = false;
	}	
	
	$(paginationNumberContainer+ " a").removeClass("pageSelect");
	$(paginationNumberContainer+ " a:eq("+(pageNum-1)+")").addClass("pageSelect");
        

	// pagination selected states and function
	$(paginationNumberContainer+ " a").unbind().click(function(){
				var pageNumberRel = $(this).attr('rel');
				var PageNumberRel = parseFloat(pageNumberRel);
				$(paginationNumberContainer+ " a").removeClass("pageSelect");
				
				dispPage(pageNumberRel);
				$(this).addClass("pageSelect");
				return false
				
		});

}catch(err){alert(err);}
}


$(function(){
dispPage(1);



// gets rid of last comma in tags
/*
	$('.searchTag').each(function(){
		var x = $(this).html();
		lastComma = x.lastIndexOf(",");
		x = x.substring(0, lastComma);
		$(this).html(x);
	}); 

*/
// shorten neighborhood description
	
	$('.searchDesc').each(function() {
                var newChar = $(this).text().substring(0, 250);
                var newChar = $(this).text(newChar);
                var newChar = $(this).text().lastIndexOf(' ');
                var newChar = $(this).text().substring(0, newChar);
		$(this).text(newChar);
	}); 




// Show and Hide Comments in the event page

$(".btnAddComment a").toggle(function(){
    $(this).parent().siblings(".comments-meta").show();
    $(this).addClass("hideComment").text("Hide Comments/Info");
}, function(){
     $(this).parent().siblings(".comments-meta").hide();
    $(this).removeClass("hideComment").text("Add Comments/Info");
}
);


// Navigation Fade Styles


//$('.nav a').hover(function(){

//$(this).children().fadeToggle();

//});	
	


//remove empty br tags

//$('.contentWysiwyg br')
//   .filter(function() {
//      return $.trim($(this).text()) === ''
// })
// .remove()

$('.147').remove();
$('.624').remove();
$('#dispStaff .addPaddingTop').remove();




//toggle newsletter archive

$('.newsletterArchive').hide();
$('.showList').click(function(){
    $('.newsletterArchive').slideToggle();

});
	
	
});	


    

    

    

    

    

    

    

    

    

    

    

    
