
//-------------------------------------------------------------
top.window.moveTo(0,0);
if (document.all) { top.window.resizeTo(screen.availWidth,screen.availHeight); }
else if (document.layers||document.getElementById)
	{
	if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
		{
		top.window.outerHeight = screen.availHeight;
		top.window.outerWidth = screen.availWidth;
		}
	}
//-------------------------------------------------------------
function print(str){ open("print.php?id="+str, "", 'toolbar=0,menubar=1,scrollbars=1,status=0,resizable=0,width=600,height=550,left=0,top=0');}
function printall(str){ open("print.php?term="+str, "", 'toolbar=0,menubar=1,scrollbars=1,status=0,resizable=0,width=600,height=550,left=0,top=0');}
function tran(str,lan){ open("tran.php?term="+str+"&lan="+lan, "", 'toolbar=0,menubar=1,scrollbars=1,status=0,resizable=0,width=600,height=550,left=0,top=0');}

//-------------------------------------------------------------
function highlight(x,y){document.forms[x].elements[y].select()}

//-------------------------------------------------------------
function iscorrect(form)
	{
	var pattern=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-zA-Z]{2,4}|\d+){1,3}$/i;
	var rval=pattern.test(form.email.value);
	if (form.name.value=="")
		{
		alert("Please enter your name before submit.");
		form.name.select();
		rval=false;
		}
	else if (rval==false)
		{
		alert("Please enter a valid email address.");
		form.email.select();
		}
	else if (form.comments.value=="")
		{
		alert("Please write your comments before submit.");
		form.comments.select();
		rval=false;
		}
	return rval;
	}

//-------------------------------------------------------------
var http = getHTTPObject();

function getHTTPObject() {
	var xmlhttp;
	if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
	else if (window.ActiveXObject)
		{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if (!xmlhttp) xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	return xmlhttp;
	}

function Showlist(divID) {
		document.getElementById('loading').style.visibility='visible';
		var sTerm = encodeURIComponent(document.getElementById("search").value);
		http.open("GET", "find.php?search="+ sTerm, true);
		http.onreadystatechange = function () {	
			if (http.readyState==4 && http.status==200) {
				var results=http.responseText;
				document.getElementById(divID).innerHTML = results;
				document.getElementById('loading').style.visibility='hidden';
				document.getElementById(divID).scrollTop=0;
  				}
			};
		http.send(null);
		}

function Show(url,divID) {
		hidebox();//hide email box if visible
		document.getElementById('loading').style.visibility='visible';
		http.open('GET', url, true);
		http.onreadystatechange = function () {	
			if (http.readyState==4 && http.status==200) {
				var results=http.responseText;
				document.getElementById(divID).innerHTML = results;
				document.getElementById('loading').style.visibility='hidden';
				document.getElementById(divID).scrollTop=0;
  				}
			};
		http.send(null);
		}

function Send() {
		document.getElementById('sendstatus').innerHTML='Sending...';
		document.getElementById('sending').style.visibility='visible';
		var sName = document.contact.name.value;
		var sEmail = document.contact.email.value;
		for (i=0; i<document.contact.subject.length; i++)
			if (document.contact.subject[i].checked==true) {
				if (i==0) {var sSubject='[PSDic] Technical Suggestion'; }
				else if (i==1) {var sSubject='[PSDic] Suggest a new term or definition'; }
				else if (i==2) {var sSubject='[PSDic] Other'; }
				}
		var sComments = document.contact.comments.value;
		http.open('GET', 'sendcomments.php?name='+sName+'&email='+sEmail+'&subject='+sSubject+'&comments='+sComments, true);
		http.onreadystatechange = function () {	
			if (http.readyState==4 && http.status==200) {
				var results=http.responseText;
				document.getElementById('sendstatus').innerHTML=results;
				document.getElementById('sending').style.visibility='hidden';
				document.contact.name.value='';
				document.contact.email.value='';
				document.contact.comments.value='';
				document.contact.subject[0].checked=true;
  				}
			};
		http.send(null);
		}
//-------------------------------------------------------------
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns4 = (document.layers && !dom) ? true : false
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

function showhint(menucontents, obj, e, tipwidth){
if (/*(ie||ns6) && */document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=(ns4||ns5)? e.pageX: window.event.clientX + document.body.scrollLeft;
dropmenuobj.y=(ns4||ns5)? e.pageY: window.event.clientY + document.body.scrollTop;
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

// ---------

function getmail(id, term, obj, e){
if (/*(ie||ns6) && */document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML='<form><center><b>Send This Term to a Friend</b><br><table border=0><tr><td align=right nowrap>Your name:</td><td align=left><input name="fname" type=text size=20 class=frm /></td></tr><tr><td align=right nowrap>Your friend\'s email:</td><td align=left><input name="fmail" type=text size=20 class=frm /></td></tr></table><div id="emailsent">&nbsp;</div><input type=button value="Send" onclick="sendmail(\''+id+'\',\''+term+'\',this.form)" class=btn /><br>[<a href=# onclick=hidebox()>close</a>]</center></form>'
dropmenuobj.style.left=dropmenuobj.style.top=-500
dropmenuobj.x=(ns4||ns5)? e.pageX: window.event.clientX + document.body.scrollLeft;
dropmenuobj.y=(ns4||ns5)? e.pageY: window.event.clientY + document.body.scrollTop;
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
}
}

function hidebox(){
if ((ie||ns6) && document.getElementById("hintbox")) document.getElementById("hintbox").style.visibility="hidden"
}

function sendmail(id,term,form)
	{
	var pattern=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-zA-Z]{2,4}|\d+){1,3}$/i;
	var rval=pattern.test(form.fmail.value);
	if (form.fname.value=="")
		{
		alert("Please enter your name before submit.");
		form.fname.select();
		return false;
		}
	else if (rval==false)
		{
		alert("Please enter a valid email address.");
		form.fmail.select();
		return false;
		}
	document.getElementById('emailsent').innerHTML = 'Sending...';
	document.getElementById('sending').style.visibility='visible';
	var url='sendmail.php?term='+term;
	if (id!='') url+='&id='+id;
	url+='&email='+form.fmail.value+'&name='+form.fname.value;
	http.open('GET', url, true);
	http.onreadystatechange = function () {	
		if (http.readyState==4 && http.status==200) {
			var results=http.responseText;
			document.getElementById('emailsent').innerHTML = results;
			document.getElementById('sending').style.visibility='hidden';
			form.fname.value='';
			form.fmail.value='';
 			}
		};
	http.send(null);
	}

function reportmissedterm(missedterm)
	{
	document.getElementById('termsent').innerHTML = 'Reporting missed term...';
	document.getElementById('sending').style.visibility='visible';
	var url='reportterm.php?missedterm='+encodeURIComponent(missedterm);
	http.open('GET', url, true);
	http.onreadystatechange = function () {	
		if (http.readyState==4 && http.status==200) {
			var results=http.responseText;
			document.getElementById('termsent').innerHTML = results;
			document.getElementById('sending').style.visibility='hidden';
 			}
		};
	http.send(null);
	}

//-----------------------------------------------------------------------
