﻿function checkFileExt(ctrl) {
    //set the name of our form
    var form = document.form1;
    //retrieve our control
    var file = document.getElementById(ctrl).value;
    if (file == "")
        return;
    var type = "";
    //create an array of acceptable files
    var gFileExts = ".jpg,.jpeg,.gif,.png";
    var validExtensions = gFileExts.split(","); //new Array(".csv", ".ldif");
    var allowSubmit = false;
    //if our control contains no file then alert the user
    if (file.indexOf("\\") == -1) {
        alert("Lütfen bir dosya seçiniz...");
        event.returnValue = false;
        return;
    }
    else {
        //get the file type
        type = file.slice(file.indexOf("\\") + 1);
        var ext = file.slice(file.lastIndexOf(".")).toLowerCase();
        //loop through our array of extensions
        for (var i = 0; i < validExtensions.length; i++) {
            //check to see if it's the proper extension
            if (validExtensions[i] == ext) {
                //it's the proper extension
                allowSubmit = true;
                break;
            }
        }
    }
    event.returnValue = allowSubmit;
    //now check the final bool value
    if (!allowSubmit) {
        //let the user know they selected a wrong file extension
        alert("Sadece " + (validExtensions.join("  ").toUpperCase()) + " uzantılı dosyalar geçerlidir.");
    }
}

function openImage(pUrl) {
    window.open(pUrl);
}


function DeleteConfirm() {
    if (confirm('Bu kaydı silmek istediğinize emin misiniz?') == false) {
        event.returnValue = false;
    }
        /*if (typeof (Page_ClientValidate) == false) {
            return Page_ClientValidate(); 
        }
        else {
            return true; 
        } 
    } else {
        return false; 
    }*/
}

function e(objname) {
    return document.getElementById(objname);
}

function WindowOpen(pUrl, pWidth, pHeight) {
    var vTop = (screen.height - pHeight) / 2;
    var vLeft = (screen.width - pWidth) / 2;
    var vFeatures = "width=" + pWidth + "px,height=" + pHeight + "px,top=" + vTop + ",left=" + vLeft + ",status=yes,scrollbars=yes";
    window.open(pUrl, "", vFeatures);
}

function RefreshOpener(pFN) {
    var opener = window.opener;
    if (pFN != '') {
        opener.RefreshPage();        
    }
    else {
        opener.location.href = opener.location.href;
    }
}

// float değere çevrim
function toFloat(t) {
    if (isNaN(t)) {
        t = t.replace(",", ".");
    }
    return isNaN(parseFloat(t)) ? -1 : parseFloat(t);
}

function IsNumeric(o, args) {
    args.IsValid = toFloat(args.Value) >= 0;
}

function PageTabs(p_Select, p_Count) {
    for (var i = 1; i <= p_Count; i++)
        if (i == p_Select)
        document.getElementById('fs_0' + i).style.display = 'block';
    else
        document.getElementById('fs_0' + i).style.display = 'none';
}
