// onload event handler - handles multiple function for the onLoad event
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


// make external links open in a new window
// just add a rel="extLink" to any link that you want to open in a new window
function externalLinks() {
	if(!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName('a');
	for (var i=0; i<links.length; i++) {
		var thislink = links[i];
		if (thislink.getAttribute('rel')=='extLink'){
			thislink.setAttribute('title','Opens in a new window');
			thislink.onclick = function(){
				window.open(this.href);
				return false;
			}
		}
	}	
}


// highlights a navigation menu element based on the id of the body tag in the current page
// if adding an item to the nav menu, give the page's body an ID 
// and the nav list element an ID of 'nav_' and the corresponding body ID
function menuMarker(){
	if(!document.getElementById('nav')) return false;
	var thisPageId = document.body.getAttribute('id');
	var targetId = 'nav_' + thisPageId;
	if(!document.getElementById(targetId)) return false;
	document.getElementById(targetId).className='active';
}



// contact form stuff
function contactForm(){
	if(!document.getElementById('contactForm')) return false;
	var contactForm = document.getElementById('contactForm');
	
	
	var inputs = contactForm.elements;

	for (var i=0; i<inputs.length; i++){
		var thisinput = inputs[i];
	
		thisinput.onclick=function(){
				var oc = this.value;
				if(this.value!="Send Enquiry"){
					if(this.value=="Your name" || this.value=="Your company name" || this.value=="Your phone number" || this.value=="Your email address" || this.value=="Your enquiry" || this.value=="Date Employment Commenced" || this.value=="Date of Terminations"){
					this.value='';
				}
				
					this.onblur=function(){
						if(this.value==''){
							this.value=oc;
						}
					}
				}
		}
		
	}
	

	if(document.forms[0].remployer.checked){
		document.getElementById('employeeinfo').style.display='none';
	}
	
	//display effects
	
	//show the salary block
	document.getElementById('remployee').onclick=function(){
		if(document.getElementById('employeeinfo').style.display=="none"){		
			Effect.Phase('employeeinfo');	
		}		
	}
	
	//hide the salary block
	document.getElementById('remployer').onclick=function(){
		if(document.getElementById('employeeinfo').style.display!="none"){		
			Effect.Phase('employeeinfo');
		}
	}
	
	
	
	//form validation
//	contactForm.onsubmit=function(){
//		new Ajax.Updater('contactBox','/includes/inc_contactBox.php',{ asynchronous:true, evalScripts:true, method:'post', parameters:Form.serialize(this)});
//		return false;
//	}
	
}






