﻿function start_slideshow(start_frame, end_frame, delay) 
{
    setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
}
                        
function switch_slides(frame, start_frame, end_frame, delay) 
{
    return (function() {
        Effect.Fade('slideshow' + frame);
        if (frame != end_frame)
        {
            document.getElementById('slideshow1').style.zIndex = '20';
            nextFrame = frame + 1;
        }
        else
        {
            document.getElementById('slideshow1').style.zIndex = '5';
            nextFrame = 1;
        }
        document.getElementById('slideshow' + nextFrame).style.display = "block";
        if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
        setTimeout("Effect.Appear('slideshow" + frame + "');", 850);
        setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
    })
}
function EditCategory()
{
    var elem = document.getElementById('AdminPanelBar_p1_p0_CategoriesCombo');
    var dropdownIndex = elem.selectedIndex;
    document.getElementById('editcategory').style.display = 'block';
    document.getElementById('AdminPanelBar_p1_p0_CategoryEditText').value = elem[dropdownIndex].text;
}
function DeleteCategory()
{
    if (confirm('Are you sure you want to delete the selected product category?'))
    {
        var elem = document.getElementById('AdminPanelBar_p1_p0_CategoriesCombo');
        var dropdownIndex = elem.selectedIndex;
        var cid = elem[dropdownIndex].value;
        window.location = 'admin.aspx?apc=1&d=1&cid=' + cid;
    }
}
function EditProduct()
{
    var elem = document.getElementById('AdminPanelBar_p2_p0_EditProductDropDown');
    var dropdownIndex = elem.selectedIndex;
    //document.getElementById('editcategory').style.display = 'block';
    window.location = 'admin.aspx?ap=1&e=1&pid=' + elem[dropdownIndex].value;
}
function EditFormula() {
    var elem = document.getElementById('AdminPanelBar_p3_p0_EditFormulaDropDown');
    var dropdownIndex = elem.selectedIndex;
    //document.getElementById('editcategory').style.display = 'block';
    window.location = 'admin.aspx?af=1&e=1&fid=' + elem[dropdownIndex].value;
}
function DeleteProduct()
{
    if (confirm('Are you sure you want to delete the selected product?'))
    {
        var elem = document.getElementById('AdminPanelBar_p2_p0_EditProductDropDown');
        var dropdownIndex = elem.selectedIndex;
        var pid = elem[dropdownIndex].value;
        window.location = 'admin.aspx?ap=1&d=1&pid=' + pid;
    }
}
function DeleteFormula() {
    if (confirm('Are you sure you want to delete the selected formula?')) {
        var elem = document.getElementById('AdminPanelBar_p3_p0_EditFormulaDropDown');
        var dropdownIndex = elem.selectedIndex;
        var fid = elem[dropdownIndex].value;
        window.location = 'admin.aspx?af=1&d=1&fid=' + fid;
    }
}