function getMasterString()
{
	return "Sorry, we can not complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n";
}

function checkError(error)
{
	var flag = false;
	var MasterString = getMasterString();
	
	if(error != "")
	{
		MasterString = MasterString + error;
		flag=true;
	}
	
	if(flag == true)
	{
		alert(MasterString);
		return false;
	}
	else
		return true;
}

// Function to validate contact form
function ValidateContactForm()
{
	var error = '';
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var bolFocus = false;
	var FocusID = '';
	
	if(document.getElementById('frmContact').Name.value == "")
	{
		error += "\n- Name is required.";
		if(!bolFocus)
		{
			bolFocus = true;
			FocusID = 'Name';
		}
	}
	if(document.getElementById('frmContact').frmEmail.value == "")
	{
		error += "\n- Email is required.";
		if(!bolFocus)
		{
			bolFocus = true;
			FocusID = 'frmEmail';
		}
	}
	else if(!regEmail.test(document.getElementById('frmContact').frmEmail.value))
	{
		error +='\n- Email must contain an e-mail Address.';
		if(!bolFocus)
		{
			bolFocus = true;
			FocusID = 'frmEmail';
		}
	}
	
	if(document.getElementById('frmContact').select.value == "")
	{
			error +='\n- Our Services is required.';
			if(!bolFocus)
			{
				bolFocus = true;
				FocusID = 'select';
			}
			
	}
	
	if(document.getElementById('frmContact').select.value == "SEO")
	{
		if(document.getElementById('frmContact').frmURL.value =="")
		{
			error +='\n- URL is required.';
			if(!bolFocus)
			{
				bolFocus = true;
				FocusID = 'frmURL';
			}
		}	
	}
	
	
	if(document.getElementById('frmContact').frmURL.value != "") 
	{ 
		var val = document.getElementById('frmContact').frmURL.value;
		//var tomatch = /^(http:\/\/)?[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;		
		var tomatch =	/^(http:\/\/)*[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;
		if (!tomatch.test(val))
		{			 
			 error += '\n- URL must be valid e.g. http://www.abc.com or www.abc.com';
			 if(!bolFocus)
			 {
				bolFocus = true;
				FocusID = 'frmURL';
			 }
		}		
		
	 }	
	
	if(document.getElementById('frmContact').security_code.value == "")
	{
		error += "\n- Verification Code is required.";
		if(!bolFocus)
			{
				bolFocus = true;
				FocusID = 'security_code';
			}
	}
	
	if(error != "")
	{
		document.getElementById(FocusID).focus();
		return checkError(error);
	} 
}
