/* Menu functie */
sfHover = function() {

	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// $j is voor conflict oplossen met prototype. Overval $j = jQuery

var $j = jQuery;

$j(document).ready(function(){

	/* Payoff positionering functie */

	function position() {
		var pos = $j("#wrapper").offset();
		posleft = pos.left - 150;
		if ( posleft < 0) posleft = 0;
		$j("#payoff").css( { "left": (posleft) + "px", "top":pos.top + "px" } );
		$j("#payoff").show();
		$j("#payoff").click(function () {
			window.location.href='http://www.telegraafmedia.nl/';
		});
	}

	if ($j('div#payoff').length > 0) {
		position();
		$j(window).bind('resize', function() {
			position();
		});
	}

	$j('ul.sf-menu').supersubs().superfish({
		autoArrows:  false,
		dropShadows: false
	}); 

	$j('li.nolink a:eq(0)').click(function() {
	    return false;
	});
	$j('#head').click(function() {
        window.location.href = "/";
    });
    $j('#head').hover(function() {
        $(this).css('cursor','pointer');
    }, function() {
        $(this).css('cursor','auto');
    });
    $j('#head embed').hover(function() {
        $(this).css('cursor','pointer');
    }, function() {
        $(this).css('cursor','auto');
    });

    $j('div.news-amenu-container').append('<div class="toonarchief" align="right">Toon archief<\/div><div class="verwijderarchief" style="display: none;" align="right">Sluit archief<\/div>');
    $j('div.news-amenu-container').find('ul:gt(0)').find('li').hide();


    $j("div.toonarchief").click(function(){
        $j('div.news-amenu-container').find('ul:gt(0)').find('li').show();
        $j(this).parent().find('div.verwijderarchief').show();
        $j(this).parent().find('div.toonarchief').hide();
    });

    $j("div.verwijderarchief").click(function(){
        $j('div.news-amenu-container').find('ul:gt(0)').find('li').hide();
        $j(this).parent().find('div.verwijderarchief').hide();
        $j(this).parent().find('div.toonarchief').show();
    });
});