﻿var namclik = 1;

function preloadspic() {

    for (i = 0; i < spnamesA.length - 1; i++) {
        pics = new Image();
        pics.src = "http://www.bbi-israel.co.il/gallary3/" + spnamesA[i];
    }

}
function btnon(name) {

    var picn = "label";
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else {
        picn += results.toString().substring(6, 8);
        document.getElementById(picn).style.color = "#A51E21";

    }
//    document.getElementById("prgallery.aspx").style.color = "#ffffff";
}

function preloadbpic() {

    for (i = 0; i < bpnamesA.length - 1; i++) {
        picb = new Image();
        picb.src = "http://www.bbi-israel.co.il/gallary3/" + bpnamesA[i];
    }
}
//navigation
function ChngColor(color) {
    color.style.color = "#A51E21";
}
function BackColor2(lblnum) {
    document.getElementById("label" + lblnum).style.color = "#000000";
    btnon("np");
}
//    function topcatclick(num, aaa) {
//      window.location = "gallery.aspx?cat=" + num + "&np=" + aaa;
//  }

//end navigation


function cngMpic(picid) {
    // imgfout('mainpic',100);
    cngsrc(picid);
    //  window.setTimeout("imgfin('mainpic',0)",350);  
}
function cngsrc(pid) {
    document.getElementById("mainpic").src = "../gallary3/" + bpnamesA[parseInt(pid.toString().substring(2)) + smInd * picnum];
    // מקור תמונה ל לייט בוקס
    lightimg = "../gallary3/" + bpnamesA[parseInt(pid.toString().substring(2)) + smInd * picnum];
    //    MainImgHeight(bpnamesA[parseInt(pid.toString().substring(2)) + smInd * picnum]);
    document.getElementById("mainpic").title = labelsA[parseInt(pid.toString().substring(2)) + smInd * picnum];
    document.getElementById("descp").value = "";
    document.getElementById("descp").innerHTML = labelsA[parseInt(pid.toString().substring(2)) + smInd * picnum];

}
function imgfin(pid, opa) {
    document.getElementById(pid).style.filter = 'alpha(opacity=100)';
    //    if (opa<100)
    //    {
    //    window.setTimeout("imgfin('"+pid+"',"+(opa+10)+")",10);
    //    }
}
function imgfout(pid, opa) {
    document.getElementById(pid).style.filter = 'alpha(opacity=' + (opa - 10) + ')';
    if (opa > 0) {
        window.setTimeout("imgfout('" + pid + "'," + (opa - 10) + ")", 25);
    }
    else {
        document.getElementById(pid).style.filter = 100;
    }
}
function cngIndByNum(nam) {
    for (i = 1; i < pagenum + 1; i++) {
        document.getElementById("click" + i).style.color = "#A51E21";
    }
    document.getElementById("click" + nam).style.color = "#000000";
    namclik = nam;
    if (smInd == maxInd) {

        for (i = 0; i < picnum; i++) {
            document.getElementById("SM" + i).style.visibility = "visible";
            document.getElementById("SM" + i + 1).style.visibility = "visible";


        }
    }
    smInd = -1;
    smInd = parseInt(smInd) + nam;
    for (i = 0; i < picnum; i++) {

        document.getElementById("SM" + i).src = "../gallary3/" + spnamesA[i + smInd * picnum];

    }
    if (smInd == maxInd) {
        var t = parseInt((spnamesA.length - 1) % picnum);
        if (t != 0) {
            for (i = t; i < picnum; i++) {
                document.getElementById("SM" + i).style.visibility = "hidden";
                document.getElementById("SM" + i + 1).style.visibility = "hidden";

            }
        }
    }
}
function cngInd(side) {

    if ((side == "l") && (smInd != 0)) {
        for (i = 1; i < pagenum + 1; i++) {
            document.getElementById("click" + i).style.color = "#A51E21";
        }
        namclik = namclik - 1;
        document.getElementById("click" + namclik).style.color = "#000000";

        if (smInd == maxInd) {
            for (i = 0; i < picnum; i++) {
                document.getElementById("SM" + i).style.visibility = "visible";
                document.getElementById("SM" + i + 1).style.visibility = "visible";
            }


        }
        smInd = smInd - 1;
        for (i = 0; i < picnum; i++) {
            document.getElementById("SM" + i).src = "../gallary3/" + spnamesA[i + smInd * picnum];
        }
    }
    if ((side == "r") && (smInd != maxInd)) {
        for (i = 1; i < pagenum + 1; i++) {
            document.getElementById("click" + i).style.color = "#A51E21";
        }
        document.getElementById("click" + (namclik + 1)).style.color = "#000000";
        namclik = namclik + 1;

        smInd = parseInt(smInd) + 1;
        for (i = 0; i < picnum; i++) {
            document.getElementById("SM" + i).src = "../gallary3/" + spnamesA[i + smInd * picnum];
        }
        if (smInd == maxInd) {
            var t = parseInt((spnamesA.length - 1) % picnum);
            if (t != 0) {
                for (i = t; i < picnum; i++) {
                    document.getElementById("SM" + i).style.visibility = "hidden";
                    document.getElementById("SM" + i + 1).style.visibility = "hidden";
                }
            }
        }
    }
}
function arrcngpic(side) {
    if ((side == "l") && (picind != 0)) {
        picind = parseInt(picind) - 1;
    }
    else if ((side == "r") && (picind != maxpicind)) {
        picind = parseInt(picind) + 1;
    }
    document.getElementById("mainpic").src = "../gallary3/" + bpnamesA[picind];
    document.getElementById("descp").value = "";
    document.getElementById("descp").innerHTML = labelsA[picind];
}

//function imgHeight(imgid, srcc) {
//    pic1 = new Image();
//    pic1.src = "../gallary3/" + srcc;
//    var w = pic1.width;
//    var h = pic1.height;
//    if (w > 95) {
//        document.getElementById(imgid).style.width = "95px";
//    }
//    else {
//        document.getElementById(imgid).style.width = w + "px";
//    }
//    if (h > 110) {
//        document.getElementById(imgid).style.height = "110px";
//    }
//    else
//        document.getElementById(imgid).style.height = h + "px";

//}
//function MainImgHeight(srcc) {

//    pic1 = new Image();
//    pic1.src = "../gallary/" + srcc;
//    var w = pic1.width;
//    var h = pic1.height;
//  
//        if (w > 450) {
//        document.getElementById("mainpic").style.width = "450px";
//        
//    }
//    else {
//        document.getElementById("mainpic").style.width = w + "px";
//    }
//    if (h > 330) {
//        document.getElementById("mainpic").style.height = "350px";
//    }
//    else
//        document.getElementById("mainpic").style.height = h + "px";
//    

//}

    


    



