﻿function FP_preloadImgs() {//v1.0
    var d = document, a = arguments; if (!d.FP_imgs) d.FP_imgs = new Array();
    for (var i = 0; i < a.length; i++) { d.FP_imgs[i] = new Image; d.FP_imgs[i].src = a[i]; }
}

function FP_swapImgRestore() {//v1.0
    var doc = document, i; if (doc.$imgSwaps) {
        for (i = 0; i < doc.$imgSwaps.length; i++) {
            var elm = doc.$imgSwaps[i]; if (elm) { elm.src = elm.$src; elm.$src = null; }
        }
        doc.$imgSwaps = null;
    }
}

function FP_swapImg() {//v1.0
    var doc = document, args = arguments, elm, n; doc.$imgSwaps = new Array();
    for (n = 2; n < args.length; n += 2) {
        elm = FP_getObjectByID(args[n]); if (elm) {
            doc.$imgSwaps[doc.$imgSwaps.length] = elm;
            elm.$src = elm.src; elm.src = args[n + 1];
        }
    }
}
function FP_getObjectByID(id, o) {//v1.0
    var c, el, els, f, m, n; if (!o) o = document; if (o.getElementById) el = o.getElementById(id);
    else if (o.layers) c = o.layers; else if (o.all) el = o.all[id]; if (el) return el;
    if (o.id == id || o.name == id) return o; if (o.childNodes) c = o.childNodes; if (c)
        for (n = 0; n < c.length; n++) { el = FP_getObjectByID(id, c[n]); if (el) return el; }
    f = o.forms; if (f) for (n = 0; n < f.length; n++) {
        els = f[n].elements;
        for (m = 0; m < els.length; m++) { el = FP_getObjectByID(id, els[n]); if (el) return el; }
    }
    return null;
}

function hndlSummary() {
    var vwFeedbackDiv = document.getElementById("cntPHPgContent_feedBackSummary_vwFeedbackMessages");
    if (vwFeedbackDiv != null) {
        var valSummary = document.getElementById("cntPHPgContent_feedBackSummary_valSummary");
        var iknIndicator = document.getElementById("cntPHPgContent_feedBackSummary_ikonImage");
        if (!(valSummary.innerHTML == null || valSummary.innerHTML == "")) {
            vwFeedbackDiv.style.background = "#fff0f0";
            vwFeedbackDiv.style.border = "solid 1px #f00";
            vwFeedbackDiv.style.padding = "5px";
            iknIndicator.setAttribute("src", "../siteImages/ikon_Error.png");
        }
    }
}

function CheckFileType(sender, args) {
    //var objFile = window.document.SBBankInfoManage.Browsefield.value;
    var obj = window.document.getElementById("ctl00_cntPHPgContent_filVideoUpload");
    var objFile = obj.value;
    var ext = objFile.slice(objFile.lastIndexOf(".")).toLowerCase();
    if (ext == ".flv") {
        alert("FLV Video");
        args.IsValid = true;
        return;
    }
    else {
        alert("Only Flash Videos are allowed, Please upload a valid Flash Video..");
        obj.value = "";
        args.IsValid = false;
        return;
    }
}

function fileUploadSuccess() {

}

function fileTypeCheck(sender, args) {
    var filename = args.get_fileName();
    if (filename != "") {
        // code to get File Extension..
        var arr1 = new Array;
        arr1 = filename.split("\\");
        var len = arr1.length;
        var img1 = arr1[len - 1];
        var filext = img1.substring(img1.lastIndexOf(".") + 1);

        // Checking Extension
        if (filext == "flv")
            return true;
        else {
            alert("Only Flash Videos are allowed, Please upload a valid Flash Video..");
            // var fVU = document.getElementById("<%=filVidUpload.ClientID%>");
            // document.getElementById("<%=filVidUpload.ClientID%>").innerHTML = fVU.innerHTML;
            clearContents();
            return false;
        }
    }
}
function fileTypeCheck4Logo(sender, args) {
    var filename = args.get_fileName();
    if (filename != "") {
        // code to get File Extension..
        var arr1 = new Array;
        arr1 = filename.split("\\");
        var len = arr1.length;
        var img1 = arr1[len - 1];
        var filext = img1.substring(img1.lastIndexOf(".") + 1);

        // Checking Extension
        if (filext == "jpg" || filext == "gif" || filext == "png" || filext == "jpeg")
            return true;
        else {
            alert("Only supported Image types are allowed for Logo, Please upload a jpg, gif or png format Logo..");
            var AsyncFileUpload = $get("<%=filLogoUpload.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";
                }
            }
            return false;
        }
    }
}
// added on March 17 2011 
function fileTypeCheck4Docs(sender, args) {
    var filename = args.get_fileName();
    if (filename != "") {
        // code to get File Extension..
        var arr1 = new Array;
        arr1 = filename.split("\\");
        var len = arr1.length;
        var img1 = arr1[len - 1];
        var filext = img1.substring(img1.lastIndexOf(".") + 1);
        filext = filext.toLowerCase();
        // Checking Extension
        if (filext == "doc" || filext == "docx" || filext == "pdf" || filext == "xsl")
            return true;
        else {
            alert("Only supported Document types are allowed, Please upload a doc, docx, pdf or xsl format file..");
            var AsyncFileUpload = $get("<%=filResumeUpload.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";
                }                    
            }
            return false;
        }
    }
}

function fileUploadError(sender, args) {
}

function clearContents(sender) {
    var AsyncFileUpload = $get("<%=filVidUpload.ClientID%>");
    var txts = AsyncFileUpload.getElementsByTagName("input");
    alert(txts.length);
    for (var i = 0; i < txts.length; i++) {
        if (txts[i].type == "text") {
            txts[i].value = "";
            txts[i].style.backgroundColor = "white";
        }
    }
}

