﻿// Initialise JavaScript namespaces.

	Website = {};
	Website.Base = {};

// IE6 background image flicker fix.
try { document.execCommand("BackgroundImageCache", false, true); } catch (err) { }

// jquery fix
/*
String.prototype.endsWith = function(str) {
    return (this.match(str + '$') == str)
}

jQuery.extend(
	jQuery.expr[":"].asp = function(a,i,m) {
//	return jQuery(a).attr('id').endsWith(m[3]);
	return (id = jQuery(a).attr('id')) && id.endsWith(m[3]);
	//return jQuery(a).attr('id') && jQuery(a).attr('id').endsWith(m[3]);
    }
);
*/
// end jquery fix



// functions for menu mouse over and login control	
window.addEvent('domready', function(){   								 
	$$('.menuImage').each( function(el){
		el.addEvent('mouseover', function(event){
			this.addClass('over');
		});
		el.addEvent('mouseout', function(event){
			this.removeClass('over');
		});
	 });				

	$$('.loginForm input').each( function(el){
		
		var orginalValue = el.value;
		// if the password field is text onlick turn off display and turn on real field
		if (el.hasClass("passwordInputHack"))
		{
		   el.addClass('formLabel');
		   el.addEvent('focus', function(event){				
				$(this.id +"Field").style.display = 'inline';
				this.style.display = 'none';
				$(this.id +"Field").focus();
			});	
		}	
		// if password fields blank turn off and make fake field display
		else if (el.hasClass("passwordInput"))
		{
		   el.addEvent('blur', function(event){		
				if (this.value.length == 0)
				{
					this.style.display = 'none';
					$(this.id.substr(0, this.id.length-5)).style.display = 'inline';
				}

			});	
		}	
		else if (el.hasClass('fieldComplete'))
		{
			// don't do anyting this class makes it so it doesn't mess with the inputs
		}
		else if (el.type == 'text')
		{	
		   el.addClass('formLabel');
		   el.addEvent('focus', function(event){
				if (this.value == orginalValue )
				{
					this.selectionStart = 0;
				}
			});	
		   el.addEvent('keydown', function(event){
				if (this.value == orginalValue)
				{
					this.value = '';
					el.removeClass('formLabel');
				}
			});	
		   
			el.addEvent('blur', function(event){
				if (this.value.length == 0)
				{
					this.value = orginalValue;
					 el.addClass('formLabel');
				}
			});			   
		}
				
	 });  	

	
});


function loadGeneralForm(){
	$$('.generalForm input').each( function(el){
		
		var orginalValue = el.value;
		// if the password field is text onlick turn off display and turn on real field
		if (el.hasClass("passwordInputHack"))
		{
		   el.addClass('formLabel');
		   el.addEvent('focus', function(event){				
				$(this.id +"Field").style.display = 'inline';
				this.style.display = 'none';
				$(this.id +"Field").focus();
			});	
		}	
		// if password fields blank turn off and make fake field display
		else if (el.hasClass("passwordInput"))
		{
		   el.addEvent('blur', function(event){		
				if (this.value.length == 0)
				{
					this.style.display = 'none';
					$(this.id.substr(0, this.id.length-5)).style.display = 'inline';
				}

			});	
		}	
		else if (el.hasClass('fieldComplete'))
		{
			// don't do anyting this class makes it so it doesn't mess with the inputs
		}
		else if (el.type == 'text')
		{	
		   el.addClass('formLabel');
		   el.addEvent('focus', function(event){
				if (this.value == orginalValue )
				{
					this.selectionStart = 0;
				}
			});	
		   el.addEvent('keydown', function(event){
				if (this.value == orginalValue)
				{
					this.value = '';
					el.removeClass('formLabel');
				}
			});	
		   
			el.addEvent('blur', function(event){
				if (this.value.length == 0)
				{
					this.value = orginalValue;
					 el.addClass('formLabel');
				}
			});			   
		}
				
	 });  	
	
	$$('.generalForm select').each( function(el){
		
		var orginalValue = el.value;
		
		el.addClass('formLabel');
		el.addEvent('click', function(event){			
			if (this.value != orginalValue)
			{
				el.removeClass('formLabel');
			}
		});	
		el.addEvent('keypress', function(event){			
			if (this.value != orginalValue)
			{
				el.removeClass('formLabel');
			}
		});			
		
		el.addEvent('blur', function(event){
			if (this.value == orginalValue)
			{
				this.value = orginalValue;
				 el.addClass('formLabel');
			}
		});	
				
	 });  		
	
	$$('.generalForm textarea').each( function(el){
											   
		var tempValue = el.value;	
		el.addClass('formLabel');
	   	el.addEvent('keydown', function(event){			
			if (this.value == tempValue)
			{
				this.value = '';
				el.removeClass('formLabel');
			}			
		});	
				
	 });  	
}



GeneralForm = { };
GeneralForm.ErrorBubble = { };
GeneralForm.ErrorBubble.Visible = true;
GeneralForm.ErrorBubble.ShowError = function(event, text) {
	if (GeneralForm.ErrorBubble.Visible) {
		var e = new Event(event);
		var bubble = $('FormErrorBubble');
		var caller = Utils.isMSIE ? $(e.relatedTarget) : $(e.target);
        
		bubble.DoShow = true;
        
		if (caller.init != true) {
			caller.addEvent("mousemove", function(e) { GeneralForm.ErrorBubble.MouseMove(e); });
			caller.addEvent("mouseout", function(e) { GeneralForm.ErrorBubble.MouseOut(e); });
			caller.init = true;
		}
        
		$('errorBubbleText').innerHTML = text;
		bubble.setStyle("display", "block");
	}
}

GeneralForm.ErrorBubble.MouseOut = function() {
    var bubble = $('FormErrorBubble');
    bubble.DoShow = false;
    
    clearInterval(bubble.interval);
    bubble.interval = setInterval("GeneralForm.ErrorBubble.HideBubble();", 100);
}

GeneralForm.ErrorBubble.HideBubble = function() {
	 var bubble = $('FormErrorBubble');
	 
	 if (!bubble.DoShow) {
		bubble.setStyle("display", "none");
	}
}

GeneralForm.ErrorBubble.MouseMove = function(e) {
    if(e.page ==null) {
        return;
    }
    var bubble = $('FormErrorBubble');
    var top = e.page.y - 6;
    var left = e.page.x + 14;
    if (bubble.DoShow) {
		bubble.setStyle("top", top + "px");
		bubble.setStyle("left", left + "px");
	}
}


/*function for registration form*/
function loadRegistrationForm(){
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName') != null)
	{
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName').value ="First Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtLastName').value = "Last Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtDOB').value = "DOB - DD/MM/YYYY";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobile').value = "Mobile";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordField').value = "";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirmField').value = "";
		// only reset email and friend email if not send a firend
		if (String(window.location.href).search(/\?f/) == -1)
		{
			$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').value = "Email";
			$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFriendEmail').value = "";
		}
		
		loadGeneralForm();
		
		
		var req = new Request({
		  method: "post",
		  url: "/ajaxCaller.aspx",
		  data: "ajax=1&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail").value+"",
		   onComplete: function (response) {                           
			if (response.length == 0)
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "email valid";
			}
			else
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "";
			}

			}
		}).send();
		   
		var req = new Request({
		  method: "post",
		  url: "/ajaxCaller.aspx",
		  data: "ajax=2&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobile").value+"",
		   onComplete: function (response) {                        
			if (response.length == 0)
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobileAjaxValidator").value = "phone valid";
			}
			else
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobileAjaxValidator").value = "";
			}

			}
		}).send();
	
		
	 /* check email  */
	   $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').addEvent('keyup', function(event) {	        
			var t = this; 
			if (this.value != this.lastValue ==  this.value.length > 5) {
				if (this.timer) clearTimeout(this.timer);
				this.timer = setTimeout(function () {
					var req = new Request({
					  method: "post",
					  url: "/ajaxCaller.aspx",
					  data: "ajax=1&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail").value+"",
					   onComplete: function (response) {                           
						if (response.length == 0)
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "email valid";
						}
						else
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "";
						}
	
						}
					}).send();
				}, 200);
			  }
				this.lastValue = this.value;
		   });
		   
		   
		/* check phone  */
	   $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobile').addEvent('keyup', function(event) {	        
			var t = this; 
			if (this.value != this.lastValue ==  this.value.length > 5) {
				if (this.timer) clearTimeout(this.timer);
				this.timer = setTimeout(function () {
					var req = new Request({
					  method: "post",
					  url: "/ajaxCaller.aspx",
					  data: "ajax=2&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobile").value+"",
					   onComplete: function (response) {                        
						if (response.length == 0)
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobileAjaxValidator").value = "phone valid";
						}
						else
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobileAjaxValidator").value = "";
						}
	
						}
					}).send();
				}, 200);
			  }
				this.lastValue = this.value;
		   });
	}
}

function checkRegistrationForm(){
	var hasError = false;
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName') != null)
	{
		var firstName = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName');
		var lastName = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtLastName');
		var DOB = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtDOB');
		var email = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail');
		var emailAjax = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator');
		var mobile = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobile');
		var mobileAjax = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtMobileAjaxValidator');
		
		
		var password = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordField');
		var passwordDisplay = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPassword');	
		var passwordConfirm = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirmField');
		var passwordConfirmDisplay = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirm');
		var friendEmail = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFriendEmail');
		var waiver = $('ctl00_ctl00_cBodyContainer_cBodyContainer_chkWaiver');

		var hearAbout = $('ctl00_ctl00_cBodyContainer_cBodyContainer_ddlHearAbout');
	
		firstName.onmouseover = null;
		firstName.removeClass("containsErrors");
		if (firstName.value != 'First Name')
		{
			if(!containsAlphaOnly(firstName.value))
			{
			   firstName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid First Name"); };		   
			   firstName.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			firstName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your First Name"); };
			firstName.addClass("containsErrors");
			hasError = true;
		}
		
		
		lastName.onmouseover = null;
		lastName.removeClass("containsErrors");
		if (lastName.value != 'Last Name')
		{
			if(!containsAlphaOnly(lastName.value))
			{
			   lastName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Last Name"); };		   
			   lastName.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			lastName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Last Name"); };
			lastName.addClass("containsErrors");
			hasError = true;
		}	
		
		email.onmouseover = null;
		email.removeClass("containsErrors");
		if (email.value != 'Email')
		{
			if(emailAjax.value == '')
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "This email already exists in the system"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			else if(!isValidEmail(email.value))
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Email"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Email "); };
			email.addClass("containsErrors");
			hasError = true;
		}		
		
		mobile.onmouseover = null;
		mobile.removeClass("containsErrors");
		if (mobile.value != 'Mobile')
		{
			if(mobileAjax.value == '')
			{
			   mobile.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "This mobile number already exists in the system"); };		   
			   mobile.addClass("containsErrors");
			   hasError = true;
			}
			else if(!isValidMobile(mobile.value))
			{
			   mobile.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Mobile number"); };		   
			   mobile.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			mobile.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Mobile number "); };
			mobile.addClass("containsErrors");
			hasError = true;
		}		
		
		
		var waiverSigned = waiver.checked;	
		if (!Utils.isMSIE && !Utils.isMSIE6)
		{
			waiver = waiver.parentNode;
		}
		waiver.onmouseover = null;
		waiver.removeClass("containsErrors");
		if (!waiverSigned)
		{
		   waiver.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "You must agree to the terms and conditions"); };	
		   waiver.addClass("containsErrors");
		   hasError = true;
		}		

		
		friendEmail.onmouseover = null;
		friendEmail.removeClass("containsErrors");
		if (friendEmail.value != '')
		{
			if(!isValidEmail(friendEmail.value))
			{
			   friendEmail.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Email"); };		   
			   friendEmail.addClass("containsErrors");
			   hasError = true;
			}

        }

        hearAbout.onmouseover = null;
        hearAbout.removeClass("containsErrors");
        if (hearAbout.selectedIndex == "0") {
            hearAbout.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please select how you heard about us"); };
            hearAbout.addClass("containsErrors");
            hasError = true;
        }		
	
	
		DOB.onmouseover = null;
		DOB.removeClass("containsErrors");
		if (DOB.value != 'DOB - DD/MM/YYYY')
		{
			if (isValidDate(DOB.value))
			{
				 var dobString = DOB.value.split("/")[1] +"/"+ DOB.value.split("/")[0] +"/"+ DOB.value.split("/")[2];
				 var dobDate =  new Date(dobString);	
				 var currentDate =  new Date();
	
				 if (dobDate.getFullYear() < 1901)
				 {
					DOB.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Invalid DOB, are you really a centenarian?"); };		   
					DOB.addClass("containsErrors");
					hasError = true;					 
				 }					 
	
				 dobDate.setFullYear(dobDate.getFullYear()+16);
				 if (dobDate > currentDate)
				 {
					DOB.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "You must be 16 to register"); };		   
					DOB.addClass("containsErrors");
					hasError = true;					 
				 }
	
			}
			else
			{
				DOB.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Invalid DOB, please check and re-enter"); };		   
				DOB.addClass("containsErrors");
				hasError = true;			
			}
	
		}
		else
		{
			DOB.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your DOB"); };
			DOB.addClass("containsErrors");
			hasError = true;
		}	
	
		passwordConfirm.onmouseover = null;
		passwordConfirmDisplay.onmouseover = null;
		passwordConfirm.removeClass("containsErrors");
		passwordConfirmDisplay.removeClass("containsErrors");	
		password.onmouseover = null;
		passwordDisplay.onmouseover = null;
		password.removeClass("containsErrors");
		passwordDisplay.removeClass("containsErrors");	
		if (passwordConfirm.value != "")
		{
			if(password.value != passwordConfirm.value)
			{
			   passwordConfirm.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };		   
			   passwordConfirm.addClass("containsErrors");
			   password.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };		   
			   password.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordConfirmDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a Password"); };
			passwordConfirmDisplay.addClass("containsErrors");
			hasError = true;
		}		
	
		if (password.value != '')
		{
			if((password.value).search(/(?=.{8,50})(?=.*[A-Za-z])(?=.*[0-9])(?!.*\s).*/))
			{
			   password.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password must be at least 8 characters with a combination of letters and numbers"); };		   
			   password.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a Password"); };
			passwordDisplay.addClass("containsErrors");
			hasError = true;
		}		

	}
	return !hasError;
	
}





/*function for employer registration form*/
function loadEmployerRegistrationForm(){
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName') != null)
	{
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName').value ="First Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtLastName').value = "Last Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmployer').value = "Company Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordField').value = "";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirmField').value = "";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').value = "Email";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtWebsite').value = "Company Website";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPhone').value = "Primary Phone";
		
		var positionSelect = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPosition');
		positionSelect.selectedIndex = "0";
		var positionOther = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPositionOther');
		positionOther.value = "Please Specify Position";
				
		loadGeneralForm();		
		
		var req = new Request({
		  method: "post",
		  url: "/ajaxCaller.aspx",
		  data: "ajax=1&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail").value+"",
		   onComplete: function (response) {                           
			if (response.length == 0)
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "email valid";
			}
			else
			{
				 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "";
			}

			}
		}).send();	
	
	/* position */
	positionSelect.addEvent('click', function(event){		
		if (positionSelect.value == "Other")
		{
			$('formOther').style.display = 'block';	
		}
		else
		{
			$('formOther').style.display = 'none';
			positionOther.value = "Please Specify Position";
			positionOther.addClass("formLabel");
		}
	});		
	positionSelect.addEvent('keypress', function(event){		
		if (positionSelect.value == "Other")
		{
			$('formOther').style.display = 'block';		
		}
		else
		{
			$('formOther').style.display = 'none';
			positionOther.value = "Please Specify Position";
			positionOther.addClass("formLabel");
		}
	});		
	
		
	 /* check email  */
	   $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').addEvent('keyup', function(event) {	        
			var t = this; 
			if (this.value != this.lastValue ==  this.value.length > 5) {
				if (this.timer) clearTimeout(this.timer);
				this.timer = setTimeout(function () {
					var req = new Request({
					  method: "post",
					  url: "/ajaxCaller.aspx",
					  data: "ajax=1&input="+$("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail").value+"",
					   onComplete: function (response) {                           
						if (response.length == 0)
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "email valid";
						}
						else
						{
							 $("ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator").value = "";
						}
	
						}
					}).send();
				}, 200);
			  }
				this.lastValue = this.value;
		   });
		   
	}
}

function checkEmployerRegistrationForm(){
	var hasError = false;
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName') != null)
	{
		var firstName = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFirstName');
		var lastName = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtLastName');
		var employer = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmployer');
		var email = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail');
		var emailAjax = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmailAjaxValidator');
		var website = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtWebsite');
		var phone = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPhone');
		
		
		var password = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordField');
		var passwordDisplay = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPassword');	
		var passwordConfirm = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirmField');
		var passwordConfirmDisplay = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPasswordConfirm');
		var positionSelect = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPosition');
		var positionOther = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtPositionOther');
		var waiver = $('ctl00_ctl00_cBodyContainer_cBodyContainer_chkWaiver');
		var hearAbout = $('ctl00_ctl00_cBodyContainer_cBodyContainer_ddlHearAbout');
		
	
		employer.onmouseover = null;
		employer.removeClass("containsErrors");
		if (employer.value == 'Company Name')
		{
			employer.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a Company Name"); };
			employer.addClass("containsErrors");
			hasError = true;
		}		
		
		website.onmouseover = null;
		website.removeClass("containsErrors");
		if (website.value != 'Company Website')
		{
			// need a function to check for valid url
			if(!isValidURL(website.value))
			{
			   website.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Website"); };		   
			   website.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			website.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Company's Website"); };
			website.addClass("containsErrors");
			hasError = true;
		}		
				
		phone.onmouseover = null;
		phone.removeClass("containsErrors");
		if (phone.Value != 'Primary Phone')
		{
			if(!isValidPhone(phone.value))
			{
			   phone.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Phone number"); };		   
			   phone.addClass("containsErrors");
			   hasError = true;
			}	
			else if((phone.value).substring(0,2) == "04" )
			{
			   phone.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Mobile numbers cannot be used, please enter in a Landline"); };		   
			   phone.addClass("containsErrors");
			   hasError = true;
			}			
		}
		else
		{
			phone.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your primary Phone"); };
			phone.addClass("containsErrors");
			hasError = true;
		}
		
		positionSelect.onmouseover = null;
		positionSelect.removeClass("containsErrors");
		if (positionSelect.selectedIndex == 0)
		{
			positionSelect.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please select your position"); };
			positionSelect.addClass("containsErrors");
			hasError = true;
		}		
		
		
		positionOther.onmouseover = null;
		positionOther.removeClass("containsErrors");
		if (positionSelect.value == 'Other' && positionOther.value == 'Please Specify Position')
		{
			positionOther.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please specify your position"); };
			positionOther.addClass("containsErrors");
			hasError = true;
		}


		hearAbout.onmouseover = null;
		hearAbout.removeClass("containsErrors");
		if (hearAbout.selectedIndex == "0") {
		    hearAbout.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please select how you heard about us"); };
		    hearAbout.addClass("containsErrors");
		    hasError = true;
		}		
	
		firstName.onmouseover = null;
		firstName.removeClass("containsErrors");
		if (firstName.value != 'First Name')
		{
			if(!containsAlphaOnly(firstName.value))
			{
			   firstName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid First Name"); };		   
			   firstName.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			firstName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your First Name"); };
			firstName.addClass("containsErrors");
			hasError = true;
		}
		
		
		lastName.onmouseover = null;
		lastName.removeClass("containsErrors");
		if (lastName.value != 'Last Name')
		{
			if(!containsAlphaOnly(lastName.value))
			{
			   lastName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Last Name"); };		   
			   lastName.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			lastName.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Last Name"); };
			lastName.addClass("containsErrors");
			hasError = true;
		}	
		
		email.onmouseover = null;
		email.removeClass("containsErrors");
		if (email.value != 'Email')
		{
			if(emailAjax.value == '')
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "This email already exists in the system"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			else if(!isValidEmail(email.value))
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Email"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			else if (!isValidEmployerEmail(email.value))
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please use your work email, web-based emails are not accepted"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Email "); };
			email.addClass("containsErrors");
			hasError = true;
		}		
		
		
		var waiverSigned = waiver.checked;	
		if (!Utils.isMSIE && !Utils.isMSIE6)
		{
			waiver = waiver.parentNode;
		}
		waiver.onmouseover = null;
		waiver.removeClass("containsErrors");
		if (!waiverSigned)
		{
		   waiver.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "You must agree to the terms and conditions"); };	
		   waiver.addClass("containsErrors");
		   hasError = true;
		}


		passwordConfirm.onmouseover = null;
		passwordConfirmDisplay.onmouseover = null;
		passwordConfirm.removeClass("containsErrors");
		passwordConfirmDisplay.removeClass("containsErrors");	
		password.onmouseover = null;
		passwordDisplay.onmouseover = null;
		password.removeClass("containsErrors");
		passwordDisplay.removeClass("containsErrors");	
		if (passwordConfirm.value != "")
		{
			if(password.value != passwordConfirm.value)
			{
			   passwordConfirm.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };		   
			   passwordConfirm.addClass("containsErrors");
			   password.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };		   
			   password.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordConfirmDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a Password"); };
			passwordConfirmDisplay.addClass("containsErrors");
			hasError = true;
		}		
	
		if (password.value != '')
		{
			if((password.value).search(/(?=.{8,50})(?=.*[A-Za-z])(?=.*[0-9])(?!.*\s).*/))
			{
			   password.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Password must be at least 8 characters with a combination of letters and numbers"); };		   
			   password.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a Password"); };
			passwordDisplay.addClass("containsErrors");
			hasError = true;
		}		

	}
	return !hasError;
	
}


/*function for contact  form*/
function loadContactForm(){
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_cSubject') != null)
	{
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cSubject').selectedIndex =0;
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cSubject').focus();
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cName').value = "Your Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cEmail').value = "Your Email";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cPhone').value = "Your Phone Number";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_cText').value = "Comments or Questions";
		loadGeneralForm();		
	}
}

function checkContactForm(){
	var hasError = false;
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_cSubject') != null)
	{
		var name = $('ctl00_ctl00_cBodyContainer_cBodyContainer_cName');
		var subject = $('ctl00_ctl00_cBodyContainer_cBodyContainer_cSubject');
		var email = $('ctl00_ctl00_cBodyContainer_cBodyContainer_cEmail');
		var phone = $('ctl00_ctl00_cBodyContainer_cBodyContainer_cPhone');
		var textv = $('ctl00_ctl00_cBodyContainer_cBodyContainer_cText');

		subject.onmouseover = null;
		subject.removeClass("containsErrors");
		if (subject.selectedIndex == 0)
		{
		   subject.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please select a Subject"); };		   
		   subject.addClass("containsErrors");
		   hasError = true;
		}
		
		
		name.onmouseover = null;
		name.removeClass("containsErrors");
		if (name.value != 'Your Name')
		{
			if(!containsAlphaOnly(name.value))
			{
			   name.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Name"); };		   
			   name.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			name.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter Your Name"); };
			name.addClass("containsErrors");
			hasError = true;
		}
		
		
		email.onmouseover = null;
		email.removeClass("containsErrors");
		if (email.value != 'Your Email')
		{
			if(!isValidEmail(email.value))
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Email"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Email "); };
			email.addClass("containsErrors");
			hasError = true;
		}		
		
		phone.onmouseover = null;
		phone.removeClass("containsErrors");
		if (phone.value != 'Your Phone Number')
		{
			if(!isValidPhone(phone.value))
			{
			   phone.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Phone Number"); };		   
			   phone.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			phone.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Phone Number "); };
			phone.addClass("containsErrors");
			hasError = true;
		}		
		
		
		textv.onmouseover = null;
		textv.removeClass("containsErrors");
		if (textv.value == '' || textv.value == "Comments or Questions")
		{
		   textv.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter your Comments or Questions"); };		   
		   textv.addClass("containsErrors");
		   hasError = true;
		}	
	

	}
	return !hasError;
	
}




/*function for homepage search  form*/
function loadHomeSearchForm(){
	if ($('keywordSearch') != null)
	{
		
		industryInitalLoad(-1, $('canIndustry1'), false, true); 
		industryInitalLoad(-1, $('canIndustry2'), false, true); 
		locationInitalLoad(-1, $('canLocation1'), false, true); 
		locationInitalLoad(-1, $('canLocation2'), false, true); 
		
		$('keywordSearch').value = "Keyword";
		$('workType').options[0].text = "Employment Type";
		$('canIndustry1').options[0].text = "Primary Classification";
		$('canIndustry2').options[0].text = "Sub Classification";
		$('canLocation1').options[0].text = "State";
		$('canLocation2').options[0].text = "Location";
		
		$('workType').selectedIndex = 0;
		$('canIndustry1').selectedIndex = 0;
		$('canIndustry2').selectedIndex = 0;
		$('canLocation1').selectedIndex = 0;
		$('canLocation2').selectedIndex = 0;	
		
		loadGeneralForm();		
	}
}

function checkHomeSearchForm(){
	var hasError = false;	
	
	if ($('keywordSearch') != null)
	{
		var name = $('keywordSearch');
		if ($('workType').selectedIndex == 0 && ($('keywordSearch').value == "Keyword" || $('keywordSearch').value == "") && 
		$('canIndustry1').selectedIndex == 0 &&
		$('canLocation1').selectedIndex == 0 )	
		{
			alert("Please select at least one criteria before continuing");
			hasError = true;
		}
	
	
	}
	return !hasError;
	
}

function checkCandidateMailSearchForm(){
	var hasError = false;	
	
	if ($('keywordSearch') != null)
	{
		var name = $('keywordSearch');
		if ($('workType').selectedIndex == 0 && ($('keywordSearch').value == "") && 
		$('canIndustry1').selectedIndex == 0  &&
		$('canLocation1').selectedIndex == 0 )	
		{
			alert("Please select at least one criteria before continuing");
			hasError = true;
		}
	
		$('searchName').onmouseover = null;
		$('searchName').removeClass("containsErrors");
		if ($('searchName').value == '' )
		{
		   $('searchName').onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a search name"); };		   
		   $('searchName').addClass("containsErrors");
		   hasError = true;
		}	
	
	}
	return !hasError;
	
}


function checkBrowseSearch(form){
	var hasError = true;	
	for(var d = 0; d<form.getElementsByTagName('input').length; d++)	
	{
		if (form.getElementsByTagName('input')[d].checked)
		{
			hasError  = false;
			break;
		}
	}
	if (hasError)
	{
		alert("Please select at lease one classification before continuing");
	}
	return !hasError;
	
}




/*function for send a friend form*/
function loadFriendForm(){
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFullName') != null)
	{
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFullName').focus();
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFullName').value = "Your Friend's Name";
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').value = "Your Friend's Email";
		loadGeneralForm();		
	}
}

function checkFriendForm(){
	var hasError = false;
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFullName') != null)
	{
		var name = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtFullName');
		var email = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail');


		name.onmouseover = null;
		name.removeClass("containsErrors");
		if (name.value != "Your Friend's Name")
		{
			if(!containsAlphaOnly(name.value))
			{
			   name.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Name"); };		   
			   name.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			name.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter Your Friend's Name"); };
			name.addClass("containsErrors");
			hasError = true;
		}
		
		
		email.onmouseover = null;
		email.removeClass("containsErrors");
		if (email.value != "Your Friend's Email")
		{
			if(!isValidEmail(email.value))
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a valid Email"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter Your Friend's Email"); };
			email.addClass("containsErrors");
			hasError = true;
		}			

	}
	return !hasError;
	
}

/*function for profile request form*/
function loadProfileRequestForm(){
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail') != null)
	{
		$('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail').value = "Email";
		loadGeneralForm();		
	}
}

function checkProfileRequestForm(){
	var hasError = false;
	if ($('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail') != null)
	{
		var email = $('ctl00_ctl00_cBodyContainer_cBodyContainer_txtEmail');
		var existingEmail = $('ctl00_ctl00_cBodyContainer_cBodyContainer_empEmail');
		var waiver = $('ctl00_ctl00_cBodyContainer_cBodyContainer_chkWaiver');
		var employmentType = $('employmentType');
		var PD = $('ctl00_ctl00_cBodyContainer_cBodyContainer_productDescription');
		var PDdiv = $('productDescriptionDiv');

		var waiverSigned = waiver.checked;	
		if (!Utils.isMSIE && !Utils.isMSIE6)
		{
			waiver = waiver.parentNode;
		}
		waiver.onmouseover = null;
		waiver.removeClass("containsErrors");
		if (!waiverSigned)
		{
		   waiver.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "You must agree to the terms and conditions"); };	
		   waiver.addClass("containsErrors");
		   hasError = true;
		}
		
		
		employmentType.onmouseover = null;
		employmentType.removeClass("containsErrors");
		if (!$('ctl00_ctl00_cBodyContainer_cBodyContainer_employmentType_Contract').checked &&
			   !$('ctl00_ctl00_cBodyContainer_cBodyContainer_employmentType_FullTime').checked &&
			   !$('ctl00_ctl00_cBodyContainer_cBodyContainer_employmentType_PartTime').checked &&
			   !$('ctl00_ctl00_cBodyContainer_cBodyContainer_employmentType_Casual').checked &&
			   !$('ctl00_ctl00_cBodyContainer_cBodyContainer_employmentType_Vacation').checked)
		{
		   employmentType.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "You select at least one employment type"); };	
		   employmentType.addClass("containsErrors");
		   hasError = true;
		}		
		
		PDdiv.onmouseover = null;
		PDdiv.removeClass("containsErrors");
		if (PD.value != "")
		{
			var fileExtention = PD.value.substring(PD.value.lastIndexOf(".")+1);
			var allowedExtention = "doc, docx, pdf, xls, xlsx";
			if(allowedExtention.indexOf(fileExtention) == -1)
			{
			   PDdiv.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Supplied file is in the wrong format, please select another file."); };		   
			   PDdiv.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			PDdiv.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please upload a position description"); };
			PDdiv.addClass("containsErrors");
			hasError = true;
		}			
		
		
		email.onmouseover = null;
		email.removeClass("containsErrors");
		if (email.value != "Email")
		{
			if(existingEmail.value.toLowerCase() != email.value.toLowerCase())
			{
			   email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Supplied email does not match the email you signed up with"); };		   
			   email.addClass("containsErrors");
			   hasError = true;
			}
			
		}
		else
		{
			email.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter Your Email"); };
			email.addClass("containsErrors");
			hasError = true;
		}			

	}
	return !hasError;
	
}






/*function for change password form*/
function loadChangePasswordForm(){
	if ($('cBodyContainer_cBodyContainer_PasswordForm_txtPresentPassword') != null)
	{		
//		$('cBodyContainer_cBodyContainer_PasswordForm_txtPresentPassword').value ="Current Password";
//		$('cBodyContainer_cBodyContainer_PasswordForm_txtPassword').value = "New Password";
//		$('cBodyContainer_cBodyContainer_PasswordForm_txtPasswordConfirm').value = "Confirm New Password";
		loadGeneralForm();		
	}
}

function checkChangePasswordForm(){
	var hasError = false;
	if ($('cBodyContainer_cBodyContainer_PasswordForm_txtPresentPassword') != null)
	{
		var cPasswordDisplay = $('cBodyContainer_cBodyContainer_PasswordForm_txtPresentPassword');
		var passwordDisplay = $('cBodyContainer_cBodyContainer_PasswordForm_txtPassword');
		var passwordConfirmDisplay = $('cBodyContainer_cBodyContainer_PasswordForm_txtPasswordConfirm');
//		var cPassword = $('ctl00_ctl00_cBodyContainer_cBodyContainer_PasswordForm_txtPresentPasswordField');
//		var password = $('ctl00_ctl00_cBodyContainer_cBodyContainer_PasswordForm_txtPasswordField');
//		var passwordConfirm = $('ctl00_ctl00_cBodyContainer_cBodyContainer_PasswordForm_txtPasswordConfirmField');

		
		cPasswordDisplay.onmouseover = null;
		cPasswordDisplay.removeClass("containsErrors");
		if (cPasswordDisplay.value == '')
		{
 			cPasswordDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please provide your current password"); };		   
			cPasswordDisplay.addClass("containsErrors");
			hasError = true;
		}		
	
		//passwordConfirm.onmouseover = null;
		passwordConfirmDisplay.onmouseover = null;
		//passwordConfirm.removeClass("containsErrors");
		passwordConfirmDisplay.removeClass("containsErrors");	
		//password.onmouseover = null;
		passwordDisplay.onmouseover = null;
		//password.removeClass("containsErrors");
		passwordDisplay.removeClass("containsErrors");
		if (passwordConfirmDisplay.value != "")
		{
			if (passwordDisplay.value != passwordConfirmDisplay.value)
			{
				passwordConfirmDisplay.onmouseover = function (e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };
				passwordConfirmDisplay.addClass("containsErrors");
				passwordDisplay.onmouseover = function (e) { GeneralForm.ErrorBubble.ShowError(e, "Password does not match"); };
				passwordDisplay.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordConfirmDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a new Password"); };
			passwordConfirmDisplay.addClass("containsErrors");
			hasError = true;
		}

		if (passwordDisplay.value != '')
		{
			if ((passwordDisplay.value).search(/(?=.{8,50})(?=.*[A-Za-z])(?=.*[0-9])(?!.*\s).*/))
			{
				passwordDisplay.onmouseover = function (e) { GeneralForm.ErrorBubble.ShowError(e, "Password must be at least 8 characters with a combination of letters and numbers"); };
				passwordDisplay.addClass("containsErrors");
			   hasError = true;
			}
		}
		else
		{
			passwordDisplay.onmouseover = function(e) { GeneralForm.ErrorBubble.ShowError(e, "Please enter a new Password"); };
			passwordDisplay.addClass("containsErrors");
			hasError = true;
		}		

	}
	return !hasError;
	
}

// toggle for search candidate selector

function toggleCandidateSelector(checkBox, value)
{
	
	if (checkBox.checked)
	{
		((checkBox.parentNode).parentNode).className = 'resultTitleBar checked';	
		var currentSelected = Cookie.read('candidateSelected');
		if (currentSelected != null)
		{
			Cookie.write('candidateSelected', currentSelected + "," + value, {duration: 1});
		}
		else
		{
			Cookie.write('candidateSelected', value, {duration: 1});
		}
	}
	else
	{
		//checkBox.parentNode.parentNode.removeClass('checked');
		((checkBox.parentNode).parentNode).className = 'resultTitleBar';	
		
		var currentSelected = Cookie.read('candidateSelected');
		if (currentSelected != null)
		{
			if (currentSelected.indexOf(value) != '-1')
			{
				var selectedArray = currentSelected.split(',');
				selectedArray = selectedArray.erase(value);
				currentSelected = selectedArray.join(",");
			}		
			Cookie.write('candidateSelected', currentSelected, {duration: 1});
		}
	}
	
	var totalSelected = Cookie.read('candidateSelected');
	if (totalSelected != null && totalSelected != "")
	{
		$$('.checkboxSummaryText')[0].innerHTML = totalSelected.split(',').length+ " candidates selected";
		$$('.viewCandidates')[0].style.display = 'block';
		$$('.checkboxSummaryText')[1].innerHTML = totalSelected.split(',').length+ " candidates selected";
		$$('.viewCandidates')[1].style.display = 'block';
	}
	else
	{
		$$('.checkboxSummaryText')[0].innerHTML = "0 candidates selected - click on check boxes to view details of multiple candidates";
		$$('.viewCandidates')[0].style.display = 'none';
		$$('.checkboxSummaryText')[1].innerHTML = "0 candidates selected - click on check boxes to view details of multiple candidates";
		$$('.viewCandidates')[1].style.display = 'none';
	}
}

function loadSelectedCandidates(){
	var currentSelected = Cookie.read('candidateSelected');
	if (currentSelected != null)
	{

		var totalSelected = currentSelected.split(',').length;
		if (totalSelected > 0)
		{
			$$('.checkboxSummaryText')[0].innerHTML = totalSelected + " candidates selected";
			$$('.viewCandidates')[0].style.display = 'block';
			$$('.checkboxSummaryText')[1].innerHTML = totalSelected + " candidates selected";
			$$('.viewCandidates')[1].style.display = 'block';
		}
		
		var displayedCandidates = $$('.hiddenDisplayProfiles')[0].value.split(",");
		for(var j = 0; j<displayedCandidates.length-1; j++)				
		{
			if (currentSelected.indexOf(displayedCandidates[j])!= -1)
			{
				$$('.resultTitleBar')[j].className = 'resultTitleBar checked';
				$$('.resultTitleBar')[j].getChildren()[0].getChildren()[0].checked = true;
			}
			else
			{
				$$('.resultTitleBar')[j].getChildren()[0].getChildren()[0].checked = false;				
			}
			
			
		}
	}
	
}

// toggle for search filter display
function toggleFilter(filterName, filterLink)
{	

	var selectedFilter = $$('.'+filterName);
	if (selectedFilter.hasClass('closed')  == 'true')
	{
		selectedFilter.removeClass('closed');
		filterLink.innerHTML = "Less <img src='/App_Assets/images/close.jpg' /></a>";
	}
	else
	{
		selectedFilter.addClass('closed');
		filterLink.innerHTML = "More <img src='/App_Assets/images/open.jpg' /></a>";
	}
}

// loads filters and set the sizes
function loadFilters()
{	
	if ($$('.locationFilterLink') != null)
	{
		if ($$('.locationFilterLink') == ""){ $$('.locationFilter').removeClass('closed');}
	}
	if ($$('.workTypeFilterLink') != null)
	{
		if ($$('.workTypeFilterLink') == ""){ $$('.workTypeFilter').removeClass('closed');}
	}
	if ($$('.industryFilterLink') != null)
	{
		if ($$('.industryFilterLink') == ""){ $$('.industryFilter').removeClass('closed');}
	}	


	
}

// load xml function
function loadXMLDoc(dname) 
{
	var xmlDoc;


	if (window.XMLHttpRequest)
	  {
	  xmlDoc=new window.XMLHttpRequest();
	  xmlDoc.open("GET",dname,false);
	  xmlDoc.send("");
	  return xmlDoc.responseXML;
	  }  
	// IE 5 and IE 6
	else if (window.ActiveXObject)
	{
		
		try 
		{					
		  xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
		  xmlDoc.async=false;
		  xmlDoc.load(dname);
		  return xmlDoc;			
		}
		catch (e)
		{
		
			try
			{			
				xmlDoc=new ActiveXObject("Msxml2.DomDocument");
				xmlDoc.async=false;
				xmlDoc.load(dname);

				return xmlDoc;				
			}
		
			catch (e)
			{
		
			}
		}

	}
	else
	{
		alert("Error loading document");
	}
	/*else if (ActiveXObject("Microsoft.XMLDOM"))
	  {
	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	  xmlDoc.async=false;
	  xmlDoc.load(dname);
	  return xmlDoc;
	  }*/
	
	return null;
}

// load xml for location and industry onload to avoid loading repeatedly

var xmlLocationDoc1=null;
var xmlLocationDoc2=null;
var xmlLocationDoc3=null;
var xmlIndustryDoc1= null;
var xmlIndustryDoc2= null;
var xmlIndustryDoc3= null;
var xmlLocationSearchBasic= null;

function locationsOnChange(obj, loadObj, isSearch){	
	var xmlLocationDoc;
	var type = 0;
	if (isSearch == null)
	{
		isSearch = false;
	}
	if (loadObj.name.indexOf('canLocation1') != -1)
	{
		if (xmlLocationDoc1 == null) {xmlLocationDoc1 = loadXMLDoc("/App_Assets/scripts/locationTop.xml")};
		xmlLocationDoc = xmlLocationDoc1;
		type = 1;
	}
	else if (loadObj.name.indexOf('canLocation2') != -1)
	{
		if (isSearch)
		{
			if (xmlLocationSearchBasic == null) {xmlLocationSearchBasic = loadXMLDoc("/App_Assets/scripts/locationSearchMid.xml")};
			xmlLocationDoc = xmlLocationSearchBasic;
		}
		else
		{
			if (xmlLocationDoc2 == null) {xmlLocationDoc2 = loadXMLDoc("/App_Assets/scripts/locationMid.xml")};
			xmlLocationDoc = xmlLocationDoc2;
		}
		
		type = 2;		
	}
	else
	{
		if (xmlLocationDoc3 == null) {xmlLocationDoc3 = loadXMLDoc("/App_Assets/scripts/locationLow.xml")};
		xmlLocationDoc = xmlLocationDoc3;
		type = 3;
	}	
	
	var nodeObject;	
	var parentID = obj.options[obj.selectedIndex].value;
	var foundGroup = false;
	loadObj.options.length = 1;
	for (var x = 0; x <xmlLocationDoc.getElementsByTagName("location").length; x++ )
	{
		
		nodeObject = xmlLocationDoc.getElementsByTagName("location")[x];
		
		if (nodeObject.childNodes[0].firstChild.nodeValue == parentID)
		{
			var z;
			for (z= 0; z <nodeObject.getElementsByTagName("sublocation").length; z++ )
			{
				if (isSearch)
				{			
					// if publish
					if (nodeObject.getElementsByTagName("sublocation")[z].childNodes[4].firstChild.nodeValue == 1)
					{
						var thisSubNode = nodeObject.getElementsByTagName("sublocation")[z];
						if (thisSubNode.getElementsByTagName("thridLocation").length)
						{
							var thisValueName = nodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue;
							loadObj.options[loadObj.length] = new Option(thisValueName + " - All", nodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	

							for (s= 0; s <thisSubNode.getElementsByTagName("thridLocation").length; s++ )
							{		
								// if publish
								if (thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[4].firstChild.nodeValue == 1)
								{
									loadObj.options[loadObj.length] = new Option(thisValueName + " - " + thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[3].firstChild.nodeValue, thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[0].firstChild.nodeValue);		
								}
							}
						}
						else
						{
							loadObj.options[loadObj.length] = new Option(nodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, nodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
						}
					}
				}	
				else
				{
					loadObj.options[loadObj.length] = new Option(nodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, nodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
				}
			}				
			foundGroup = true;
		}		
		// roles are listed in groups of their parent role, if you find a role you will find everything for that role
		// if you move into a new group there is no need to loop through the whole file
		if (foundGroup && nodeObject.childNodes[1].firstChild.nodeValue != parentID)
		{
			break;
		}		
	}
	
	if (loadObj.options.length == 1)
	{
		loadObj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		loadObj.options[0] = new Option("Please Select", "0");
	}
	
	loadObj.selectedIndex = 0;
}




function locationsOnChangeMultiple(obj, loadObj){	
	var xmlLocationDoc;
	var type = 0;
	if (loadObj.name.indexOf('canLocation1') != -1)
	{
		if (xmlLocationDoc1 == null) {xmlLocationDoc1 = loadXMLDoc("/App_Assets/scripts/locationTop.xml")};
		xmlLocationDoc = xmlLocationDoc1;
		type = 1;
	}
	else if (loadObj.name.indexOf('canLocation2') != -1)
	{
		if (xmlLocationDoc2 == null) {xmlLocationDoc2 = loadXMLDoc("/App_Assets/scripts/locationMid.xml")};
		xmlLocationDoc = xmlLocationDoc2;
		type = 2;		
	}
	else
	{
		if (xmlLocationDoc3 == null) {xmlLocationDoc3 = loadXMLDoc("/App_Assets/scripts/locationLow.xml")};
		xmlLocationDoc = xmlLocationDoc3;
		type = 3;
	}	
	
	var nodeObject;	
	var parentIDs = "";
	for (var h = 0; h <obj.options.length; h++) 
	{
		if (obj.options[h].selected)
		{
			parentIDs += "|"  + obj.options[h].value + "|";
		}
	}
	loadObj.options.length = 1;
	for (var x = 0; x <xmlLocationDoc.getElementsByTagName("location").length; x++ )
	{
		
		nodeObject = xmlLocationDoc.getElementsByTagName("location")[x];
		
		if (parentIDs.indexOf("|"+nodeObject.childNodes[0].firstChild.nodeValue+"|") != -1)
		{
			var z;
			for (z= 0; z <nodeObject.getElementsByTagName("sublocation").length; z++ )
			{		
				// if publish
				if (nodeObject.getElementsByTagName("sublocation")[z].childNodes[4].firstChild.nodeValue == 1)
				{
						loadObj.options[loadObj.length] = new Option(nodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, nodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
				}
			}				
		}		
	
	}
	
	if (loadObj.options.length == 1)
	{
		loadObj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		loadObj.options[0] = new Option("Please Select", "0");
	}
	
	loadObj.selectedIndex = 0;
}



function locationInitalLoad(value, Obj, isSubLocation, isSearch){	
	var xmlLocationDoc;
	var type = 0;
	if (isSearch == null)
	{
		isSearch = false;
	}
	
	if (Obj.name.indexOf('canLocation1') != -1)
	{
		if (xmlLocationDoc1 == null) {xmlLocationDoc1 = loadXMLDoc("/App_Assets/scripts/locationTop.xml")};
		xmlLocationDoc = xmlLocationDoc1;
		type = 1;
	}
	else if (Obj.name.indexOf('canLocation2') != -1)
	{
		if (isSearch)
		{
			if (xmlLocationSearchBasic == null) {xmlLocationSearchBasic = loadXMLDoc("/App_Assets/scripts/locationSearchMid.xml")};
			xmlLocationDoc = xmlLocationSearchBasic;
		}
		else
		{
			if (xmlLocationDoc2 == null) {xmlLocationDoc2 = loadXMLDoc("/App_Assets/scripts/locationMid.xml")};
			xmlLocationDoc = xmlLocationDoc2;
		}
		
		type = 2;

	}
	else
	{
		if (xmlLocationDoc3 == null) {xmlLocationDoc3 = loadXMLDoc("/App_Assets/scripts/locationLow.xml")};
		xmlLocationDoc = xmlLocationDoc3;
		type = 3;
	}

	var nodeObject = null;	
	Obj.options.length = 1;
		var searchTagName = "location";
	if (type > 1)
	{
		searchTagName = "sublocation";
	}
	// loop through all locations to find the selected location
	for (var x = 0; x <xmlLocationDoc.getElementsByTagName(searchTagName).length; x++ )
	{			
		if (xmlLocationDoc.getElementsByTagName(searchTagName)[x].childNodes[0].firstChild.nodeValue == value)
		{
		    nodeObject = xmlLocationDoc.getElementsByTagName(searchTagName)[x];
			break;
		}
	}
	var subNodeObject;
	var y = 0;
	var foundGroup = false;
	if (value != "" || !isSubLocation)
	{
		for (y = 0; y <xmlLocationDoc.getElementsByTagName("location").length; y++ )
		{			
			subNodeObject = xmlLocationDoc.getElementsByTagName("location")[y];
			
			// loading if value is provided (and if is search then display == 1)
			
			
			if (nodeObject != null && ((subNodeObject.childNodes[4].firstChild.nodeValue == 1 && isSearch) || !isSearch))
			{
				if (value != 0)
				{
					// if top level location
					if (type ==1 && subNodeObject.childNodes[1].firstChild.nodeValue == "-1")
					{
						Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);	
						foundGroup = true;
					}		
					// if secondary location
					else if (type ==2 && subNodeObject.childNodes[0].firstChild.nodeValue == nodeObject.childNodes[1].firstChild.nodeValue)
					{
						var z;
						for (z= 0; z <subNodeObject.getElementsByTagName("sublocation").length; z++ )
						{
							if (isSearch)
							{			
								// if publish
								if (subNodeObject.getElementsByTagName("sublocation")[z].childNodes[4].firstChild.nodeValue == 1)
								{
									var thisSubNode = subNodeObject.getElementsByTagName("sublocation")[z];
									if (thisSubNode.getElementsByTagName("thridLocation").length)
									{
										var thisValueName = subNodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue;
										Obj.options[Obj.length] = new Option(thisValueName + " - All", subNodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
										for (s= 0; s <thisSubNode.getElementsByTagName("thridLocation").length; s++ )
										{		
											// if publish
											if (thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[4].firstChild.nodeValue == 1)
											{
												Obj.options[Obj.length] = new Option(thisValueName + " - " + thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[3].firstChild.nodeValue, thisSubNode.getElementsByTagName("thridLocation")[s].childNodes[0].firstChild.nodeValue);		
											}
										}
									}
									else
									{
										Obj.options[Obj.length] = new Option(subNodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, subNodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);										
									}
								}
							}
							else
							{
								Obj.options[Obj.length] = new Option(subNodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, subNodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
							}			
							
						}
						
						foundGroup = true;
					}	
					// if tertiary location
					else if (type ==3 && subNodeObject.childNodes[0].firstChild.nodeValue == nodeObject.childNodes[1].firstChild.nodeValue)
					{
						var z;
						for (z= 0; z <subNodeObject.getElementsByTagName("sublocation").length; z++ )
						{
							Obj.options[Obj.length] = new Option(subNodeObject.getElementsByTagName("sublocation")[z].childNodes[3].firstChild.nodeValue, subNodeObject.getElementsByTagName("sublocation")[z].childNodes[0].firstChild.nodeValue);	
						}
						
						foundGroup = true;
					}
					// roles are listed in groups of their parent role, if you find a role you will find everything for that role
					// if you move into a new group there is no need to loop through the whole file
					if (foundGroup && subNodeObject.childNodes[1].firstChild.nodeValue != nodeObject.childNodes[1].firstChild.nodeValue)
					{
						break;
					}				
				}
	
				// if value not provided just load top level
				else if (!isSubLocation )
				{
					if ( nodeObject.childNodes[1].firstChild.nodeValue == "-1")
					{
						Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);			
					}			
				}
				else
				{
					break;
				}
			}
			// if no item found then load states (this will only be applied for top level items)
			else if (nodeObject == null && Obj.name.contains("1"))
			{
				if ( subNodeObject.childNodes[1].firstChild.nodeValue == "-1" && ((subNodeObject.childNodes[4].firstChild.nodeValue == 1 && isSearch) || !isSearch))
				{
					Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);			
				}		
			}
			else
			{
				break;
			}
		}	
	}
	if (Obj.options.length == 1)
	{
		Obj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		Obj.options[0] = new Option("Please Select", "0");
	}
	Obj.selectedIndex = 0;

}



function industryOnChange(obj, loadObj, isSearch){	

	var xmlIndustryDoc;
	var type = 0;
	if (isSearch == null)
	{
		isSearch = false;
	}	
	if (loadObj.name.indexOf('canIndustry1') != -1)
	{
		if (xmlIndustryDoc1 == null) {xmlIndustryDoc1 = loadXMLDoc("/App_Assets/scripts/industryTop.xml")};
		xmlIndustryDoc = xmlIndustryDoc1;
		type = 1;
	}
	else if (loadObj.name.indexOf('canIndustry2') != -1)
	{
		if (xmlIndustryDoc2 == null) {xmlIndustryDoc2 = loadXMLDoc("/App_Assets/scripts/industryMid.xml")};
		xmlIndustryDoc = xmlIndustryDoc2;
		type = 2;
	}
	else
	{
		if (xmlIndustryDoc3 == null) {xmlIndustryDoc3 = loadXMLDoc("/App_Assets/scripts/industryLow.xml")};
		xmlIndustryDoc = xmlIndustryDoc3;
		type = 3;
	}
	
	var nodeObject;	
	var parentID = obj.options[obj.selectedIndex].value;
	var foundGroup = false;
	loadObj.options.length = 1;

	for (var x = 0; x <xmlIndustryDoc.getElementsByTagName("industry").length; x++ )
	{
		
		nodeObject = xmlIndustryDoc.getElementsByTagName("industry")[x];
		if (nodeObject.childNodes[0].firstChild.nodeValue == parentID)
		{
			
			var z;
			for (z= 0; z <nodeObject.getElementsByTagName("subindustry").length; z++ )
			{
				
				if (!isSearch  || (isSearch && nodeObject.getElementsByTagName("subindustry")[z].childNodes[4].firstChild.nodeValue == 1) )
				{			
					loadObj.options[loadObj.length] = new Option(nodeObject.getElementsByTagName("subindustry")[z].childNodes[3].firstChild.nodeValue, nodeObject.getElementsByTagName("subindustry")[z].childNodes[0].firstChild.nodeValue);	
				}
			}				
			foundGroup = true;
		
		}	
		
		// roles are listed in groups of their parent role, if you find a role you will find everything for that role
		// if you move into a new group there is no need to loop through the whole file
		if (foundGroup && nodeObject.childNodes[1].firstChild.nodeValue != parentID)
		{
			break;
		}		
	}
	
	if (loadObj.options.length == 1)
	{
		loadObj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		loadObj.options[0] = new Option("Please Select", "-1");
	}
	
	loadObj.selectedIndex = 0;
}

function industryOnChangeMultiple(obj, loadObj){	

	var xmlIndustryDoc;
	var type = 0;
	if (loadObj.name.indexOf('canIndustry1') != -1)
	{
		if (xmlIndustryDoc1 == null) {xmlIndustryDoc1 = loadXMLDoc("/App_Assets/scripts/industryTop.xml")};
		xmlIndustryDoc = xmlIndustryDoc1;
		type = 1;
	}
	else if (loadObj.name.indexOf('canIndustry2') != -1)
	{
		if (xmlIndustryDoc2 == null) {xmlIndustryDoc2 = loadXMLDoc("/App_Assets/scripts/industryMid.xml")};
		xmlIndustryDoc = xmlIndustryDoc2;
		type = 2;
	}
	else
	{
		if (xmlIndustryDoc3 == null) {xmlIndustryDoc3 = loadXMLDoc("/App_Assets/scripts/industryLow.xml")};
		xmlIndustryDoc = xmlIndustryDoc3;
		type = 3;
	}
	
	var nodeObject;	
	var parentIDs = "";
	for (var h = 0; h <obj.options.length; h++) 
	{
		if (obj.options[h].selected)
		{
			parentIDs += "|"  + obj.options[h].value + "|";
		}
	}
	loadObj.options.length = 1;

	for (var x = 0; x <xmlIndustryDoc.getElementsByTagName("industry").length; x++ )
	{
		
		nodeObject = xmlIndustryDoc.getElementsByTagName("industry")[x];
		if (parentIDs.indexOf("|"+nodeObject.childNodes[0].firstChild.nodeValue+"|") != -1)
		{
			
			var z;
			for (z= 0; z <nodeObject.getElementsByTagName("subindustry").length; z++ )
			{
				
				if (nodeObject.getElementsByTagName("subindustry")[z].childNodes[4].firstChild.nodeValue == 1)
				{			
					loadObj.options[loadObj.length] = new Option(nodeObject.getElementsByTagName("subindustry")[z].childNodes[3].firstChild.nodeValue, nodeObject.getElementsByTagName("subindustry")[z].childNodes[0].firstChild.nodeValue);	
				}
			}				
		}	
	}
	
	if (loadObj.options.length == 1)
	{
		loadObj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		loadObj.options[0] = new Option("Please Select", "-1");
	}
	
	loadObj.selectedIndex = 0;
}

function industryInitalLoad(value, Obj, isSubIndustry, isSearch){	

	var xmlIndustryDoc;
	var type = 0;
	if (isSearch == null)
	{
		isSearch = false;
	}	
	if (Obj.name.indexOf('canIndustry1') != -1)
	{
		if (xmlIndustryDoc1 == null) {xmlIndustryDoc1 = loadXMLDoc("/App_Assets/scripts/industryTop.xml");};
		xmlIndustryDoc = xmlIndustryDoc1;
		type = 1;
	}
	else if (Obj.name.indexOf('canIndustry2') != -1)
	{
		if (xmlIndustryDoc2 == null) {xmlIndustryDoc2 = loadXMLDoc("/App_Assets/scripts/industryMid.xml")};
		xmlIndustryDoc = xmlIndustryDoc2;
		type = 2;
	}
	else
	{
		if (xmlIndustryDoc3 == null) {xmlIndustryDoc3 = loadXMLDoc("/App_Assets/scripts/industryLow.xml")};
		xmlIndustryDoc = xmlIndustryDoc3;
		type = 3;
	}
	
	var nodeObject = null;	
	Obj.options.length = 1;
	var searchTagName = "industry";
	if (type > 1)
	{
		searchTagName = "subindustry";
	}
	// loop through all industry to find the selected industry
	
	for (var x = 0; x <xmlIndustryDoc.getElementsByTagName(searchTagName).length; x++ )
	{
		
		if (xmlIndustryDoc.getElementsByTagName(searchTagName)[x].childNodes[0].firstChild.nodeValue == value)
		{
		    nodeObject = xmlIndustryDoc.getElementsByTagName(searchTagName)[x];
			break;
		}
	}
	var subNodeObject;
	var y;
	var foundGroup = false;

	if (value != "")
	{
		for (y = 0; y <xmlIndustryDoc.getElementsByTagName("industry").length; y++ )
		{			
			subNodeObject = xmlIndustryDoc.getElementsByTagName("industry")[y];

			
			if (nodeObject != null && ((subNodeObject.childNodes[4].firstChild.nodeValue == 1 && isSearch) || !isSearch))
			{
				// loading if value is provided
				if (value != 0)
				{
					// if top level industry
					if (type == 1 && subNodeObject.childNodes[1].firstChild.nodeValue == "-1")
					{
						Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);	
						foundGroup = true;
					}		
					// if secondary industry
					else if (type == 2 && subNodeObject.childNodes[0].firstChild.nodeValue == nodeObject.childNodes[1].firstChild.nodeValue)
					{
						var z;
						for (z= 0; z <subNodeObject.getElementsByTagName("subindustry").length; z++ )
						{
							if ((subNodeObject.getElementsByTagName("subindustry")[z].childNodes[4].firstChild.nodeValue == 1 && isSearch) || !isSearch)
							{
								Obj.options[Obj.length] = new Option(subNodeObject.getElementsByTagName("subindustry")[z].childNodes[3].firstChild.nodeValue, subNodeObject.getElementsByTagName("subindustry")[z].childNodes[0].firstChild.nodeValue);	
							}
						}
						
						foundGroup = true;
					}	
					// if tertiary industry
					else if (type == 3 && subNodeObject.childNodes[0].firstChild.nodeValue == nodeObject.childNodes[1].firstChild.nodeValue)
					{
						var z;
						for (z= 0; z <subNodeObject.getElementsByTagName("subindustry").length; z++ )
						{
							Obj.options[Obj.length] = new Option(subNodeObject.getElementsByTagName("subindustry")[z].childNodes[3].firstChild.nodeValue, subNodeObject.getElementsByTagName("subindustry")[z].childNodes[0].firstChild.nodeValue);	
						}
						
						foundGroup = true;
					}
					
					// roles are listed in groups of their parent role, if you find a role you will find everything for that role
					// if you move into a new group there is no need to loop through the whole file
					if (foundGroup && subNodeObject.childNodes[1].firstChild.nodeValue != nodeObject.childNodes[1].firstChild.nodeValue)
					{
						break;
					}
				}
				// if value not provided just load top level
				else if (!isSubIndustry)
				{				
					if (nodeObject.childNodes[1].firstChild.nodeValue == "-1")
					{
						Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);			
					}			
				}
				else
				{
					break;
				}
			}
			// if no item found then load states (this will only be applied for top level items)
			else if (nodeObject == null && Obj.name.contains("1") && ((subNodeObject.childNodes[4].firstChild.nodeValue == 1 && isSearch) || !isSearch))
			{
				
				if ( subNodeObject.childNodes[1].firstChild.nodeValue == "-1")
				{
					Obj.options[Obj.length] = new Option(subNodeObject.childNodes[3].firstChild.nodeValue, subNodeObject.childNodes[0].firstChild.nodeValue);			
				}		
			}
			else
			{
				break;
			}
		}
	}

	if (Obj.options.length == 1)
	{
		Obj.options[0] = new Option("Not Required", "-1");
	}
	else
	{
		Obj.options[0] = new Option("Please Select", "-1");
	}
	Obj.selectedIndex = 0;

}

function limitText(limitField, limitNum) {
	
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}


function submitAdvancedForm(e) {

    var caller = getEventCaller(e);
	
    if (getEventKeyCode(e) == 13 && caller.type.toLowerCase() != "textarea") {
		$$('.searchButton')[0].onclick();
		
        return false;		
    }
    
    return true;
}

function submitSearchForm(e) {

    var caller = getEventCaller(e);
	
    if (getEventKeyCode(e) == 13 && caller.type.toLowerCase() != "textarea") {
		$$('.headerSearchButton')[0].onclick();
		
        return false;		
    }
    
    return true;
}

function submitFormByCorrectButton(e, sender) {

    var caller = getEventCaller(e);
	
    if (getEventKeyCode(e) == 13 && caller.type.toLowerCase() != "textarea") {
		
        var elements    = sender.childNodes;           
		var clicked = checkNodesForSubmit(elements, caller);
		
		if (!clicked)
		{
			elements = sender;
			checkNodesForSubmit(elements, caller);
		}

        return false;		
    }
    
    return true;
}

function checkNodesForSubmit(elements, caller)
{
	var clicked = false;
	var callerFound = false;
	for (var i = 0; i < elements.length; i++) {
		var element = elements[i];
		var type    = element.tagName;
		

		if (element.id == caller.id) { callerFound = true; }
		if (type)                    { type        = type.toLowerCase(); }

		if (type == 'input')
		{				
			type = (element.type).toLowerCase();
		}
		
		if (callerFound && (type == "image" || type == "submit" || type == "a" )) {
			if ( type == "a")
			{
				element.onclick();
				clicked = true;
				 break;
			}
			else
			{
				element.click();
				clicked = true;
				break;
			}    
		}
	}
	return clicked;
}
						

function getEventKeyCode(e) {
    if (window.event) {
        return e.keyCode;
    } else if (e.which) {
        return e.which;
    }
}

function getEventCaller(e) {
    if (window.event) {
        return e.srcElement;
    } else if (e.which) {
        return e.target;
    }
}

// Checks the date input for a valid format.
// This code accepts the date formats: DD/MM/YYYY or DD-MM-YYYY
// To alter the format checked for, change the datePat (date pattern) -
//    d{2} requires 2 digits, d{1,2} requires either 1 or 2 digits etc.
//    \/|- requires / or - as a separator etc.
//
// Created (16 Oct 2000) Raymond Woo
	function isValidDate (strValue) {
		var datePat = /^(\d{2})(\/)(\d{2})\2(\d{4})$/; // Change this to check for a different format
		var matchArray = strValue.match(datePat); // is the format ok?
		if (matchArray == null) { return false;	}
		day = matchArray[1]; month = matchArray[3]; year = matchArray[4];
		if (month < 1 || month > 12) { return false; }
		if (day < 1 || day > 31) { return false; }
		if ((month==4 || month==6 || month==9 || month==11) && day==31) { return false; }
		if (month==2) {
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) { return false; }
		}
		return true;  // date is valid
	}
	
function isValidEmail(strValue)
{
	return (strValue).search ( /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/) != -1; 
}
function isValidEmployerEmail(strValue)
{
	if (strValue.indexOf("aol.com") != -1) {return false;}
	if (strValue.indexOf("gmail.com") != -1) {return false;}
	if (strValue.indexOf("hotmail.com") != -1) {return false;}
	if (strValue.indexOf("@yahoo.") != -1) {return false;}
	if (strValue.indexOf("@mail.com") != -1) {return false;}
	return true;

}
function isValidMobile(strValue)
{
	return (strValue).search (/^[0-9\s]{10,20}$/) != -1; 
}
function isValidPhone(strValue)
{
	return (strValue).search (/^[0-9\s()]{8,20}$/) != -1; 
}
function isValidURL(strValue)
{
	if (strValue.indexOf("http") == -1)
	{
		strValue = "http://" + strValue;
	}	
	return (strValue).search(/[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/) != -1; 
	//return (strValue).search(/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/) != -1; 
}
function containsAlphaOnly(strValue){
	return String(strValue).search(/^[a-zA-Z\-\'\s]{2,}$/) != -1; 
}

