function close_popup()
{
	setTimeout("self.close()", 2*1000);
}

function image(id, w, h)
{
	url = "/popup/image/";
	url += id;
	popup(url,'image', w, h, 'no');
}

function image_edit(page, id, w, h, db, dir)
{
	url = "/popup/image_edit/";
	url += id;
	url += "/";
	url += page;
	url += "/";
	url += db;
	url += dir;
	popup(url,'image_edit', 440, 520, 'no');
}

function menus(id)
{
	url = "/popup/menus/";
	url += id;
	popup(url, 'menus', 480, 400, 'yes');
}

function popup(url, name, width, height, scrollbar)
{
	var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	// exactly Internet Explorer 7
	var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/;
	// at least Internet Explorer 7
	var gteIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;
	// any Internet Explorer (thanks to Dean)
	var isMSIE = /*@cc_on!@*/false;
	
	if (IE7==true)
	{
		var reheight = height+80;
		var rewidth = width+7;
	} else if (IE6==true) {
		var reheight = height+37;
		var rewidth = width+8;
	} else {
		var reheight = height+56;
		var rewidth = width+5;
	}
	
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', directories=no';
	params += ', location=no';
	params += ', menubar=no';
	params += ', resizable=no';
	params += ', scrollbars='+scrollbar;
	params += ', status=no';
	params += ', toolbar=no';
	newwin=window.open(url, name, params);
	newwin.resizeTo(rewidth, reheight);
	if (window.focus) { newwin.focus() }
	return false;
}

function reload_close($url)
{
	top.parent.window.opener.location.href = $url;
	setTimeout("self.close()", 2*1000);
}

function rights_menu(id)
{
	url = "/popup/rights_menu/";
	url += id;
	popup(url, 'rights_menu', 480, 400, 'yes');
}

function rights_page(id)
{
	url = "/popup/rights_page/";
	url += id;
	popup(url, 'rights_page', 480, 400, 'yes');
}

function rights_user(id)
{
	url = "/popup/rights_user/";
	url += id;
	popup(url, 'rights_user', 480, 400, 'yes');
}

function show_limit(textField, displayArea, maxChars)
{
 	if (textField.value.length > maxChars)
	{
 		textField.value = textField.value.slice(0, maxChars);
 	}
 	displayArea.innerHTML = "kasutatud <b>"+textField.value.length+"</b> tähemärki lubatud <b>"+maxChars+"</b>";
}

function submitform()
{
	document.form.submit();
}

function upload_banner(id, id2)
{
	url = "/popup/upload_banner/";
	url += id;
	url += "/";
	url += id2;
	popup(url, 'upload_banner', 480, 400, 'yes');
}

function upload_image(id, id2)
{
	url = "/popup/upload_image/";
	url += id;
	url += "/";
	url += id2;
	popup(url, 'upload_image', 480, 400, 'yes');
}
