jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

function validate(form)
{
	var vf = true;
	
	$('.rtb',form).each
	(
	 	function ()
			{
				if ($.trim(this.value)==this.dv)
					{
						alert(this.title + ' is required.');
						this.focus();
						vf = false;
						return false;
					}
			}
	);
	
	if (!vf) return vf;
	
	$('.emailtb',form).each
	(
	 	function ()
			{
				if (!filterE(this.value))
					{
						alert('Please enter a valid email address');
						this.value = '';
						this.focus();
						vf = false;
						return false;
					}
			}
	);
	
	if (!vf) return vf;
	
	$(".rb",form).each
	(
		function ()
			{
				var isSel = false;
				
				$(".rb",form).each
					(
						function ()
							{
								if (this.checked) 
									{
										$(".rb[@name="+this.name+"]",form).each
											(
												function ()
													{
														this.isSel = true;
													}
											);
											
									}
							}
					);
				
				$(".rb",form).each
				(
					function ()
					{
					if (!vf) return vf;
					if (!this.isSel)
						{
						alert('Please select atleast one option');
						this.focus();
						vf = false;
						return false;
						}
					}
				);
			}
	);	
	
	return vf;
}

function filterE(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		   	return false;
		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		   	return false;
		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		   	return false;
		else if (str.indexOf(at,(lat+1))!=-1)
			return false;
		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		   	return false;
		else if (str.indexOf(dot,(lat+2))==-1)
		    return false;
		else if (str.indexOf(" ")!=-1)
		    return false;
 		return true					
	}