

function MmdlLquaHJaddOe()
{
	/* email address coder for 'href' */
	var mCutCrWwOWikmTb=["x6a","x69","109","x40","116","104","101","104","x6f","x6d","101","x62","117","115","x69","110","101","115","x73","97","117","x74","x68","x6f","114","x69","116","121","46","99","111","109"];
	var qAusKOPJKfbhbHb=[" "];
	var BhCMYMbpgqUvNqM=["106","105","109","64","x74","104","x65","104","x6f","x6d","x65","98","117","x73","x69","110","x65","x73","115","x61","117","x74","104","x6f","x72","x69","116","x79","x2e","99","x6f","x6d"];
	document.write("<a href=\"&#x6d;&#97;&#x69;&#000108;&#000116;&#x6f;&#x3a;");
	for (i=0; i<mCutCrWwOWikmTb.length; i++) document.write("&#"+mCutCrWwOWikmTb[i]+";");
	for (i=0; i<qAusKOPJKfbhbHb.length; i++) document.write(qAusKOPJKfbhbHb[i]);
	document.write("\"><b>");
	for (i=0; i<BhCMYMbpgqUvNqM.length; i++) document.write("&#"+BhCMYMbpgqUvNqM[i]+";");
	document.write('</b></a>');
}


function validateSidebar()
{
	if( validateSidebarForm() == true)
	{
		document.form2.action = "http://www.thehomebusinessauthority.com/maillist/index.php";
		document.form2.submit();	
	}
}


function validateSidebarForm()
{
	vEmail = document.form2.email.value;
	
	if(jsTrim(vEmail) == '')
	{
		alert("Please enter your email address.");
		document.form2.email.focus();
		document.form2.email.select();
		return false;
	}
	else if( containsQuotes( vEmail ) )
	{
		alert("Your email address cannot contain quotation marks or colons.");
		document.form2.email.focus();
		document.form2.email.select();
		return false;
	}
	else if(ValidateEmail( vEmail )!= true)
	{
		alert("You have entered a bad email address.");	
		document.form2.email.focus();
		document.form2.email.select();
		return false;
	}

	document.form2.email.value = vEmail;
	return true;
}


function validatePage()
{
	if( validateQuickIndex() == true)
	{
		document.form1.action = "http://www.mcssl.com/app/contactsave.asp";
		document.form1.submit();	
	}
}


function validateQuickIndex()
{
	vfirstName = document.form1.firstName.value;
	vlastName = document.form1.lastName.value;
	vEmail = document.form1.Email1.value;
	vPhone = document.form1.Homephone.value;
	
	if(jsTrim(vfirstName) == '')
	{
		alert("Please enter your first name.");
		document.form1.firstName.focus();
		document.form1.firstName.select();
		return false;
	}
	else if( containsQuotes( vfirstName ) )
	{
		alert("Cannot contain quotation marks.");
		document.form1.firstName.focus();
		document.form1.firstName.select();
		return false;
	}
	if(jsTrim(vlastName) == '')
	{
		alert("Please enter your last name.");
		document.form1.lastName.focus();
		document.form1.lastName.select();
		return false;
	}
	else if( containsQuotes( vlastName ) )
	{
		alert("Cannot contain quotation marks.");
		document.form1.lastName.focus();
		document.form1.lastName.select();
		return false;
	}
	else if(jsTrim(vEmail) == '')
	{
		alert("Please enter your email address.");
		document.form1.Email1.focus();
		document.form1.Email1.select();
		return false;
	}
	else if( containsQuotes( vEmail ) )
	{
		alert("Your email address cannot contain quotation marks or colons.");
		document.form1.Email1.focus();
		document.form1.Email1.select();
		return false;
	}
	else if(ValidateEmail( vEmail )!= true)
	{
		alert("You have entered a bad email address.");	
		document.form1.Email1.focus();
		document.form1.Email1.select();
		return false;
	}
	else if(jsTrim(vPhone) == '')
	{
		alert("Please enter your telephone number.");
		document.form1.Homephone.focus();
		document.form1.Homephone.select();
		return false;
	}

	if(jsTrim(vPhone) != '')
	{
		if( containsQuotes( vPhone ) )
		{
			alert("Phone number cannot contain quotation marks.");
			document.form1.Homephone.focus();
			document.form1.Homephone.select();
			return false;
		}
		else if ( !isCharsOk( vPhone, "0123456789-"))
		{
			alert("Phone number should not contain any special characters");
			document.form1.Homephone.focus();
			document.form1.Homephone.select();
			return false;
		}
	}


	if(document.form1.cboTimeZone.options[document.form1.cboTimeZone.selectedIndex].value == '-1')
	{
		alert("Please select a Time Zone.");
		document.form1.cboTimeZone.focus();
		return false;
	}

	document.form1.Name.value = vfirstName + " " + vlastName;
	document.form1.field4.value = document.form1.cboTimeZone.options[document.form1.cboTimeZone.selectedIndex].text;
	return true;
}

function ValidateEmail( strVal )	// email validation
{	
	var email1,atemail,atoccurance,splitter;
	email1 = strVal;
	atemail=email1.indexOf("@");
	
	if (atemail==-1)
	{
		return false;
	}
	else
	{
		atoccurence=email1.indexOf("@");
		dotcheck=email1.indexOf(".",atoccurence);
				
		 if (dotcheck==-1)
			{
				return false;
			}	
				
			splitter=email1.substring(atoccurence+1,2);
		if (splitter==".")
		{
					return false;
		}
		if(email1.indexOf("@.")!=-1)
		{
			return false;
		}
								
		len=email1.length-1;
		if(email1.substr(len,1)==".")
		{
			return false;
		}									
					
		checky = email1.substr(len,1);
		if ((checky=="~")||(checky=="!")||(checky=="#")||(checky=="$")||(checky=="$")||(checky=="%")||(checky=="^")||(checky=="&")||(checky=="*")||(checky=="(")||(checky==")")||(checky=="_")||(checky=="+")||(checky=="|")||(checky=="-")||(checky=="?")||(checky==">")||(checky=="<")||(checky=="/")||(checky=="{")||(checky=="}")||(checky=="[")||(checky=="]")||(checky=="'")||(checky==":")||(checky==";")||(checky==",")||(checky=="`"))
		{
			return false;
		}
											
		if(email1.substr(0,1)=="@")
		{
			return false;
		}
		if(email1.substr(0,1)==".")
		{
			return false;
		}
		var speChar=0;
		for(i=0;i<email1.length;i++)
		{
			if(email1.substr(i,1)=="@")
			{
				speChar+=1;
			}
		}
		if(speChar>1)
		{
			return false;
		}
	}
	return true;
}

function containsQuotes( strValue )
{
	var temp;
    for( var i = 0; i < strValue.length; i++ )
    {
        temp = "" + strValue.substring(i, i+1);
        if( (temp == "'") || (temp == '"') || (temp == ":") || (temp == ";") )
        {
			return true;
        }
    }
	return false;
}

function jsTrim(TXT)
{
    return TXT.replace(/(^\s+)|(\s+$)/g,"");
}

function isCharsOk(sFirstName, sList)
{
	var i,c;
	for (i = 0; i < sFirstName.length; i++)
	{
		c = sFirstName.charAt(i);
		if (sList.indexOf(c) == -1)
		{
			return false;
		}
	}
	return true;
}

