﻿// JScript File
function performEnterDetailedFeedback(e, frmPage, sSubject, sFeedback, sEmail) {
    var iKey;


    if (!e) {e = window.event;}
    iKey = e.keyCode;
    if (iKey == null) {iKey = e.which;}     //older firefox, opera
    
    //peform search only if key press is an enter
    if (iKey == 13)
    {    
        e.returnValue = false;      //cancel the event
        e.cancelBubble = true;      //cancel event bubbling to form submit
        if (e.stopPropagation) {e.stopPropagation();}
        performDetailedFeedback(frmPage, sSubject, sFeedback, sEmail);
    }
    
    return false;
}

function performDetailedFeedback(frmPage, sSubject, sFeedback, sEmail)
{
    if ((sSubject == null) || (sSubject == "")) {
		alert("Please supply a subject.");
		return;
    }
    else {
        //check for restricted characters
        if (sSubject.indexOf("<") > -1) {
            alert("The character sequence '<' is not allowed in the subject.");
            return;
        }
        
        if (sSubject.indexOf(">") > -1) {
            alert("The character sequence '>' is not allowed in the subject.");
            return;
        }
    }

    if ((sFeedback == null) || (sFeedback == "")) {
		alert("Please supply a feedback/question.");
		return;
    }
    else {
        //check for restricted characters
        if (sFeedback.indexOf("<") > -1) {
            alert("The character sequence '<' is not allowed in the feedback.");
            return;
        }
        
        if (sFeedback.indexOf(">") > -1) {
            alert("The character sequence '>' is not allowed in the feedback.");
            return;
        }
    }
    

    

    
    if ((sEmail != null) && (sEmail != "")) {
        if ((sEmail.indexOf("@") < 0) || (sEmail.indexOf(".") < 0)) {
		    alert("Please supply a valid email.");
		    return;
		}
		
		//check for restricted characters
        if (sEmail.indexOf("<") > -1) {
            alert("The character sequence '<' is not allowed in the email.");
            return;
        }
        
        if (sEmail.indexOf(">") > -1) {
            alert("The character sequence '>' is not allowed in the email.");
            return;
        }
    }
    
    frmPage.submit();
}

