//Global variables for these functions
liCache = {};

var myrules = {
	'.footer_nav li img' : function(e){
		
		if(!/icn_new/.test(e.src)) { //don't touch the "new" badge
		
		//e.style.height = "23px";
		the_parent = findParent(e,'li');
		the_parent.style.height = "23px";
		
		if(!/Safari/.test(navigator.userAgent))  {
		new growImg(e,{width:'106px',height:'33px',duration:0.10});
		}
		
		liCache[e.id] = {width:e.style.width,
			   height:e.style.height,
			   left:e.style.left,
			   top:e.style.top};
			   
		liCache[the_parent.id] = {width:the_parent.style.width,
			   height:the_parent.style.height,
			   left:the_parent.style.left,
			   top:the_parent.style.top};
			   
		} 
		

	},

	'.footer_nav li' : function(e){
		
		e.onmouseover = function() {
		this.style.backgroundColor = '#ccc';
		}
		e.onmouseout = function() {
		this.style.backgroundColor = '';
		}	
	
	
	},

	'.left_nav li' : function(e){
		
				
		if(isAChild(e,'left_nav_link')) {

			e.onmouseover = function() {
			this.style.backgroundColor = '#ccc';
			}
			e.onmouseout = function() {
			this.style.backgroundColor = '';
			}	
		
		}
			
	},
	
	'#right_bar_opacity': function(e) {
		
		if(nav_section_start) {
		
			if(/MSIE/.test(navigator.userAgent))  {
			new Effect.BlindLeftRight(e,{delay:1.2,duration:0.3});
			new Effect.Show(findChild(e,'content_bar'),{delay:1.4});
			} else {
			new Effect.Appear(e,{from:0,to:0.85});						
			new Effect.Appear(findChild(e,'content_bar'),{from:0,to:0.85});	
			}
		
		} 
		
	},
	
	'#homepage_opacity': function(e) {

		new Effect.Appear(e,{from:0,to:0.85});			
		
		
	},

	'#left_bar_opacity': function(e) {

		if(nav_section_start) {
			
			if(/MSIE/.test(navigator.userAgent))  {
			new Effect.BlindLeftRight(e,{duration:0.2,delay:1});
			} else {
			new Effect.Appear(e,{from:0,to:0.85});			
			}
		
		} 
		
	},	
	
	'#left_bar_image': function(e) {
				
		//Get the hight of the left bar scroll area
		if(/MSIE 5.5/.test(navigator.userAgent))  {
		left_bar_height = $('left_li_area').offsetHeight + 150;					
		} else {
		left_bar_height = $('left_li_area').offsetHeight + 100;		
		}
		$('left_bar_image').style.marginTop = left_bar_height + 'px';	
		
		if(nav_section_start) {
		new Effect.Appear(e,{from:1,to:1,delay:0.5});	
		} else {
		new Effect.Appear(e,{from:1,to:1,delay:0});	
		}	
		
	},
	
	'img' : function(e) {  
		
         var img = e;
		 
		 /* Make PNG Transparent */
         var imgName = img.src.toUpperCase()
			 if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		 		if(/MSIE/.test(navigator.userAgent) && /png_trans/.test(img.className))  {
					var imgID = (img.id) ? "id='" + img.id + "' " : "";
					var imgClass = (img.className) ? "class='" + img.className + "' " : "";
					var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
					var imgStyle = "display:block;";
					if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
					new_height = (img.height*1);
					if(/logo/.test(img.src)) {
					new_height+=3;			   
				    }
					var strNewHTML = '<span ' + imgID + imgClass + imgTitle	+ ' style="width:' + img.width + 'px; height:' + new_height + 'px;' + imgStyle + ';' + 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src + '\', sizingMethod=\'scale\');"></span>';
					img.outerHTML = strNewHTML;
				} else {
				new Effect.Appear(e,{from:1,to:1,delay:0});	
				}
			 }			
	},
	
	'form': function(e) {

		if(/validation/.test(e.className)) {
		new Validation(e.id);
		}	
		
	},
	
	'input': function(e) {

		if(/required/.test(e.name)) {		
			
			value_array = e.value.split("@@@");
			value_array.each(function(c,i) {
				if(c != e.value) {
					if(i == 1) {
						Element.addClassName($(value_array[0]),value_array[1]);
						Element.addClassName($(value_array[0]),'required');
					}
				} else {
				Element.addClassName($(e.value),'required');
				}
			});
		
					
		}	
		
		if(/upload/.test(e.className)) {	
		
			hidden_path_id = 'file_path_'+e.id;
			e.onblur = function() {		
			$(hidden_path_id).value = e.value;
			}		
		
		}
		
	},		
	
	'a': function(e) {
		
		if(/popup_map/.test(e.href)) {
			e.href='/#';
			e.onclick = function() {				
				new popup(this,'/app/view/content/map.html',{title:'Map to dot-gap',width:'335',height:'345'});				
				return false;
			}			
			
		} else if (/sitemap_link/.test(e.id)) {
			
			e.onmouseover = function() {				
			 $('sitemap_holder').style.backgroundColor = '#e4e4e4';					
			}
			
			e.onmouseout = function() {				
			 $('sitemap_holder').style.backgroundColor = '';					
			}			
			
		}
		
	}	
	
};

Behaviour.register(myrules);