// Javascript Rules

var myrules = {
	'div#sidebar-top' : function(element){
		// See if Requirements are rendered or die
		var myLogin = $('login');
		if (!myLogin) { return; };
		// Search for the enter box or die
		var box = $('tour');
		if (!box) { return; };
		box.anim = new fx.Height(box, {duration: 400});
		myLogin.anim = new fx.Height(myLogin, {duration: 400});
		myLogin.anim.hide();
		myLogin.className = 'show';
	},
	'div#slideshow' : function(element){
		// See if Requirements are rendered or die
		var myReq = $('requirements');
		if (!myReq) { return; };
		// Search for the enter box or die
		var showImage = $('show-image');
		if (!showImage) { return; };
		showImage.anim = new fx.Height(showImage, {duration: 400});
		myReq.anim = new fx.Height(myReq, {duration: 400});
		myReq.anim.hide();
		myReq.className = 'show';
	},
	'a#show-req' : function(element){
		var myReq = $('requirements');
		var showImage = $('show-image');
		var noFlash = $('no-flash');
		element.onclick = function(){
			if(noFlash) {
				myReq.anim.toggle();
				showImage.anim.toggle();
			} else {
				callExternalInterface();
			}
		}
	},
	'a.close-req' : function(element){
		var myReq = $('requirements');
		var showImage = $('show-image');
		element.onclick = function(){
			myReq.anim.toggle();
			showImage.anim.toggle();
		}
	},
	'div#header p.login-toggle a' : function(element){
		var myLogin = $('login');
		var box = $('tour');
		element.onclick = function(){	
			myLogin.anim.toggle();
			box.anim.toggle();
		}
	},
	'a.close-login' : function(element){
		var myLogin = $('login');
		var box = $('tour');
		element.onclick = function(){
			myLogin.anim.toggle();
			box.anim.toggle();
		}
	},
	'input#loginUsername' : function(element){
		element.onblur = function(){
			changeInputField('loginUsername', 'textBlur', 'username');
		}
		element.onfocus = function(){
			changeInputField('loginUsername', 'textFocus', 'username');
		}
	},
	'input#loginPassword' : function(element){
		element.onblur = function(){
			changeInputField('loginPassword', 'textBlur', 'password');
		}
		element.onfocus = function(){
			changeInputField('loginPassword', 'textFocus', 'password');
		}
	}
};
	
Behaviour.register(myrules);