function ValidateDownloadRegForm()
{
var obtnDownload = $('btnDownload');
var oEmail = $('email');
var oOrganization = $('organization');
var oFirstName = $('fname');
var oLastName = $('lname');
var oNotifyForUpdates = $('notifyForUpdates');
var isValid  = true;

if (!oNotifyForUpdates.checked) 
return true;

if (!oEmail.value)
{
    oEmail.style.backgroundColor='yellow';
    
    isValid = false;
}
else
{
    if (!CheckEmail(oEmail.value))
    
    {
      oEmail.style.backgroundColor='yellow';
      isValid = false;
    }
    else
    
    {
      oEmail.style.backgroundColor='white';
    }
}

if (!oFirstName.value)
{
    oFirstName.style.backgroundColor='yellow';
     isValid = false;
}
else
{
    oFirstName.style.backgroundColor='white';
}

if (!oLastName.value)
{
    oLastName.style.backgroundColor='yellow';
     isValid = false;
}
else
{
    oLastName.style.backgroundColor='white';
}
return isValid;

};

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
}

//the email was okay; at least it had a @, more than 1 username chars,
//more than 6 chars after the "@", and the substring after the "@"
// contained a "." char

return true 

}

function SubmitForm()
{
	$('mainForm').submit();
}

function SubmitForm(formId) {
    $(formId).submit();
} 

function Subscribe()
{
	$('thank-you-for-subscription').hide();
	$('failed-subscription').hide();
	 var valid = new Validation('subscribeForm', {onSubmit:false});    
	 var result = valid.validate();
	 
	 if (result)
	 {
	
	
		$('subscribe-button').disabled=true;
	

		$('subscribeForm').request( { onComplete: function(){ $('subscribe-button').disabled=false;$('thank-you-for-subscription').show(); } } );
	 }

} 
function OnSuccess(transport)
{
	$('subscribe-button').disabled=false;
	$('thank-you-for-subscription').show();
};
function OnFailure()
{ 
	$('subscribe-button').disabled=false;
	$('failed-subscription').show();
};
