var cnv;
var jg;
function submitForm(formId, actionId, actionValue) {
    document.getElementById(actionId).value=actionValue;
    if (actionValue == 'Cancel') {
        if (confirm('Are you sure you want to cancel - \n Details will be lost?')){
            document.getElementById(formId).submit();
        } else {
            return false;
        }
    } else {
        document.getElementById(formId).submit();
    }
}

function closeForm(redirectUrl) {
    window.opener.location.href=redirectUrl;
    window.close();
}

function prepareInsuranceNeedsGraph(canvas, imgUrl) {
    cnv = document.getElementById(canvas);
    jg = new jsGraphics(cnv);
    jg.drawImage(imgUrl,0,0,562,382);
}

function plotInsuranceNeedsPoint(x1,y1) {
    var x = x1;
    x = (450 / 25 * x);
    x = x + 56;
    var y = y1;
    y = 30 - y;
    y = (300 / 30 * y);
    y=y+41;
    
    jg.setColor("#e60e64");
    if (x > (450 - 15)){
        x = 450 - 15;
    }
    if (y > (300 - 15)) {
        y = 300 - 15;
    }
    jg.fillEllipse(x,y,15,15);
    
    jg.setColor("#e60e64");
    jg.fillEllipse(10,388,15,15);
    jg.setFont("arial","15px",Font.ITALIC_BOLD);     
    jg.drawString("Indicates your positioning",30,388);// - x:y is "+x1+":"+y1,30,388);     
    jg.paint(); // draws, in this case, directly into the document
}

function prepareShortTermInsuranceGraph(canvas, imgUrl) {
    cnv = document.getElementById(canvas);
    jg = new jsGraphics(cnv);
    jg.drawImage(imgUrl,0,0,562,382);
}

function plotShortTermInsurancePoint(x1,y1) {
    var x = x1;
    x = (450 / 25 * x);
    x = x + 56;
    var y = y1;
    y = 30 - y;
    y = (300 / 30 * y);
    y = y + 41;
//    jg.setColor("#babcbe");
//    jg.drawString('x:'+x1+' y:'+y1, x-12,y-12);
    if (x > (450 - 15)){
        x = 450 - 15;
    }
    if (y > (300 - 15)) {
        y = 300 - 15;
    }
    jg.setColor("#e60e64");
    jg.fillEllipse(x,y,15,15);

    jg.setColor("#e60e64");
    jg.fillEllipse(10,388,15,15);
    jg.setFont("arial","15px",Font.ITALIC_BOLD);     
    jg.drawString("Indicates your positioning",30,388);// - x:y is "+x1+":"+y1,30,388);     

    jg.paint(); // draws, in this case, directly into the document
}

