﻿function newsslider(prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#gallery li.selected').length ? $('#gallery li.selected') : $('#gallery li:first');

    //if prev is set to 1 (previous item)
    if (prev) {

        //Get previous sibling
        var next_image = (current_image.prev().length) ? current_image.prev() : $('#gallery li:last');

        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        var next_image = (current_image.next().length) ? current_image.next() : $('#gallery li:first');
    }

    //clear the selected class
    $('#gallery li').removeClass('selected');

    //reassign the selected class to current items
    next_image.addClass('selected');

    //Scroll the items
    $(current_image).animate({ "opacity": "toggle" }, { duration: 1000 });
    setTimeout(function() { $(next_image).animate({ 'opacity': 'toggle' }, { duration: 1000 }); }, 1100);
}

function LoadSlideShow() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/SliderHome",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#slider').html(response.d);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

//--------------------------------------------JIM BOUWMEESTER---------------------------------------
function LoadJimBouwmeester() {
    $('#menu a').removeClass('selected');
    $('#menuitem1').addClass('selected');
    $("link.customstyles").attr("href", "/css/jimbouwmeester.css");
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/DefaultTextAndImage",
        data: "{xmlfile: 'jimbouwmeester'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#contentcontainer').html(response.d);
                setTimeout("$('#text').customScroller();", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

//--------------------------------------------PROJECTS---------------------------------------        
var totalcountprojects = 0;
var currentimageprojects = 1;

function newssliderprojects(prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#galleryprojects li.selected').length ? $('#galleryprojects li.selected') : $('#galleryprojects li:first');

    //if prev is set to 1 (previous item)
    if (prev) {

        //Get previous sibling
        var next_image = (current_image.prev().length) ? current_image.prev() : $('#galleryprojects li:last');
        currentimageprojects = currentimageprojects - 1;

        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        var next_image = (current_image.next().length) ? current_image.next() : $('#galleryprojects li:first');
        currentimageprojects = currentimageprojects + 1;
    }

    //clear the selected class
    $('#galleryprojects li').removeClass('selected');
    //reassign the selected class to current items
    next_image.addClass('selected');

    //Scroll the items
    $('#mask-galleryprojects').scrollTo(next_image, 1000);
    checkpositionprojects();
}

function LoadSlideShowprojects(projectid) {
    $('#sliderprojects').html('<div id="loading"><img src="images/ajax-loader.gif" alt="loading..."</div>');
    $('#thumbgalleryprojects li').removeClass('selected');
    $('.itemprojects' + projectid).addClass('selected');
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/SliderProjects",
        data: "{project: '" + projectid + "', xmlfile: 'projects'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#sliderprojects').html(response.d);
                setTimeout("ChromeLoadProjects();", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function LoadSlideShowThumbsprojects() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/SliderProjectsThumbs",
        data: "{index: '1', xmlfile: 'projects'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#thumbsliderprojects').html(response.d);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function checkpositionprojects() {
    if (currentimageprojects == 1) {
        $('#btnprojects-prev').toggle(false);
    }
    else {
        $('#btnprojects-prev').toggle(true);
    }
    if (currentimageprojects == totalcountprojects) {
        $('#btnprojects-next').toggle(false);
    }
    else {
        $('#btnprojects-next').toggle(true);
    }
}

function ChromeLoadProjects() {
    $('#mask-galleryprojects, #galleryprojects li').width($('#sliderprojects').width());
    $('#galleryprojects').width($('#sliderprojects').width() * $('#galleryprojects li').length);
    $('#mask-galleryprojects, #galleryprojects li').height($('#sliderprojects').height());
    totalcountprojects = $('#galleryprojects li').length;
    currentimageprojects = 1;
    $('#btnprojects-prev').toggle(false);
    $('#btnprojects-next').toggle(true);
}


//--------------------------------------------SHOWROOM---------------------------------------
var selecteddivshowroom = 1;
var thumbcountshowroom = 0;
var thumbtotalshownshowroom = 7;
var thumbtotalshowroom = 0;


function newsslidershowroom(prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#thumbgalleryshowroom li.selectedthumbshowroom').length ? $('#thumbgalleryshowroom li.selectedthumbshowroom') : $('#thumbgalleryshowroom li:first');
    //if prev is set to 1 (previous item)
    if (prev) {
        //Get previous sibling
        thumbcountshowroom = thumbcountshowroom - 1;
        var next_image = (current_image.prev().length) ? current_image.prev() : $('#thumbgalleryshowroom li:last');
        //if prev is set to 0 (next item)
    } else {
        //Get next sibling
        thumbcountshowroom = thumbcountshowroom + 1;
        var next_image = (current_image.next().length) ? current_image.next() : $('#thumbgalleryshowroom li:first');
    }

    //clear the selected class
    $('#thumbgalleryshowroom li').removeClass('selectedthumb');

    //reassign the selected class to current items
    next_image.addClass('selectedthumbshowroom');

    //Scroll the items
    $('#mask-thumbgalleryshowroom').scrollTo(next_image, 1000);

    if ((thumbtotalshowroom - thumbcountshowroom) == thumbtotalshownshowroom) {
        $('#btnshowroom-thumbnext').toggle();
    }
    else {
        $('#btnshowroom-thumbnext').toggle(true);
    }
    if (thumbcount == 0) {
        $('#btnshowroom-thumbprev').toggle();
    }
    else {
        $('#btnshowroom-thumbprev').toggle(true);
    }
}

function LoadShowRoomshowroom(showroomid) {
    $("#itemshowroom" + selecteddivshowroom).animate({ "opacity": "toggle" }, { duration: 1000 });
    setTimeout("$('#itemshowroom" + showroomid + "').animate({ 'opacity': 'toggle' }, { duration: 1000 })", 1000);
    $('#thumbgalleryshowroom li').removeClass('selected');
    $('.itemshowroom' + showroomid).addClass('selected');
    selecteddivshowroom = showroomid;
}

function LoadShowRoomThumbsshowroom() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/ShowThumbs",
        data: "{xmlfile: 'showroom'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#thumbslidershowroom').html(response.d);

                setTimeout("if($('#thumbgalleryshowroom li').length > 7) { $('#btnshowroom-thumbnext').toggle();}", 100);
                $('.itemshowroom1').addClass('selected');
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function PreLoadShowRoomshowroom() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/ShowDivs",
        data: "{xmlfile: 'showroom'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#slidershowroom').html(response.d);
                setTimeout("$('#itemshowroom1').animate({ 'opacity': 'toggle' }, { duration: 1000 });", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}


//--------------------------------------------TEAM---------------------------------------
var countpicturesteam = 1;
var totalpicturesteam = 0;

function newssliderteam(prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#galleryteam li.selected').length ? $('#galleryteam li.selected') : $('#galleryteam li:first');
    var current_thumb = $('#thumbgalleryteam li.selected').length ? $('#thumbgalleryteam li.selected') : $('#thumbgalleryteam li:first');

    //if prev is set to 1 (previous item)
    if (prev) {

        //Get previous sibling
        var next_image = (current_image.prev().length) ? current_image.prev() : $('#galleryteam li:last');
        var next_thumb = (current_thumb.prev().length) ? current_thumb.prev() : $('#thumbgalleryteam li:last');
        $('#tableteam' + countpicturesteam).animate({ "opacity": "toggle" }, { duration: 100 });
        countpicturesteam = countpicturesteam - 1;
        setTimeout("$('#tableteam" + countpicturesteam + "').animate({ 'opacity': 'toggle' }, { duration: 100 })", 400);


        //if prev is set to 0 (next item)
    } else {

        //Get next sibling
        var next_image = (current_image.next().length) ? current_image.next() : $('#galleryteam li:first');
        var next_thumb = (current_thumb.next().length) ? current_thumb.next() : $('#thumbgalleryteam li:first');
        $('#tableteam' + countpicturesteam).animate({ "opacity": "toggle" }, { duration: 100 });
        countpicturesteam = countpicturesteam + 1;
        setTimeout("$('#tableteam" + countpicturesteam + "').animate({ 'opacity': 'toggle' }, { duration: 100 })", 400);
    }

    //clear the selected class
    $('#galleryteam li, #thumbgalleryteam li').removeClass('selected');

    //reassign the selected class to current items
    next_image.addClass('selected');
    next_thumb.addClass('selected');

    //Scroll the items
    $('#mask-galleryteam').scrollTo(next_image, 1000);
    checkpositionteam();
}

function LoadTeamteam() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/SliderTeam",
        data: "{xmlfile: 'team'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#sliderteam').html(response.d);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function LoadTeamThumbsteam() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/TeamThumbs",
        data: "{xmlfile: 'team'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#thumbteamslider').html(response.d);
                $('#btnteam-prev').toggle(false);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function LoadTeamDescriptionsteam() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/TeamDescriptions",
        data: "{xmlfile: 'team'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#tabledescriptionsteam').html(response.d);
                setTimeout("$('#tableteam1').toggle();", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function GoToteam(item, index) {
    $('#tableteam' + countpicturesteam).animate({ "opacity": "toggle" }, { duration: 100 });
    setTimeout("$('#tableteam" + index + "').animate({ 'opacity': 'toggle' }, { duration: 100 })", 400);
    countpicturesteam = index;
    $('#thumbgalleryteam li, #galleryteam li').removeClass('selected');
    $('#mask-galleryteam').scrollTo(item, 1000);
    $(item).addClass('selected');
    checkpositionteam();
}

function checkpositionteam() {
    if (countpicturesteam == 1) {
        $('#btnteam-prev').toggle(false);
    }
    else {
        $('#btnteam-prev').toggle(true);
    }
    if (countpicturesteam == totalpicturesteam) {
        $('#btnteam-next').toggle(false);
    }
    else {
        $('#btnteam-next').toggle(true);
    }
}


//--------------------------------------------PRODUCTS---------------------------------------
var selecteddivproducts = 1;
var thumbcountproducts = 0;
var thumbtotalshownproducts = 7;
var thumbtotalproducts = 0;

function newssliderproducts(prev) {

    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image = $('#thumbgalleryproducts li.selectedthumbproducts').length ? $('#thumbgalleryproducts li.selectedthumbproducts') : $('#thumbgalleryproducts li:first');
    //if prev is set to 1 (previous item)
    if (prev) {
        //Get previous sibling
        thumbcountproducts = thumbcountproducts - 1;
        var next_image = (current_image.prev().length) ? current_image.prev() : $('#thumbgalleryproducts li:last');
        //if prev is set to 0 (next item)
    } else {
        //Get next sibling
        thumbcountproducts = thumbcountproducts + 1;
        var next_image = (current_image.next().length) ? current_image.next() : $('#thumbgalleryproducts li:first');
    }

    //clear the selected class
    $('#thumbgalleryproducts li').removeClass('selectedthumb');

    //reassign the selected class to current items
    next_image.addClass('selectedthumbproducts');

    //Scroll the items
    $('#mask-thumbgalleryproducts').scrollTo(next_image, 1000);

    if ((thumbtotalproducts - thumbcountproducts) == thumbtotalshownproducts) {
        $('#btnproducts-thumbnext').toggle();
    }
    else {
        $('#btnproducts-thumbnext').toggle(true);
    }
    if (thumbcountproducts == 0) {
        $('#btnproducts-thumbprev').toggle();
    }
    else {
        $('#btnproducts-thumbprev').toggle(true);
    }
}

function LoadProductsproducts(productid) {
    $("#itemproducts" + selecteddivproducts).animate({ "opacity": "toggle" }, { duration: 1000 });
    setTimeout("$('#itemproducts" + productid + "').animate({ 'opacity': 'toggle' }, { duration: 1000 })", 1000);
    $('#thumbgalleryproducts li').removeClass('selected');
    $('.itemproducts' + productid).addClass('selected');
    selecteddivproducts = productid;
}

function LoadProductsThumbsproducts() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/ShowThumbs",
        data: "{xmlfile: 'products'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#thumbsliderproducts').html(response.d);
                setTimeout("if($('#thumbgalleryproducts li').length > 7) { $('#btnproducts-thumbnext').toggle();}", 100);
                $('.itemproducts1').addClass('selected');
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function PreLoadProductsproducts() {
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/ShowDivs",
        data: "{xmlfile: 'products'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#sliderproducts').html(response.d);
                setTimeout("$('#itemproducts1').animate({ 'opacity': 'toggle' }, { duration: 1000 });", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function LoadContact() {
    $('#menu a').removeClass('selected');
    $('#menuitem6').addClass('selected');
    $("link.customstyles").attr("href", "/css/contact.css");
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/Contact",
        data: "{xmlfile: 'contact'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#slidercontact').html(response.d);
                setTimeout("$('#contact').toggle();", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}

function LoadParketGroep() {
    $('#menu a').removeClass('selected');
    $('#menuitem7').addClass('selected');
    $("link.customstyles").attr("href", "/css/parketgroep.css");
    var bool = false;
    $.ajax({
        type: "POST",
        url: "BouwmeesterService.asmx/DefaultTextAndImage",
        data: "{xmlfile: 'parketgroep'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function(response) {
            if (response.d == '') {
                alert('Error Loading data');
            }
            else {
                $('#contentcontainer').html(response.d);
                setTimeout("$('#text').customScroller();", 100);
                bool = true;
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
    return bool;
}