﻿
var currentIndx = 1;
var str;
var item;
var cat2;
var catnum;
var count;
var count2;
var countpage;
var str3;
var str1;
var m = 0;
var d;
var bt;
var bt1;
var currentPix;
var currentPix1;
var currrentPic;
var lastPix;
var arrPart0;
var arrPart1;
var dimLeft;
var dimRight;
var dimrb;
var dimlb;
var remainder = 0;
var remainder1;
var j = (NaN == null);
var brand2;
var dims;
var itemid;
dimL();
dimR();

brand1()
cat1();
catTotal();
count1();
page1();
currentPix1();
remainder1();
bt1();


function brand1() {

    var value = new String();
    var brand = document.location.href;
    if (brand.indexOf("?") == -1) {
        return "null";
    }
    brand = brand.split("?");
    brand = brand[1].split("&");
    q = 0;
    if (q < brand.length) {
        var pair = brand[q].split("=");
        brand = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (brand.toLowerCase() == brand) {
            brand2 = (value);
        }
    }

}

function cat1() {

    var value = new String();
    var cat = document.location.href;
    if (cat.indexOf("?") == -1) {
        return "null";
    }
    cat = cat.split("?");
    cat = cat[1].split("&");
    q = 1;
    if (q < cat.length) {
        var pair = cat[q].split("=");
        cat = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (cat.toLowerCase() == cat) {
            cat2 = value;
        }
    }

}

function catTotal() {

    var value = new String();
    var catnumber = document.location.href;
    if (catnumber.indexOf("?") == -1) {
        return "null";
    }
    catnumber = catnumber.split("?");
    catnumber = catnumber[1].split("&");
    q = 2;
    if (q < catnumber.length) {
        var pair = catnumber[q].split("=");
        catnumber = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (catnumber.toLowerCase() == catnumber) {
            catnum = parseInt(value);
        }
    }

}


function count1() {

    var value = new String();
    var count = document.location.href;
    if (count.indexOf("?") == -1) {
        return "null";
    }
    count = count.split("?");
    count = count[1].split("&");
    q = 4;
    if (q < count.length) {
        var pair = count[q].split("=");
        count = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (count.toLowerCase() == count) {
            count2 = parseInt(value);
        }
    }

}

function page1() {

    var value = new String();
    var pages = document.location.href;
    if (pages.indexOf("?") == -1) {
        return "null";
    }
    pages = pages.split("?");
    pages = pages[1].split("&");
    q = 5;
    if (q < pages.length) {
        var pair = pages[q].split("=");
        pages = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (pages.toLowerCase() == pages) {

            str1 = parseInt(value);
            str3 = parseInt(str1);
        }
    }

}


function currentPix1() {

    var value = new String();
    var currentPic = document.location.href;
    if (currentPic.indexOf("?") == -1) {
        return "null";
    }
    currentPic = currentPic.split("?");
    currentPic = currentPic[1].split("&");
    q = 6;
    if (q < currentPic.length) {
        var pair = currentPic[q].split("=");
        currentPic = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (currentPic.toLowerCase() == currentPic) {
            currentPix1 = parseInt(value);
            currentPix = parseInt(currentPix1);
        }
    }

}

function remainder1() {

    var value = new String();
    var remainders = document.location.href;
    if (remainders.indexOf("?") == -1) {
        return "null";
    }
    remainders = remainders.split("?");
    remainders = remainders[1].split("&");
    q = 7;
    if (q < remainders.length) {
        var pair = remainders[q].split("=");
        remainders = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (remainders.toLowerCase() == remainders) {
            remainder1 = parseInt(value);
            remainder = parseInt(remainder1);
        }
    }

}

function bt1() {

    var value = new String();
    var bts = document.location.href;
    if (bts.indexOf("?") == -1) {
        return "null";
    }
    bts = bts.split("?");
    bts = bts[1].split("&");
    q = 8;
    if (q < bts.length) {
        var pair = bts[q].split("=");
        bts = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (bts.toLowerCase() == bts) {
            bt1 = parseInt(value);
            bt = parseInt(bt1);
        }
    }

}

function dimL() {

    var value = new String();
    var dimlb = document.location.href;
    if (dimlb.indexOf("?") == -1) {
        return "null";
    }
    dimlb = dimlb.split("?");
    dimlb = dimlb[1].split("&");
    q = 9;
    if (q < dimlb.length) {
        var pair = dimlb[q].split("=");
        dimlb = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (dimlb.toLowerCase() == dimlb) {
            //                dimlb = parseInt(value);
            //                dimLeft = parseInt(dimlb);
            dimLeft = value;
        }
    }

}

function dimR() {

    var value = new String();
    var dimrb = document.location.href;
    if (dimrb.indexOf("?") == -1) {
        return "null";
    }
    dimrb = dimrb.split("?");
    dimrb = dimrb[1].split("&");
    q = 10;
    if (q < dimrb.length) {
        var pair = dimrb[q].split("=");
        dimrb = pair[0].toLowerCase();
        value = pair[1].toLowerCase();
        if (dimrb.toLowerCase() == dimrb) {
            //                dimrb = parseInt(value);
            //                dimRight = parseInt(dimrb
            dimRight = value;
        }
    }

}


//    item = (queryStringValue2("noob"));
//    item = parseInt(item);

//    count = (queryStringValue3("noob"));
//    count = parseInt(count);

//    str3 = (queryStringValue4("noob"));
//    str3 = parseInt(str3);

//    currentPix = (queryStringValue5("noob"));
//    currentPix = parseInt(currentPix);

//    remainder = (queryStringValue6("noob"));
//    remainder = parseInt(remainder);

//    bt = (queryStringValue7("noob"));
//    bt = parseInt(bt);



//        1 = 0.3
//        2 = 0.6
//        3 = 1
//        4 = 1.3
//        5 = 1.6
//        6 = 2
//        7 = 2.3
//        8 = 2.6
//        9 = 3
//        10 = 3.3
//        11 = 3.6
//        12 = 4
//        13 = 4.3
//        14 = 4.6
//        15 = 5

str = parseInt(catnum);

catnumber(str)
count = parseInt(count2);
str3 = parseInt(str1);
currentPix = parseInt(currentPix1);
remainder = parseInt(remainder1);
bt = parseInt(bt1);

//    dimLeft = parseInt(dimlb);
//    dimRight = parseInt(dimrb);

pic = 10;

function catnumber(str) {
    str = str / 3;


    d = str;

    if (str != NaN) {
        str = d;
    }


    if (str == d) {
        str = str.toFixed(1);
        var s1 = str.split('.');
        arrPart0 = s1[0];
        arrPart1 = s1[1];
    }

}


if (count > 1) {
    currentIndx = count;
}






if (str3 < 1) {
    m = str3;
}



function Nexter2() {

    bt = 0;


    var back_button = document.getElementById('backlink');
    back_button.style.visibility = 'visible';

    //        4 = 1.3
    //        5 = 1.6
    //        6 = 2
    //        7 = 2.3
    //        8 = 2.6
    //        9 = 3
    //        10 = 3.3
    //        11 = 3.6
    //        12 = 4
    //        13 = 4.3
    //        14 = 4.6
    //        15 = 5
    if (arrPart1 == undefined) {
        return
    }

    if (arrPart0 == 0) {
        return
        //            zeroDigit();
    }

    if (arrPart1 == 0) {
        oneDigit();
    }

    if (arrPart0 != 0) {
        if (arrPart1 != 0) {
            twoDigit();
        }

    }



}

function zeroDigit() {
    switch (arrPart1) {
        case "3":
            remainder = 224;
            //                    m = -20;

            scrollPix();
            break;
        case "7":
            remainder = 116;
            //                    m = 0;
            currentPix = remainder;
            currentIndx = currentIndx + 1;

            var next_button = document.getElementById('nextlink');
            next_button.style.visibility = 'hidden';
            var next_button2 = document.getElementById('nextlink2');
            next_button2.style.visibility = 'visible';
            scrollPix();
            break;
    }

}


function oneDigit() {
    bt = 0;
    currentPix = -344;

    document.getElementById('backlink').src = "leftArrow.png";
    document.getElementById('backer').setAttribute("href", "javascript:Backer2();");

    if (currentIndx < arrPart0) {
        dd = currentIndx + 1;
        if (str == dd) {
            document.getElementById('nextlink').src = "Dim_rightArrow.GIF";
            document.getElementById('nexter').removeAttribute("href");

            document.getElementById('backlink').src = "leftArrow.png";
            document.getElementById('backer').setAttribute("href", "javascript:Backer2();");
            dimLeft = "yes";
            dimRight = "no";

        }
        if (currentIndx == dd) {
            document.getElementById('nextlink').src = "Dim_rightArrow.GIF";
            document.getElementById('nexter').removeAttribute("href");
            //                document.getElementById('nexter').removeAttribute("href");


            document.getElementById('backlink').src = "leftArrow.GIF";
            // document.getElementById('backer').setAttribute("href", "javascript:Backer2();");
            document.getElementById('backer').setAttribute("href", "javascript:Backer2();");

            dimLeft = "yes";
            dimRight = "no";
        }


        currentPix = currentPix * currentIndx;
        currentIndx = currentIndx + 1;
        scrollPix();
    }
}


function twoDigit() {

    bt = 0;
    currentPix = -344;

    //document.getElementById('backer').setAttribute('href', 'javascript:Backer2();');
    document.getElementById('backer').setAttribute("href", "javascript:Backer2();");
    document.getElementById('backlink').src = "leftArrow.GIF";

    if (currentIndx < arrPart0) {

        if (remainder != NaN) {
            dimLeft = "yes";
            dimRight = "yes";

            switch (remainder) {
                case 224:
                    currentPix = (currentPix * currentIndx) + remainder;
                    currentIndx = currentIndx + 1;

                    // document.getElementById('backer').setAttribute('href', 'javascript:Backer2();');
                    document.getElementById('backer').setAttribute("href", "javascript:Backer2();");
                    document.getElementById('backlink').src = "leftArrow.GIF";
                    dimLeft = "yes";
                    dimRight = "yes";
                    scrollPix();
                    break;
                case 116: ;
                    currentPix = (currentPix * currentIndx) + remainder;
                    currentIndx = currentIndx + 1;

                    // document.getElementById('backer').setAttribute('href', 'javascript:Backer2();');
                    document.getElementById('backer').setAttribute("href", "javascript:Backer2();");
                    document.getElementById('backlink').src = "leftArrow.GIF";
                    dimLeft = "yes";
                    dimRight = "yes";
                    scrollPix();
                    break;
                default:



                    currentPix = currentPix * currentIndx;
                    currentIndx = currentIndx + 1;
                    scrollPix();
                    break;
            }
        }
    }


    else {
        currentPix = -344;
        switch (arrPart1) {
            case "3":
                remainder = 224;
                //                    m = -20;
                currentPix = (currentPix * currentIndx + remainder);
                currentIndx = currentIndx + 1;

                document.getElementById('nextlink').src = "Dim_rightArrow.GIF";
                document.getElementById('nexter').removeAttribute("href");
                //document.getElementById('nexter').removeAttribute("href");
                dimRight = "no";
                dimLeft = "yes";

                scrollPix();
                break;
            case "7":
                remainder = 116;
                //                    m = 0;
                currentPix = (currentPix * currentIndx + remainder);
                currentIndx = currentIndx + 1;
                document.getElementById('nextlink').src = "Dim_rightArrow.GIF";
                document.getElementById('nexter').removeAttribute("href");
                document.getElementById('nexter').removeAttribute("href");
                dimRight = "no";
                dimLeft = "yes";

                scrollPix();
                break;


        }

    }
}




function Backer2() {

    bt = 1;

    if (currentPix <= -344) {
        currentPix = currentPix + 344
        currentIndx = currentIndx - 1

        // document.getElementById('nexter').setAttribute('href', 'javascript:Nexter2();');
        document.getElementById('nexter').setAttribute('href', 'javascript:Nexter2();');
        document.getElementById('nextlink').src = "rightArrow.GIF";
        dimLeft = "no";
        dimRight = "yes";

        if (currentIndx == 1) {


            document.getElementById('backer').removeAttribute('href');
            document.getElementById('backlink').src = "Dim_leftArrow.GIF";
            dimLeft = "no";

        }


        if (m > 0) {
            dimLeft = "yes";
            dimRight = "yes";
            // document.getElementById('backer').setAttribute('href', 'javascript:Backer2();');
            document.getElementById('backer').setAttribute('href', 'javascript:Backer2();');
            document.getElementById('backlink').src = "leftArrow.GIF";
        }
        scrollPics2()


    }
    else {
        currentIndx = currentIndx - 1
        currentPix = currentPix - currentPix

        document.getElementById('backlink').src = "Dim_leftArrow.png";
        // document.getElementById('backer').removeAttribute('href');
        document.getElementById('backer').removeAttribute('href');

        dimLeft = "no";
        dimRight = "yes";

        document.getElementById('nextlink').src = "rightArrow.png";
        //document.getElementById('nexter').setAttribute('href', 'javascript:Nexter2();');
        document.getElementById('nexter').setAttribute('href', 'javascript:Nexter2();');

        if (m == 0) {
            document.getElementById('backlink').src = "Dim_leftArrow.png";
            //document.getElementById('backer').removeAttribute('href');
            document.getElementById('backer').removeAttribute('href');
            dimLeft = "no";
        }

        scrollPics2()
    }
}

function scrollPics2() {

    if (currentPix == 0) {
        if (currentPix >= m) {
            m = m + 8;
            document.getElementById('div1').style.left = m + 'px';
            setTimeout("scrollPics2()", 0000);
        }
    }
    else {

        if (currentPix >= m) {
            m = m + 8;
            document.getElementById('div1').style.left = m + 'px';
            //            document.getElementById('itemProduct').style.left = m + 'px';
            setTimeout("scrollPics2()", 0000);

            //        currentPix = currentPix - 320;

        }
    }
}

function scrollPix() {


    m = m - 8;
    if (m >= currentPix) {
        document.getElementById('div1').style.left = m + 'px';
        //            document.getElementById('itemProduct').style.left = m + 'px';
        setTimeout("scrollPix()", 0000);

    }


}

function page2(item, subitem) {
    window.location = "items.aspx?brand=" + brand2 + "&cat=" + cat2 + "&catnumber=" + catnum + "&item=" + item + "&subitem=" + subitem + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;

}

function cart(item) {

    window.location = "shoppingcart.aspx?action=add&itemID=" + item + "&add=1";

}

function logout2() {

    var brand = document.location.href;

    window.location = brand + "&logout=yes";
    return true;

}

function logout() {

    var brand = document.location.href;

    window.location = brand + "?logout=yes";
    return true;

}

function page3(item) {
    window.location = "./items.aspx?brand=" + brand2 + "&cat=" + cat2 + "&catnumber=" + catnum + "&item=" + item + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;

}

function edititem(item, brand, cat) {

    window.location = "edititems.aspx?itemID=" + item + "&brand=" + brand + "&cat=" + cat;

}
function additem(item, brand, cat) {

    window.location = "additem.aspx?itemID=" + item + "&brand=" + brand + "&cat=" + cat;

}


function deleteitem(id) {
    var txtBoxEle = document.getElementById('sku');
    //window.location = "additem.aspx?itemID=" + item;
    if (confirm("Are you sure you want to delete Item SKU: " + txtBoxEle.value + "?") == true) {
        document.getElementById('del').value = "yes";
        var brand = document.location.href;

        window.location = brand + "&itemid2=" + id;
        return true;
    }
    else {
        document.getElementById('del').value = "no";
        return;
    }
}

function deletethumblargeitem(test) {

    //window.location = "additem.aspx?itemID=" + item;
    if (confirm("Are you sure you want to delete Item SKU: " + test + "?") == true) {
        document.getElementById('del').value = "yes";

        var brand = document.location.href;

        window.location = brand + "&itemid=" + test;
    }
    else {
        window.location = brand;

    }
}


function deletePhotogallery(imagecat2, folderstring, imageid, imagedir2, imagename) {

    //window.location = "additem.aspx?itemID=" + item;
    if (confirm("Are you sure you want to delete photogallery ID: " + imageid + "?") == true) {
        document.getElementById('del').value = "yes";

        var brand = document.location.href;

        window.location = "photogalleryEdit.aspx?" + "dir2=" + imagecat2 + "&fs=" + folderstring + "&imagedir2=" + imagedir2 + "&delete=yes" + "&image_id=" + imageid;
    }
    else {
        document.getElementById('del').value = "no";
        return;
    }
}




function submitted() {
    alert("good job");
    window.location = "viewallitems.aspx?itemID=" + item;
}

function opendialog() {
    window.opendialog('dealer.aspx');

}

var popupWindow = null; 

function child_open() {
    popupWindow = window.open('dealers.aspx', "_blank", "directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200"); 
} 

function parent_disable() {
    if (popupWindow && !popupWindow.closed) popupWindow.focus(); 
} 





function addthumblarge(item) {

    window.location = "addthumblarge.aspx?itemID=" + item;

}


function page(item) {

    if (dimLeft == "no") {

        document.getElementById('backlink').src = "Dim_leftArrow.GIF";
        document.getElementById('backer').removeAttribute("href");
    }
    if (dimLeft == "yes") {
        dimLeft = "yes";
        document.getElementById('backlink').src = "leftArrow.GIF";
        document.getElementById('backer').setAttribute("href");
    }

    if (dimLeft != "yes" && dimLeft != "no") {
        document.getElementById('backlink').src = "Dim_leftArrow.GIF";
        document.getElementById('backer').removeAttribute("href");
    }


    if (dimRight == "no") {

        document.getElementById('nextlink').src = "Dim_rightArrow.GIF";
        document.getElementById('nexter').removeAttribute("href");
    }
    if (dimRight == "yes") {
        dimRight = "yes";
        document.getElementById('nextlink').src = "rightArrow.GIF";
        document.getElementById('nexter').setAttribute("href");
    }

    if (dimRight != "yes" && dimRight != "no") {
        document.getElementById('nextlink').src = "rightArrow.GIF";
        document.getElementById('nexter').setAttribute("href");
    }


    //window.location = "http://web.troybarbell.com/Website/items.aspx?brand=" + brand2 + "&cat=" + cat2 + "&catnumber=" + catnum + "&item=" + item + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;

    window.location = "http://localhost:3698/Website/test2.aspx?brand=" + brand2 + "&cat=" + cat2 + "&catnumber=" + catnum + "&item=" + item + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;
    //        window.location = "http://localhost:3698/Website/items.aspx?brand=" + brand2 + "&cat=" + cat2 + "&catnumber=" + catnum + "&item=" + item + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;

    //        window.location = "http://173.212.244.218/WebSite/bottomJavascript2.aspx?cat=" + cat + "&item=" + item + "&count=" + currentIndx + "&pages=" + m + "&currentPix=" + currentPix + "&remainder=" + remainder + "&bt=" + bt + "&dimLeft=" + dimLeft + "&dimRight=" + dimRight;
    //   
}
