function close_popup()
{
	setTimeout("self.close()", 2*1000);
}

function gallery(id)
{
	url = "/popup/gallery/";
	url += id;
	popup(url, 'gallery', 500, 545, 'no');
}

function image(id, w, h)
{
	url = "/popup/image/";
	url += id;
	popup(url, 'image', w, h, '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 showhide(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
		if (obj.style.display == "none")
		{
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
}

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_file(id, id2)
{
	url = "/popup/upload_file/";
	url += id;
	url += "/";
	url += id2;
	popup(url, 'upload_file', 480, 400, 'yes');
}

function upload_image(id, id2)
{
	url = "/popup/upload_image/";
	url += id;
	url += "/";
	url += id2;
	popup(url, 'upload_image', 480, 400, 'yes');
}

function upload_image_gallery(id)
{
	url = "/popup/upload_image_gallery/";
	url += id;
	popup(url, 'upload_image_gallery', 480, 400, 'yes');
}

function upload_image_gallery_zip(id)
{
	url = "/popup/upload_image_gallery_zip/";
	url += id;
	popup(url, 'upload_image_gallery_zip', 480, 400, 'yes');
}