﻿var winl = (screen.width - 630) / 2;
var wint = (screen.height - 540) / 2;
var winprops = 'resizable,scrollbars=1,dependent, menubar=0,width=630px,height=540px,top=' + wint + ',left=' + winl
var clicked = false;
var currentProjectID = 8;

function SetProjectID(projectID)
{
    currentProjectID = projectID;
}

function keyPress(question, e) {
    if (document.all) {
        if (window.event.keyCode == 13) {
            return AskQuestion(question);
        }
    }
    else {
        if ((e.keyCode == 13) || (event.which == 13)) {
            return AskQuestion(question);
        }
    }
    
    return true;
}

function BrowseAll()
{
    //var url = "explorefaq.asp?projectid=" + projectID;
    var url = "http://www.flexanswer.com/home/agathos/explorefaq.asp?projectid=" + currentProjectID;
    var newWindow = '_explorefaq';
    var browseProps = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1';
    
    browseAllWindow = window.open(url, newWindow, browseProps);
    browseAllWindow.focus();
}

function ViewAnswer(mesID)
{
    var responseType = 0;
    var TOPV = "YES"; //add to count for FAQs report
    var CCT = "YES"; //do not show internal note
    //var url = "/Home/hybrid/show.asp?Project=<%=lngProjectId%>" +
    var url = "http://www.flexanswer.com/home/hybrid/show.asp?Project=" + currentProjectID +
								 "&isCFP=1&MesId=" + mesID + "&CCT=" + CCT + "&TOP=" + TOPV;
    
    var newWindow = 'ViewAnswerWindow' + Math.round(Math.random() * 100000).toString(10);
    var viewAnswerWindow = window.open(url, newWindow, winprops);
    viewAnswerWindow.focus();
    return false;
}

function AskQuestion(question) {
    if (document.getElementById(question).value == "Type your question here")
    {
        alert('Please enter your question.');
    }
    else if (document.getElementById(question).value == "")
    {
        alert('Please enter your question.');
    }
    else
    {
        var url = "http://www.flexanswer.com/home/hybrid/answer.asp?Project=" + currentProjectID +
            '&isCFP=1&Question=' + document.getElementById(question).value;
            
        var newWindow = 'ViewAnswerWindow' + Math.round(Math.random() * 100000).toString(10);
        var viewAnswerWindow = window.open(url, newWindow, winprops);
        viewAnswerWindow.focus();
    }
    
    return false;
}