var name = "#sidebar";  //name of sidebar to perform scroll onto
var menuYloc = null; 
var menuYbuffer = 175; 
  
$(document).ready(function(){ 
	//form counter
	$("#cf_field_10").jqEasyCounter({
		'maxChars': 500,
    	'maxCharsWarning': 450,	
		'msgTextAlign': 'right'
	});
	
	//cycle through messages in main page
	$("ul#slides").cycle({
		fx: 'fade', //use fade effect
		timeout: 6500 //delay between messages
	});

 	/*SIDEBAR CODE*/
 	$("#sidebar").ready(function(){ //create a div having the same height dimensions as the side bar to prevent the page to collapse on itself if the content is smaller than the sidebar
		$("#sidebar").parent().append("<div id='hidden-sidebar'></div>");
		$("#hidden-sidebar").height($("#sidebar").height());
	});
 
	/*$(window).scroll(function () {  
		var offset = $(document).scrollTop() - menuYbuffer +"px"; 
		if(offset.substring(0, offset.length-2) < ($("#sidebar").parent().height() - $("#sidebar").height())){ //prevent the sidebar from scrolling to low (into the footer and areas outside of the sidebar's parent's dimension restrictions
			if($(window).scrollTop() > menuYbuffer){//only scroll the sidebar down if the window has been scrolled low enough (by measurement of menuYbuffer)
				$(name).animate({top:offset},{duration:500,queue:false});  //perform scroll on sidebar
			}else{
				$(name).animate({top:0},{duration:500,queue:false});  //perform scroll on sidebar
			}
		}else{
			//do nothing
		}
	});*/ 
	
	/*$("#sidebar a").click(function(e){
		if($(this).attr("href").substring(0,1) == "#"){
			e.preventDefault();
			
		}
	});*/
	
 
});  
