﻿//debugger
var blnDebug = false;
var DBGDividingLine = "\n\r--------------------------------------------------------------------------------------";
var DBGLineNumber = 0;
var DBGLineNumberWritten;
var _testBox;

function _getDBGLineNumberWritten() {
    return (DBGLineNumber + ">\t");
}

function DBGWriteLine(strLine, blnClear) {
    if (blnDebug && (_testBox != null)) {
        if (blnClear) {
            _testBox.attr("value", _getDBGLineNumberWritten() + strLine + "\n\r")
        }
        else {
            _testBox.attr("value", _testBox.attr("value") + _getDBGLineNumberWritten() + strLine + "\n\r");
        }
        DBGLineNumber++;
    }
}
//<--


var _ar_div_to_center = new Array("#container");

$(function() {
    _testBox = $("#test")
    if (blnDebug) {
        _testBox.show();
    }

    var ar_preload_img = new Array();
    $("img").each(function() {
        ar_preload_img.push($(this).attr("src"));
        DBGWriteLine($(this).attr("src"), false);
    });
    var i = 0;
    $.imgpreload(ar_preload_img,
            {
                each: function() {
                    i++;
                    DBGWriteLine(ar_preload_img.length + "--" + $(this).attr("src") + " ----- index + 1: " + i);

                    // this = new image object
                    // callback executes on every image load
                },
                all: function() {
                    // this = array of new image objects
                    // callback executes when all images are loaded
                    //!!!!gaat niet op voor IE-->idem each-->not funny
                    DBGWriteLine(ar_preload_img.length);
                    if (!blnIsIE) {
                        _verticallyCentreElements(_ar_div_to_center, "margin", false, false, true, 200);

                    }
                }
            });


    if (blnIsIE) {
        _verticallyCentreElements(_ar_div_to_center, "margin", false, false, true, 200);
    }

    _initPages();
});

function pageLoad() {
    //call naar evt page-specifieke pageLoad
    if (_curPageLoad != "") {
        eval(_curPageLoad + "()");
    }
}

var TO = false;
function _forIeCentre() {
    _verticallyCentreElements(_ar_div_to_center, "margin", false, false, true, 200);
}


$(window).resize(function() {
    if (blnIsIE) {
        if (TO !== false)
            clearTimeout(TO);
        TO = setTimeout(_forIeCentre, 200);

    } else {
        _verticallyCentreElements(_ar_div_to_center, "margin", false, false, true, 200);
    }
});



//logo_list-->
var _intLastMovedItemIndex = 0;
var _intSpeed = 120;
var _intTimeOut = 55;

function _moveListItemRecursive() {
    var el_list = $("ul#logo_list li a");
    var el = $("ul#logo_list li a:eq(" + [_intLastMovedItemIndex] + ")");

    if (_intLastMovedItemIndex > 6) {
        _intSpeed -= 30;
        _intTimeOut -= 15;
    }
    _distanceTop = _verticallyCentreGetDistance(el, false, true);
    el.css({ "visibility": "visible" });
    el.animate({ "top": _distanceTop + 20 }, _intSpeed).animate({ "top": _distanceTop - 20 }, _intSpeed - 10).animate({ "top": _distanceTop + 10 }, _intSpeed - 20).animate({ "top": _distanceTop - 10 }, _intSpeed - 40).animate({ "top": _distanceTop }, _intSpeed - 44);
    setTimeout(function() {
        _intLastMovedItemIndex += 1;
        _moveListItemRecursive();
    }, _intTimeOut);
}

function _verticallyCentreLogoList() {
    var _distanceTop = 0;
    var el = null;

    $("ul#logo_list li").each(function() {
        el = $(this);
        var _img = el.find("a:first img:first");
        el.css({ "width": _img.attr("width") }, 0);
    });
    _moveListItemRecursive();
}
//<--
