// Farmacotherapie-specifieke functies voor vormgeving etc.

function getFarmacoForm(a,b){
	var targetUrl
	if(b){
		targetUrl=a;
	}else{
		targetUrl=$(a).attr("targetUrl");
	}
	if(targetUrl){
		$.post(targetUrl,{ ajaxreq: "1"}, function(data){
			$( ".dialog:ui-dialog" ).dialog( "destroy" );
			$( ".dialog" ).html(data);
			$( ".dialog" ).dialog({ 
				modal: true,
				minWidth: 550,
				maxHeight: 550,
				show: 'fade',
				hide: 'fade', 
				resizable: false,
				position: 'center',
				draggable: false,
				open: function(event, ui) {
				    $('.ui-widget-overlay').bind('click', function(){
					    $(".dialog").dialog('close'); });
				    }
			});
		});
	}
}
	
	
function wopen(url, h, w){
	if (h == null) h = 600;
	if (w == null) w = 800;
	window.open(url, '_blank', 'width=' + w + ', height=' + h + ', toolbar=yes, resizable=yes, location=yes, scrollbars=yes, status=yes');
}
   
function openWindowLightbox(id){
	t = '';
	id = id.replace(/[\u2013|\u2014]/g, "-"); // vervang lange Word-streepjes door gewone streepjes
	t_array = id.split(',');
	t_num=0;
	while (t_num < t_array.length){
		q=jQuery.trim(t_array[t_num]);
		l_array = q.split('-');
		if(l_array.length<2){
			if(t_array[t_num])t+=addRef(q);
		}else{
			begin=jQuery.trim(l_array[0]);
			eind=jQuery.trim(l_array[1]);
			while(begin <= eind){
				if(t_array[t_num])t+=addRef(begin);
				begin++;
			}
		}
		t_num++;
	}
  
	$( ".dialog:ui-dialog" ).dialog( "destroy" );
	$( ".dialog" ).html('<table>'+t+'</table>');	
	$( ".dialog" ).dialog({ 
		modal: true,
		minWidth: 550,
		show: 'fade',
		hide: 'fade', 
		resizable: false,
		position: 'center',
		draggable: false
	});
}
function openTextWindowLightbox(t){
	$( ".dialog:ui-dialog" ).dialog( "destroy" );
	t=t.replace(/\n/g, "<br/>");
	$( ".dialog" ).html(''+t+'');	
	$( ".dialog" ).dialog({ 
		modal: true,
		minWidth: 550,
		show: 'fade',
		hide: 'fade', 
		resizable: false,
		position: 'center',
		draggable: false
	});
}

function addRef(refid){
	var refblock=$("#reference" + refid).html();
	if(!refblock)refblock='[invalid reference]';
	t='<tr><td class=\'refid\'>'+refid+'</td><td class=\'refblock\'>'+refblock+'</td></tr>';
	return t;
}

function resizeEwise(){
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=navigator.appVersion.substring(22, 25);
	var totaal=window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	var gg=totaal-(205);

	if(document.getElementById('scaleDivTab')){gg=gg-16;}

	var myFrame = document.getElementById('scaleDiv');

	if (myFrame) {
		if(browser!="Microsoft Internet Explorer"){gg=gg-11;}
		if((browser=="Microsoft Internet Explorer") && (version<7)){
			gg=gg-70;myFrame.style.height =gg+"px";
		}else{
			myFrame.style.minHeight =gg+"px";
		}
	}
}

