function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function order_data(data,pathid,pathfile) {
     req_order = Inint_AJAX();
     req_order.open('POST',pathfile,true);
     req_order.onreadystatechange = function() {
	  if (req_order.readyState == 4) {
          if (req_order.status == 200) {         
               document.getElementById(pathid).innerHTML=req_order.responseText; 
          }
     }
	 }
	 
	 req_order.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
     req_order.send(data);
};

function del(){	if (window.confirm("คุณต้องการลบ ใช่หรือไม่ ?")) return true;else return false; } 

function checked_form_reg_org() {			
			if(document.sent.name_contact.value=="") {alert("กรุณากรอก ชื่อ-นามสกุล ผู้ติดต่อ ให้ถูกต้อง") ;document.sent.name_contact.focus() ;
			return false ;
			}else  if(document.sent.name_organization.value=="") {alert("กรุณากรอก ชื่อองค์กร/บริษัท ให้ถูกต้อง") ;document.sent.name_organization.focus() ;
			return false ;
			}else  if(document.sent.address.value=="") {alert("กรุณากรอก ที่อยู่องค์กร ให้ถูกต้อง") ;document.sent.address.focus() ;
			return false ;
			}else  if(document.sent.province.value =="0") {alert("กรุณาเลือก จังหวัด ให้ถูกต้อง") ;document.sent.province.focus()  ;
			return false ;
			}else  if(document.sent.phone.value=="") {alert("กรุณากรอก เบอร์โทรที่ติดต่อ ให้ถูกต้อง") ;document.sent.phone.focus() ;
			return false ;
			}else  if(document.sent.email.value=="") {alert("กรุณากรอก  อีเมล์ ให้ถูกต้อง") ;document.sent.email.focus() ;
			return false ;
			}else  if(document.sent.password1.value=="") {alert("กรุณากรอก รหัสผ่าน ให้ถูกต้อง") ;document.sent.password1.focus() ;
			return false ;
			}else  if(document.sent.password2.value != document.sent.password1.value) {alert("กรุณายืนยันรหัสผ่านให้ถูกต้อง") ;document.sent.password2.focus()  ;
			return false ;
			}else{
			return true ;
			}
}
	function checked_add_announcements() {			
			if(document.postmodify.sub_main_menu_id.value=="0") {alert("กรุณาเลือก หมวดย่อ ให้ถูกต้อง") ;document.postmodify.sub_main_menu_id.focus() ;
			return false ;
			}else  if(document.postmodify.title.value=="") {alert("กรุณากรอก หัวข้อประกาศ ให้ถูกต้อง") ;document.postmodify.title.focus() ;
			return false ;
			}else  if(document.postmodify.description.value=="") {alert("กรุณากรอกรายละเอียดการประกาศ ให้ถูกต้อง") ;document.postmodify.description.focus() ;
			return false ;
			}else{
			return true ;
			}
}	
function checked_add_job() {			
			if(document.postmodify.title.value=="") {alert("กรุณากรอก หัวข้อประกาศ ให้ถูกต้อง") ;document.postmodify.title.focus() ;
			return false ;
			}else  if(document.postmodify.contact.value=="") {alert("กรุณากรอก ผู้ลงประกาศ ให้ถูกต้อง") ;document.postmodify.contact.focus() ;
			return false ;
			}else{
			return true ;
			}
}	
	function checked_add_board() {			
			if(document.postmodify.title.value=="") {alert("กรุณากรอก หัวข้อกระทู้ ให้ถูกต้อง") ;document.postmodify.title.focus() ;
			return false ;
			}else  if(document.postmodify.message.value=="") {alert("กรุณากรอก รายละเอียดกระทู้ ให้ถูกต้อง") ;document.postmodify.message.focus() ;
			return false ;
			}else  if(document.postmodify.name.value=="") {alert("กรุณากรอก ชื่อผู้แต่งกระทู้ ให้ถูกต้อง") ;document.postmodify.name.focus() ;
			return false ;
			}else  if(document.postmodify.num.value=="") {alert("กรุณากรอก ตอบปัญหาโจทย์ ให้ถูกต้อง") ;document.postmodify.num.focus() ;
			return false ;
			}else{
			return true ;
			}
}

function checked_add_file() {			
			if(document.postmodify.title.value=="") {alert("กรุณากรอก ชื่อเอกสาร ให้ถูกต้อง") ;document.postmodify.title.focus() ;
			return false ;
			}else  if(document.postmodify.name.value=="") {alert("กรุณากรอก ผู้โฟส ให้ถูกต้อง") ;document.postmodify.name.focus() ;
			return false ;
			}else  if(document.postmodify.num.value=="") {alert("กรุณากรอก ตอบปัญหาโจทย์ ให้ถูกต้อง") ;document.postmodify.num.focus() ;
			return false ;
			}else{
			return true ;
			}
}

function checked_add_position() {			
			if(document.sent.category.value=="0") {alert("กรุณาเลือก หมวด ให้ถูกต้อง") ;document.sent.category.focus() ;
			return false ;
			}else  if(document.sent.name_position.value=="") {alert("กรุณากรอก ตำแหน่งงานที่ต้องการประกาศ ให้ถูกต้อง") ;document.sent.name_position.focus() ;
			return false ;
			}else  if(document.sent.detail.value=="") {alert("กรุณากรอก รายละเอียดงาน ให้ถูกต้อง") ;document.sent.detail.focus() ;
			return false ;
			}else  if(document.sent.property.value=="") {alert("กรุณากรอก คุณสมบัติการสมัคร ให้ถูกต้อง") ;document.sent.property.focus() ;
			return false ;
			}else  if(document.sent.process.value=="") {alert("กรุณากรอก วิธีการสมัคร ให้ถูกต้อง") ;document.sent.process.focus() ;
			return false ;
			}else{
			return true ;
			}
}	

	function check_amp(value){
					if(value == "10"){
					document.sent.sub_province.disabled = false;
					}else{
					document.sent.sub_province[0].selected=true
					document.sent.sub_province.disabled = true;
					}
	}
	
function checked_add_app_personal() {			
			if(document.sent.name.value=="") {alert("กรุณากรอก ชื่อของคุณ ให้ถูกต้อง") ;document.sent.name.focus() ;
			return false ;
			}else  if(document.sent.lastname.value=="") {alert("กรุณากรอก นามสกุลของคุณ ให้ถูกต้อง") ;document.sent.lastname.focus() ;
			return false ;
			}else  if(document.sent.nationality.value=="") {alert("กรุณากรอก สัญชาติ  ให้ถูกต้อง") ;document.sent.nationality.focus() ;
			return false ;
			}else  if(document.sent.race.value=="") {alert("กรุณากรอก เชื้อชาติ ให้ถูกต้อง") ;document.sent.race.focus() ;
			return false ;
			}else  if(document.sent.religion.value=="") {alert("กรุณากรอก ศาสนา  ให้ถูกต้อง") ;document.sent.religion.focus() ;
			return false ;
			}else  if(document.sent.heigth.value=="") {alert("กรุณากรอก ส่วนสูง ให้ถูกต้อง") ;document.sent.heigth.focus() ;
			return false ;
			}else  if(document.sent.weigth.value=="") {alert("กรุณากรอก น้ำหนัก ให้ถูกต้อง") ;document.sent.weigth.focus() ;
			return false ;
			}else  if(document.sent.domicile.value=="") {alert("กรุณากรอก ภูมิลำเนาเดิม ให้ถูกต้อง") ;document.sent.domicile.focus() ;
			return false ;
			}else  if(document.sent.address.value=="") {alert("กรุณากรอก ที่อยู่ที่ติดต่อได้  ให้ถูกต้อง") ;document.sent.address.focus() ;
			return false ;
			}else  if(document.sent.province.value=="0") {alert("กรุณาเลือก จังหวัด  ให้ถูกต้อง") ;document.sent.province.focus() ;
			return false ;
			}else  if(document.sent.province.value == "10" && document.sent.sub_province.value == "0") {alert("กรุณาเลือก เขต  ให้ถูกต้อง") ;document.sent.sub_province.focus() ;
			return false ;
			}else  if(document.sent.phone.value=="") {alert("กรุณาเลือก วิธีการสมัคร ให้ถูกต้อง") ;document.sent.phone.focus() ;
			return false ;
			}else{
			return true ;
			}
}	


function years(num,time){
 
if(num !='')
document.sent.old.value = time - num ;
else
document.sent.old.value = '' ;
}

function checknew_password(){
			if(document.sent.password.value=="") {
				alert("กรุณากรอก รหัสผ่านเดิม ให้ถูกต้อง") ;document.sent.password.focus() ;
			return false ;
			}else if(document.sent.password_new.value == "") {
				alert("กรุณากรอก รหัสผ่านใหม่ ให้ถูกต้อง") ;document.sent.password_new.focus()  ;
			return false ;
			}else if(document.sent.password_new.value != document.sent.password_new1.value) {
				alert("กรุณายืนยันรหัสผ่านให้ถูกต้อง") ;document.sent.password_new1.focus()  ;
			return false ;
			}else{
			return true ;
			}
	}
	
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function myPopupRelocate() {
  var scrolledX, scrolledY;
  if( self.pageYOffset ) {
    scrolledX = self.pageXOffset;
    scrolledY = self.pageYOffset;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    scrolledX = document.documentElement.scrollLeft;
    scrolledY = document.documentElement.scrollTop;
  } else if( document.body ) {
    scrolledX = document.body.scrollLeft;
    scrolledY = document.body.scrollTop;
  }

  var centerX, centerY;
  if( self.innerHeight ) {
    centerX = self.innerWidth;
    centerY = self.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) 

{
    centerX = document.documentElement.clientWidth;
    centerY = document.documentElement.clientHeight;
  } else if( document.body ) {
    centerX = document.body.clientWidth;
    centerY = document.body.clientHeight;
  }

  var leftOffset = 500;
  var topOffset = scrolledY + (centerY +  650)/5;
  var leftOffset2 = 500;
  var topOffset2 = scrolledY + (centerY - 10)/2;


  document.getElementById("mypopup").style.top = topOffset + "px";
  document.getElementById("mypopup").style.left = leftOffset + "px";
   document.getElementById("mypopup2").style.top = topOffset2 + "px";
  document.getElementById("mypopup2").style.left = leftOffset2 + "px";
}

function fireMyPopup() {
  myPopupRelocate();
  document.getElementById("mypopup").style.display = "block";
  document.getElementById("mypopup2").style.display = "block";
  document.body.onscroll = myPopupRelocate;
  window.onscroll = myPopupRelocate;
}

function close() {
document.getElementById("mypopup").style.display="none";
}
function close2() {
document.getElementById("mypopup2").style.display="none";
}

var smf_formSubmitted = false;

// Define document.getElementById for Internet Explorer 4.
if (typeof(document.getElementById) == "undefined")
	document.getElementById = function (id)
	{
		// Just return the corresponding index of all.
		return document.all[id];
	}
// Define XMLHttpRequest for IE 5 and above. (don't bother for IE 4 :/.... works in Opera 7.6 and Safari 1.2!)
else if (!window.XMLHttpRequest && window.ActiveXObject)
	window.XMLHttpRequest = function ()
	{
		return new ActiveXObject(navigator.userAgent.indexOf("MSIE 5") != -1 ? "Microsoft.XMLHTTP" : "MSXML2.XMLHTTP");
	};

// Some older versions of Mozilla don't have this, for some reason.
if (typeof(document.forms) == "undefined")
	document.forms = document.getElementsByTagName("form");

// Load an XML document using XMLHttpRequest.
function getXMLDocument(url, callback)
{
	if (!window.XMLHttpRequest)
		return false;

	var myDoc = new XMLHttpRequest();
	if (typeof(callback) != "undefined")
	{
		myDoc.onreadystatechange = function ()
		{
			if (myDoc.readyState != 4)
				return;

			if (myDoc.responseXML != null && myDoc.status == 200)
				callback(myDoc.responseXML);
		};
	}
	myDoc.open('GET', url, true);
	myDoc.send(null);

	return true;
}

// Send a post form to the server using XMLHttpRequest.
function sendXMLDocument(url, content, callback)
{
	if (!window.XMLHttpRequest)
		return false;

	var sendDoc = new window.XMLHttpRequest();
	if (typeof(callback) != "undefined")
	{
		sendDoc.onreadystatechange = function ()
		{
			if (sendDoc.readyState != 4)
				return;

			if (sendDoc.responseXML != null && sendDoc.status == 200)
				callback(sendDoc.responseXML);
			else
				callback(false);
		};
	}
	sendDoc.open('POST', url, true);
	if (typeof(sendDoc.setRequestHeader) != "undefined")
		sendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	sendDoc.send(content);

	return true;
}

function textToEntities(text)
{
	var entities = "";
	for (var i = 0; i < text.length; i++)
	{
		if (text.charCodeAt(i) > 127)
			entities += "&#" + text.charCodeAt(i) + ";";
		else
			entities += text.charAt(i);
	}

	return entities;
}

// Open a new window.
function reqWin(desktopURL, alternateWidth, alternateHeight, noScrollbars)
{
	if ((alternateWidth && self.screen.availWidth * 0.8 < alternateWidth) || (alternateHeight && self.screen.availHeight * 0.8 < alternateHeight))
	{
		noScrollbars = false;
		alternateWidth = Math.min(alternateWidth, self.screen.availWidth * 0.8);
		alternateHeight = Math.min(alternateHeight, self.screen.availHeight * 0.8);
	}
	else
		noScrollbars = typeof(noScrollbars) != "undefined" && noScrollbars == true;

	window.open(desktopURL, 'requested_popup', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=' + (noScrollbars ? 'no' : 'yes') + ',width=' + (alternateWidth ? alternateWidth : 480) + ',height=' + (alternateHeight ? alternateHeight : 220) + ',resizable=no');

	// Return false so the click won't follow the link ;).
	return false;
}

// Remember the current position.
function storeCaret(text)
{
	// Only bother if it will be useful.
	if (typeof(text.createTextRange) != "undefined")
		text.caretPos = document.selection.createRange().duplicate();
}

// Replaces the currently selected text with the passed text.
function replaceText(text, textarea)
{
	// Attempt to create a text range (IE).
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
	{
		var caretPos = textarea.caretPos;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		caretPos.select();
	}
	// Mozilla text range replace.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text + end;

		if (textarea.setSelectionRange)
		{
			textarea.focus();
			textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put it on the end.
	else
	{
		textarea.value += text;
		textarea.focus(textarea.value.length - 1);
	}
}

// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea)
{
	// Can a text range be created?
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
	{
		var caretPos = textarea.caretPos, temp_length = caretPos.text.length;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;

		if (temp_length == 0)
		{
			caretPos.moveStart("character", -text2.length);
			caretPos.moveEnd("character", -text2.length);
			caretPos.select();
		}
		else
			textarea.focus(caretPos);
	}
	// Mozilla text range wrap.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var newCursorPos = textarea.selectionStart;
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text1 + selection + text2 + end;

		if (textarea.setSelectionRange)
		{
			if (selection.length == 0)
				textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
			else
				textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
			textarea.focus();
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put them on the end, then.
	else
	{
		textarea.value += text1 + text2;
		textarea.focus(textarea.value.length - 1);
	}
}

// Checks if the passed input's value is nothing.
function isEmptyText(theField)
{
	// Copy the value so changes can be made..
	var theValue = theField.value;

	// Strip whitespace off the left side.
	while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
		theValue = theValue.substring(1, theValue.length);
	// Strip whitespace off the right side.
	while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
		theValue = theValue.substring(0, theValue.length - 1);

	if (theValue == '')
		return true;
	else
		return false;
}

// Only allow form submission ONCE.
function submitonce(theform)
{
	smf_formSubmitted = true;
}
function submitThisOnce(form)
{
	// Hateful, hateful fix for Safari 1.3 beta.
	if (navigator.userAgent.indexOf('AppleWebKit') != -1)
		return !smf_formSubmitted;

	if (typeof(form.form) != "undefined")
		form = form.form;

	for (var i = 0; i < form.length; i++)
		if (typeof(form[i]) != "undefined" && form[i].tagName.toLowerCase() == "textarea")
			form[i].readOnly = true;

	return !smf_formSubmitted;
}

// Set the "inside" HTML of an element.
function setInnerHTML(element, toValue)
{
	// IE has this built in...
	if (typeof(element.innerHTML) != 'undefined')
		element.innerHTML = toValue;
	// Otherwise, try createContextualFragment().
	else
	{
		var range = document.createRange();
		range.selectNodeContents(element);
		range.deleteContents();
		element.appendChild(range.createContextualFragment(toValue));
	}
}

// Set the "outer" HTML of an element.
function setOuterHTML(element, toValue)
{
	if (typeof(element.outerHTML) != 'undefined')
		element.outerHTML = toValue;
	else
	{
		var range = document.createRange();
		range.setStartBefore(element);
		element.parentNode.replaceChild(range.createContextualFragment(toValue), element);
	}
}

// Get the inner HTML of an element.
function getInnerHTML(element)
{
	if (typeof(element.innerHTML) != 'undefined')
		return element.innerHTML;
	else
	{
		var returnStr = '';
		for (var i = 0; i < element.childNodes.length; i++)
			returnStr += getOuterHTML(element.childNodes[i]);

		return returnStr;
	}
}

function getOuterHTML(node)
{
	if (typeof(node.outerHTML) != 'undefined')
		return node.outerHTML;

	var str = '';

	switch (node.nodeType)
	{
	// An element.
	case 1:
		str += '<' + node.nodeName;

		for (var i = 0; i < node.attributes.length; i++)
		{
			if (node.attributes[i].nodeValue != null)
				str += ' ' + node.attributes[i].nodeName + '="' + node.attributes[i].nodeValue + '"';
		}

		if (node.childNodes.length == 0 && in_array(node.nodeName.toLowerCase(), ['hr', 'input', 'img', 'link', 'meta', 'br']))
			str += ' />';
		else
			str += '>' + getInnerHTML(node) + '</' + node.nodeName + '>';
		break;

	// 2 is an attribute.

	// Just some text..
	case 3:
		str += node.nodeValue;
		break;

	// A CDATA section.
	case 4:
		str += '<![CDATA' + '[' + node.nodeValue + ']' + ']>';
		break;

	// Entity reference..
	case 5:
		str += '&' + node.nodeName + ';';
		break;

	// 6 is an actual entity, 7 is a PI.

	// Comment.
	case 8:
		str += '<!--' + node.nodeValue + '-->';
		break;
	}

	return str;
}

// Checks for variable in theArray.
function in_array(variable, theArray)
{
	for (var i = 0; i < theArray.length; i++)
	{
		if (theArray[i] == variable)
			return true;
	}
	return false;
}

// Find a specific radio button in its group and select it.
function selectRadioByName(radioGroup, name)
{
	if (typeof(radioGroup.length) == "undefined")
		return radioGroup.checked = true;

	for (var i = 0; i < radioGroup.length; i++)
	{
		if (radioGroup[i].value == name)
			return radioGroup[i].checked = true;
	}

	return false;
}

// Invert all checkboxes at once by clicking a single checkbox.
function invertAll(headerfield, checkform, mask)
{
	for (var i = 0; i < checkform.length; i++)
	{
		if (typeof(checkform[i].name) == "undefined" || (typeof(mask) != "undefined" && checkform[i].name.substr(0, mask.length) != mask))
			continue;

		if (!checkform[i].disabled)
			checkform[i].checked = headerfield.checked;
	}
}

// Keep the session alive - always!
var lastKeepAliveCheck = new Date().getTime();
function smf_sessionKeepAlive()
{
	var curTime = new Date().getTime();

	// Prevent a Firefox bug from hammering the server.
	if (smf_scripturl && curTime - lastKeepAliveCheck > 900000)
	{
		var tempImage = new Image();
		tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=keepalive;" + curTime;
		lastKeepAliveCheck = curTime;
	}

	window.setTimeout("smf_sessionKeepAlive();", 1200000);
}
window.setTimeout("smf_sessionKeepAlive();", 1200000);

// Set a theme option through javascript.
function smf_setThemeOption(option, value, theme, cur_session_id)
{
	// Compatibility.
	if (cur_session_id == null)
		cur_session_id = smf_session_id;

	var tempImage = new Image();
	tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=jsoption;var=" + option + ";val=" + value + ";sesc=" + cur_session_id + (theme == null ? "" : "&id=" + theme) + ";" + (new Date().getTime());
}

function smf_avatarResize()
{
	var possibleAvatars = document.getElementsByTagName ? document.getElementsByTagName("img") : document.all.tags("img");

	for (var i = 0; i < possibleAvatars.length; i++)
	{
		if (possibleAvatars[i].className != "avatar")
			continue;

		var tempAvatar = new Image();
		tempAvatar.src = possibleAvatars[i].src;

		if (smf_avatarMaxWidth != 0 && tempAvatar.width > smf_avatarMaxWidth)
		{
			possibleAvatars[i].height = (smf_avatarMaxWidth * tempAvatar.height) / tempAvatar.width;
			possibleAvatars[i].width = smf_avatarMaxWidth;
		}
		else if (smf_avatarMaxHeight != 0 && tempAvatar.height > smf_avatarMaxHeight)
		{
			possibleAvatars[i].width = (smf_avatarMaxHeight * tempAvatar.width) / tempAvatar.height;
			possibleAvatars[i].height = smf_avatarMaxHeight;
		}
		else
		{
			possibleAvatars[i].width = tempAvatar.width;
			possibleAvatars[i].height = tempAvatar.height;
		}
	}

	if (typeof(window_oldAvatarOnload) != "undefined" && window_oldAvatarOnload)
	{
		window_oldAvatarOnload();
		window_oldAvatarOnload = null;
	}
}

function hashLoginPassword(doForm, cur_session_id)
{
	// Compatibility.
	if (cur_session_id == null)
		cur_session_id = smf_session_id;

	if (typeof(hex_sha1) == "undefined")
		return;
	// Are they using an email address?
	if (doForm.user.value.indexOf("@") != -1)
		return;

	// Unless the browser is Opera, the password will not save properly.
	if (typeof(window.opera) == "undefined")
		doForm.passwrd.autocomplete = "off";

	doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);

	// It looks nicer to fill it with asterisks, but Firefox will try to save that.
	if (navigator.userAgent.indexOf("Firefox/") != -1)
		doForm.passwrd.value = "";
	else
		doForm.passwrd.value = doForm.passwrd.value.replace(/./g, "*");
}

function hashAdminPassword(doForm, username, cur_session_id)
{
	// Compatibility.
	if (cur_session_id == null)
		cur_session_id = smf_session_id;

	if (typeof(hex_sha1) == "undefined")
		return;

	doForm.admin_hash_pass.value = hex_sha1(hex_sha1(username.toLowerCase() + doForm.admin_pass.value) + cur_session_id);
	doForm.admin_pass.value = doForm.admin_pass.value.replace(/./g, "*");
}

function ajax_indicator(turn_on)
{
	var indicator = document.getElementById("ajax_in_progress");
	if (indicator != null)
	{
		if (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("MSIE 7") == -1)
		{
			indicator.style.top = document.documentElement.scrollTop;
		}
		indicator.style.display = turn_on ? "block" : "none";
	}
}
		