 function selectAllMsgs() {
  var checkbox = null;
  var index = 0;

  while((checkbox = document.getElementById("check_" + index)) != null) {
    checkbox.checked = true;
    index += 1;
  }
}

function deselectSelectedMsgs() {
  var checkbox = null;
  var index = 0;

  while((checkbox = document.getElementById("check_" + index)) != null) {
    if(checkbox.checked) {
		checkbox.checked = false;
    }
    index += 1;
  }
}

function fireMsgOperation(code) {
  var submitForm = document.getElementById("msg_operation_form");
  var switcher = document.getElementById("operation_type");
  switcher.value = code;
  submitForm.submit();
}

function sendMessageReply() {
  var submitForm = document.getElementById("msg_reply_form");
  submitForm.submit();
}

function sendAdminMessageReply() {
	var adminCheck = document.getElementById("is_admin_toggle");
	var submitForm = document.getElementById("msg_reply_form");
	adminCheck.value = "1";
  submitForm.submit();
}

function switchLanguage(language) {
	var updForm = document.getElementById("change_lang_form");
	var updInput = document.getElementById("hidden_new_language");
	updInput.value = language;
	updForm.submit();
}

function selectMsgReplyLang(index) {
  var checkbox = null;
  var chIndex = 0;
  while((checkbox = document.getElementById("msg_reply_lang_checkbox_" + chIndex)) != null) {
    if(chIndex == index) {
      checkbox.checked = true;
    } else {
      checkbox.checked = false;
    }
    chIndex += 1;
  }
}
function sendMessageAnswerReply() {
  var submitForm = document.getElementById("msg_answer_reply_form");
  submitForm.submit();
}

function fireSingleMsgAction(code, id) {
  var massSwitcher = document.getElementById("mass_op_input");
  var singleSwitcher = document.getElementById("single_op_input");
  var operationIndicator = document.getElementById("operation_type");
  var updForm = document.getElementById("msg_operation_form");
  var idField = document.getElementById("single_op_id");

  operationIndicator.value = code;
  singleSwitcher.value = 1;
  massSwitcher.value = 0;
  idField.value=id;
  updForm.submit();

}

function fireProfileChangedEvent() {
  var updForm = document.getElementById("change_profile_form");
  var updInput = document.getElementById("hidden_newprofile");
  var selector = document.getElementById("select_change_profile");
  
  updInput.value = selector.options[selector.selectedIndex].value;
  updForm.submit();
}
function viewArticle(id) {
  for(var i = 0; ; ++i) {
	var tDiv = document.getElementById("pi_title_"+i);
	var iDiv = document.getElementById("pi_intro_"+i);
	var xDiv = document.getElementById("pi_text_"+i);
	if(tDiv == null || iDiv == null || xDiv == null) {
		break;
	} else {
		if(id == i) {
			if(xDiv.style.display == "none") {
				tDiv.style.display = "";
				tDiv.style.fontWeight = "bold";
				iDiv.style.display = "";
				iDiv.style.fontWeight = "bold";
				iDiv.style.color = "#333";
				iDiv.style.borderBottomWidth = "0px";
				iDiv.style.backgroundColor = "#EAEDF4";
				iDiv.style.paddingTop = "10px";
				xDiv.style.display = "";
				xDiv.style.backgroundColor = "#EAEDF4";
				xDiv.style.paddingBottom = "10px";
			} else {
				tDiv.style.display = "";
				tDiv.style.fontWeight = "";
				iDiv.style.display = "";
				iDiv.style.fontWeight = "";
				iDiv.style.borderBottomWidth = "1px";
				iDiv.style.backgroundColor = "";
				iDiv.style.paddingTop = "";
				iDiv.style.color = "";
				xDiv.style.display = "none";
				xDiv.style.backgroundColor = "";
				xDiv.style.paddingBottom = "15px";
			}
		} else {
			tDiv.style.display = "";
				tDiv.style.fontWeight = "";
				iDiv.style.display = "";
				iDiv.style.fontWeight = "";
				iDiv.style.borderBottomWidth = "1px";
				iDiv.style.backgroundColor = "";
				iDiv.style.paddingTop = "";
				iDiv.style.color = "";
				xDiv.style.display = "none";
				xDiv.style.backgroundColor = "";
				xDiv.style.paddingBottom = "15px";
		}
	}
  }
}
/**
 * Funkcja przelaczajaca automatycznie widocznosc panela logowania.
 */
function toggleLoginFields(errorRecovery) {
	var loginDiv = document.getElementById("logging_fields_div");
	var mainDiv = document.getElementById("top_options");
	var expanded = loginDiv.style.display == "none" ? false : true;

	if(errorRecovery == 1) {
		var errorDiv = document.getElementById("logging_error");
		errorDiv.style.display = "none";
	}
	if(!expanded) {
		mainDiv.style.height = "36px";
		loginDiv.style.display = "inline";
	} else {
		mainDiv.style.height = "24px";
		loginDiv.style.display = "none";
	}
}
function fireLoggingSubmit() {
	var logForm = document.getElementById("logging_form");
	var loginDiv = document.getElementById("logging_fields_div");
	loginDiv.style.display = "none";
	logForm.submit();
}

function fireUnregSubmit(field, action) {
  var unregForm = document.getElementById("unreg_form_"+field);
  var decisionInput = document.getElementById("unreg_action");
  decisionInput.value = action;
  unregForm.submit();
}
function fireWaitingProfileSubmit(field, action) {
  var updForm = document.getElementById("update_form_"+field);
  var decisionInput = document.getElementById("update_action");
  decisionInput.value = action;
  updForm.submit();
}
function fireSubmitJobCreate() {
  var updForm = document.getElementById("jobs_create_form");
  updForm.submit();
}
function fireSubmitJobUpdate() {
  var updForm = document.getElementById("job_update_form");
  updForm.submit();
}
function fireDetailedSearchSubmit() {
  var updForm = document.getElementById("detailed_search_form");
  updForm.submit();
}
function fireQuickSearchSubmit() {
  var updForm = document.getElementById("av_quick_search");
  updForm.submit();
}
function fireOwnerOfferSubmit() {
  var updForm = document.getElementById("owner_offer_form");
  updForm.submit();
}
function fireAnswerMessageDelete() {
  var updForm = document.getElementById("msg_operation_form");
  updForm.submit();
}
function sendSystemMessage() {
  var updForm = document.getElementById("msg_system_form");
  updForm.submit();
}
function firePressinfoCreate() {
  var updForm = document.getElementById("pinfo_create_form");
  updForm.submit();
}
function togglePinfo(infoId) {
  var updForm = document.getElementById("pinfo_action_form");
  var acType = document.getElementById("pinfo_action_at");
  var pid = document.getElementById("pinfo_action_pid");
  
  acType.value = "visibility";
  pid.value = infoId;
  updForm.submit();
}
function delPinfo(infoId) {
  var updForm = document.getElementById("pinfo_action_form");
  var acType = document.getElementById("pinfo_action_at");
  var pid = document.getElementById("pinfo_action_pid");
  
  acType.value = "delete";
  pid.value = infoId;
  updForm.submit();
}
function toggleBranch(deptId) {
  var updForm = document.getElementById("dept_action_form");
  var acType = document.getElementById("dept_action_tp");
  var did = document.getElementById("dept_action_did");
  
  acType.value = "chvis";
  did.value = deptId;
  updForm.submit();
}
function delBranch(deptId) {
  var updForm = document.getElementById("dept_action_form");
  var acType = document.getElementById("dept_action_tp");
  var did = document.getElementById("dept_action_did");
  
  acType.value = "delete";
  did.value = deptId;
  updForm.submit();
}
function toggleRep(repId) {
  var updForm = document.getElementById("rep_action_form");
  var acType = document.getElementById("rep_action_tp");
  var rid = document.getElementById("rep_action_rid");
  
  acType.value = "chvis";
  rid.value = repId;
  updForm.submit();
}
function delOwnerRep(repId) {
  var updForm = document.getElementById("rep_action_form");
  var acType = document.getElementById("rep_action_tp");
  var rid = document.getElementById("rep_action_rid");
  
  acType.value = "delete";
  rid.value = repId;
  updForm.submit();
}

function delDept(deptId) {
  var updForm = document.getElementById("dept_action_form");
  var did = document.getElementById("dept_action_did");
  
  did.value = deptId;
  updForm.submit();
}
function delRep(repId) {
  var updForm = document.getElementById("rep_action_form");
  var rid = document.getElementById("rep_action_rid");
  
  rid.value = repId;
  updForm.submit();
}
var cleared = false;
function clearSearchInput() {
	if(!cleared) {
		var srchInput = document.getElementById("main_search_input");
		srchInput.value = "";
		cleared = true;
	}
}

function fireSearch() {
	var updForm = document.getElementById("main_search_form");
	updForm.submit();
}
function fireSubmitCategoryShownUpdate() {
  var updForm = document.getElementById("cat_shown_update");
	updForm.submit();
}
function toggleJobActive(positive, negative, block, unblock) {
  var div = document.getElementById("job_active_text");
	var blocker = document.getElementById("job_active_switch");
	var hiddenInput = document.getElementById("hidden_active_job");

	if(div.childNodes[0].nodeValue == negative) {
		div.childNodes[0].nodeValue = positive;
		hiddenInput.value = 1;
		blocker.childNodes[0].nodeValue = unblock;
 	}
	else {
		div.childNodes[0].nodeValue = negative;
		hiddenInput.value = 0;
		blocker.childNodes[0].nodeValue = block;
	}
}
function fireJobActivate(no) {
  var updForm = document.getElementById("job_activation_form_" + no);
  updForm.submit();
}
function fireSubmitJobDelete() {
  var delForm = document.getElementById("job_delete_form");
  delForm.submit();
}
function fireProfileContactSubmit() {
  var updForm = document.getElementById("profiles_contact_form");
  updForm.submit();
}
function fireMassContactSubmit() {
  var updForm = document.getElementById("company_mass_contact");
  updForm.submit();
}
function fireOffersFilterSubmit() {
  var updForm = document.getElementById("offers_filter_form");
  updForm.submit();
}
function fireLoginSubmit() {
  var updForm = document.getElementById("login_form");
  updForm.submit();
}
function fireWizard1Submit() {
  var updForm = document.getElementById("owner_creator_1");
  updForm.submit();
}
function fireOwnerLogoChange() {
  var updForm = document.getElementById("owner_creator_1");
  var logoUpdate = document.getElementById("logo_change_hidden");
  logoUpdate.value = 1;
  updForm.submit();
}
function fireCustomSubmit(id) {
  var updForm = document.getElementById(id);
  updForm.submit();
}
function fireOwnerOfferDelete(id) {
  var updForm = document.getElementById("owner_offer_delete_form");
  var switcher = document.getElementById("owner_offer_sid");
  switcher.value = id;
  updForm.submit();
}

function toggleOfferWarning() {
  var div = document.getElementById("owner_offer_warning_div");
  if(div.style.display == "none") {
	div.style.display = "";
  } else {
    div.style.display = "none";
  }
}

var allSelected = 0;
function selectCompanyContact(i, maxSelected) {
  var input = document.getElementById("c_"+i);

  if(allSelected < maxSelected) {
	  if(input.checked) {
		allSelected += 1;
	  } else {
		allSelected -= 1;
	  }
	  var infop = document.getElementById("selected_cat_count");
	  infop.childNodes[0].nodeValue = allSelected;
  } else {
    if(input.checked) {
		input.checked = false;
	} else {
		allSelected -= 1;
		var infop = document.getElementById("selected_cat_count");
		infop.childNodes[0].nodeValue = allSelected;
	}
  }
}
function fireContactOfferSubmit() {
  var updForm = document.getElementById("offers_contact_form");
  updForm.submit();
}
function checkSearchOption(option) {
  var checkbox1 = document.getElementById("main_search_checkbox_1");
  var checkbox2 = document.getElementById("main_search_checkbox_2");
  var inputType = document.getElementById("search_type");

  if(option == 1) {
    checkbox1.checked = true;
    checkbox2.checked = false;
    inputType.value = 1;
  } else {
    checkbox1.checked = false;
    checkbox2.checked = true;
    inputType.value = 2;
  }
}
function switchDetailedSearch(index) {
  var checkbox1 = document.getElementById("detail_check_1");
  var checkbox2 = document.getElementById("detail_check_2");
  var inputType = document.getElementById("search_type");
  var expiryDiv = document.getElementById("expiry_div");

  if(index == 1) {
    checkbox1.checked = true;
    checkbox2.checked = false;
    inputType.value = 1;
    expiryDiv.style.display = "none";

  } else {
    checkbox1.checked = false;
    checkbox2.checked = true;
    inputType.value = 2;
    expiryDiv.style.display = "";

  }
}
function toggleConfirm(identifier) {
	var expiryDiv = document.getElementById(identifier);
	if(expiryDiv.style.display == "none") {
	  expiryDiv.style.display = "";
	} else {
	  expiryDiv.style.display = "none";
	}
}
function popUp(URL) {
   window.open(URL, '', 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=800,height=600');
}

var msgSelectionColour = "#7486B4";
var originalMsgSelectionColour;
function selectMsgRow(row) {
	if(row != null) {
		originalMsgSelectionColour = row.parentNode.style.backgroundColor;
		row.parentNode.style.backgroundColor = msgSelectionColour;
	}
}
function deselectMsgRow(row) {
	if(row != null) {
		row.parentNode.style.backgroundColor = originalMsgSelectionColour;
	}
}


/**
 * Funckja przekierowujaca strone do podanego adresu.
 */
function redirect(toLocation) {
  window.location = toLocation;
}
/* End of login functions */

/* Admin panel functions */
var currentlyExpanded = 0;

function toggleAdminOption(option) {
	var index = 1;
	var subDiv = document.getElementById("so_"+option+"_"+index);
	/*var debug = "";
	for(keys in subDiv.style) {
		debug += "[" + keys + "] = [" + subDiv.style[keys] + "]\n";
	}
	alert("DEBUG: so_" + option + "_" + index + "\n" + debug);*/
	var isExpanded;

	if(subDiv != null) {
		//alert("Style.display: "+(subDiv.style.display == ""));
		if(subDiv.style.display != "") {
			isExpanded = (subDiv.style.display == "none" ? false : true);

		} else {
			isExpanded = false;
		}
	} else {
		isExpanded = false;
	}

	if(currentlyExpanded > 0) {
		var expDiv;
		while((expDiv = document.getElementById("so_"+currentlyExpanded+"_"+index)) != null) {
			expDiv.style.display = "none";
			index += 1;
		}
	}

	index = 1;
	while((subDiv = document.getElementById("so_"+option+"_"+index)) != null) {
		subDiv.style.display = (isExpanded ? "none" : "block");
		currentlyExpanded = (isExpanded ? 0 : option);
		index += 1;
	}
}

//
var originalBackground;
function highlight(element) {
	originalBackground = element.style.backgroundColor;
	element.style.backgroundColor = "#7486B4";
}

function dehighlight(element) {
	element.style.backgroundColor = originalBackground;
}

function toogleAccountBlock(positive, negative, block, unblock) {
	var div = document.getElementById("account_block");
	var blocker = document.getElementById("account_blocker");
	var hiddenInput = document.getElementById("hidden_account_block");

	if(div.childNodes[0].nodeValue == negative) {
		div.childNodes[0].nodeValue = positive;
		hiddenInput.value = 1;
		blocker.childNodes[0].nodeValue = unblock;
 	}
	else {
		div.childNodes[0].nodeValue = negative;
		hiddenInput.value = 0;
		blocker.childNodes[0].nodeValue = block;
	}

}

function toogleAccountPlatinum(positive, negative, block, unblock) {
	var div = document.getElementById("account_platinum");
	var blocker = document.getElementById("account_switcher");
	var hiddenInput = document.getElementById("hidden_account_platinum");

	if(div.childNodes[0].nodeValue == negative) {
		div.childNodes[0].nodeValue = positive;
		hiddenInput.value = 1;
		blocker.childNodes[0].nodeValue = unblock;
 	}
	else {
		div.childNodes[0].nodeValue = negative;
		hiddenInput.value = 0;
		blocker.childNodes[0].nodeValue = block;
	}

}

function accountPlatinumSwitch(positive, negative, block, unblock) {
	toogleAccountPlatinum(positive, negative, block, unblock);
	var div = document.getElementById("account_platinum");
	var tr = document.getElementById("platinum_expiry_row");

	if(div.childNodes[0].nodeValue == negative) {
		tr.style.display = "none";
	} else {
		tr.style.display = "table-row";
	}
}

function toggleAccountDelConfirmation() {
	var qDiv = document.getElementById("confirm_div");
	var isExpanded;

	if(qDiv != null) {
		if(qDiv.style.display != "") {
			isExpanded = (qDiv.style.display == "none" ? false : true);
		} else {
			isExpanded = false;
		}

		if(!isExpanded) {
			qDiv.style.display = "block";
		} else {
			qDiv.style.display = "none";
		}
	}
}

function toggleProfileDelConfirmation() {
	var qDiv = document.getElementById("confirm_div");
	var isExpanded;

	if(qDiv != null) {
		if(qDiv.style.display != "") {
			isExpanded = (qDiv.style.display == "none" ? false : true);
		} else {
			isExpanded = false;
		}

		if(!isExpanded) {
			qDiv.style.display = "block";
		} else {
			qDiv.style.display = "none";
		}
	}
}

function toggleJobDelConfirmation() {
	var qDiv = document.getElementById("confirm_div");
	var isExpanded;

	if(qDiv != null) {
		if(qDiv.style.display != "") {
			isExpanded = (qDiv.style.display == "none" ? false : true);
		} else {
			isExpanded = false;
		}

		if(!isExpanded) {
			qDiv.style.display = "block";
		} else {
			qDiv.style.display = "none";
		}
	}
}

function toggleCompanyDataDiv() {
	var qDiv = document.getElementById("company_data_div");
	var isExpanded;

	if(qDiv != null) {
		if(qDiv.style.display != "") {
			isExpanded = (qDiv.style.display == "none" ? false : true);
		} else {
			isExpanded = false;
		}

		if(!isExpanded) {
			qDiv.style.display = "block";
		} else {
			qDiv.style.display = "none";
		}
	}
}
function toggleCategoryDelConfirmation() {
	var qDiv = document.getElementById("confirm_div");
	var isExpanded;

	if(qDiv != null) {
		if(qDiv.style.display != "") {
			isExpanded = (qDiv.style.display == "none" ? false : true);
		} else {
			isExpanded = false;
		}

		if(!isExpanded) {
			qDiv.style.display = "block";
		} else {
			qDiv.style.display = "none";
		}
	}
}
function toogleProfileLogo(positive, negative, off, on) {
	var indicator = document.getElementById("profile_use_logo");
	var switcher = document.getElementById("profile_logo_switcher");
	var hiddenInput = document.getElementById("company_using_logo");

	if(indicator.childNodes[0].nodeValue == negative) {
		indicator.childNodes[0].nodeValue = positive;
		hiddenInput.value = 1;
		switcher.childNodes[0].nodeValue = on;
 	}
	else {
		indicator.childNodes[0].nodeValue = negative;
		hiddenInput.value = 0;
		switcher.childNodes[0].nodeValue = off;
	}
}
function toggleAddCatDiv() {
	var div = document.getElementById("new_cat_div");
	if(div.style.display == "none" || div.style.display == null) {
		div.style.display = "block";
	} else {
		div.style.display = "none";
	}
}

function generatePassword(len) {
	var box = document.getElementById("account_pass").childNodes[0];
	var pass = "";

	for(var i = 0; i < len; ++i) {
		var rand = Math.random();
		pass += (rand  <= 0.33 ? String.fromCharCode((Math.round(rand * 100) % 26) + 65) :
						 (rand <= 0.66 ? String.fromCharCode((Math.round(rand * 100) % 26) + 97) :
							(Math.round(rand * 100) % 10) + ""));
	}
	box.value = pass;
}

function fireSubmitAccountDelete() {
	var delForm = document.getElementById("delete_form");
	delForm.submit();
}

function fireSubmitAccountUpdate() {
	var updForm = document.getElementById("update_form");
	updForm.submit();
}

function fireSubmitAccountCreate() {
	var crtForm = document.getElementById("create_form");
	crtForm.submit();
}

function fireSubmitProfileDelete() {
	var delForm = document.getElementById("delete_form");
	delForm.submit();
}

function fireSubmitProfileUpdate() {
	var updForm = document.getElementById("update_form");
	updForm.submit();
}

function fireSubmitProfileDescUpdate() {
	var updForm = document.getElementById("desc_update_form");
	updForm.submit();
}

function fireSubmitProfileCatUpdate() {
	var updForm = document.getElementById("cat_update_form");
	updForm.submit();
}

function fireSubmitProfileCreate() {
	var updForm = document.getElementById("create_form");
	updForm.submit();
}

function fireSubmitCatCreation() {
	var updForm = document.getElementById("new_cat_form");
	updForm.submit();
}

function fireSubmitCategoryRecDelete() {
	var delForm = document.getElementById("delete_form");
	var hiddenInput = document.getElementById("cat_recursive_del");
	hiddenInput.value = 1;
	delForm.submit();
}

function fireSubmitCategoryUpdate() {
	var updForm = document.getElementById("update_cat_form");
	updForm.submit();
}
function fireSubmitCategoryDelete() {
	var delForm = document.getElementById("delete_form");
	var hiddenInput = document.getElementById("cat_recursive_del");
	hiddenInput.value = 0;
	delForm.submit();
}

var originalLanguageTdBackground;
function selectLanguageVersion(srcTd) {

	originalLanguageTdBackground = srcTd.style.backgroundColor;
	srcTd.style.backgroundColor = "#84C2D2";
}
function deselectLanguageVersion(srcTd) {
	srcTd.style.backgroundColor = originalLanguageTdBackground;
}
function changeLanguageVersion(srcId) {
	var i = 0;
	var section = null;
	var debug = "";
	while((section = document.getElementById("lang_section_" + i)) != null) {
		originalLanguageTdBackground = "#EEEEEE";
		if(srcId == i) {
			document.getElementById("lang_menu_" + i).style.backgroundColor = "#EEEEEE";
			document.getElementById("lang_menu_" + i).style.borderWidth = "1px 1px 0px 1px";
			section.style.display = "";

		} else {
			document.getElementById("lang_menu_" + i).style.backgroundColor = "#AAAAAA";
			document.getElementById("lang_menu_" + i).style.borderWidth = "1px";
			section.style.display = "none";
		}

		i += 1;
	}

	//document.getElementById("lang_menu_1").style.width = "90px";
	//alert(debug);
}
function changeOwnerLanguageVersion(srcId, sectionId) {
	var i = 0;
	var section = null;
	var debug = "";
	while((section = document.getElementById("lang_owner" + sectionId + "_section_" + i)) != null) {
		originalLanguageTdBackground = "#EEEEEE";
		if(srcId == i) {
			document.getElementById("lang_owner" + sectionId + "_menu_" + i).style.backgroundColor = "#EEEEEE";
			document.getElementById("lang_owner" + sectionId + "_menu_" + i).style.borderWidth = "1px 1px 0px 1px";
			section.style.display = "";

		} else {
			document.getElementById("lang_owner" + sectionId + "_menu_" + i).style.backgroundColor = "#AAAAAA";
			document.getElementById("lang_owner" + sectionId + "_menu_" + i).style.borderWidth = "1px";
			section.style.display = "none";
		}

		i += 1;
	}
}
function switchOfferType() {
  var switcher = document.getElementById("offer_type_switcher");
  var seekDiv = document.getElementById("seeked_price_div");
  var offerDiv = document.getElementById("offered_price_div");

  if(switcher.selectedIndex == 0) {//oferta kupna
    seekDiv.style.display = "";
    offerDiv.style.display = "none";
  } else {//oferta sprzedazy
    seekDiv.style.display = "none";
    offerDiv.style.display = "";
  }
}
function fireCategoriesImgRefresh() {
	var theForm = document.getElementById("company_mass_contact");
	var submitInput = document.getElementById("contact_submit_input");
	var refreshInput = document.getElementById("captcha_refresh_input");
	
	submitInput.value = 0;
	refreshInput.value = 1;
	theForm.submit();
}

function fireProfileImgRefresh() {
	var theForm = document.getElementById("profiles_contact_form");
	var submitInput = document.getElementById("contact_submit_input");
	var refreshInput = document.getElementById("captcha_refresh_input");
	
	submitInput.value = 0;
	refreshInput.value = 1;
	theForm.submit();
}

function fireOfferImgRefresh() {
	var theForm = document.getElementById("offers_contact_form");
	var submitInput = document.getElementById("contact_submit_input");
	var refreshInput = document.getElementById("captcha_refresh_input");
	
	submitInput.value = 0;
	refreshInput.value = 1;
	theForm.submit();
}


function fireRWordAction(actionType, actionContent) {
	var theForm = document.getElementById("rword_form");
	var typeElement = document.getElementById("rword_action_type");
	var contentElement = document.getElementById("rword_action_content");
	
	typeElement.value = actionType;
	contentElement.value = (actionType == "add" ? document.getElementById("entered_rword").value : actionContent);
	theForm.submit();
}

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
    else
        countfield.value = maxlimit - field.value.length;
}

function handleEnter(field, event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13) {
        return false;
    }
    else
        return true;
}      
