$( function() {
	$("#dialog_cms")
			.dialog(
					{
						autoOpen :false,
						height :300,
						width :700,
						modal :true,
						buttons : {
							'Sluiten' : function() {
								$(this).dialog('close');
							},
							'Vernieuwen' : function() {
								var iFrameObj = document
										.getElementById('dialog_cms_frame');
								iFrameObj.src = iFrameObj.src;
							}
						},
						resizeStop : function(event, ui) {
							var iFrameObj = document
									.getElementById('dialog_cms_frame');
							iFrameObj.width = $("#dialog_cms").dialog('option',
									'width') - 30;
							iFrameObj.height = $("#dialog_cms").dialog(
									'option', 'height') - 100;
						}
					});
});

$( function() {
	$("#dialog_cms_sub")
			.dialog(
					{
						autoOpen :false,
						height :300,
						width :700,
						modal :true,
						buttons : {
							'Sluiten' : function() {
								var parentFrame=top.document.getElementById('dialog_cms_frame');
								parentFrame.src=parentFrame.src;
								$(this).dialog('close');
							},
							'Vernieuwen' : function() {
								var iFrameObj = document.getElementById('dialog_cms_sub_frame');
								iFrameObj.src = iFrameObj.src;
							}
						},
						resizeStop : function(event, ui) {
							var iFrameObj = document.getElementById('dialog_cms_sub_frame');
							iFrameObj.width = $("#dialog_cms_sub").dialog('option', 'width') - 30;
							iFrameObj.height = $("#dialog_cms_sub").dialog('option', 'height') - 100;
						}
					});
});

function djCms_openSubPopup(h, w, title, src) {
	$("#dialog_cms_sub").dialog('option', 'title', title);
	$("#dialog_cms_sub").dialog('option', 'height', h);
	$("#dialog_cms_sub").dialog('option', 'width', w);
	$("#dialog_cms_sub").dialog("open");
	$("#dialog_cms_sub").html("");
	$("#dialog_cms_sub")
			.html(
					"<iframe id='dialog_cms_sub_frame' src='"
							+ src
							+ "' WIDTH='"
							+ (w - 30)
							+ "' HEIGHT='"
							+ (h - 100)
							+ "' frameborder=0 marginheight=0 marginwidht=0 scrolling=auto></iframe>");
}

function djCms_openPopup(h, w, title, src) {
	$("#dialog_cms").dialog('option', 'title', title);
	$("#dialog_cms").dialog('option', 'height', h);
	$("#dialog_cms").dialog('option', 'width', w);
	$("#dialog_cms").dialog("open");
	$("#dialog_cms").html("");
	$("#dialog_cms")
			.html(
					"<iframe id='dialog_cms_frame' src='"
							+ src 
							+ "' WIDTH='"
							+ (w - 30)
							+ "' HEIGHT='"
							+ (h - 100)
							+ "' frameborder=0 marginheight=0 marginwidht=0 scrolling=auto></iframe>");
}
function djCms_openPopupWysiwyg(h, w, title, src) {
	djCms_openPopup(h, w, title, src);
	$("#dialog_cms").dialog('option', 'buttons', {
		"Sluiten" : function() {
			$(this).dialog("close");
		}
	});
}
function hide_form_hint() {
	hint_div = document.getElementById('hint');
	arrow_div = document.getElementById('hintpointer');
	hint_div.style.visibility = 'hidden';
	arrow_div.style.visibility = 'hidden';
}
function show_form_hint(obj, label, inputWidth) {
	if (!document.getElementById('hint')) {
		var hint_div = document.createElement('div');
		hint_div.setAttribute('id', 'hint');
		hint_div.setAttribute('class', 'hint');
		hint_div.style.position = "absolute";
		document.body.appendChild(hint_div);
	}
	if (!document.getElementById('hintpointer')) {
		var arrow_div = document.createElement('div');
		arrow_div.setAttribute('id', 'hintpointer');
		arrow_div.setAttribute('class', 'hintpointer');
		arrow_div.style.position = "absolute";
		document.body.appendChild(arrow_div);
		arrow_div = document.getElementById('hintpointer');
	}
	var posLeft = findPosX(obj) + inputWidth + 9;
	var posTop = findPosY(obj) - 3;
	hint_div = document.getElementById('hint');
	hint_div.innerHTML = label;
	hint_div.style.left = posLeft + 'px';
	hint_div.style.top = posTop + 'px';
	hint_div.style.visibility = 'visible';
	arrow_div = document.getElementById('hintpointer');
	arrow_div.style.left = (findPosX(obj) + inputWidth) + 'px';
	arrow_div.style.top = (findPosY(obj)) + 'px';
	arrow_div.style.visibility = 'visible';
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
		while (1) {
			curleft += obj.offsetLeft;
			if (!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
		while (1) {
			curtop += obj.offsetTop;
			if (!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
