/* script launches AIS */

function windowOpener(name, args) {

    var popuWin = null;
    var aisURL = document.aisform.action;

    if (typeof(popupWin) != "object") {
        /*        alert("1 " + aisURL);*/
        popupWin = window.open(aisURL, name, args);
        //        if(popupWin!=null){
        //            alert("AAAAA");
        //        }
    } else {
        /*        alert("2 " + aisURL);*/
        if (!popupWin.closed) {
            /*            alert("3 " + aisURL);*/
            popupWin.location.href = aisURL;
        } else {
            /*            alert("4 " + aisURL);*/
            popupWin = window.open(aisURL, name, args);
        }
    }
    if (popupWin != null && popupWin.opener == null) {
        popupWin.opener = self;
    }
    popupWin.focus();
}

function vesselmap(llpno) {
    windowOpener('mapview', '');

    if (llpno != null) {
        document.aisform.query.value = 'vessel'
        document.aisform.llpnos.value = llpno;
        document.aisform.submit();
    } else {
        document.aisform.query.value = 'vessel'
        //document.aisform.llpnos.value = document.aisform.llpnos.value;
        document.aisform.submit();
    }
}

/*
function globalmap() {
    windowOpener('mapview', '');
    document.aisform.query.value = 'vessel'
    //document.aisform.llpnos.value = document.aisform.llpnos.value;
    document.aisform.submit();
}
*/

function newais() {    
    document.aisform.submit();
}

function newaisfree() {
    document.aisformfree.submit();
}

function newaislite() {
    document.aisformlite.submit();
}

function portmap(portidno) {
    windowOpener('mapview', '');
    if (portidno != null) {
        document.aisform.query.value = 'port'
        document.aisform.idnos.value = portidno;
        document.aisform.submit();
    } else {
        // document.vsllist.llpnos.value = document.vsllist.llpnos.value;
        // document.vsllist.submit();
    }
}

function casmap(casrefno) {
    windowOpener('mapview', '');
    if (casrefno != null) {
        document.aisform.query.value = 'casualty'
        document.aisform.refnos.value = casrefno;
        document.aisform.submit();
    } else {
        // document.vsllist.llpnos.value = document.vsllist.llpnos.value;
        // document.vsllist.submit();
    }
}

