$j(document).ready(function(){   
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
	$j('div.cover_container').append('<iframe class="CoverFlash"></iframe>');}
});

function switchAgendaItem(item_id)
{
	var container_id = 'container_agenda_bg_'+item_id;
	var loading_id = 'container_agendaitem_loader_'+item_id;
	var leesmeerid = 'lees_meer_'+item_id;
	if($(container_id).style.display == 'none')
	{
		$(loading_id).toggle()
		new Ajax.Updater(container_id, 'agenda_item_content.php?id='+item_id, {asynchronous:true, onComplete:function(){ $(container_id).show(); $(loading_id).hide(); $(leesmeerid).hide();}});
	}
	else
	{
		$(container_id).toggle();
		$(leesmeerid).toggle();
	}
}

function closeAgendaItem(item_id)
{
	var container_id = 'container_agenda_bg_'+item_id;
	var leesmeerid = 'lees_meer_'+item_id;
	$(container_id).hide();
	$(leesmeerid).show();
}

function showPop(url){
   if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$j("body","html").css({height: "100%", width: "100%"});
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$j("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div>");
				$j("#TB_overlay").click(hidePop);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$j("body").append("<div id='TB_overlay'></div>");
				$j("#TB_overlay").click(hidePop);
			}
		}
		
		if(tb_detectMacXFF()){
			$j("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$j("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
    new Ajax.Updater('pop_page', url, {asynchronous:true, onComplete:function(){center('pop_page')}});
	return false;
}

function hidePop(){
	$('pop_page').hide();
    $j('#TB_overlay').remove();
    if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
    	$j('#TB_HideSelect').remove();}
    return false;
}

function center(element){
    try{
        element = $(element);
    }catch(e){
        return;
    }

    element.style.zIndex   = 999;
    element.show();
    popSifr();
}

function getDim(){
	
    var my_width  = 0;
    var my_height = 0;
	var dim = new Array();
    
    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }
    dim[0] = my_width;
    dim[1] = my_height ;
    return dim;
}

function popSifr(page){	
	sIFR.replaceElement("h1.popkopwhite", named({sFlashSrc: "./simple_bold.swf", sColor: "#ffffff", sBgColor: "#111111", sFlashVars:"letterSpacing=-1", sWmode:"opaque" }));
	sIFR.replaceElement("h1.popkopred", named({sFlashSrc: "./simple_bold.swf", sColor: "#ed145b", sBgColor: "#111111", sFlashVars:"letterSpacing=-1", sWmode:"opaque"}));
	sIFR.setup();
}

function archiefItem(id){
	var url = 'archief_item.php?id='+id;
	new Ajax.Updater('pop_page', url, {asynchronous:true, onComplete:function(){popSifr()}});
}

function nieuwsArchiefItem(id){
	var url = 'nieuwsarchief_item.php?id='+id;
	new Ajax.Updater('pop_page', url, {asynchronous:true, onComplete:function(){popSifr()}});
}

function jsPop(id,w,h){
	var vars = 'width='+w+',height='+h+',scrollbars=0,status=0,menubar=0,directories=0,toolbar=0,location=0,resizable=0'
	window.open('pictures.php?id='+id,'Images',vars);
	return false;
}

function contactSend(){
	var params = Form.serialize($('contact_form'));
	new Ajax.Updater('reply_message','contact_send.php', {method:'post', asynchronous:true, parameters:params});
}
