// JavaScript Document

var myrules = {
	'#memberTab' : function(element){
		element.onmouseover = function(){
			//alert('hello');
			this.src = this.src.replace('-off.','-on.');
			 hideAllSubNav('blue');
		}
		element.onmouseout = function(){
			//this.src = this.src.replace('on','off');
		}
	},
	'#renterTab' : function(element){
		element.onmouseover = function(){
			hideAllSubNav('green');
			this.src = this.src.replace('-off.','-on.');
		}
		element.onmouseout = function(){
			//this.src = this.src.replace('on','off');
		}
	},
	'#loginTab' : function(element){
		element.onmouseover = function(){
			hideAllSubNav('red');
			this.src = this.src.replace('-off.','-on.');
		}
		element.onmouseout = function(){
			//this.src = this.src.replace('on','off');
		}
	},
	'#subNav_blueBar img' : function(element){
		element.onmouseover = function(){
			this.src = this.src.replace('-off.','-on.');
		}
		element.onmouseout = function(){
			this.src = this.src.replace('-on.','-off.');
		}
	},
	'#subNav_greenBar img' : function(element){
		element.onmouseover = function(){
			this.src = this.src.replace('-off.','-on.');
		}
		element.onmouseout = function(){
			this.src = this.src.replace('-on.','-off.');
		}
	},
	'#subNav_redBar img' : function(element){
		element.onmouseover = function(){
			this.src = this.src.replace('-off.','-on.');
		}
		element.onmouseout = function(){
			this.src = this.src.replace('-on.','-off.');
		}
	},
	'#searchForm .searchTextField' : function(element){
		element.onfocus = function(){
			this.style.backgroundImage = 'none';
		}
		element.onblur = function(){
			if(this.value == ''){
				this.style.backgroundImage = 'url(/images/searchField_bg.gif)';
			}
		}
	},
	'#usernameField' : function(element){
		element.onfocus = function(){
			this.style.backgroundImage = 'none';
		}
		element.onblur = function(){
			if(this.value == ''){
				this.style.backgroundImage = 'url(/images/usernameField_bg.gif)';
			}
		}
	},
	'#passwordField' : function(element){
		element.onfocus = function(){
			this.style.backgroundImage = 'none';
		}
		element.onblur = function(){
			if(this.value == ''){
				this.style.backgroundImage = 'url(/images/passwordField_bg.gif)';
			}
		}
	},
	'.loginButton' : function(element){
		element.onmouseover = function(){
			this.style.color = '#000000';
		}
		element.onmouseout = function(){
			this.style.color = '#FFFFFF';
		}
	},
	'.searchButton' : function(element){
		element.onmouseover = function(){
			this.style.color = '#000000';
		}
		element.onmouseout = function(){
			this.style.color = '#CC0009';
		}
	},
	'.expandLink' : function(element){
		element.onclick = function(){
			var display = document.getElementById(this.getAttribute('showHide_id')).style.display;
			if(display == 'block'){
				document.getElementById(this.getAttribute('showHide_id')).style.display='none';
			}else{
				document.getElementById(this.getAttribute('showHide_id')).style.display='block';
			}
		}
		element.onmouseover = function(){
			this.style.textDecoration='underline';
		}
		element.onmouseout = function(){
			this.style.textDecoration='none';
		}
	}
};
Behaviour.register(myrules);

function hideAllSubNav(showTab){
	var blue = document.getElementById('subNav_blueBar');
	var green = document.getElementById('subNav_greenBar');
	var red = document.getElementById('subNav_redBar');
	
	var memberTab = document.getElementById('memberTab');
	var renterTab = document.getElementById('renterTab');
	var loginTab = document.getElementById('loginTab');
	
	if(showTab == 'blue'){
		blue.style.display = 'block';
	}else{
		memberTab.src = memberTab.src.replace('-on','-off');
		blue.style.display = 'none';
	}
	if(showTab == 'green'){
		green.style.display = 'block';
	}else{
		renterTab.src = renterTab.src.replace('-on','-off');
		green.style.display = 'none';
	}
	if(showTab == 'red'){
		red.style.display = 'block';
	}else{
		loginTab.src = loginTab.src.replace('-on','-off');
		red.style.display = 'none';
	}
}

function pop(url, x, y) {
    window.open(url, '', 'menubar=no,location=no,resizable=yes,toolbar=no,scrollbars=yes,directories=no,personalbar=no,status=yes,height='+y+',width='+x);
}

