function CheckEmail(email)
{
    var firstchunk,indx,secondchunk;

    if (email == ""){
        return false;
    }

    //get the zero-based index of the "@" character
    indx = email.indexOf("@");

    //if the string does not contain an @ then then return true
    if (indx == -1 ){


        return false;
    }

    //if the first part of email is < 2 chars and second part < 7 chars
    //(arbitrary but workable criteria) then reject the input address

    firstchunk = email.substr(0,indx); //up to but not including the "@"

    //start at char following the "@" and include up to end of email addr
    secondchunk = email.substr(indx + 1) ;

    //if the part  following the "@" does not include a period "." then
    //also return false
    if ((firstchunk.length < 2 ) || (secondchunk.length < 7) ||
    (secondchunk.indexOf(".") == -1)){ 

    return false
    }
    return true;
}




function controlMandatory()
{
	var txtName = document.getElementById("txtName");
	var txtEmail = document.getElementById("txtEmail");
	var txtComments = document.getElementById("txtYourComments");
	var txtSubject = document.getElementById("txtSubject");
	
	if(txtName)
	{	
		if(txtName.value == "") return false;
	}
	if(txtEmail)
	{	
		if(txtEmail.value == "") return false;
	}
	if(txtComments)
	{	
		if(txtComments.value == "") return false;
	}
	if(txtSubject)
	{	
		if(txtSubject.value == "") return false;
	}
	return true;
}

function controlSubmit()
{
	invisibleErrors();
	var mandatory = controlMandatory();
	var labelStatus = null;
	if(!mandatory)
    {
        labelStatus = document.getElementById("labStatusMandatory");
        labelStatus.style.display="block";   
        return false;
    }
    var emailcontrol = controlMail();
    if(!emailcontrol)
    {
        labelStatus = document.getElementById("labStatusEmail");
        labelStatus.style.display="block";   
        return false;
    }
    return true;
    

}
function invisibleErrors()
{
var labelStatus = document.getElementById("labStatusTrue");
if(labelStatus) labelStatus.style.display="none";
labelStatus = document.getElementById("labStatusFalse");
if(labelStatus) labelStatus.style.display="none";
labelStatus = document.getElementById("labStatusMandatory");
if(labelStatus) labelStatus.style.display="none";
labelStatus = document.getElementById("labStatusEmail");
if(labelStatus) labelStatus.style.display="none";



}
function controlMail()
{
	var txtEmail = document.getElementById("txtEmail");
	if(txtEmail)
	{
		return CheckEmail(txtEmail.value);
	}
	return false;
}

function showStatus()
{
    if(window.location.href.indexOf("send=")>-1)
    {
        var labelStatus = null;
        if(window.location.href.indexOf("send=true")>-1)
        {
            labelStatus = document.getElementById("labStatusTrue");
        }
        else
        {
			labelStatus = document.getElementById("labStatusFalse");
        }
        if(labelStatus)
        {
            labelStatus.style.display="block";    
        }
    }
}