var rules = {
	'div#warnJS' : function(element){
		element.style.display='none';
	},
	'.imgMO' : function(element){
		element.onmouseover = function () {
			imgMO(this);
		}
		element.onmouseout = function () {
			imgMO(this);
		}	
	},
	'input' : function(element){
		element.onmouseover = function () {
			this.style.backgroundColor='#f0f0f0';
		}
		element.onmouseout = function () {
			if (!this.hasFocus)	
				this.style.backgroundColor='#FFFFFF';
		}
		element.onfocus = function () {
			this.style.backgroundColor='#f0f0f0';
			this.hasFocus = true;
		}
		element.onblur = function () {
			this.style.backgroundColor='#FFFFFF';
			this.hasFocus = false;
		}		
	},	
	'textarea' : function(element){
		element.onmouseover = function () {
			this.style.backgroundColor='#f0f0f0';
		}
		element.onmouseout = function () {
			if (!this.hasFocus)	
				this.style.backgroundColor='#FFFFFF';
		}
		element.onfocus = function () {
			this.style.backgroundColor='#f0f0f0';
			this.hasFocus = true;
		}
		element.onblur = function () {
			this.style.backgroundColor='#FFFFFF';
			this.hasFocus = false;
		}		
	},	
	'.frmField' : function(element){
		element.onfocus = function () {
			if (!this.cleared) 
				clearField(this); 
			this.cleared=true;
		}	
		element.onblur = function () {
			resetField(this);
		}
	},
	'div#navigation_link' : function(element){
		element.onclick = function () {

			if (!this.active && $('outer_container').className.indexOf('navActive')<0) {
				//this.className = this.className+' active';
				Element.addClassName(this,'active');
				this.active=true;
				$('outer_container').addClassName('navActive');

				new Ajax.Updater('', 'ajax/setActive.php', {  method: 'post',parameters: { activate: 1, typ: 'nav' }, onFailure:show_failure, onException:show_exception});
			}
			else {
				Element.removeClassName(this,'active');
				this.active=false;
				$('outer_container').removeClassName('navActive');
				new Ajax.Updater('', 'ajax/setActive.php', {  method: 'post',parameters: { activate: 0, typ: 'nav' }, onFailure:show_failure, onException:show_exception});
			
			}
			//this.style.backgroundColor = '#ffffff';
		}
	},
	'div#lightbox_link' : function(element){
		element.onclick = function () {

			if (!this.active && $('outer_container').className.indexOf('lbActive')<0) {
				Element.addClassName(this,'active');
				this.active=true;
				$('outer_container').addClassName('lbActive');
				new Ajax.Updater('', 'ajax/setActive.php', {  method: 'post',parameters: { activate: 1, typ: 'lb' }, onFailure:show_failure, onException:show_exception});

			}
			else {
				Element.removeClassName(this,'active');
				this.active=false;
				$('outer_container').removeClassName('lbActive');
				new Ajax.Updater('', 'ajax/setActive.php', {  method: 'post',parameters: { activate: 0, typ: 'lb' }, onFailure:show_failure, onException:show_exception});
			
			}
			//this.style.backgroundColor = '#ffffff';
		}
	},	
	'div#image_resize_container img' : function(element){
		element.onmouseover = function () {
			$('image_resize_description').style.display='block';
			$('image_resize_pages').style.display='block';
			Element.addClassName(this,'imgHover');
			this.active = true;
		}
		element.onmouseout = function () {
			var thisObj = this;
			thisObj.active = false;
			setTimeout(function() {
				if (!thisObj.active) {
					$('image_resize_description').style.display='none';
					$('image_resize_pages').style.display='none';
					Element.removeClassName(thisObj,'imgHover');
				}
			},50);
		}		
	},
	'div#image_resize_description' : function(element){
	
		element.onmouseover = function () {
			//$('image_resize').active = true;
			$('image_resize_inner').getElementsByTagName('IMG')[0].active = true;
		}
		element.onmouseout = function () {
			$('image_resize_inner').getElementsByTagName('IMG')[0].active = false;
			setTimeout(function() {
				if (!$('image_resize_inner').getElementsByTagName('IMG')[0].active) {
					$('image_resize_description').style.display='none';
					Element.removeClassName($('image_resize_inner').getElementsByTagName('IMG')[0],'imgHover');
				}
			},50);			
		}		
	},	
	'div#image_resize_inner' : function(element){
	
		if(typeof Droppables=='undefined') {}
		else		
		new Draggable(element, {  
			handle: 'lightboxDrag', 
			ghosting : 'true', 
			revert : 'true', 
			reverteffect : function(draggable_object,y1,x1){
				new Effect.Move(draggable_object, { 
					x: -x1, y: -y1, mode: 'relative',duration: 0 
				});
			},
			onStart: function(){
				$$('body')[0].setAttribute('style','overflow:hidden');
				$$('.image_resize_description')[1].setAttribute('style','visibility:hidden');
		
			},
			onEnd: function(){
				setTimeout(function(){$$('body')[0].removeAttribute('style')},250);
				$$('.image_resize_description')[0].setAttribute('style','visibility:visible');
			}
		});

	},	
	'div.news_image div.lbDrag' : function(element){

		if(typeof Droppables=='undefined') {}
		else	{	

		new Draggable(element, {  
			handle: 'lightboxDrag', 
			ghosting : 'true', 
			revert : 'true', 
			reverteffect : function(draggable_object,y1,x1){
				new Effect.Move(draggable_object, { 
					x: -x1, y: -y1, mode: 'relative',duration: 0 
				});
			},
			onStart: function(){
				$$('body')[0].setAttribute('style','overflow:hidden');
				cH = getClientHeight();	
				sO = $('page_container').cumulativeScrollOffset();
				$('nav_footer').style.position='absolute';
				$('nav_footer').style.top=(cH[1]-117+sO.top)+'px';				
			},
			onEnd: function(){
				setTimeout(function(){$$('body')[0].removeAttribute('style')},250);
				$('nav_footer').style.position='fixed';
				$('nav_footer').style.top='auto';						
			}
		});
		}

	},		
	'#page.lightbox div#list_resize' : function(element){
		
		Sortable.create('list_resize', {tag:'a',constraint:'',onChange:function(obj){dragStart = true;},onUpdate:function (obj) {doSort(obj);setTimeout(function() {dragStart = false;},50);return false;}});	

	},		
	'div#list_resize img' : function(element){

			
		if (!$('lb_desc_save')) {
			if(typeof Droppables=='undefined') {}
			else	
			new Draggable(element, {  
				handle: 'lightboxDrag', 
				ghosting : 'true', 
				revert : 'true', 
				reverteffect : function(draggable_object,y1,x1){
					new Effect.Move(draggable_object, { 
						x: -x1, y: -y1, mode: 'relative',duration: 0 
					});
					
				},
				onStart: function(){
					$$('body')[0].setAttribute('style','overflow:hidden');

					dragStart = true;
					cH = getClientHeight();	
					sO = $('page_container').cumulativeScrollOffset();
					$('nav_footer').style.position='absolute';
					$('nav_footer').style.top=(cH[1]-117+sO.top)+'px';				
				},
				onEnd: function(){
					$$('body')[0].removeAttribute('style');
					setTimeout(function() {dragStart = false;},50);
					$('nav_footer').style.position='fixed';
					$('nav_footer').style.top='auto';						
				}
			});
		}
	},
	'ul#dropbox' : function(element){
		if(typeof Droppables=='undefined') {}
		else
			addDrop();	
	},
	'ul#dropbox_remove' : function(element){
		if(typeof Droppables=='undefined') {}
		else 
			addDrop('remove');
		
	},

	'a.spacing' : function(element){
		element.onmouseover = function () {
			Element.addClassName(this,'focus');			
		}
		element.onmouseout = function () {
			Element.removeClassName(this,'focus');
		}      
	},
	'a#reset_lightbox' : function(element){
		element.onclick = function () {
			if (confirm('Do you really want to remove the images?'))
				new Ajax.Updater('', 'ajax/reset_lightbox.php', {  method: 'post',parameters: { }, onComplete:function(obj){document.location.reload()}, onFailure:show_failure, onException:show_exception});
			
		}  
	}	
	
	
};
/*Event.observe(document, 'scroll', function(){	
	if ($('page').className=='compendium') {
		cH = getClientHeight();	
		clearTimeout(scroll);
		scroll = setTimeout(function() {
			tmp = $('page_container').cumulativeScrollOffset();
			if (tmp.top>0) {
				$('nav_footer').style.position='absolute';
				if (scrollTop)
					$('nav_footer').style.top=(cH[1]-117+tmp.top)+'px';
				else	
					new Effect.Move('nav_footer', { x: 0, y: (cH[1]-117+tmp.top), mode: 'absolute' });
				scrollTop = false;
			}
			else {
				
				new Effect.Move('nav_footer', { x: 0, y: (cH[1]-117+tmp.top), mode: 'absolute', duration: 0.5, afterFinish: function() {
					$('nav_footer').style.position='fixed';
					$('nav_footer').style.top='auto';	
					scrollTop = true;				
				}});
			}	
		},250);
	}
});*/

for (selector in rules){
	Behavior.register(selector,rules[selector]);
}
