/* Apply Text box CSS and Error Text Box CSS */

function resetTextBoxCSS(object)
{
	object.style.border='1px solid #7f9db9';
	object.style.background='#ffffff';
}
function applyErrorTextBoxCSS(object)
{
	object.style.border='1px solid red';
	object.style.background='#FFDDDD';
}


/* Function for Feedback Form */
function frm_feedback(check)
{
	errorDetails = '';
	errorControl = '';
	resetTextBoxCSS(check.first_name);
	resetTextBoxCSS(check.last_name);
	resetTextBoxCSS(check.email);
	resetTextBoxCSS(check.title);
	resetTextBoxCSS(check.description);
	
	
	if (check.first_name.value == "")
	{
		applyErrorTextBoxCSS(check.first_name);
		if (errorDetails == '')
		{
			errorControl = check.first_name;
		}
		errorDetails = errorDetails + " - First name field cannot be blank\n";
		
	}
	if (check.last_name.value == "")
	{
		applyErrorTextBoxCSS(check.last_name);
		if (errorDetails == '')
		{
			errorControl = check.last_name;
		}
		errorDetails = errorDetails + " - Last name field cannot be blank\n";
		
	}
	if (check.email.value == "")
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - The Email field cannot be blank\n";
	}
	if (isValidEmail(check.email.value)==false)
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - Please enter a valid email address\n";
	}
	if (check.title.value == "")
	{
		applyErrorTextBoxCSS(check.title);
		if (errorDetails == '')
		{
			errorControl = check.title;
		}
		errorDetails = errorDetails + " - The Subject field cannot be blank\n";
		
	}
	if (check.description.value == "")
	{
		applyErrorTextBoxCSS(check.description);
		if (errorDetails == '')
		{
			errorControl = check.description;
		}
		errorDetails = errorDetails + " - The Comments field cannot be blank\n";
		
	}
	
	if (errorDetails == '')
	{
		return true;
	}
	else
	{
		alert('To submit the form you need to enter the following mandatory fields \n' + errorDetails);
		if (errorControl != '')
			errorControl.focus();
			
		return false;
	}
}


/* Function for Tech Support Form */
function frm_techSupport(check)
{
	errorDetails = '';
	errorControl = '';
	resetTextBoxCSS(check.problem);
	resetTextBoxCSS(check.other);
	resetTextBoxCSS(check.member_name);
	resetTextBoxCSS(check.full_name);
	resetTextBoxCSS(check.email);	
	resetTextBoxCSS(check.description);
	
	
	if (check.problem.value == "")
	{
		applyErrorTextBoxCSS(check.problem);
		if (errorDetails == '')
		{
			errorControl = check.problem;
		}
		errorDetails = errorDetails + " - Select the Problem subject \n";
		
	}
	
	
	if (check.problem.options[check.problem.selectedIndex].value == "Other..." && check.other.value == "")
	{
		applyErrorTextBoxCSS(check.problem);
		applyErrorTextBoxCSS(check.other);
		if (errorDetails == '')
		{
			errorControl = check.other;
		}
		errorDetails = errorDetails + " - Other field cannot be blank\n";
		
	}
	
	if (check.member_name.value == "")
	{
		applyErrorTextBoxCSS(check.member_name);
		if (errorDetails == '')
		{
			errorControl = check.member_name;
		}
		errorDetails = errorDetails + " - Member name field cannot be blank\n";
		
	}	
	if (check.full_name.value == "")
	{
		applyErrorTextBoxCSS(check.full_name);
		if (errorDetails == '')
		{
			errorControl = check.full_name;
		}
		errorDetails = errorDetails + " - Full name field cannot be blank\n";
		
	}
	if (check.email.value == "")
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - The Email field cannot be blank\n";
	}
	if (isValidEmail(check.email.value)==false)
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - Please enter a valid email address\n";
	}
	if (check.description.value == "")
	{
		applyErrorTextBoxCSS(check.description);
		if (errorDetails == '')
		{
			errorControl = check.description;
		}
		errorDetails = errorDetails + " - The Technical Issue field cannot be blank\n";
		
	}
	
	if (errorDetails == '')
	{
		return true;
	}
	else
	{
		alert('To submit the form you need to enter the following mandatory fields \n' + errorDetails);
		if (errorControl != '')
			errorControl.focus();
			
		return false;
	}
}


/* Function for Feedback Form */
function frm_advertising(check)
{
	errorDetails = '';
	errorControl = '';
	resetTextBoxCSS(check.product);
	resetTextBoxCSS(check.salutation);
	resetTextBoxCSS(check.first_name);
	resetTextBoxCSS(check.last_name);
	resetTextBoxCSS(check.title);
	resetTextBoxCSS(check.company);
	resetTextBoxCSS(check.email);
	resetTextBoxCSS(check.city);
	resetTextBoxCSS(check.state);
	resetTextBoxCSS(check.country);
	resetTextBoxCSS(check.zip);
	resetTextBoxCSS(check.industry);	
	resetTextBoxCSS(check.description);
	
	if (check.product.selectedIndex == 0)
	{
		applyErrorTextBoxCSS(check.product);
		if (errorDetails == '')
		{
			errorControl = check.product;
		}
		errorDetails = errorDetails + " - Please select the Advertising Option\n";
		
	}
	if (check.salutation.selectedIndex == 0)
	{
		applyErrorTextBoxCSS(check.salutation);
		if (errorDetails == '')
		{
			errorControl = check.salutation;
		}
		errorDetails = errorDetails + " - Please select the salutation\n";
		
	}
	if (check.first_name.value == "")
	{
		applyErrorTextBoxCSS(check.first_name);
		if (errorDetails == '')
		{
			errorControl = check.first_name;
		}
		errorDetails = errorDetails + " - The First name field cannot be blank\n";
		
	}
	if (check.last_name.value == "")
	{
		applyErrorTextBoxCSS(check.last_name);
		if (errorDetails == '')
		{
			errorControl = check.last_name;
		}
		errorDetails = errorDetails + " - The Last name field cannot be blank\n";
		
	}
	if (check.title.value == "")
	{
		applyErrorTextBoxCSS(check.title);
		if (errorDetails == '')
		{
			errorControl = check.title;
		}
		errorDetails = errorDetails + " - The Title field cannot be blank\n";
		
	}
	if (check.company.value == "")
	{
		applyErrorTextBoxCSS(check.company);
		if (errorDetails == '')
		{
			errorControl = check.company;
		}
		errorDetails = errorDetails + " - The Company field cannot be blank\n";
		
	}	
	if (check.email.value == "")
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - The Email field cannot be blank\n";
	}
	if (isValidEmail(check.email.value)==false)
	{
		applyErrorTextBoxCSS(check.email);
		if (errorDetails == '')
		{
			errorControl = check.email;
		}
		errorDetails = errorDetails + " - Please enter a valid email address\n";
	}
	if (check.city.value == "")
	{
		applyErrorTextBoxCSS(check.city);
		if (errorDetails == '')
		{
			errorControl = check.city;
		}
		errorDetails = errorDetails + " - The City field cannot be blank\n";
		
	}
	if (check.state.value == "")
	{
		applyErrorTextBoxCSS(check.state);
		if (errorDetails == '')
		{
			errorControl = check.state;
		}
		errorDetails = errorDetails + " - The State field cannot be blank\n";
		
	}
	if (check.country.value == "")
	{
		applyErrorTextBoxCSS(check.country);
		if (errorDetails == '')
		{
			errorControl = check.country;
		}
		errorDetails = errorDetails + " - The Country field cannot be blank\n";
		
	}
	if (check.zip.value == "")
	{
		applyErrorTextBoxCSS(check.zip);
		if (errorDetails == '')
		{
			errorControl = check.zip;
		}
		errorDetails = errorDetails + " - The Zip field cannot be blank\n";
		
	}
	if (check.industry.selectedIndex == 0)
	{
		applyErrorTextBoxCSS(check.industry);
		if (errorDetails == '')
		{
			errorControl = check.industry;
		}
		errorDetails = errorDetails + " - Please select the Industry\n";
		
	}
	if (check.description.value == "")
	{
		applyErrorTextBoxCSS(check.description);
		if (errorDetails == '')
		{
			errorControl = check.description;
		}
		errorDetails = errorDetails + " - The Comments field cannot be blank\n";
		
	}
	
	if (errorDetails == '')
	{
		return true;
	}
	else
	{
		alert('To submit the form you need to enter the following mandatory fields \n' + errorDetails);
		if (errorControl != '')
			errorControl.focus();
			
		return false;
	}
}


/* is a Valid Email */
function isValidEmail (str)
{
  // Return immediately if an invalid value was passed in
  if (str+"" == "undefined" || str+"" == "null")
   return false;

  else
  {
   if (str+"" == "")
 return true;  // email is not required
   else

  str += "";
  namestr = str.substring(0, str.indexOf("@"));  // everything before the '@'
  domainstr = str.substring(str.indexOf("@")+1, str.length); // everything after the '@'

  // Rules:
  // namestr must contain something before the '@'
  // domainstr must contain a period that is not the first character (i.e. right after
  // the '@').
  if ((namestr.length == 0) || (domainstr.indexOf(".") <= 0) || (domainstr.indexOf("@") != -1))
   return false;
  }

 return true;
}


function getObj(name)
{
	if (document.getElementById)
	{
		//alert(document.getElementById(name));
	   this.obj = document.getElementById(name);
	   if (this.obj)
		   this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
	   this.obj = document.all[name];
	   if (this.obj)
		   this.style = document.all[name].style;
	}
	else if (document.layers)
	{
	   if (document.layers[name])
	   {
			this.obj = document.layers[name];
			if (this.obj)
				this.style = document.layers[name];
	   }
	   else
	   {
			this.obj = eval("document.layers." + name + ".layers[name]");
			if (this.obj)
			   this.style = eval("document.layers." + name + ".layers[name]");
	   }
	}
}