function search(mode){
	this.userQuery = false;
	this.modes = {};
	this.modes.users = {};
	this.modes.videos = {};
	this.modes.users.title = 'Търси потребители';
	this.modes.users.action = 'search_users.php';
	this.modes.videos.title = 'Търси видео клипове';
	this.modes.videos.action = 'search_videos.php';
	
	this.setMode = function(mode){
		this.title = this.modes[mode].title;
		this.action = this.modes[mode].action;
		this.mode = mode;
		try{
			document.getElementById("j_searchQuery").value = this.title;
			document.getElementById("j_searchForm").action = this.action;
		}catch(e){};
	}
	
	this.toggleMode = function(){
		if(this.mode == 'users'){
			this.setMode('videos');
		}else{
			this.setMode('users');
		}
	}
	
	this.setQuery = function(){
		var el = document.getElementById("j_searchQuery");
		if(el.value == '' && this.userQuery == true){
			el.value = this.title;
			this.userQuery = false;
		}else if(this.userQuery == false){
				el.value = '';
				this.userQuery = true;
		}
	}
	
	this.setMode(mode);
}
