function get_object(object_id) {
    if(document.getElementById && document.getElementById(object_id)) {
		return document.getElementById(object_id);
    } else if(document.all && document.all(object_id)) {
		return document.all(object_id);
    } else if(document.layers && document.layers[object_id]) {
		return document.layers[object_id];
    } else {
		return false;
    }
}

function smiley(id, text) {
	var obj = get_object(id);
	obj.focus();
	text = " " + text + " ";
	//obj.value  += text;
	insert_at_cursor(obj, text);
	//obj.focus();
}

function insert_at_cursor(obj, text) {
	if (document.selection) { //IE support
		obj.focus();
		sel = document.selection.createRange();
		sel.text = text;
	} else if (obj.selectionStart || obj.selectionStart == '0') { //MOZILLA/NETSCAPE support
		var start_pos = obj.selectionStart;
		var end_pos = obj.selectionEnd;
		obj.value = obj.value.substring(0, start_pos) + text + obj.value.substring(end_pos, obj.value.length);
	} else {
		obj.value += text;
	}
}

function popImage(imageURL, imageTitle)
{
	if(imageTitle == undefined)
		imageTitle = "Officiële Kratpatsers Homepage";
	var params = "scrollbars=auto,width=150,height=100,left=" + 200 + ",top=" + 200;
	imgWin = window.open("about:blank", "", params);
	
	with(imgWin.document)
	{
		writeln("<html><head><title>Loading...</title><style>body {margin: 0px;}</style>");
		writeln("<sc" + "ript>");
		writeln("var isNN, isIE;");
		writeln("if(parseInt(navigator.appVersion.charAt(0)) >= 4)");
		writeln("{ isNN = (navigator.appName == \"Netscape\") ? 1 : 0;");
		writeln("isIE = (navigator.appName.indexOf(\"Microsoft\") != -1) ? 1 : 0;}");
		writeln("function reSizeToImage()");
		writeln("{ if(isIE)");
		writeln("{ window.resizeTo(120, 120);");
		writeln("width = 120 - (document.body.clientWidth - document.images[0].width);");
		writeln("height = 120 - (document.body.clientHeight-document.images[0].height);");
		writeln("window.resizeTo(width, height);}");
		writeln("if(isNN)");       
		writeln("{window.innerWidth = document.images[\"image\"].width;");
		writeln("window.innerHeight = document.images[\"image\"].height; } }");
		writeln("function doTitle(){ document.title='" + imageTitle + "'; }");
		writeln("</sc" + "ript>");
		writeln("</head><body scroll=\"no\" onload=\"reSizeToImage(); doTitle(); self.focus()\" onblur=\"self.close()\">");
		writeln("<img name=\"image\" src=\"" + imageURL + "\" style=\"display: block;\"></body></html>");
		close();
	}
}

function popup(img_src, img_title, width, height) {
	
	page = "about:blank";
	target = "";
	params = "scrollbars=auto,width=" + width + ",height=" + height + ",left=" + 150 + ",top=" + 150;
	img_win = window.open(page, target, params);
	
	with(img_win.document) {
		writeln("<html>\
                 <head>\
                 <title>" + img_title + "</title>\
                 </head>\
                 <body scroll=\"no\" style=\"margin: 0px 0px 0px 0px;\" onload=\"self.focus();\" onblur=\"self.close();\">\
                 <img src=\"" + img_src + "\" alt=\"" + img_title + "\" title=\"Klik om af te sluiten\" style=\"cursor: pointer;\" onclick=\"self.close();\" />\
                 </body>\
                 </html>");
		close();
	}
}

function disable_button(id) {
	var button = get_object(id);
	if(button) {
		button.disabled = "disabled";
	}
}
