$(document).ready(function(){

	$("#middle .article img").each(function(){
		if($(this).width() > 597)
			$(this).width(597);

		if($(this).attr('align') == 'left')
			$(this).css('margin-right','10px');
		else if($(this).attr('align') == 'right')
			$(this).css('margin-left','10px');
	});

	/* TITLES */
    $(".title h1.title").each(function(){
		if($(this).children('a').length){
	    	t = $(this).children('a:first').html();
			if(t)
				$(this).children('a:first').html("<img src=\"/domains/cyclingindustriesalkmaar.nl/generate/title.php?txt=" + t + "\" alt=\"" + t + "\" border=\"0\" />");
		}else{
	    	t = $(this).html();
			if(t)
				$(this).html("<img src=\"/domains/cyclingindustriesalkmaar.nl/generate/title.php?txt=" + t + "\" alt=\"" + t + "\" border=\"0\" />");
		}
    });

	/* MENU BUTTONS */
    $(".submenu_module ul li a").each(function(){
    	t = $(this).html();
		$(this).html("<img class=\"buttonImg\" src=\"/domains/cyclingindustriesalkmaar.nl/generate/button.php?txt=" + t + "\" border=\"0\" />");

    	//hover
    	$(".submenu_module img.buttonImg").parent('a').hover(
        	function(){
                if(!$(this).children('.buttonImg').attr('origSrc'))
        			$(this).children('.buttonImg').attr('origSrc',$(this).children('.buttonImg:eq(0)').attr('src'));

        		s = $(this).children('.buttonImg').attr('origSrc');
        		$(this).children('.buttonImg').attr('src',s + '&over=1');
        	},
        	function(){
        		s = $(this).children('.buttonImg').attr('origSrc');
        		$(this).children('.buttonImg').attr('src',s);
        	}
    	);
    });

    $(".submenu_module ul li").hover(
		function(){
			if($(this).children('ul:eq(0)').is(':hidden'))
				$(this).children('ul:eq(0)').slideDown('normal');
		},
		function(){
			if($(this).children('ul:eq(0)').is(':visible'))
				$(this).children('ul:eq(0)').slideUp('normal');
		}
    );

});


//emulate popup function...
function popWindow(u,w,h){
	e = u.substring(u.lastIndexOf('.')).toLowerCase();
	if(e == 'png' || e == 'gif' || e == 'jpg')
		popEl = $("<img width=\"" + w + "\" height=\"" + h + "\">")
	else
		popEl = $("<iframe width=\"" + w + "\" height=\"" + h + "\" border=\"0\" frameborder=\"0\"></iframe>");
	
	popEl.attr('src',u).appendTo('#container').displayBox();
}
