function trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;

}
function isEmailAddress(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
	if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
function confirmDelete()
{
	var agree=confirm("Are you sure you wish to continue?");
	if (agree)
		return true ;
	else
		return false ;
}
function confirmApprove()
{
	var agree=confirm("Are you sure you wish to continue?");
	if(agree)
		return true;
	else
		return false;
}
function check_software(frm)
{
	with(frm)
	{
		if((trimAll(software_name.value))=="")
		{	
			alert("please enter your software name");
			software_name.focus();
			return false;
		}
		if((trimAll(product_url.value))=="")
		{	
			alert("please enter your Product Url");
			product_url.focus();
			return false;
		}
		if((trimAll(description.value))=="")
		{	
			alert("please enter your Description");
			description.focus();
			return false;
		}
		if((trimAll(detailed_description.value))=="")
		{	
			alert("please enter your Detailed description");
			detailed_description.focus();
			return false;
		}

		var chks = document.getElementsByName('directories[]');
		var checkCount = 0;
		for (var i = 0; i < chks.options.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the directories");
			return false;
		}
		return true;

	}
}
function checkbuyer(frm)
{
	with(frm)
	{
		if((trimAll(name.value))=="")
		{	
			alert("Please enter your Name");
			name.focus();
			return false;
		}
		if((trimAll(email.value))=="")
		{	
			alert("Please enter your Email");
			email.focus();
			return false;
		}
		
		if((trimAll(company_name.value))=="")
		{	
			alert("Please enter your Company Name");
			company_name.focus();
			return false; 
		}
		if((trimAll(url.value))=="")
		{	
			alert("Please enter your Company Url");
			url.focus();
			return false;
		}
		
		
		if(document.request_information["industry[]"].value == "")
		{
			alert('Please select the Industry');
			return false; 
		}
		if(document.request_information["software_category[]"].value == "")
		{
			alert('Please select the Software category!');
			return false; 
		}


		if((trimAll(details.value))=="")
		{	
			alert("Please enter your Details");
			details.focus();
			return false;
		}

		if((trimAll(features.value))=="")
		{	
			alert("Please enter your Required Features");
			features.focus();
			return false;
		}
		return true;			
	}
}
function checkvendor(frm)
{
	with(frm)
	{
		if((trimAll(user_name.value))=="")
		{	
			alert("please enter your username");
			user_name.focus();
			return false;
		}
		if((trimAll(password.value))=="")
		{
			alert("please enter your password");
			password.focus();
			return false;
		}
		if((trimAll(company_name.value))=="")
		{
			alert("please enter the company name");
			company_name.focus();
			return false;
		}
		if((trimAll(company_url.value))=="")
		{
			alert("please enter the company url");
			company_url.focus();
			return false;
		}
		if((trimAll(first_name.value))=="")
		{
			alert("please enter the first name");
			first_name.focus();
			return false;
		}
		if((trimAll(last_name.value))=="")
		{
			alert("please enter the last name");
			last_name.focus();
			return false;
		}
		if(!isEmailAddress(email.value))
		{
			alert('please enter a valid email address');
			email.focus();
			return false;
		}
		if((trimAll(phone.value))=="")
		{
			alert("please enter your phone number");
			phone.focus();
			return false;
		}
		if((trimAll(software_name.value))=="")
		{
			alert("please enter your software name");
			software_name.focus();
			return false;
		}
		if((trimAll(description.value))=="")
		{
			alert("please enter your description");
			description.focus();
			return false;
		}
		
		return true;			
		
	}
}
function check(frm)
{
	with(frm)
	{
		if((trimAll(product_url.value))=="")
		{	
			alert("please enter your Product Url");
			product_url.focus();
			return false;
		}
		if((trimAll(description.value))=="")
		{
			alert("please enter your description");
			description.focus();
			return false;
		}
		if((trimAll(detailed_description.value))=="")
		{
			alert("please enter the Detailed description");
			detailed_description.focus();
			return false;
		}
		var chks = document.getElementsByName('directories[]');
		var checkCount = 0;
		for (var i = 0; i < chks.options.length; i++)
		{
			if (chks[i].selected)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the Directories");
			return false;
		}

		return true;
	}
}
function checkfe(frm)
{
	with(frm)
	{
		
		var chks = document.getElementsByName('platform[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the Platform");
			return false;
		}
		

		var chks = document.getElementsByName('feature[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the features");
			return false;
		}
		
		var chks = document.getElementsByName('number_of_users[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the Number of users");
			return false;
		}
		return true;

	}
}


function check_soft(frm)
{
	with(frm)
	{
		
		var chks = document.getElementsByName('platform[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the Platform");
			return false;
		}
		var chks = document.getElementsByName('number_of_users[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the Number of users");
			return false;
		}

		var chks = document.getElementsByName('feature[]');
		var checkCount = 0;
		for (var i = 0; i < chks.length; i++)
		{
			if (chks[i].checked)
			{
				checkCount++;
			}
		}
		if (checkCount < 1)
		{
			alert("Please select the features");
			return false;
		}

		return true;

	}
}

