function insertForm(formname, taget_url, hist_back_site){
	/* debug 
	blub = 'Name: ' + formname + '\nTarget: ' + taget_url + '\nHistory_url: ' + hist_back_site;
	alert(blub);
	return false;
	*/
	document.forms[formname].history_url.value = hist_back_site;
	document.forms[formname].action = taget_url;
	document.forms[formname].submit();
}

function minmax(divId) {
	divObj = document.getElementById(divId);
	divObj.style.display == 'none' ? divObj.style.display = 'block' : divObj.style.display = 'none';
	return false;
} // end function minmax    

function Go(x) {
	if(x == "nothing") {
        	document.forms[0].reset();
		document.forms[0].elements[0].blur();
		return;
	} else {
		window.location.href = x;
		document.forms[0].reset();
		document.forms[0].elements[0].blur();
	} // if
} // function


/**
* Handles challenge/response login (CHAP)
*
* Sets the response value of login form and deletes the password entry
* Note: fields must be identified as
*  - username (text input field for username)
*  - password (text input field for password)
*  - response (hidden field for calculated string)
*  - challenge (hidden field for unique seed)
* Note: the form has to be identified as 'login_form'
*
* @access   public
*/
function doChallengeResponse() {

	response = document.getElementById('username').value + ':' +
	hex_md5(document.getElementById('password').value) + ":" +
	document.getElementById('challenge').value;
	// set response
	document.getElementById('response').value = hex_md5(response);
	document.getElementById('password').value = "";
	document.getElementById('login_form').submit();
} // end function doChallengeResponse



/**
 * Opens a pop up window
 *
 * @param   string  url
 * @param   integer width
 * @param   integer height
 * @param   string  title
 * @return  boolean
*/
function popup(url) {

  var width = (arguments.length > 1) ? parseInt(arguments[1]) : 620;
  var height = (arguments.length > 2) ? parseInt(arguments[2]) : 380;
  var title = (arguments.length > 3) ? arguments[3] : '';
  var props = "width=" + width + ",height=" + height + ",resizable=yes,menubar=no,locationbar=no,status=no,scrollbars=auto,depend=yes,left=10,top=10";
  var popup;

  if (popup = window.open(url, title, props)) {

    popup.focus();
    return true;
  }

  return false;
} // end function popupwindow


