function loginTabs(){
	var tabs = $('login-tabs');
	if(tabs){
		var tj = $('login-tab-jobseekers');
		var tc = $('login-tab-clients');
		if(tj){
			tj.onclick = function(){
				$('login-content-jobseekers').style.display = 'block';
				$('login-content-clients').style.display = 'none';
				return false;
			}
		}
		if(tc){
			tc.onclick = function(){
				$('login-content-clients').style.display = 'block';
				$('login-content-jobseekers').style.display = 'none';
				return false;
			}
		}
	}
}

function newsArticles(){
	var ln = $('latest-news') 
	if(ln){
		var articles = getElementsByClassName('article',ln,'div');
		for(var i=0;i<articles.length;i++){
			var a = articles[i];
			var h = a.getElementsByTagName('h1')[0];
			var p = a.getElementsByTagName('p')[0];
			
			p.style.display = 'none';
			h.style.cursor = 'pointer';
			h.onclick = function(){
				var p = this.parentNode.getElementsByTagName('p')[0];
				if(p.style.display == 'none'){
					this.className = 'selected';
					p.style.display = '';
				}else{
					this.className = '';
					p.style.display = 'none';
				}
			};
		}
	}
}

function collapsableJobs(){
	var container = $('job-search-results');
	if(container){
		var jobs = getElementsByClassName('result',$('job-search-results'),'div');
		for(var i=0;i<jobs.length;i++){
			if(jobs[i].className.indexOf('bold') === -1){
				var j = jobs[i];
				var h = j.getElementsByTagName('h4')[0];
				var d = getElementsByClassName('other-detail',j,'div')[0];
				
				h.style.cursor = 'pointer';
				d.style.display = 'none';
				
				h.onclick = function(){
					var d = getElementsByClassName('other-detail',this.parentNode,'div')[0];
					if(d.style.display == 'none'){
						this.className = 'selected';
						d.style.display = '';
					}else{
						this.className = '';
						d.style.display = 'none';
					}
				};
				
				h.getElementsByTagName('a')[0].onclick = function(){
					return false;
				};
			}
		}
	}
}

function $(id){
	return document.getElementById(id);
}

function getElementsByClassName(cls,node,tag){
	if(!cls){
		throw new Error('Class must be specified for getElementsByClassName');
	}
	if(!node){
		throw new Error('Node must be specified for getElementsByClassName');
	}
	if(!tag){
		throw new Error('Tag must be specified for getElementsByClassName');
	}
	var retNodes = new Array();
	var elem = node.getElementsByTagName(tag);
	var pattern = new RegExp('(^| )'+cls+'($| )','g');
	for(var i=0;i<elem.length;i++){
		//if(elem[i].className == cls){
		if(elem[i].className.match(pattern)){
			retNodes.push(elem[i]);
		}
	}
	return retNodes;
}

function getRequestParam(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp(regexS);
	var results = regex.exec( window.location.href );
	if(results == null)
		return "";
	else
		return results[1];
}

function getRequestParamArray(name){
	var name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = eval("/[\\?&]"+name+"=([^&#]*)/g");
	var regex = new RegExp(regexS);
	
	var found = new Array();
	while((results = regex.exec(window.location.href)) != null){
		found.push(results[1]);
	}
	return found;
}