

/* show contact form if checkbox is clicked */
function show_contact(checked)
{
	try
	{
		ele = document.getElementById("contact_form");
		if(checked)
			ele.style.display = "";
		else
			ele.style.display = "none";
	}catch(e){}
	return false;
}
/*****************************
Email Validation Function
******************************/
function isEmail(str)
{
	// are regular expressions supported?


	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported)
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

/* validate all the hidden input fields within specified div */
function validate_div(divname)
{
	followdiv	= document.getElementById(divname);
	inputs		= followdiv.getElementsByTagName('input');
	
	for(i=0;i<inputs.length;i++)
	{
		
		if(inputs[i].type=='hidden')
		{
			if(inputs[i].value.split(' ').join('').length==0)
			{
				alert('Please answer all questions.  Indicate N/A if you have no opinion.');
				return false;
			}
		}
	}
	return true;
}


/* Final form validation script */
function validate(frm,ids)
{
	
	for(i=0;i<frm.elements.length;i++)
	{
		ename = frm.elements[i].name.split("-");
		if(ids!=undefined)
		{	
			if(ids.length>0)
				if(ids.indexOf("-"+ename[0]+"-")==-1)
					continue;
		}
		
		if(ename.length>1)
		{
			if(frm.elements[i].value.split(' ').join('').length==0)
			{
				
				alert('Please answer all questions.  Indicate N/A if you have no opinion.');
				return false;
			}
		}
	}
	try{
		
		if(!isEmail(frm.email.value) && frm.email.value.length!=0)
		{
			alert('Please enter valid email.');
			return false;
		}
	}catch(e){}
		return true;
}

/* Onclick box/link selection function (for rating)*/
function selectMe(lnk,ajax)
{
	id 			= lnk.id.split('-');
	selectedid 	= id[0] + '-' + id[1];

	for(i=1;i<=10;i++)
	{
		ele = document.getElementById(selectedid+'-'+i);
		ele.style.backgroundColor = '#ffffff';
		ele.style.color = '#aa0000';
	}


	ele = document.getElementById(selectedid+'-NA');
	ele.style.backgroundColor = '#ffffff';
	ele.style.color = '#aa0000';


	/// above is the code to refine ranking strip


	lnk.style.backgroundColor = '#aa0000';
	lnk.style.color = '#ffffff';



	frm = document.frmmain;


	for(i=0;i<frm.elements.length;i++)
	{
		ename = frm.elements[i].name.split("-");
		if(ename.length>0)
		{
			if(ename[0]==id[0] && (ename[1]==id[1] || id[1].length==0))
			{
				frm.elements[i].value = id[2];
				break;
			}
		}
	}
	
	if(ajax==1)
		return;

	min_rank = 11;

	for(i=0;i<frm.elements.length;i++)
	{
		ename = frm.elements[i].name.split("-");
		if(ename.length>0)
		{
			if(ename[0]==id[0])
			{

				if(frm.elements[i].value.length==0)
				{
					return;
				}
				else{
					if(frm.elements[i].value=='NA')
					continue;

					if(parseFloat(frm.elements[i].value)<min_rank)
					{
						min_rank = parseFloat(frm.elements[i].value);
					}
				}
			}
		}
	}

	min_answer = id[0] + '-' + id[1] + '-' + min_rank;
	ele = document.getElementById("followup"+id[0]);

	if(id[2]=='NA' && min_rank==11 )
	{
		ele.style.display = 'none';
	}else{
		ele.style.display = '';
		ajax_loadContent("followup"+id[0],'career_audit_tool.php?func=followup&id='+min_answer);
	}
}


/* Not in use */
function message(msg)
{
	ele = document.getElementById('msgbox');
	ele.innerHTML = '<DIV id="fadeinbox">'+msg+'<br><div align="right"> <a href="#" onClick="hidefadebox();return false">Close</a></div></DIV>';
}


