﻿var Omega = {

    WebService: {
        FwdResearchViaEmail: function () {                   
            var id = 'divSendResearchToForm_clone', data = Array();
            $('#'+id+' input, #'+id+' textarea').each(function(i) { data[i] = $(this).val(); });
        
            if (data[1].length < 8 || data[2].length < 2 || data[1].indexOf('@') < 1 || data[2].indexOf('@') < 1)
            {
                if ($('#'+id+' #e').length == 0)
                    $('<span id=\"e\" style=\"color:#cc0000\">Please enter a valid email address for both you and the recipient</span>').insertBefore('#divSendResearchToForm_clone div.research-fwd-form table');
                return;
            }
           
           WebService.FwdResearchViaEmail(G_OpenFormId,data[0],data[1],data[2],data[3], Omega.WebService._fwdresearchviaemail_oncomplete, _MSAjax_OnError, _MSAjax_OnTimeOut);   
        },
        _fwdresearchviaemail_oncomplete: function (data) {
	        var o = eval('('+data+')');
	        if (o.success)
	        {
	            $('#divSendResearchToForm_clone div.research-fwd-form')
	                .html("<span style='font-size:8pt'>You have successfully forwarded the research article <b>\"" + o.title + "\"</b> to your associate. Thanks for your interest in Omega Protein plant nutrition research.</span>");
	        }
        }
    }
}

function _MSAjax_OnComplete(arg)
{
    //alert(arg);
    return true;
}
function _MSAjax_OnError(arg)
{
    alert("error has occured: " + arg.get_message());
}
function _MSAjax_OnTimeOut(arg)
{
   alert("timeout has occured");
}