
function validateTMCForm(frm)
{
	var bValid=true;
	$(frm.id).select('input.rfv').each(function(s)
		{
			if($('rfv_'+ s.id)!=null)
			{
				if (s.value=="") 
				{
					$('rfv_'+ s.id).style.display="";
					bValid=false;
				}
				else
				{
					$('rfv_'+ s.id).style.display="none";
				}
			}
		}
		);
		
		$(frm.id).select('textarea.rfv').each(function(s)
		{
			if ($('rfv_'+ s.id)!=null)
			{
				if (s.value=="") 
				{
					$('rfv_'+ s.id).style.display="";
					bValid=false;
				}
				else
				{
					$('rfv_'+ s.id).style.display="none";
				}
			}
		}
		);
		
		$(frm.id).select('select.rfv').each(function(s)
		{
			if($('rfv_'+ s.id)!=null)
			{
				if (s.options[s.selectedIndex].value=="-1") 
				{
					$('rfv_'+ s.id).style.display="";
					bValid=false;
				}
				else
				{
					$('rfv_'+ s.id).style.display="none";
				}
			}
		}
		);
		
	$(frm.id).select('input.efv').each(function(s)
		{
			if($('rfv_'+ s.id)!=null)
				{
				if (!s.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i))
				{
					if ($('rfv_' + s.id).style.display=="none")
					{
						$('efv_'+ s.id).style.display="";
						bValid=false;
					}
				}
				else
				{
					$('efv_'+ s.id).style.display="none";
				}
			}
		}
		);
		
	// terms and conditions	
	$(frm.id).select('input.tac').each(function(s)
		{
			if($('tac_'+ s.id)!=null)
			{
				if (!s.checked)
				{
					$('tac_'+ s.id).style.display="";
					bValid=false;
				}
				else
				{
					$('tac_'+ s.id).style.display="none";
				}
			}
		}
		);
		
		
	if (bValid) 
	{
		if ($(frm.id).select('input.ajaxForm').size()>0)
			AjaxSendForm(frm);
		else
		{
			if ($(frm.id).select('#fnSendForm').size()>0)
				eval($(frm.id).select('#fnSendForm')[0].value + "(frm)");
			else
				frm.submit();
		}		
	}
	return bValid;	
}
function AjaxSendForm(frm)
{
	params=frm.serialize();
	
	// notice the use of a proxy to circumvent the Same Origin Policy.

	new Ajax.Request("/company/ajaxSendMail.asp", {
	  method: 'post',
	  parameters: params,
	  onSuccess: function(transport) {
	    var jsonSM=transport.responseText.evalJSON(false);
		var ajaxSendResponseID=$(frm.ajaxSendResponseID)
		$(ajaxSendResponseID.value).innerHTML=jsonSM.txtResult;
		var mb="#" + ajaxSendResponseID.value + "Box";
		$j.facebox($j(mb).html());
		$j('#facebox .content .text').html(jsonSM.txtResult);
		$j('#facebox .content .text').attr("style","color:red;");
		setTimeout ( "$j.facebox.close()", 2000 );
		
		if (jsonSM.status=="Ok")
		{
			frm.style.display="none";
			//if (!frm.ajaxTrackPageView==undefined)
			if (!$(frm.id).select('input.ajaxTrackPageView').size()>0)
			{
				pageTracker._trackPageview(frm.ajaxTrackPageView.value);
			}
		}
		
		
			
	  }
	});
}