window.addEvent('domready', function(){

		
		$$('.flydown').each(function(el) {			

			el.addEvents({
				'mouseenter': function(){
					
					
					
					//CALCULATE FLYDOWN HEIGHT BASED ON NUM CHARS IN EACH <A>
					var flydown = this.getLast();
					var totalfh = 0;
					var fh = 0;
					var tlen = flydown.getChildren();
					
						tlen.each(function(txtel) {
							
							var len = txtel.get('text').length;
							if(len < 1) fh = 0; //NO FLYDOWN
							else if(len < 16) fh = 32; //SINGLE LINE
							else fh = 42; //WRAPPING FLYDOWN
							
							totalfh += fh;
						});	
						
					var flydownHeight = totalfh;
					if((flydownHeight > 0)&&(flydownHeight<70)) flydownHeight += 10;	
					
	
					
					flydown.set('tween', {
						duration: 400
					}).tween('height', flydownHeight + 'px');
					
		
					
				},
				'mouseleave': function(){
					// Resets to  original size
					
					
					var flydown = this.getLast();
					
					
					flydown.set('tween', {
						duration: 400
					}).tween('height', '0px');
					
					
					
				}
			});	
			

		});





	$$('#livinglist li').each(function(el) {				


			el.addEvents({
				'mouseenter': function(){
					
					//var overlay = 
					//var linkbar = 
					
					this.set('tween', {
						duration: 100
					}).tween('opacity', .81);
					
					this.getElement('.living_link').set('tween', {
						duration: 200
					}).tween('background-color', '#e4801c');
					
				},
				'mouseleave': function(){
					// Resets to  original size
					this.set('tween', {
						duration: 400
					}).tween('opacity', 1);
					
					this.getElement('.living_link').set('tween', {
						duration: 200
					}).tween('background-color', '#b74b27');
					
				}
			});	

	});	
	
	var cookie = readCookie("fontSize");
	textsize = cookie ? cookie : '';
	if (cookie) changeFontSize(textsize);
	
	
	//set nav first child padding for all browsers
	//.flydownItems >a:first-child  padding-top:15px !important;
	$$('.flydownItems a:first-child').setStyle('padding-top', '15px');
	

	


});	





function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
 
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


var tagTypes = new Array("div","a");

function changeFontSize(size) {
	
	var resizeEl = new Array("main_col", "left_col", "leftnav");
	
	//foreach resizeEl, change font size to size
	for(var j=0; j < resizeEl.length; j++) {			
		
		curEl = $(resizeEl[j]);
		if(curEl) curEl.style.fontSize = size +"%";
		
		var lh = "line-height";
		//curEl.style.lh = "2.2em";

		createCookie("fontSize", size, 365);

	}
}

