var bm_mobile_domain="m.michaelssalon.com";
document.write(unescape("%3Cscript src='"+location.protocol+"//s3.amazonaws.com/bmobilized/js/redirect.js' type='text/javascript'%3E%3C/script%3E"));


function validateForm()
{
	
			var msg = '';
			if(!ValidateTextBox("comments"))
			{
				msg += "You must enter your comments.\n";
			}
			if (!isValidEmail("contactEmail")) {
				msg += "You must provide a valid email address.\n";	
			}
			else
			{
				//if (is_valid_url("comments"))
				//{
				//	msg += "To protect this site from spam bots, web addresses are not allowed in the comments form";
				//}
			}
			if (msg != '')
  			{
      			alert(msg);
      			return false;
   			}
			else if (ValidateTextBox("comments2"))
			{
				alert("The form caused an error because text was found in a comments box used to trap spam bots.  If you put text here on purpose please refrain from doing so and try to send your comments again.  If you continue to have this error, please report it to blackey@michaelssalons.com");
				return false;
			}
			else
   			{
				 document.thisForm.submit();
				 MM_openBrWindow('/commentsThank.asp','','scrollbars=yes,resizable=yes,width=320,height=210');
				 return true;
			}
			
}

function validateForm2()
{
	
			var msg = '';
			if(!ValidateTextBox("contactEmail"))
			{
				msg += "You must enter your E-Mail address.\n";
			}
			if (msg != '')
  			{
      			alert(msg);
      			return false;
   			}
   			else
   			{
				 document.thisForm.submit();
				 return true;
			}
			
}

function validateForm3()
{
	
			
			var msg = '';
			if(ValidateTextBox("exp"))
			{
				if (is_valid_url("exp"))
				{
					msg += "To protect this site from spam bots, web addresses are not allowed in the application form.";
				}
			}
			if (msg != '')
  			{
      			alert(msg);
      			return false;
   			}
   			else
   			{
				 document.thisForm.submit();
				 return true;
			}
			
			
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function swapStyle(id, newStyle)
{
	var elem;
	elem = document.getElementById(id);
	elem.className = newStyle;
}

function ValidateTextBox (strTextBoxID)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var fIsValid = true;

	if (cTextBox.value.replace(/\s/g, "") == "")
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		
		fIsValid = false;
	}

	return (fIsValid);
}

function isValidEmail(boxID) {
	var cTextBox = document.getElementById(boxID);
	var str = cTextBox.value;
   var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|edu|jobs|museum)\b/ ;
	return str.match(re);
}

function is_valid_url(url)
{
	var cTextBox = document.getElementById(url).value;
	
	var regexp = /url=/;
	var regexp2 = /a href=/;
	var regexp3 = /link=/
	var regexp4 = /http:/
	var matchPos1 = cTextBox.search(regexp);
	var matchPos2 = cTextBox.search(regexp2);
	var matchPos3 = cTextBox.search(regexp3);
	var matchPos4 = cTextBox.search(regexp4);
	
	if(matchPos1 != -1 || matchPos2 != -1 || matchPos3 != -1 || matchPos4 != -1)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function flipStyle(id)
{
	var elem;
	elem = document.getElementById(id);
	if (elem.className == "hide")
	{
		elem.className = "menuItemNotes";
	}
	else
	{
		elem.className = "hide";
	}
}

function flipImg(id, imagePath, altPath)
{
	document[id].src=imagePath;
	document[id].alt=altPath;
}

function showRecruit()
{
	if (checkCookie())
	{
		var elem;
		if (document.getElementById('recruit'))
		{
			elem = document.getElementById('recruit');
			elem.className = 'show';
		}
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
  if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function checkCookie()
{
	rec=getCookie('recruit');
	if (rec!=null && rec!="")
	{
		return false;
	}
	else
	{
		return true;
	}
}
