function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function CheckSubmitEmail(text_email)
{
	var email_str = trim(document.getElementById(text_email).value);
	if (email_str == "")
	{
		alert ("Email address field is empty");
		document.getElementById(text_email).focus();
		return false;
	}
	else
	{
		//var email_str = document.getElementById(text_email).value;
		//alert ('str: ' + str);
		var format =  email_str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
		//alert ('format: ' + format);
		if(!format)
		{
			alert ('Invalid email address format');
			document.getElementById(text_email).focus();
			return false;
		
		}
	}

}
function CheckSubmission()
{
	//checkProductSelection();
	
	if (trim(document.getElementById("txtfname").value) == "")
	{
		alert ("First Name field is empty");
		document.getElementById("txtfname").focus();
		return false;
	}
	return CheckSubmitEmail("txtEmail_1");
	return true;
}//function CheckSubmission
	
function checkProductSelection(no_of_prod)
{
	var return_val = false;
	
	//alert ("no_of_prod: " + no_of_prod);
	
	for(i=0; i<no_of_prod; i++)
	{
		var prod_checked = document.getElementById("chkproduct_" + i).checked;
		if (prod_checked)
		{
			//alert ("chkproduct[" + i + "].value: " + document.getElementById("chkproduct_" + i).value);
			//document.reg_form.chkpwd.focus();
			//document.prod_form.chkproduct[i].name = 'chkproduct[]';
			
			return_val = true;
		}
		
	}
	if(return_val)
	{
		return 	return_val;
	}
	else
	{
		alert ("Select at least one product");
		return false;
	}
}

function prodFormSubmit(no_of_prod)
{
	if(checkProductSelection(no_of_prod))
	{
		document.prod_form.submit();
	}
}