﻿var currSubmenuItem = -1;
var hdrImgHeight = 314;

/*
if ($.browser.msie && $.browser.version == "6.0") { //use "8.0" for testing
    IE6UPDATE_OPTIONS = {
        message: "U werkt met een veroudere versie van Internet Explorer, waardoor de website niet goed wordt weergegeven. Klik hier om Explorer bij te werken.",
        icons_path: "img/ie6error/"
    }
    document.write('<script type="text/javascript" src="http://static.ie6update.com/hosted/ie6update/ie6update.js"></script>');
}
*/

$(function() {


    $('#searchbox').watermark('Zoeken...');
    $.watermark.options.className = 'searchbox_watermark';

    $('#searchbox').keydown(function(e) {

        var intKey = (window.Event) ? e.which : e.keyCode;
        if (intKey == 13) { //enter key
            doSearch();
            return false;
        }
    });
    $('#searchsubmit').click(function() {
        doSearch();
        return false;
    });




    Cufon.replace('h1');
    Cufon.replace('h3');
    Cufon.replace('.topMenuDiv a', { hover: true });


});
function doSearch() {
    if ($('#searchbox').val().length > 0) {
        window.location = "search.aspx?q=" + $('#searchbox').val();
    }
}

function showContentDiv(contentDivId) {

    var moveToTab = $("#tabButton" + contentDivId);
    if (moveToTab.hasClass('selected')) {
        return;
    }

    $("#ulTabNavigate .selected")
        .toggleClass('selected')
        .toggleClass('unselected');

    moveToTab.toggleClass('selected')
        .toggleClass('unselected');

    removeGlows();
    $(".contentDivTab").hide(500);
    $("#contentDivTab-" + contentDivId).show(500,
        function() {
            addGlows();
        });
}

function initContentDiv() {
    $(".contentDivTab").hide();
    $("#contentDivTab-1").show();
    addGlows();
}
function removeGlows() {
    $("#divContentShadowLeft").empty();
    $("#divContentShadowRight").empty();
}
function addGlows() {
    removeGlows();
    var contHeight = $("#divContent").height();
    $("#divContentShadowLeft").append('<img  id="leftGlow" src="img/global/glowLeft-medium.png" width="23" height="' + (contHeight + 90) + '" >')
                .css('background-image', 'none');
    $("#divContentShadowRight").append('<img  id="rightGlow" src="img/global/glowRight-medium.png" width="22" height="' + (contHeight + 80) + '" >')
                .css('background-image', 'none');

}

// submenuItems
$(document).ready(function() {

    //show main div
    initContentDiv();
    $('.dropShadow-img').wrap("<div class='dropShadow-div2'><div class='dropShadow-div1'></div></div>");

    //replace submenu <a> with div's

    $('.v12SubMenuItem').each(addLayout);
    $('.divSubMenuItem:first').before(getStaticItem());

    $('.boxAction').hover(function() {
        var src = $(this).attr('src').replace('.png', '');
        $(this).attr('src', src + 'Hover.png');
    }, function() {
        var src = $(this).attr('src').replace('Hover', '');
        $(this).attr('src', src);
    });
    $("#hidden_link").fancybox({ 'autoScale': false, 'frameWidth': 800 }).trigger('click');

    var boxHeightApi = $('.boxContentApi').height();

    var boxHeightBlog = $('.boxContentBlog').height();
    $('.boxBgBlog').height(boxHeightBlog);
    $('.boxBgBlog').width(287);
    var topImageblog = $('.boxBgBlog').position().top;
    $('.boxContentBlog').css('top', topImageblog + 'px');

    var boxHeightTweet = $('.boxContentTweet').height();
    $('.boxBgTweet').height(boxHeightTweet);
    $('.boxBgTweet').width(287);
    var topImageTweet = $('.boxBgTweet').position().top;
    $('.boxContentTweet').css('top', topImageTweet + 'px');

    //$('.middenBoxDiv').css('margin-left', '-285px');

    //init header img position
    //$('#' + initParams.headerImgId).css('background-position', '0px -' + hdrImgHeight * currSubmenuItem + 'px');
    $("#divSubMenuContent .divSubMenuItem").hover(function() {
        var me = $(this);
        var menuItemIndex = me.attr('indexVal');
        me.toggleClass('subMenuActive').css('background-position', '-20px 12px');
        me.stop().animate({ paddingLeft: "37px", backgroundPosition: "37px 12px" }, 300);

        //animate top image bar
        //$('#' + initParams.headerImgId).stop().animate({ backgroundPosition: '(0px -' + menuItemIndex * hdrImgHeight + 'px)' }, 1500);
    }, function() {
        var me = $(this);
        me.toggleClass('subMenuActive').stop();
        if (me.attr("indexval") == currSubmenuItem) {
            me.animate({ backgroundPosition: "-0px 12px", paddingLeft: "37px", paddingTop: "7px", width: "211px" }, 300);
        } else {
            me.animate({ backgroundPosition: "-20px 12px", paddingLeft: "37px", paddingTop: "7px", width: "211px" }, 300);
        }
        //$('#' + initParams.headerImgId).stop().animate({ backgroundPosition: '(0px -' + currSubmenuItem * hdrImgHeight + 'px)' }, 1500);
    });




    $(".tweet").tweet({
        username: "OnlineEngineers",
        //list: "@OnlineEngineers",
        join_text: "auto",
        avatar_size: 48,
        count: 6,
        /*auto_join_text_default: "v12",
        auto_join_text_ed: "v12",
        auto_join_text_ing: "v12",
        auto_join_text_reply: "v12",
        auto_join_text_url: "v12",*/
        //query: "industryof_cool",
        loading_text: "loading tweets..."
    });

});

function addLayout(index, domElem) {
    var me = $(domElem);
    var url = me.attr("href");

    //current menu item, remember
    if (me.hasClass("selected")) {
        currSubmenuItem = index;
    }
    var text = domElem.innerHTML;
    var newElem = me.replaceWith(getSubMenuItem(text, url, index));

}

function getSubMenuItem(text, url, index) {
    var cssClass = "divSubMenuItem";
    if (currSubmenuItem == index) {
        cssClass += " selected";
    }
    var subMenuText = '<div onclick="document.location.href=\'' + url + '\'; " indexVal="' + index + '" class="' + cssClass + '" >' +
     '<a href ="' + url + '">' + text + '</a>' +
     '<div class="divImgBottom"></div>';
    return subMenuText;
}
function getStaticItem() {

    return '<div class="divSubMenuItemStatic" ><div class="divImgTop"></div><div class="divImgBottom" ></div></div>';
}

/*function rearrang() {
    var boxHeightTweet = $('.boxContentTweet').height();
    //var tweetHeight = $('.tweet').height();
    //boxHeightTweet = boxHeightTweet + tweetHeight;
    $('.boxBgTweet').height(boxHeightTweet);
    $('.boxBgTweet').width(287);
    var topImageTweet = $('.boxBgTweet').position().top;
    $('.boxContentTweet').css('top', topImageTweet + 'px');

    var boxHeightBlog = $('.boxContentBlog').height();
    $('.boxBgBlog').height(boxHeightBlog);
    $('.boxBgBlog').width(287);
    var topImageblog = $('.boxBgBlog').position().top;
    $('.boxContentBlog').css('top', topImageblog + 'px');
}


window.onload = rearrang;*/


