function err(m,u,l) {
return false;
//return true;
}
window.onerror=err;

function selTop(e){
	var i=e.selectedIndex;
	while(e.options[i-1].value==e.options[i].value){
		e.selectedIndex=i-1;
		i--;
	}
}
function stayPut(s){
	var f=document.getElementById(s);
	f.action='';
}
function showAdv(){
	var tim=document.getElementById('timdiv');
	var ind=document.getElementById('inddiv');
	var etp=document.getElementById('etpdiv');
	tim.style.display='block';
	ind.style.display='block';
	etp.style.display='block';
	document.getElementById('advlink').style.display='none';
		
}
function showLoc(){
	var loc2=document.getElementById('loc2');
	var loc3=document.getElementById('loc3');
	if(loc2.style.display!='none'){
		loc3.style.display='block';
		document.getElementById('loclink').style.display='none';
	}else{
		loc2.style.display='block';
	}
		
}
function goToLoc(page,loc){
	var url='http://'+document.location.hostname+page;
	if(loc){
		url+='?'+loc+'='+document.getElementById(loc).value;
	}
	document.location=url;
}
function urlencode(s){
 	return escape(s);
}
function pad(num,dig){
	var ret=num;
	for(var i=num.length;i<dig;i++){
		ret='0'+ret;	
	}
	return ret;
}
function formatdatetime(d){
	var dt=new Date(d);
	var hr=dt.getHours();
	var sAmPm=' AM';
	if(hr>=12){
		sAmPm=' PM';
		if(hr>12){
			hr=hr-12;
		}
	}
	var formatdate=hr.toString()+':'+pad(dt.getMinutes().toString(),2)+sAmPm+' '+(dt.getMonth()+1).toString()+'/'+dt.getDate().toString()+'/'+dt.getYear().toString();
 	return formatdate;
}
function getAjaxComps(div,pn,st,ho,ve,he){
	var ajax=createAjaxObj();	
	var url='http://'+document.location.hostname+'/logoload.asp'
	var nocache=new Date();
	ajax.open('GET', url+'?pn='+pn+'&st='+st+'&ho='+ho+'&ve='+ve+'&nocache='+escape(nocache.getUTCSeconds()),true);
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 4){
			if(ajax.status == 200) {
				var xml = ajax.responseText;
				document.getElementById(div).innerHTML=xml;
				if(document.getElementById('aph')){
					document.getElementById('aph').innerHTML=he;
				}		
			}
		}
	}
	ajax.send(null);
	//prompt('','called '+url+'?pn='+pn+'&st='+st+'&ho='+ho+'&ve='+ve);
}

	
function checkSearch(e,els){
	var b=1;
	var sVal='';
	var sKey='';
	if(els){
		b=0;
		var a=els.split(',');	
		for(var i=0;i<a.length;i++){
			sKey=a[i];
			sVal=document.getElementById(sKey).value;
			switch(sKey){
				case 'cname':
				case 'kw':
					sVal=sVal.replace(/ /g,'');
					if(sVal.length){
						b=1;
					}
					break;
				case 'ind':
				case 'tm':
					if(sVal.length){
						b=1;
					}
					break;
				case 'cnt':
					if(sVal.length){
						if(parseInt(sVal)!=1){
							b=1;
						}
					}
					break;
				case 'zc1':
				case 'zc2':
				case 'zc3':
					sVal=sVal.replace(/ /g,'');
					if(sVal.length>1){
						b=1;
					}
					break;
				case 'cn1':
				case 'cn2':
				case 'cn3':
					if(sVal.length){
						if(parseInt(sVal)!=100){
							b=1;
						}
					}
					break;
			}			
		}
	}
	if(!b){
		alert('Please narrow your search criteria by entering keywords...');
		if(e && e.preventDefault){
    			e.preventDefault(); // DOM style
		}
  		return false; 
		
	}
}
function valLogin(e){
	var msg='';
	var ea=document.getElementById('username').value;
	var pw=document.getElementById('password').value;
	ea=ea.replace(/ /g,'');
	pw=pw.replace(/ /g,'');
	if(ea.length==0){
		msg+='The Email field is empty\n';
	}
	if(pw.length==0){
		msg+='The Password field is empty\n';
	}
	if(msg.length){
		msg='There was a problem with your Login: \n\n'+msg;
		alert (msg);
		if(e && e.preventDefault){
				e.preventDefault(); 
		}
		return false; 
	}
}
function valForm(e,els,email,pw){
	var msg='';
	var el='';
	var eln='';
	var b;
	var a=els.split(',');
	for(var i=0;i<a.length;i++){
		b=a[i].split('|');
		el=document.getElementById(b[0]).value;
		eln=b[1];
		el=el.replace(/ /g,'');
		if(el.length==0){
			msg+='The '+eln+' field is empty\n';
		}
	}
	if(email){
		if(!checkemail(document.getElementById(email).value)){
			msg+='The Email Address you entered is not a valid email address\n';
		}
	}
	if(pw){
		var np=document.getElementById('newpassword').value;
		var cp=document.getElementById('confirmpassword').value;
		var op=document.getElementById('oldpassword').value;
		np=np.replace(/ /g,'');
		cp=cp.replace(/ /g,'');
		op=op.replace(/ /g,'');
		if(np!=cp){
			msg+='The New Password and Confirm Password do not match\n';
		}
		if(np.length<6 && np.length>0){
			msg+='The New Password must be at least 6 characters\n';
		}		
		if(op.length==0){
			msg+='The Current Password is blank\n';
		}		
	}	
	if(msg.length){
		msg='There was a problem with your submission: \n\n'+msg;
		alert (msg);
		if(e && e.preventDefault){
				e.preventDefault(); 
		}
		return false; 
	}
}
function trim(strValue){
	return strValue.replace(/^\s+/,'').replace(/\s+$/,'');
}
function checkemail(varemail){
	var filter=/^.+@.+\..{2,4}$/
	if (filter.test(varemail)){
		return 1;
	}else{
		return 0;
	}
}
function nextwhy(){
	var src=document.getElementById('why').src;
	var sOrd=parseInt(src.substr(src.length-5,1))+1;
	if(sOrd>5){
		sOrd=1;
	}
	switch(sOrd){
		case 1:
			var lText='Need another reason?'
			break;
		case 2:
			var lText='Still not convinced?'
			break;
		case 3:
			var lText='What\'s it going to take?'
			break;
		case 4:
			var lText='Need another one?'
			break;
		case 5:
			var lText='Now what do I do?'
			document.getElementById('whyl').href='/careertools.asp';
			break;
	}
	src=src.substr(0,src.length-5)+sOrd.toString()+'.jpg';
	document.getElementById('why').src=src;
	document.getElementById('whyl').innerHTML=lText;
	return false;
}
