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);
}


function check_complaint_form(e)
{
	var msg;
	var textyname="";
	
	if ((e.y_name.value == null) || (e.y_name.value == "") || isblank(e.y_name.value)) { textyname = "Your name is Required.\n";}

	if (e.y_name.style) e.y_name.style.backgroundColor = textyname != "" ? '#FFCC66':'#FFFFFF';
	
	if ((textyname == "")) 
		{ 
			e.submit();
			return true;
		}
	
	else {
		msg = textyname ;
	}		
	alert(msg);
	return false;
}

function check_public_form(e)
{
	var msg;
	var textyname="";
	var textyaddress1="";
	
	if ((e.u_name.value == null) || (e.u_name.value == "") || isblank(e.u_name.value)) { textyname = "Name is Required.\n";}

	if (e.u_name.style) e.u_name.style.backgroundColor = textyname != "" ? '#FFCC66':'#FFFFFF';

	if ((e.address1.value == null) || (e.address1.value == "") || isblank(e.address1.value)) { textyaddress1 = "Address1 is Required.\n";}

	if (e.address1.style) e.address1.style.backgroundColor = textyaddress1 != "" ? '#FFCC66':'#FFFFFF';
	
	if ((textyname == "") && (textyaddress1 == "")) 
		{ 
			e.submit();
			return true;
		}
	
	else {
		msg = textyname + textyaddress1;
	}		
	alert(msg);
	return false;
}