﻿function ConfirmDelete() {
    if (confirm("Are you sure you want to delete the job?") == true) {
        return true;
    }
    else {
        return false;
    }
}

function ValidateDateRange(dateStart, dateEnd) {
    return dateStart < dateEnd;
}

function fadeIn(objId, opacity) {
    if (document.getElementById) {
        obj = document.getElementById(objId);
        if (opacity <= 100) {
            setOpacity(obj, opacity);
            opacity += 4;
            window.setTimeout("fadeIn('" + objId + "'," + opacity + ")", 250);
        }
    }
}

function fadeOut(objId, opacity) {
    if (document.getElementById) {
        obj = document.getElementById(objId);
        if (opacity >= 0) {
            setOpacity(obj, opacity);
            opacity -= 2;
            window.setTimeout("fadeOut('" + objId + "'," + 500 + ")", 100);
        }
        if (opacity == 0) {
            //obj.style.display = 'none';
        }
    }
}

function setOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;
    if (opacity == 0) return;
    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity / 100;
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity / 100;
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity / 100;
}


function NotifyValidationResult(msgId) {
    var msg = document.getElementById(msgId);
    if (!Page_IsValid) {
        msg.className = 'error';
        msg.innerText = 'Required fields missing.';
        fadeOut(msgId, 100);
    }
}


//Ajax async Uploader functions
function clearContents() {
    var AsyncFileUpload = $get("<%=AsyncFileUpload1.ClientID%>");
    var txts = AsyncFileUpload.getElementsByTagName("input");
    for (var i = 0; i < txts.length; i++) {
        if (txts[i].type == "text") {
            txts[i].value = "";
            txts[i].style.backgroundColor = "white";
        }
    }
}
function uploadComplete_CertificationDoc(sender, args) {
    var supportedExt = new Array(3);
    supportedExt[0] = '.jpg';
    supportedExt[1] = '.png';
    supportedExt[2] = '.jpeg';
    try {
        var fileExtension = args.get_fileName();
        var isValid = false;
        for (var i = 0; i < supportedExt.length; i++) {
            if (fileExtension.toLowerCase().indexOf(supportedExt[i]) != -1) {
                {
                    isValid = true;
                    break;
                }
            }
        }
        if (isValid) {
            $get("uploadMessage").innerHTML = "Upload succesful";
        }
        else {
            $get("uploadMessage").innerHTML = "File extension not supported. Images only";
        }

        clearContents();
    }
    catch (e) {
       // alert(e);
    }
}

