
$(document).ready(function()
{
    buildMainMenu();

    if ($('input:checkbox').length > 0)
    {
        styleCheckBoxes();
    }

//    if ($(".listItemLink").length > 0)
//    {
//        createAreaHover();
//    }

    if ($(".video").length > 0)
    {
        createPlayIcons();
    }

    if ($(".fancyBox").length > 0)
    {
        setFancyBoxLinks();
    }

    if ($(".fancyBoxContact").length > 0)
    {
        setFancyBoxContact();
    }

});

/* this function open the newsletter */
function subscribe()
{
    window.open('http://www.mailinglijst.nl/nieuwsbrief/subscribe.asp?l=508', 'newsletter', 'width=500,height=600,scrollbars=yes,toolbar=no,location=no');
}

function setFancyBoxLinks()
{
    $(".fancyBox").fancybox({
        'titleShow': false,
        'overlayOpacity': 0.8,
        'padding': 0,
		'overlayColor': '#000000',
        'transitionIn': 'fade',
        'transitionOut': 'fade'
    });
}

function setFancyBoxContact()
{
    $(".fancyBoxContact").fancybox({
        'titleShow': false,
        'overlayOpacity': 0.8,
        'padding': 0,
        'overlayColor': '#000000',
        'transitionIn': 'fade',
        'transitionOut': 'fade'
    });
}

function createPlayIcons()
{
    var imageLocation = imagePath + playIcon;

    $(".video a").each(function()
    {
        var image = $(this).find('img');
        var pos = image.position();
        var tx = pos.left;
        var ty = pos.top;
        var tw = image.width();
        var th = image.height();

        // create the css object
        var cssObj = {
            'position': 'absolute',
            'z-index': 100,
            'top': (ty + (th / 2)) - 15,
            'left': (tx + (tw / 2) ) -15
        }

        //$(this).clone().appendTo('.video').find('img').attr('src', imageLocation).width(30).height(30).css(cssObj);
        $(this).clone().appendTo('.video').find('img').attr('src', '/FrontEnd/includes/image/transparentPlay.png').width(32).height(32).css(cssObj).addClass( 'playIconBg' );
    });

}


function createAreaHover()
{
    var originalColor;

    $(".listItemLink").hover(


		function()
		{


		    var listSection = $(this).parent().parent();
		    var date = listSection.find('span.date');
		    var list = listSection.find('ul');

		    //		    $(this).css("color", themeColorHover);
		    //		    listSection.css("color", themeColorHover);
		    //		    date.css("color", themeColorHover);
		    //		    list.css("color", themeColorHover);
		    //		    list.first().children().addClass('hover');

		    listSection.toggleClass("themeBorderTopColorHover");
		    date.toggleClass("hoverColorFont");
		},
		function()
		{

		    var listSection = $(this).parent().parent();
		    var date = listSection.find('span.date');
		    var list = listSection.find('ul');

		    //		    $(this).css("color", originalColor);
		    //		    listSection.css("color", themeColor);
		    //		    date.css("color", themeColor);
		    //		    list.css("color", themeColor);
		    //		    list.first().children().removeClass('hover');

		    listSection.toggleClass("themeBorderTopColorHover");
		    date.toggleClass("hoverColorFont");
		}
	);
}

function buildMainMenu()
{

    $("ul.sf-menu").superfish({
        pathLevels: 1,
        animation: { height: 'show' },
        delay: 200,     // 1.2 second delay on mouseout 
        speed: 'fast',
        autoArrows: false
    });
}

function styleCheckBoxes()
{
    $('input:checkbox').checkbox();

}

