var m_arrImageIds = [];
function printPage()
{
	this.focus();
	this.print();
}

function showDiv(p_intId)
{
    if (document.getElementById(''+p_intId+'') != null){ 
        document.getElementById(''+p_intId+'').style.display = "block";
    }
}

function hideDivs(p_intIdPart)
{
    var l_intCount = 0;
    while (document.getElementById(''+p_intIdPart+''+l_intCount+'')){
        document.getElementById(''+p_intIdPart+''+l_intCount+'').style.display = "none";
        l_intCount = l_intCount + 1;
    }
}

function hideSubMenu() {
    $(".SubMenu").css("display", "none");
}

function hideMenu(p_intId) {
    $(".SubMenu").css("display", "none");
    $("#SubMenu" + p_intId).css("display", "block");
}

function StartFadeImg(p_strId, p_intOpac)
{
    var l_objImg = document.getElementById('Img_' + p_strId + '_0');
    if (document.getElementById('Img_' + p_strId + '_0') != null) {
        document.getElementById('BannerLink').href = document.getElementById('Img_' + p_strId + '_0').getAttribute('imglink');
        document.getElementById('BannerLink').target = document.getElementById('Img_' + p_strId + '_0').getAttribute('imglinktarget');

        l_objImg.style.filter = 'alpha(opacity=' + p_intOpac + ')';
        l_objImg.style.opacity = p_intOpac / 100;
        p_intOpac = p_intOpac + 5;

        if (p_intOpac < 101) {
            setTimeout("StartFadeImg('" + p_strId + "'," + p_intOpac + ")", 70);
        }
        else if (document.getElementById('Img_' + p_strId + '_1')) {
            var l_intStart = 0;
            var l_intNext = 0;
            if (document.getElementById('Img_' + p_strId + '_1')) {
                l_intNext = 1;
                setTimeout("FadeImg('" + p_strId + "'," + l_intStart + "," + l_intNext + ",0)", 5000);
            }
        }
    }
}

function FadeImg(p_strId, p_intStart, p_intNext, p_intOpac)
{
    var l_objCurrentImg = document.getElementById('Img_' + p_strId + '_' + p_intStart);
    var l_objNextImg = document.getElementById('Img_' + p_strId + '_' + p_intNext);
    var l_intCurrentOpac = 100 - p_intOpac;
    
    l_objCurrentImg.style.filter = 'alpha(opacity=' + l_intCurrentOpac + ')';
    l_objCurrentImg.style.opacity = l_intCurrentOpac/100;
    l_objNextImg.style.filter = 'alpha(opacity=' + p_intOpac + ')';
    l_objNextImg.style.opacity = p_intOpac/100;

    p_intOpac = p_intOpac + 5;

    if(p_intOpac < 101)
    {
        setTimeout("FadeImg('" + p_strId + "'," + p_intStart + "," + p_intNext + "," + p_intOpac + ")", 70);
    }
    else
    {
        p_intStart = p_intNext;
        
        document.getElementById('BannerLink').href=document.getElementById('Img_' + p_strId + '_' + p_intNext).getAttribute('imglink');
        document.getElementById('BannerLink').target=document.getElementById('Img_' + p_strId + '_' + p_intNext).getAttribute('imglinktarget');
        
        if(document.getElementById('Img_' + p_strId + '_' + (p_intNext + 1)))
            p_intNext = p_intNext +1;
        else
            p_intNext = 0;
        setTimeout("FadeImg('" + p_strId + "'," + p_intStart + "," + p_intNext + ",0)", 5000);
    }
}

function checkMailFriend()
{
    if(document.getElementById('Email').value=='')
    {
        window.alert('Email is verplicht.');
        document.getElementById('Email').focus();
        return false;
    }
}
function Next(g_strJSPointer,fotoboek,mId,rId)
{

    if(PhotoArray[Pointer+1] != null)
    {
        top.location=fotoboek+'.aspx?mId='+mId+'&rId='+rId+'&fId=' + PhotoArray[Pointer+1] + '#f'+ PhotoArray[Pointer+1];
        Pointer++;
    }
}
function Previous(g_strJSPointer,fotoboek,mId,rId)
{
    if(PhotoArray[Pointer-1] != null)
    {
        top.location=fotoboek+'.aspx?mId='+mId+'&rId='+rId+'&fId=' + PhotoArray[Pointer-1] + '#f'+ PhotoArray[Pointer-1];
        Pointer--;
    }
}
function copyToClipboard() {
    alert('Tekst gekopieerd naar klembord.');
}
var m_strImageId = '';
$(document).ready(function () {
    $('img#SocialCopy').zclip({
        path: '/Include/Clipboard/ZeroClipboard.swf',
        copy: $('div#SocialTextCopy').text()
    });
    $('img#IntroCopy').zclip({
        path: '/Include/Clipboard/ZeroClipboard.swf',
        copy: $('div#IntroTextCopy').text()
    });
    $('img#BodyCopy').zclip({
        path: '/Include/Clipboard/ZeroClipboard.swf',
        copy: $('div#BodyTextCopy').text()
    });
    $('img#SocialCopy').hover(
        function () {
            $('div#SocialTextCopy').addClass('yellow');
        },
        function () {
            $('div#SocialTextCopy').removeClass('yellow');
        }
    );
    $('img#IntroCopy').hover(
        function () {
            $('div#IntroTextCopy').addClass('yellow');
        },
        function () {
            $('div#IntroTextCopy').removeClass('yellow');
        }
    );
    $('img#BodyCopy').hover(
        function () {
            $('div#BodyTextCopy').addClass('yellow');
        },
        function () {
            $('div#BodyTextCopy').removeClass('yellow');
        }
    );
    for (var i = 0; i < m_arrImageIds.length; i++) {
        m_strImageId = m_arrImageIds[i];
        SetImageCopy(m_strImageId);
        SetImageHover(m_strImageId);
    }
});
function SetImageCopy(p_strImageId) {
    $('img#Image' + p_strImageId + 'Copy').zclip({
        path: '/Include/Clipboard/ZeroClipboard.swf',
        copy: $('div#Image' + p_strImageId + 'TextCopy').text()
    });
}
function SetImageHover(p_strImageId) {
    $('img#Image' + p_strImageId + 'Copy').hover(
        function () {
            $('div#Image' + p_strImageId + 'TextCopy').addClass('yellow');
        },
        function () {
            $('div#Image' + p_strImageId + 'TextCopy').removeClass('yellow');
        }
    );
}

function showScherm() {
    $("#opleidingzoeker").css("background-image", "url('/Images/opleidingzoeker/opleidingzoekerActief.png')");
    if ($('#layover').is(":visible")) {
        $("#layover").css("display", "none");
        $('.SocialMediaBox').css('visibility', 'visible');
        $('.st_plusone').css('display', 'inline');
    } else {
        $("#layover").css("display", "block");
        $('.SocialMediaBox').css('visibility', 'hidden');
        $('.st_plusone').css('display', 'none');
    }

    var l_strResult = $.ajax({
        url: "/Templates/Ajax/OpenHistory.aspx",
        type: "GET",
        dataType: "html",
        async: false
    }).responseText;
    if (l_strResult != "") {
        $("#OpleidingZoekerHistory").html(l_strResult);
    }
}
var showClusterBusy = false;
function showCluster(p_strUnit) {
    showClusterBusy = true;
    $.ajax({
        url: "/Templates/Ajax/kiesRichting.aspx?Unit=" + p_strUnit,
        type: "GET",
        dataType: "html",
        cache: false,
        success: function (p_strResponse, p_strstatus) {
            if (p_strResponse != "") {
                $("#stap2richtingen").html(p_strResponse);
                $("#stap2").css("display", "block");

                $(".stap1_link").css("color", "#979b9c");
                $(".stap1_link").css("background", "none");

                $("#stap1_" + p_strUnit).css("color", "#00838a");
                $("#stap1_" + p_strUnit).css("background-image", "url('/Images/opleidingzoeker/bg_menu.png')");
                $("#stap1_" + p_strUnit).css("background-position", "bottom right");
                $("#stap1_" + p_strUnit).css("background-repeat", "no-repeat");
                $("#stap3").css("display", "none");
                $("#stap4").css("display", "none");
                var heightMax = 0;
                var heightStap1 = $('#stap1richtingen').height();
                var heightStap2 = $('#stap2richtingen').height();
                if (heightStap1 > heightMax) {
                    heightMax = $('#stap1richtingen').height();
                }
                if (heightStap2 > heightMax) {
                    heightMax = $('#stap2richtingen').height();
                }
                $('#stap1').height(heightMax);
                $('#stap2').height(heightMax);
            } else {

            }
            showClusterBusy = false;
        }
    });    
}

var showUnitBusy = false;
function showUnit(p_strCluster, p_strUnit) {
    showUnitBusy = true;
    if (showClusterBusy) {
        setTimeout('showUnit (' + p_strCluster + ', ' + p_strUnit + ');', 20);
    } else {
        var l_strResult = $.ajax({
            url: "/Templates/Ajax/kiesUnit.aspx?Cluster=" + p_strCluster + "&Unit=" + p_strUnit,
            type: "GET",
            dataType: "html",
            async: false
        }).responseText;
        if (l_strResult != "") {
            $("#stap3richtingen").html(l_strResult);
            $("#stap3").css("display", "block");
            $(".stap2_link").css("color", "#979b9c");
            $(".stap2_link").css("background", "none");

            $("#stap2_" + p_strCluster).css("color", "#00838a");
            $("#stap2_" + p_strCluster).css("background-image", "url('/Images/opleidingzoeker/bg_menu.png')");
            $("#stap2_" + p_strCluster).css("background-position", "bottom right");
            $("#stap2_" + p_strCluster).css("background-repeat", "no-repeat");
            $("#stap4").css("display", "none");
            var heightMax = 0;
            var heightStap1 = $('#stap1richtingen').height();
            var heightStap2 = $('#stap2richtingen').height();
            var heightStap3 = $('#stap3richtingen').height();
            if (heightStap1 > heightMax) {
                heightMax = $('#stap1richtingen').height();
            }
            if (heightStap2 > heightMax) {
                heightMax = $('#stap2richtingen').height();
            }
            if (heightStap3 > heightMax) {
                heightMax = $('#stap3richtingen').height();
            }
            $('#stap1').height(heightMax);
            $('#stap2').height(heightMax);
            $('#stap3').height(heightMax);
        } else {

        }
        showUnitBusy = false;
    }
}

function showAfdeling(p_strAfdeling, p_strCluster, p_strUnit) {
    if (showClusterBusy || showUnitBusy) {
        setTimeout('showAfdeling (' + p_strAfdeling + ', ' + p_strCluster + ', ' + p_strUnit + ');', 20);
    } else {
        var l_strResult = $.ajax({
            url: "/Templates/Ajax/kiesAfdeling.aspx?afdeling=" + p_strAfdeling + "&Cluster=" + p_strCluster + "&Unit=" + p_strUnit,
            type: "GET",
            dataType: "html",
            async: false
        }).responseText;
        if (l_strResult != "") {
            $("#stap4richtingen").html(l_strResult);
            $("#stap4").css("display", "block");
            $(".stap3_link").css("color", "#979b9c");
            $(".stap3_link").css("background", "none");

            $("#stap3_" + p_strAfdeling).css("color", "#00838a");
            $("#stap3_" + p_strAfdeling).css("background-image", "url('/Images/opleidingzoeker/bg_menu.png')");
            $("#stap3_" + p_strAfdeling).css("background-position", "bottom right");
            $("#stap3_" + p_strAfdeling).css("background-repeat", "no-repeat");
            var heightMax = 0;
            var heightStap1 = $('#stap1richtingen').height();
            var heightStap2 = $('#stap2richtingen').height();
            var heightStap3 = $('#stap3richtingen').height();
            var heightStap4 = $('#stap4richtingen').height();
            if (heightStap1 > heightMax) {
                heightMax = $('#stap1richtingen').height();
            }
            if (heightStap2 > heightMax) {
                heightMax = $('#stap2richtingen').height();
            }
            if (heightStap3 > heightMax) {
                heightMax = $('#stap3richtingen').height();
            }
            if (heightStap4 > heightMax) {
                heightMax = $('#stap4richtingen').height();
            }
            
            $('#stap1').height(heightMax);
            $('#stap2').height(heightMax);
            $('#stap3').height(heightMax);
            $('#stap4').height(heightMax);

        } else {

        }
    }
}


function CheckMe() {
    $('#FormValid').val('w3srules');
    return true;
}
