/************************** SEND TO FRIEND **************************/
var txtFriendEmail;
var txtMyEmail;
var chkCopyToMe;
var txtFriendName;
var SF_txtSubject;
var SF_strMessage;

function cls_send_friend()
{
    this.complete= Completed;  
}

function Completed(strResponse)
{
    var SendToFriendBlock= top.window.document.getElementById("popupContainer");
   SendToFriendBlock.style.height= "110px";
   var SendToFriendIframe= top.window.document.getElementById("popupFrame");
   SendToFriendIframe.style.height= "110px";
   
    var SendToFriendBlock= top.window.document.getElementById("popupContainer");
   SendToFriendBlock.style.width= "430px";
   var SendToFriendIframe= top.window.document.getElementById("popupFrame");
   SendToFriendIframe.style.width= "430px";
   HideInputs();
}

function HideInputs()
{
    document.getElementById('divInput').style.display= 'none';
    document.getElementById('SendToFriendResult').style.display= 'block';
}

function StartSendToFriend(str_url)
{
    var strUrl= str_url;
  
    LoadSendToFriendParam(document.getElementById('txtFriendEmail'),
    document.getElementById('txtYourEmail'),
    document.getElementById('chkCopy'),
    document.getElementById('txtName'),
    document.getElementById('txtSubject'),
    document.getElementById('txtMessage'));
    
    var objSendFriend= new cls_send_friend();
        
    if(CheckSendToFriend())
    {
    var strFriendEmail = removeBadChar(txtFriendEmail.value);
    var strMyEmail = removeBadChar(txtMyEmail.value);
    var strFriendName = txtFriendName.value;
    var strSubject = SF_txtSubject.value;
    var strMessage = SF_strMessage.value;
    
    TestShAjax(strUrl + "&FE=" + strFriendEmail + "&ME=" + strMyEmail + "&C=" 
    + chkCopyToMe.checked + "&FN=" +  strFriendName + "&S=" + strSubject 
    + "&M=" + encodeURIComponent(strMessage) + "&OP=" + escape(top.window.location.href)  ,
    'Message',objSendFriend);
    }
    
}

function ClearFields()
{
    if( txtFriendEmail != null )
    {
        txtFriendEmail.value= "";
        txtMyEmail.value= "";
        chkCopyToMe.checked= "";
        txtFriendName.value= "";
        SF_txtSubject.value = "";
        SF_strMessage.value= "";
        document.getElementById('Message').innerHTML= "";
    }
}

function LoadSendToFriendParam(txt_FriendEmail, txt_MyEmail, chk_CopyToMe, txt_FriendName, SF_txt_Subject,
SF_txt_Message)
{
    txtFriendEmail= txt_FriendEmail;
    txtMyEmail= txt_MyEmail;
    chkCopyToMe= chk_CopyToMe;
    txtFriendName= txt_FriendName;
    SF_txtSubject= SF_txt_Subject;
    SF_strMessage= SF_txt_Message;
}

function CheckSendToFriend()
{
    var strError= "";
    
    if (txtFriendEmail == null)
        return false;
        
    if ( IsEmpty(txtFriendEmail) )
        strError += "- Enter Your Friend Email\n";
    
    if( ! (IsEmpty(txtFriendEmail) || IsValidEmail(txtFriendEmail.value)) )
        strError += "- Enter a valid Friend Email\n";
        
         if( IsEmpty(txtFriendName) )
        strError += "- Enter the name\n";
        
    if(IsEmpty(txtMyEmail))
        strError += "- Enter your Email\n";
        
    if( ! (IsEmpty(txtMyEmail) || IsValidEmail(txtMyEmail.value)) )
        strError += "- Enter your Email in a valid Format\n";
        
    if( IsEmpty(SF_txtSubject) )
        strError += "- Enter the subject\n";
        
     if( IsEmpty(SF_strMessage) )
        strError += "- Enter the message\n";
        
    if( strError.length > 1 )
    {
       alert( strError );
        return false;
    }
    
    return true;
}
/**********************************************************************/
             
