var bigstring = " ";

function shake(n) 
{
	if (self.moveBy) 
	{
		for (i = 10; i > 0; i--) 
		{
			for (j = n; j > 0; j--) 
			{
				self.moveBy(0,i);
				self.moveBy(i,0);
				self.moveBy(0,-i);
				self.moveBy(-i,0);
			}
		}
	}
}
function doesexist(inputValue, inputExpected) 
{
  var aCharExists=0
  if (inputValue) 
  {
    for (var i=0; i<inputValue.length; i++) 
    {
      if (inputValue.charAt(i) != " ") 
      {
        aCharExists = 1
      }
    }
  }
  if (!aCharExists) 
  {
    bigstring = bigstring += inputExpected += "\n ";
  }
}
function check_user_create()
{
	doesexist(document.form1.username.value, '- Enter Username')
	doesexist(document.form1.password.value, '- Enter Password')
	doesexist(document.form1.password_confirm.value, '- Confirm Password')
	doesexist(document.form1.first_name.value, '- Enter First Name')
	doesexist(document.form1.last_name.value, '- Enter Last Name')
	doesexist(document.form1.email.value, '- Enter Your Email')
	doesexist(document.form1.dob_Y.value, '- Enter Year of Birth')
	doesexist(document.form1.dob_M.value, '- Enter Month of Birth')
	doesexist(document.form1.dob_D.value, '- Enter Day of Birth')
  	if (bigstring != " ")
	{
		alert("Please fill out the following fields: \n" + bigstring)
		bigstring = " "
		return false
	}
	return true
}

function check_business_account_create()
{
	doesexist(document.business_account_create.username.value, '- Enter Username')
	doesexist(document.business_account_create.password.value, '- Enter Password')
	doesexist(document.business_account_create.password_confirm.value, '- Confirm Password')
	doesexist(document.business_account_create.email.value, '- Enter Your Email')
	doesexist(document.business_account_create.dob_Y.value, '- Enter Year of Birth')
	doesexist(document.business_account_create.dob_M.value, '- Enter Month of Birth')
	doesexist(document.business_account_create.dob_D.value, '- Enter Day of Birth')
	/*doesexist(document.business_account_create.business_cats_array.value, '- Select Your Business Categories')*/
	doesexist(document.business_account_create.dba.value, '- Enter Business Name')
	doesexist(document.business_account_create.loc_city.value, '- Enter City')
	doesexist(document.business_account_create.loc_state.value, '- Enter State')
	doesexist(document.business_account_create.owners.value, '- Enter Business Owners')
	doesexist(document.business_account_create.phone_1.value, '- Enter Phone 1')
	doesexist(document.business_account_create.established_Y.value, '- Enter Year Established')
	doesexist(document.business_account_create.established_M.value, '- Enter Month Established')
	doesexist(document.business_account_create.established_D.value, '- Enter Day Established')
	
	
	var catsArray = document.getElementById('business_cats_array');
	var i;
	var selectedCount = 0;

	for (i=0; i<catsArray.options.length; i++) 
	{
		if (catsArray.options[i].selected) 
		{
			selectedCount++;
		}
	}

	
	
	if(selectedCount == 0)
	{
		alert("Please Select Your Business Categories: \n")
//		document.business_account_create.business_cats_array.focus()
		bigstring = " "
		return false
	}
	if (bigstring != " ")
	{
		alert("Please fill out the following fields: \n" + bigstring)
		bigstring = " "
		return false
	}
	
	return true
}
function check_classifieds_create()
{
	doesexist(document.classifieds_create.name.value, '- Enter Your Name')
	doesexist(document.classifieds_create.contact_info.value, '- Enter Contact Info')
	doesexist(document.classifieds_create.title.value, '- Enter Ad Title')
	doesexist(document.classifieds_create.price.value, '- Enter Item Price')
	doesexist(document.classifieds_create.description.value, '- Enter Description')
	doesexist(document.classifieds_create.key.value, '- Enter Validation Key')
	
	
	var catsArray = document.getElementById('classifieds_cats_array');
	var i;
	var selectedCount = 0;

	for (i=0; i<catsArray.options.length; i++) 
	{
		if (catsArray.options[i].selected) 
		{
			selectedCount++;
		}
	}

	
	
	if(selectedCount == 0)
	{
		alert("Please Select Your Ad Categories: \n")
//		document.business_account_create.business_cats_array.focus()
		bigstring = " "
		return false
	}
	if (bigstring != " ")
	{
		alert("Please fill out the following fields: \n" + bigstring)
		bigstring = " "
		return false
	}
	
	return true
}

function check_review() 
{
//	$recommend_friend
//	$recommend_old_people
//	$recommend_young_people
//	$recommend_family
//	$recommend_couple
//	$recommend_business
	
  doesexist(document.form1.business_ID.value, '- Which Business')
  doesexist(document.form1.reviewer_name.value, '- Your Name')
  doesexist(document.form1.reviewer_location.value, '- City, State')
  doesexist(document.form1.stars_service.value, '- Service Stars')
  doesexist(document.form1.stars_building.value, '- Building Stars')
  doesexist(document.form1.stars_cleanliness.value, '- Cleanliness Stars')
  doesexist(document.form1.stars_value.value, '- Value Stars')
  doesexist(document.form1.stars_comfort.value, '- Comfort Stars')
  doesexist(document.form1.stars_location.value, '- Location Stars')
  doesexist(document.form1.stars_total.value, '- Total Stars')
  doesexist(document.form1.review_title.value, '- Review Title')
  doesexist(document.form1.review.value, '- Review')
  if (bigstring != " ")
  {
    alert("Please fill out the following fields: \n" + bigstring)
    bigstring = " "
    return false
  }
  return true
}
function check_calendar_event() 
{
  doesexist(document.edit_calendar_event.title.value, '- Event Title')
  doesexist(document.edit_calendar_event.location.value, '- Location')
  doesexist(document.edit_calendar_event.start_day.value, '- Start Day')
  doesexist(document.edit_calendar_event.start_time.value, '- Start Time')
  doesexist(document.edit_calendar_event.end_day.value, '- End Day')
  doesexist(document.edit_calendar_event.end_time.value, '- End Time')
  doesexist(document.edit_calendar_event.content.value, '- Description')
  if (bigstring != " ")
  {
    alert("Please fill in the following fields: \n" + bigstring)
    bigstring = " "
    return false
  }
  return true
}
function check_review_comment(review_ID) 
{
	var theFormName = review_ID.toString()
	var theNewFormName = 'comment_form'+theFormName
	  doesexist(document.forms[theNewFormName].commenter.value, '- Commenter (Your Name)')
	  doesexist(document.forms[theNewFormName].valid_comment_vote.value, '- Review Stars')
	  doesexist(document.forms[theNewFormName].comment.value, '- Review Comment')
	  if (bigstring != " ")
	  {
	  	
	    alert("Please fill out the following fields: \n" + bigstring)
	    bigstring = " "
	    
	    return false
	  }
	  return true
}
function newsletter_signup_check()
{
	doesexist(document.newsletter_form.email.value, '- Email Address')
	if (bigstring != " ")
  	{
    	alert("Please fill out the following fields: \n" + bigstring)
    	bigstring = " "
    	return false
  	}
  	return true
}
