///////////////////////
// Textpane funkciók //
///////////////////////

function viewsource(source, textpane) //nem muxik IE-ben
	{
	var html;
	if (source)
		{
		mystring = document.getElementById(textpane).contentWindow.document.body.innerHTML;
		mystring = mystring.replace(/[<]/g,'&lt;');
		mystring = mystring.replace(/[>]/g,'&gt;');
		document.getElementById(textpane).contentWindow.document.body.innerHTML = mystring;
		}
		else
		{
		mystring = document.getElementById(textpane).contentWindow.document.body.innerHTML;
		mystring = mystring.replace(/&lt;/g,'<');
		mystring = mystring.replace(/&gt;/g,'>');
		document.getElementById(textpane).contentWindow.document.body.innerHTML = mystring;
		};
	};

function insertNodeAtSelection(win, insertNode)
	{
	// get current selection
	var sel = win.getSelection();
	alert('1');
	// get the first range of the selection
	// (there's almost always only one range)
	var range = sel.getRangeAt(0);
	alert('2');
	// deselect everything
	sel.removeAllRanges();
	alert('3');
	// remove content of current selection from document
	range.deleteContents();
	alert('4');
	// get location of current selection
	var container = range.startContainer;
	var pos = range.startOffset;
	// make a new range for the new selection
	range=document.createRange();
	if (container.nodeType==3 && insertNode.nodeType==3)
		{
		// if we insert text in a textnode, do optimized insertion
		container.insertData(pos, insertNode.nodeValue);
		// put cursor after inserted text
		range.setEnd(container, pos+insertNode.length);
		range.setStart(container, pos+insertNode.length);
		}
		else
		{
		var afterNode;
		if (container.nodeType==3)
			{
			// when inserting into a textnode
			// we create 2 new textnodes
			// and put the insertNode in between
			var textNode = container;
			container = textNode.parentNode;
			var text = textNode.nodeValue;
			// text before the split
			var textBefore = text.substr(0,pos);
			// text after the split
			var textAfter = text.substr(pos);
			var beforeNode = document.createTextNode(textBefore);
			afterNode = document.createTextNode(textAfter);
			// insert the 3 new nodes before the old one
			container.insertBefore(afterNode, textNode);
			container.insertBefore(insertNode, afterNode);
			container.insertBefore(beforeNode, insertNode);
			// remove the old node
			container.removeChild(textNode);
			}
			else
			{
			// else simply insert the node
			afterNode = container.childNodes[pos];
			container.insertBefore(insertNode, afterNode);
			};
		range.setEnd(afterNode, 0);
		range.setStart(afterNode, 0);
		};
	sel.addRange(range);
	};

function setcolor(textpanename, color)
	{
	document.getElementById(textpanename).contentWindow.document.execCommand('ForeColor', false, color);
	document.getElementById(textpanename).contentWindow.focus();
	};
	
function sethilitecolor(textpanename, color)
	{
	document.getElementById(textpanename).contentWindow.document.execCommand('hilitecolor', false, color);
	document.getElementById(textpanename).contentWindow.focus();
	};

function insertimage(textpanename, align, lng)
	{
	imagePath = prompt(lng, "http://");
	if((imagePath != null) && (imagePath != ""))
		{
		//document.getElementById(textpanename).contentWindow.document.execCommand("InsertImage",false,imagePath);
		document.getElementById(textpanename).contentWindow.document.execCommand('InsertImage', false, imagePath);

		/*//e = document.getElementById(textpanename);
		image = document.getElementById(textpanename).contentWindow.document.createElement("img");
		image.setAttribute("src", imagePath);
		image.setAttribute("align", align);
		
		insertNodeAtSelection(document.getElementById(textpanename).contentWindow, image);
		alert('6');
   		document.getElementById(textpanename).contentWindow.focus();
		alert('7');*/
		};
	};

function stripHTML(textpanename)
	{
	document.getElementById(textpanename).contentWindow.document.body.innerHTML = document.getElementById(textpanename).contentWindow.document.body.innerHTML.replace(/<\/?[^>]+(>|$)/g, "");
	};


/*function insert_html(html, textpanename, image){
	var random_string = "insert_html_" + Math.round(Math.random()*100000000);
	//document.getElementById(textpanename).contentWindow.document.execCommand("insertimage",false, image);
	document.getElementById(textpanename).contentWindow.document.execCommand("insertimage",false, random_string);
	var pat = new RegExp("<[^<]*" + random_string + "[^>]*>");
	var current_html = document.getElementById(textpanename).contentWindow.document.body.innerHTML = document.getElementById(textpanename).contentWindow.document.body.innerHTML.replace(pat, html);
	document.getElementById(textpanename).contentWindow.focus();
	}*/

function tbclick(thisid, textpanename, lng, lng2)
	{
	if (thisid == "createlink")
		{
		var szURL = prompt(lng, "http://");
		if((szURL != null) && (szURL != ""))
			{
			document.getElementById(textpanename).contentWindow.document.execCommand("CreateLink",false,szURL);
			};
		}
		else if(thisid == "createtable")
		{
		e = document.getElementById(textpanename);
		rowstext = prompt(lng);
		colstext = prompt(lng2);
		rows = parseInt(rowstext);
		cols = parseInt(colstext);
		if((rows > 0) && (cols > 0))
			{
			table = e.contentWindow.document.createElement("table");
			table.setAttribute("border", "1");
			table.setAttribute("cellpadding", "2");
			table.setAttribute("cellspacing", "2");
			tbody = e.contentWindow.document.createElement("tbody");
			for(var i=0; i < rows; i++)
				{
				tr =e.contentWindow.document.createElement("tr");
				for(var j=0; j < cols; j++)
					{
					td =e.contentWindow.document.createElement("td");
					br =e.contentWindow.document.createElement("br");
					td.appendChild(br);
					tr.appendChild(td);
					};
				tbody.appendChild(tr);
				};
			table.appendChild(tbody);
			insertNodeAtSelection(e.contentWindow, table);
			};
		}
		else
		{
		document.getElementById(textpanename).contentWindow.document.execCommand(thisid, false, null);
		document.getElementById(textpanename).contentWindow.focus();
		};
	};

function Select(selectname, textpanename)
	{
	var cursel = document.getElementById(selectname).selectedIndex;
	if(cursel != 0)
		{
		var selected = document.getElementById(selectname).options[cursel].value;
		document.getElementById(textpanename).contentWindow.document.execCommand(selectname, false, selected);
		document.getElementById(selectname).selectedIndex = 0;
		};
	document.getElementById(textpanename).contentWindow.focus();
	};

function Start(textpanename)
	{
	document.getElementById(textpanename).contentWindow.document.designMode = "on";
	document.getElementById(textpanename).contentWindow.document.body.style.fontFamily = "arial";
	document.getElementById(textpanename).contentWindow.document.body.style.fontSize = "12px";
	document.getElementById(textpanename).contentWindow.document.body.style.lineHeight = "18px";
	document.getElementById(textpanename).contentWindow.document.body.style.margin = "4px";
	document.getElementById(textpanename).contentWindow.document.body.style.textAlign = "justify";

	/*try
		{
		document.getElementById(textpanename).contentWindow.document.execCommand("undo", false, null);
		}
		catch (e)
		{
		alert("This demo is not supported on your level of Mozilla.");
		};*/
	};

////////////////////////
// Általános funkciók //
////////////////////////

function transition(text, id)
	{
	text = text.toLowerCase();
	text = text.replace(/À/g, 'a');
	text = text.replace(/Á/g, 'a');
	text = text.replace(/Â/g, 'a');
	text = text.replace(/Ã/g, 'a');
	text = text.replace(/Ä/g, 'a');
	text = text.replace(/Å/g, 'a');
	text = text.replace(/Æ/g, 'a');
	text = text.replace(/Ç/g, 'c');
	text = text.replace(/È/g, 'e');
	text = text.replace(/É/g, 'e');
	text = text.replace(/Ê/g, 'e');
	text = text.replace(/Ë/g, 'e');
	text = text.replace(/Ì/g, 'i');
	text = text.replace(/Í/g, 'i');
	text = text.replace(/Î/g, 'i');
	text = text.replace(/Ï/g, 'i');
	text = text.replace(/Ð/g, 'd');
	text = text.replace(/Ñ/g, 'n');
	text = text.replace(/Ò/g, 'o');
	text = text.replace(/Ó/g, 'o');
	text = text.replace(/Ô/g, 'o');
	text = text.replace(/Õ/g, 'o');
	text = text.replace(/Ö/g, 'o');
	text = text.replace(/ /g, '_');
	text = text.replace(/Ø/g, '0');
	text = text.replace(/Ù/g, 'u');
	text = text.replace(/Ú/g, 'u');
	text = text.replace(/Û/g, 'u');
	text = text.replace(/Ü/g, 'u');
	text = text.replace(/Ý/g, 'y');
	text = text.replace(/Þ/g, 'p');
	text = text.replace(/ß/g, 'ss');
	text = text.replace(/à/g, 'a');
	text = text.replace(/á/g, 'a');
	text = text.replace(/â/g, 'a');
	text = text.replace(/ã/g, 'a');
	text = text.replace(/ä/g, 'a');
	text = text.replace(/å/g, 'a');
	text = text.replace(/æ/g, 'a');
	text = text.replace(/ç/g, 'c');
	text = text.replace(/è/g, 'e');
	text = text.replace(/é/g, 'e');
	text = text.replace(/ê/g, 'e');
	text = text.replace(/ë/g, 'e');
	text = text.replace(/ì/g, 'i');
	text = text.replace(/í/g, 'i');
	text = text.replace(/î/g, 'i');
	text = text.replace(/ï/g, 'i');
	text = text.replace(/ð/g, 'd');
	text = text.replace(/ñ/g, 'n');
	text = text.replace(/ò/g, 'o');
	text = text.replace(/ó/g, 'o');
	text = text.replace(/ô/g, 'o');
	text = text.replace(/õ/g, 'o');
	text = text.replace(/ö/g, 'o');
	text = text.replace(/÷/g, '');
	text = text.replace(/ø/g, '0');
	text = text.replace(/ù/g, 'u');
	text = text.replace(/ú/g, 'u');
	text = text.replace(/û/g, 'u');
	text = text.replace(/ü/g, 'u');
	text = text.replace(/ý/g, 'y');
	text = text.replace(/þ/g, 'p');
	text = text.replace(/ÿ/g, 'y');
	text = text.replace(/'/g, '');
	text = text.replace(/"/g, '');
	text = text.replace(/\+/g, '');
	text = text.replace(/!/g, '');
	text = text.replace(/%/g, '');
	text = text.replace(/\//g, '');
	text = text.replace(/=/g, '');
	text = text.replace(/\(/g, '');
	text = text.replace(/\)/g, '');
	text = text.replace(/\[/g, '');
	text = text.replace(/\]/g, '');
	text = text.replace(/\$/g, '');
	text = text.replace(/</g, '');
	text = text.replace(/>/g, '');
	text = text.replace(/#/g, '');
	text = text.replace(/&/g, '');
	text = text.replace(/@/g, '');
	text = text.replace(/{/g, '');
	text = text.replace(/}/g, '');
	text = text.replace(/,/g, '');
	text = text.replace(/\./g, '');
	text = text.replace(/;/g, '');
	text = text.replace(/>/g, '');
	text = text.replace(/-/g, '');
	text = text.replace(/\?/g, '');
	text = text.replace(/\*/g, '');
	text = text.replace(/\+/g, '');
	text = text.replace(/\\/g, '');
	text = text.replace(/\|/g, '');
	text = text.replace(/~/g, '');
	text = text.replace(/Ő/g, 'o');
	text = text.replace(/Ű/g, 'u');
	text = text.replace(/ő/g, 'o');
	text = text.replace(/ű/g, 'u');
	text = text.replace(/:/g, '');
	identity=document.getElementById(id);
	identity.value = text;
	};

function generate_users_password()
	{
	var text = prompt('password', "");
	if (text == ""){return;}
	hash = hex_md5(text);
	document.admin_list_form.users_password.value = hash;
	};

function countdown(id, total)
	{
	identity=document.getElementById(id);
	var seconds = total%60;
	var minutes = (total-seconds)/60;
	
	if(minutes == 0 && seconds == 0)
		{
		}
		else
 		{
 		total--;
		setTimeout("countdown('" + id + "', '"+total+"')",1000);
		};
	if(seconds < 10)
		{
		seconds = '0' + seconds;
		};
	identity.innerHTML = minutes + ':' + seconds;
	};

function toggle_table_visibility(hidden, visible)
	{
	var tables = document.getElementsByTagName("table");
	var num = tables.length;
	for(var i = 0; i < tables.length; i++)
		{
		if(tables[i].className == visible)
			{
			tables[i].className = hidden;
			}
		else if(tables[i].className == hidden)
			{
			tables[i].className = visible;
			};
		};
	};

function change_between_classes(id, classone, classtwo)
	{
	identity=document.getElementById(id);
	if(identity.className == classone)
		{
		identity.className = classtwo;
		}
	else if(identity.className == classtwo)
		{
		identity.className = classone;
		};
	};

function popupwindow(url, name, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable)
	{
	settings="toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",width="+width+",height="+height;
	window.open(url,name,settings);
	};

function popupimage(image_id, subdirectory)
	{
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=250";
	var myWin = window.open('','image','');
	myWin.close();
	var myWin = window.open(subdirectory + '/scripts/image_popup.php?image_id='+image_id,'image',settings);
	};

function popupimageother(image_file, subdirectory)
	{
	settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=250";
	var myWin = window.open('','image','');
	myWin.close();
	var myWin = window.open(subdirectory + '/scripts/image_popup_other.php?image_file='+image_file,'image',settings);
	};

function change_class(id, newclass)
	{
	identity=document.getElementById(id);
	identity.className=newclass;
	};

function getElementsByClassName(Element, TagName, ClassName)
	{
	var arrElements = (TagName == "*" && Element.all)? Element.all : Element.getElementsByTagName(TagName);
	var arrReturnElements = new Array();
	ClassName = ClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + ClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++)
		{
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className))
			{
			arrReturnElements.push(oElement);
			};
		};
	return (arrReturnElements)
	};
	
function delete_cookie ( cookie_name )
	{
	var cookie_date = new Date ( );  // current date & time
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
	};
	
function change_cookie_state(cookiename, stateone, statetwo)
	{
	cookievalue = readCookie(cookiename);
	if(cookievalue == null)
		{
		createCookie(cookiename, stateone);
		//document.cookie = cookiename + "=" + escape(stateone) + "; path=\"/\"";
		}
	else if(cookievalue == statetwo)
		{
		delete_cookie(cookiename);
		createCookie(cookiename, stateone);
		//document.cookie = cookiename + "=" + escape(stateone) + "; path=\"/\"";
		}
	else if(cookievalue == stateone)
		{
		delete_cookie(cookiename);
		createCookie(cookiename, statetwo);
		//document.cookie = cookiename + "=" + escape(statetwo) + "; path=\"/\"";
		};
	};	

function createCookie(name,value,days)
	{
	if (days)
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	};

function readCookie(name)
	{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
		{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
	return null;
	};

function change_class_toplink(id)
	{
	//Closes others//
	toplinks = getElementsByClassName(document, 'td', 'sidemenutoplinksub');
	for(var i=0; i<toplinks.length; i++)
		{
		if(toplinks[i].id !== id)
			{
			delete_cookie(toplinks[i].id);
			document.cookie = toplinks[i].id + "=" + escape("hidden") + "; path=\"/\"";
			toplinks[i].className = 'noborderhide';
			};
		};
	/////////////////
	identity=document.getElementById(id);
	if(identity.className=='noborderhide')
		{
		identity.className='sidemenutoplinksub';
		delete_cookie(identity.id);
		document.cookie = identity.id + "=" + escape("shown") + "; path=\"/\"";
		}
		else
		{
		identity.className='noborderhide';
		delete_cookie(identity.id);
		document.cookie = identity.id + "=" + escape("hidden") + "; path=\"/\"";
		};
	};

function textCounter(field, countfield, maxlimit)
	{
	if((field.value.length + 1) > maxlimit)
		{
		field.value = field.value.substring(0, maxlimit);
		return false;
		}
		else
		{
		countfield.value = maxlimit - field.value.length;
		};
	};

function highlight(key, total)
	{
	//alert(key + '/' + total);
	for(i = 1; i <= total; i++)
		{
		document.getElementById(i).className = '';
		};
	document.getElementById(key).className = 'current';
	//alert('a');
	};

function folder_text_change(folder_id, folder_text)
	{
	identity = document.getElementById(folder_id);
	identity.innerHTML = folder_text;
	};

function folder_state_change(folder_id, folder_state)
	{
	identity = document.getElementById(folder_id);
	identity.className = folder_state;
	};

function rating_over(number, image)
	{
	for (var x = 1; x <= number; x++)
		{
		identity=document.getElementById('rating'+x);
		identity.src=image;
		};
	};

function rating_out(number, image)
	{
	for (var x = 1; x <= number; x++)
		{
		identity=document.getElementById('rating'+x);
		identity.src=image;
		};
	};

function insertsmiley(smiley_code, form_name, form_field)
	{
	//Internet Explorer
	if (window.opener.document.selection)
		{
		window.opener.document.forms[form_name].elements[form_field].focus();
		var sel = window.opener.document.selection.createRange();
		sel.select();
		sel.text = '';
		sel.select();
		sel.text = smiley_code;
		}
	//MOZILLA & others
	else
		{
		var frm = window.opener.document.forms[form_name].elements[form_field];
		var leftText = frm.value.slice(0, frm.selectionStart);
		var rightText = frm.value.slice(frm.selectionEnd);
		frm.value = leftText + smiley_code + rightText;
		frm.selectionStart=frm.value.length-rightText.length;
		frm.selectionEnd=frm.selectionStart;
		};
	window.opener.document.forms[form_name].elements[form_field].focus();
	return;
	};

function insertpbbzero(sPBB, form_name, form_field)
	{
	//Internet Explorer
	if (document.selection)
		{
		document.forms[form_name].elements[form_field].focus();
		var sel = document.selection.createRange();
		sel.select();
		sel.text = '';
		sel.select();
		sel.text = "[" + sPBB + "]";
		}
	//MOZILLA & others
	else
		{
		var frm = document.forms[form_name].elements[form_field];
		var leftText = frm.value.slice(0, frm.selectionStart);
		var rightText = frm.value.slice(frm.selectionEnd);
		frm.value = leftText + "[" + sPBB + "]" + rightText;
		frm.selectionStart=frm.value.length-rightText.length;
		frm.selectionEnd=frm.selectionStart;
		};
	document.forms[form_name].elements[form_field].focus();
	return;
	};

function insertpbbmono(sPBB, form_name, form_field)
	{
	//Internet Explorer
	if (document.selection)
		{
		document.forms[form_name].elements[form_field].focus();
		var sel = document.selection.createRange();
		sel.select();
		sel.select();
		sel.text = "[" + sPBB + "]" + sel.text + "[/" + sPBB + "]";
		}
	//MOZILLA & others
	else
		{
		var frm = document.forms[form_name].elements[form_field];
		var leftText = frm.value.slice(0, frm.selectionStart);
		var middleText = frm.value.slice(frm.selectionStart, frm.selectionEnd);
		var rightText = frm.value.slice(frm.selectionEnd);
		frm.value = leftText + "[" + sPBB + "]" + middleText + "[/" + sPBB + "]" + rightText;
		frm.selectionStart=frm.value.length-rightText.length;
		frm.selectionEnd=frm.selectionStart;
		};
	document.forms[form_name].elements[form_field].focus();
	return;
	};

function insertpbburl(form_name, form_field, text1, text2)
	{
	var text = prompt(text1, "http://");
	if (text == ""){return;}
	var text2 = prompt(text2);
	if (text2 == ""){text2 = text;}
	//Internet Explorer
	if (document.selection)
		{
		document.forms[form_name].elements[form_field].focus();
		var sel = document.selection.createRange();
		sel.select();
		sel.select();
		sel.text = "[url]" + text + "[/url][url-text]" + text2 + "[/url-text]";
		}
	//MOZILLA & others
	else 
		{
		var frm = document.forms[form_name].elements[form_field];
		var leftText = frm.value.slice(0, frm.selectionStart);
		var rightText = frm.value.slice(frm.selectionEnd);
		frm.value = leftText + "[url]" + text + "[/url][url-text]" + text2 + "[/url-text]" + rightText;
		frm.selectionStart=frm.value.length-rightText.length;
		frm.selectionEnd=frm.selectionStart;
		};
	document.forms[form_name].elements[form_field].focus();
	return;
	};
	
//////////////////////
// Galéria funkciók //
//////////////////////

	function popupwindow(url, name, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable)
		{
		settings="toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",width="+width+",height="+height;
		MyNewWindow=window.open(url,name,settings);
		}
	function start_slideshow(parentid, galery_pictures_id_next)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + galery_pictures_id_next + '&slideshow=on');
		}
	function first_image(parentid, first)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + first);
		}
	function previous_image(parentid, galery_pictures_id_prev)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + galery_pictures_id_prev);
		}
	function next_image(parentid, galery_pictures_id_next)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + galery_pictures_id_next);
		}
	function specific_image(parentid, galery_pictures_id)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + galery_pictures_id);
		}
	function last_image(parentid, last)
		{
		location.replace('galery_picture.php?parentid=' + parentid + '&galery_pictures_id=' + last);
		}
	function next_slide(parentid, galery_pictures_id_next)
		{
		time = window.setTimeout("location.href='galery_picture.php?parentid="+parentid+"&galery_pictures_id="+galery_pictures_id_next+"&slideshow=on';",3000);
		}
	function stop_slideshow(theme, lng_start_slideshow, parentid, galery_pictures_id_next)
		{
		if(slideshow_stopped == true)
			{
			start_slideshow(parentid, galery_pictures_id_next);
			}
			else
			{
			slideshow_stopped = true;
			window.clearTimeout(time);
			identity=document.getElementById('slideshow_button');
			identity.src='../../themes/'+theme+'/galery/play.gif';
			identity.title=lng_start_slideshow;
			}
		}

//////////////////////
// Webmail funkciók //
//////////////////////

function insert_email_address(address, form_name, form_field)
	{
	//Internet Explorer
	if (document.selection)
		{
		window.opener.document.forms[form_name].elements[form_field].focus();
		var sel = window.opener.document.selection.createRange();
		sel.select();
		sel.text = '';
		sel.select();
		if(window.opener.document.forms[form_name].elements[form_field].value == '')
			{
			sel.text = address;
			}
			else
			{
			sel.text = ', ' + address;
			};
		}
	//MOZILLA & others
	else
		{
		var frm = window.opener.document.forms[form_name].elements[form_field];
		var leftText = frm.value.slice(0, frm.selectionStart);
		var rightText = frm.value.slice(frm.selectionEnd);
		if(frm.value == '')
			{
			frm.value = leftText + address + rightText;
			}
			else
			{
			frm.value = leftText + ', ' + address + rightText;
			};
		frm.selectionStart=frm.value.length-rightText.length;
		frm.selectionEnd=frm.selectionStart;
		};
	window.opener.document.forms[form_name].elements[form_field].focus();
	return;
	};

function rename_folder(num)
	{
	cell_a = document.getElementById('cell_a_' + num);
	cell_b = document.getElementById('cell_b_' + num);
	cell_a.className = 'noborderhide';
	cell_b.className = 'noborder';
	};

function change_class_webmail(row_id)
	{
	row = document.getElementById(row_id);
	//alert(row.className);
	if(row.className=='webmailodd'){row.className='webmailoddalt'}
	else if(row.className=='webmaileven'){row.className='webmailevenalt'}
	else if(row.className=='webmailoddalt'){row.className='webmailodd'}
	else if(row.className=='webmailevenalt'){row.className='webmaileven'};
	};

function change_email_icon(email_icon, theme)
	{
	email_icon=document.getElementById(email_icon);
	temp_name = email_icon.src.split("icons/");
	if(temp_name[1] == 'email.gif')
		{
		email_icon.src = '../../themes/' + theme + '/new_icons/email_seen.gif';
		}
	if(temp_name[1] == 'email_seen.gif')
		{
		email_icon.src = '../../themes/' + theme + '/new_icons/email.gif';
		}
	};

function change_email_icon_to_read(email_icon, theme)
	{
	email_icon=document.getElementById(email_icon);
	email_icon.src = '../../themes/' + theme + '/new_icons/email_seen.gif';
	};

function jump_to_first_page()
	{
	location.replace('modules/webmail/webmail_list.php?page_number=0');
	};

function multiselect_action(action, action_parameter)
	{
	document.checkboxform.action.value = action;
	document.checkboxform.action_parameter.value = action_parameter;
	document.checkboxform.submit();
	};

function cancel_link()
	{
	return false;
	};

function first_email(theme)
	{
	emaillink1 = document.getElementById('previous_email_button_link');
	if(emaillink1.onclick !== cancel_link){emaillink1.onclickold = emaillink1.onclick;};
	emaillink1.onclick = cancel_link;
	
	emailbutton1 = document.getElementById('previous_email_button');
	emailbutton1.src = 'themes/' + theme + '/new_icons/previous_email_disabled.gif';
	
	emaillink2 = document.getElementById('next_email_button_link');
	if(emaillink2.onclickold){emaillink2.onclick = emaillink2.onclickold;}
	
	emailbutton2 = document.getElementById('next_email_button');
	emailbutton2.src = 'themes/' + theme + '/new_icons/next_email.gif';
	};

function not_first_email(theme)
	{
	emaillink1 = document.getElementById('previous_email_button_link');
	if(emaillink1.onclickold){emaillink1.onclick = emaillink1.onclickold;}
	
	emailbutton1 = document.getElementById('previous_email_button');
	emailbutton1.src = 'themes/' + theme + '/new_icons/previous_email.gif';
	
	emaillink2 = document.getElementById('next_email_button_link');
	if(emaillink2.onclickold){emaillink2.onclick = emaillink2.onclickold;}
	
	emailbutton2 = document.getElementById('next_email_button');
	emailbutton2.src = 'themes/' + theme + '/new_icons/next_email.gif';
	};

function last_email(theme)
	{
	emaillink1 = document.getElementById('previous_email_button_link');
	if(emaillink1.onclickold){emaillink1.onclick = emaillink1.onclickold;}
	
	emailbutton1 = document.getElementById('previous_email_button');
	emailbutton1.src = 'themes/' + theme + '/new_icons/previous_email.gif';
	
	emaillink2 = document.getElementById('next_email_button_link');
	if(emaillink2.onclick !== cancel_link){emaillink2.onclickold = emaillink2.onclick;};
	emaillink2.onclick = cancel_link;
	
	emailbutton2 = document.getElementById('next_email_button');
	emailbutton2.src = 'themes/' + theme + '/new_icons/next_email_disabled.gif';
	};

function not_last_email(theme)
	{
	emailbutton2 = document.getElementById('next_email_button');
	emailbutton2.src = 'themes/' + theme + '/new_icons/next_email.gif';
	};

function first_page(theme)
	{
	listlink1 = document.getElementById('first_page_button_link');
	if(listlink1.onclick !== cancel_link){listlink1.onclickold = listlink1.onclick;};
	listlink1.onclick = cancel_link;
	
	listbutton1 = document.getElementById('first_page_button');
	listbutton1.src = 'themes/' + theme + '/new_icons/first_page_disabled.gif';
	
	listlink2 = document.getElementById('previous_page_button_link');
	if(listlink2.onclick !== cancel_link){listlink2.onclickold = listlink2.onclick;};
	listlink2.onclick = cancel_link;
	
	listbutton2 = document.getElementById('previous_page_button');
	listbutton2.src = 'themes/' + theme + '/new_icons/previous_page_disabled.gif';
	
	listlink3 = document.getElementById('next_page_button_link');
	if(listlink3.onclickold){listlink3.onclick = listlink3.onclickold;}
	
	listbutton3 = document.getElementById('next_page_button');
	listbutton3.src = 'themes/' + theme + '/new_icons/next_page.gif';
	
	listlink4 = document.getElementById('last_page_button_link');
	if(listlink4.onclickold){listlink4.onclick = listlink4.onclickold;}
	
	listbutton4 = document.getElementById('last_page_button');
	listbutton4.src = 'themes/' + theme + '/new_icons/last_page.gif';
	};
function other_page(theme)
	{
	listlink1 = document.getElementById('first_page_button_link');
	if(listlink1.onclickold){listlink1.onclick = listlink1.onclickold;}
	
	listbutton1 = document.getElementById('first_page_button');
	listbutton1.src = 'themes/' + theme + '/new_icons/first_page.gif';
	
	listlink2 = document.getElementById('previous_page_button_link');
	if(listlink2.onclickold){listlink2.onclick = listlink2.onclickold;}
	
	listbutton2 = document.getElementById('previous_page_button');
	listbutton2.src = 'themes/' + theme + '/new_icons/previous_page.gif';
	
	listlink3 = document.getElementById('next_page_button_link');
	if(listlink3.onclickold){listlink3.onclick = listlink3.onclickold;}
	
	listbutton3 = document.getElementById('next_page_button');
	listbutton3.src = 'themes/' + theme + '/new_icons/next_page.gif';
	
	listlink4 = document.getElementById('last_page_button_link');
	if(listlink4.onclickold){listlink4.onclick = listlink4.onclickold;}
	
	listbutton4 = document.getElementById('last_page_button');
	listbutton4.src = 'themes/' + theme + '/new_icons/last_page.gif';
	};

function last_page(theme)
	{
	listlink1 = document.getElementById('first_page_button_link');
	if(listlink1.onclickold){listlink1.onclick = listlink1.onclickold;}
	
	listbutton1 = document.getElementById('first_page_button');
	listbutton1.src = 'themes/' + theme + '/new_icons/first_page.gif';
	
	listlink2 = document.getElementById('previous_page_button_link');
	if(listlink2.onclickold){listlink2.onclick = listlink2.onclickold;}
	
	listbutton2 = document.getElementById('previous_page_button');
	listbutton2.src = 'themes/' + theme + '/new_icons/previous_page.gif';
	
	listlink3 = document.getElementById('next_page_button_link');
	if(listlink3.onclick !== cancel_link){listlink3.onclickold = listlink3.onclick;};
	listlink3.onclick = cancel_link;
	
	listbutton3 = document.getElementById('next_page_button');
	listbutton3.src = 'themes/' + theme + '/new_icons/next_page_disabled.gif';
	
	listlink4 = document.getElementById('last_page_button_link');
	if(listlink4.onclick !== cancel_link){listlink4.onclickold = listlink4.onclick;};
	listlink4.onclick = cancel_link;
	
	listbutton4 = document.getElementById('last_page_button');
	listbutton4.src = 'themes/' + theme + '/new_icons/last_page_disabled.gif';
	};

function only_page(theme)
	{
	listlink1 = document.getElementById('first_page_button_link');
	if(listlink1.onclick !== cancel_link){listlink1.onclickold = listlink1.onclick;};
	listlink1.onclick = cancel_link;
	
	listbutton1 = document.getElementById('first_page_button');
	listbutton1.src = 'themes/' + theme + '/new_icons/first_page_disabled.gif';
	
	listlink2 = document.getElementById('previous_page_button_link');
	if(listlink2.onclick !== cancel_link){listlink2.onclickold = listlink2.onclick;};
	listlink2.onclick = cancel_link;
	
	listbutton2 = document.getElementById('previous_page_button');
	listbutton2.src = 'themes/' + theme + '/new_icons/previous_page_disabled.gif';
	
	listlink3 = document.getElementById('next_page_button_link');
	if(listlink3.onclick !== cancel_link){listlink3.onclickold = listlink3.onclick;};
	listlink3.onclick = cancel_link;
	
	listbutton3 = document.getElementById('next_page_button');
	listbutton3.src = 'themes/' + theme + '/new_icons/next_page_disabled.gif';
	
	listlink4 = document.getElementById('last_page_button_link');
	if(listlink4.onclick !== cancel_link){listlink4.onclickold = listlink4.onclick;};
	listlink4.onclick = cancel_link;
	
	listbutton4 = document.getElementById('last_page_button');
	listbutton4.src = 'themes/' + theme + '/new_icons/last_page_disabled.gif';
	};

function counter(counter_text)
	{
	identity = document.getElementById('counter');
	identity.innerHTML = counter_text;
	};

function folder_name_change(folder_name)
	{
	identity = document.getElementById('folder_name');
	identity.innerHTML = folder_name;
	};

function zoom_list(theme)
	{
	identity = document.getElementById('list_frame');
	identity2 = document.getElementById('list_frame_size_icon');
	if(identity.height == list_frame_height)
		{
		identity.height = list_frame_height_zoom;
		identity2.src = 'themes/' + theme+ '/new_icons/shrink_frame.gif';
		}
		else
		{
		identity.height = list_frame_height;
		identity2.src = 'themes/' + theme+ '/new_icons/grow_frame.gif';
		};
	};

function zoom_message(theme)
	{
	identity = document.getElementById('message_frame');
	identity2 = document.getElementById('message_frame_size_icon');
	if(identity.height == message_frame_height)
		{
		identity.height = message_frame_height_zoom;
		identity2.src = 'themes/' + theme+ '/new_icons/shrink_frame.gif';
		}
		else
		{
		identity.height = message_frame_height;
		identity2.src = 'themes/' + theme+ '/new_icons/grow_frame.gif';
		};
	};

function list_frame_default_height()
	{
	identity = document.getElementById('list_frame');
	if(identity.height == 0)
		{
		identity.height = list_frame_height;
		};
	};

function message_frame_default_height()
	{
	identity = document.getElementById('message_frame');
	if(identity.height == 0)
		{
		identity.height = message_frame_height;
		};
	};


