
$(document).ready(function(){

	/* Resize main content col to the same height or taller than the left rail  
	var lr = $("#left_rail");
	var content = $("#content");
	
	if (lr.height() > content.height()) {
		content.height(lr.height());
	}
	
	*/
	

	/* Select all/none on the news form */	
	$(".editForm .toggleSelect").click(function(){
		$(".items input[type='checkbox']").each(function () {
			this.checked = $(".toggleSelect").attr("checked");
		});
	});
	
	/* Turn editable fields on */
	$(".editNews").click(function(){

		var name = $(this).attr('name');
		var content = $(this).next().html();
		$(this).next().remove();
		$(this).parent().append("<textarea rows='7' cols='62' name='editStoriesContent[]' id='"+name+"' class='contentsArea'>"+content+"</textarea><input type='hidden' name='editStoriesTitle[]' value='"+name+"'>");
 		$(this).hide();
 		return false;
 		
	});
	
	/* Initialize jQueryFileTree (on edit bios page) */
	if ($("#files_display").length > 0) {
    $("#files_display").fileTree({
		root: '../../../images/staff/',
      	script: '../js/jqueryFileTree/connectors/jqueryFileTree.php',
      	expandSpeed: 1000,
      	collapseSpeed: 1000,
      	thumbs:true
    }, function(file) {
        alert(file);
    });

	$("#files_display").css('display','none');
	
	$(".selectImgs").click( function() {
		$("#files_display").css('display','block');
		//$("#files_display").prepend("<a href='#' class='close_files'>Close</a>");
		$(".close_files").click ( function() {
 			$("#files_display").css("display","none");
 			return false;
 		});
 		
		return false;
	});
 	}
 	
 	// Insert map
 	var mapstr='<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=en&amp;ie=UTF8&amp;q=Fairview+Park+Marriott+Hotel+3111+Fairview+Park+DriveFalls+Church,+Virginia+22042&amp;fb=1&amp;split=1&amp;gl=us&amp;cid=0,0,1401962858115871911&amp;ei=coKpSpyIBcOklAeyiJnUBg&amp;ll=38.861604,-77.215959&amp;spn=0.005848,0.00912&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?hl=en&amp;ie=UTF8&amp;q=Fairview+Park+Marriott+Hotel+3111+Fairview+Park+DriveFalls+Church,+Virginia+22042&amp;fb=1&amp;split=1&amp;gl=us&amp;cid=0,0,1401962858115871911&amp;ei=coKpSpyIBcOklAeyiJnUBg&amp;ll=38.861604,-77.215959&amp;spn=0.005848,0.00912&amp;z=16&amp;iwloc=A&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>';
 	$(".addr").after(mapstr);
	
});

/*function validateNewsForm() {
	var errors = new Array();
	var title = $(".editForm input[name=title]");
	var date = $(".editForm input[name=date]");

	
	// Checks if any checkboxes have been selected 
	$(".itemsBlock input[type=checkbox]").each(function () {
		if (this.is(':checked'))
			return true;
	}); 

					
	// Check Title
	if ($(title).val().length == 0) {
		errors.push({'class':'titleInput','message':'Please enter a title'});
	}

	// Check Date
	if ($(date).val().length < 8 ) {
		errors.push({'class':'dateInput','message':'Please enter a valid date'});
	}
	
	// Check Content
	if (!$(".newsContent").val()){
		errors.push({'class':'newsContent','message':'Please enter news story content'});
	}


	if (errors.length > 0) {
		// Reset error messages/borders 
		$(".err").html(""); 
		$(".editNewsForm *").css({'border':'none'});
				
		// Loop over errors array, output messages and turn borders on (on errored inputs) 
		for (var i=0;i<errors.length;i++) {
			$("."+errors[i].class).css({"border":"3px solid red"});
			$(".err").append('<br /> - ' + errors[i].message);
		}	
		
		// Go to top of page 
		scroll(0,0); 
		
		// Stop form from submitting 
		return false;
		
		
	}

	// Form Submits 
	return true;
} */