
function doShowHelp() {
    var wnd = window.open('docs/IDEA_User_guide.pdf','Help','directories=no,location=no,menubar=no,toolbar=no,status=no,scrollbars=auto,resizable=yes');
    wnd.focus();
}

function doOpenIDEA(URL, projectId, arrayId, resizable) {
    var c = URL.indexOf('?') < 0 ? '?' : '&';
    var url = URL  + c + "projectId=" + projectId + "&arrayId=" + arrayId;
    editArrayWnd = window.open(url,'Array','directories=no,location=no,menubar=no,toolbar=no,status=yes,scrollbars=yes,resizable='+resizable);
    editArrayWnd.focus();
}

function login() {
    var wnd = self.opener;

    if(wnd != undefined && !wnd.closed){
        wnd.location.replace('index.jsp');
        self.close();
    }
    else if(wnd == undefined){
        wnd = self;
        self.location.replace('index.jsp');
    }
    else{
        wnd = window.open('index.jsp', '_blank');
        self.close();
    }

    if(wnd != undefined){
        wnd.focus();
        wnd.opener = null;
    }
}

function doShowWaitMsg(left, top, width){
    var msg = document.getElementById('waitmessage');
    if(msg != undefined){
        msg.style.visibility = 'visible';
        if(left != undefined) msg.style.left=left;
        if(top != undefined) msg.style.top=top;
        if(width != undefined) msg.style.width=width;
    }
}

function nav(ref){
    var wnd = self.opener;
    if(wnd!=undefined && !wnd.closed){
        wnd.location.replace(ref);
    }
    else{
        wnd = window.open(ref, '_blank');
    }

    wnd.focus();
    self.opener = wnd;
}

function closePopup(){
    var wnd = self.opener;
    if(wnd!=undefined && !wnd.closed){
        wnd.focus();
    }
    window.close();
}

function validateName(name, notify){
    if(name.indexOf('"') < 0) return true;
    if(notify) alert('No names are supposed to have " symbol.\nPlease enter another name and repeat the operation.');
    return false;
}

function validateEmail(email, notify){
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (filter.test(email))
        return true;
    else
        alert("Please input a valid email address!")
    return false;
}

function doShowCredits() {
    var wnd = window.open('Credits.jsp','Credits','directories=no,location=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=yes,width=420,height=190');
    wnd.focus();
}

function doShowFaq(){
    var wnd = window.open('FAQ/index.html','FAQ');
    wnd.focus();
}

var pval = "";
function checkNumber(value) {
    if(isNaN(value)){
        if (pval==value) return;
        pval = value;

        alert('Input error! Number format is incorrect!');
        return false;
    }
    pval = "";
    return true;
}

