function isblank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function CheckEmail(strEmail) {
	var i;
	var getChar;


	if ((Left(strEmail, 1) == "@") || (Right(strEmail, 1) == "@") )
		return false;
	

		getChar = 0;
	for (i = 0 ; i < strEmail.length ; i++ ) {
		if (strEmail.charAt(i)=='@'){
			getChar++;
		}
	}	    

	if ( getChar != 1 )
		return false;

	var email1;
	var email2;
	var temail;
	
	temail = strEmail.split('@')
	email1 = temail[0].replace(/\s/g, "");
	email2 = temail[1].replace(/\s/g, "");	
	
	var cemail;
	cemail = strEmail;
	cemail = cemail.replace(/\@/g, "");	
	cemail = cemail.replace(/\./g, "");	
	
	if (cemail.length == 0)
		return false;
	
	var allow;
	allow = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-";
	for(i = 0 ; i < cemail.length; i++ )
		if (allow.indexOf(cemail.charAt(i)) < 0 )
			return false;

	if (Left(email1, 1) == '.')
		return false;

	
	if (Left(email2, 1) == '.' || Right(email2, 1) == '.' || email2.replace(/\./g, "").length == email2.length)
		return false;

	if (email2.indexOf("..") >= 0 )
		return false;

	if (Left(email2, 1) == '-' || Right(email2, 1) == '-')
		return false;

	if (Left(email2, 1) == '_' || Right(email2, 1) == '_')
		return false;
	
	return true;
}	

function Left( sourceStr, charIdx ) {
	if((sourceStr==null) || (sourceStr=="")) return "";
	return sourceStr.substring(0, charIdx);
}

function Right( sourceStr, charIdx ) {	
	if((sourceStr==null) || (sourceStr=="")) return "";
	return sourceStr.substring(sourceStr.length-charIdx, sourceStr.length);
}





// Check Register
function check_info(e)
{
	var msg;
	var textname="";
	var textphone="";
	var textemail="";
	var textcontent="";
	var fg=1;


	if ((e.Name.value == null) || (e.Name.value == "") || isblank(e.Name.value)) { textname = "Name is Required.\n";}	
	if ((e.Phone.value == null) || (e.Phone.value == "") || isblank(e.Phone.value)) { textphone = "Phone is Required.\n";}
	if ((e.email.value == null) || (e.email.value == "") || isblank(e.email.value)) { textemail = "E-mail Address is Required.\n"; fg=0;}
	if (fg) {
		 if (!CheckEmail(e.email.value)) { textemail = "An Error occurred. Please enter a correct email address. \n";} 
		}
	if ((e.content.value == null) || (e.content.value == "") || isblank(e.content.value)) {textcontent = "content is Required.\n";}

	
	if (e.Name.style) e.Name.style.backgroundColor = textname != "" ? '#FFCC66':'#FFFFFF';
	if (e.Phone.style) e.Phone.style.backgroundColor = textphone != "" ? '#FFCC66':'#FFFFFF';
	if (e.email.style) e.email.style.backgroundColor = textemail != "" ? '#FFCC66':'#FFFFFF';
	if (e.content.style) e.content.style.backgroundColor = textcontent != "" ? '#FFCC66':'#FFFFFF';
	
	if ((textname == "") && (textphone == "") && (textemail == "") && (textcontent == "")) 
		{ 
			e.submit();
			return true;
		}
	
	if (textname && textphone && textemail && textcontent) {
		msg = textname + textphone + textemail + textcontent;
	} else {
		msg = textname + textphone + textemail + textcontent;
	}		
	alert(msg);
	return false;
}









