hideTendTimer=false;

function createTendina()
{
	myTend = document.createElement("div");
	myTend.id = "tendina";
	document.body.appendChild(myTend);
}

function showTendina(mySwitch,myTxt)
{
	if (!document.getElementById("tendina")) {createTendina();}
	if (hideTendTimer) {clearTimeout(hideTendTimer);}

	myTendina = document.getElementById("tendina");
	myTendina.innerHTML='';
	myTd = mySwitch.parentNode;

	myTd.getElementsByClassName = getElementsByClassName;
	myItems = myTd.getElementsByClassName("tendinaItems");
	for (i=0; i<myItems.length; i++)
	{
		tempA = document.createElement("a");
		tempA.href = "javascript:openPopup('" +myItems[i].title+ "')";
		tempA.title = "View " +myTxt;
		document.getElementById("tendina").appendChild(tempA);
		tempA.appendChild( document.createTextNode(myItems[i].innerHTML) );
	}
	if (myItems==0) {document.getElementById("tendina").appendChild( document.createTextNode("[no " +myTxt+ "s]") );}
	mySwitch.findPos = findPos;
		mySwitch.findPos();
	myTendina.style.display='block';
	myTendina.style.top = mySwitch.posTop + 15 + "px";
	myTendina.style.left = mySwitch.posLeft + "px";

	mySwitch.onblur=hideTendina;
}

function hideTendina()
{
	// Set a little delay to prevent the div to be hidden before the browser fires the link!
	hideTendTimer = setTimeout("myTendina.style.display='none';",200);
}

function showHideMsg(what2do,recipientID,replyID,targetID)
{
	/** ARGUMENTS:
	*	what2do=1		=> SHOW EVERYTHING
	*		what2do=2	=> HIDE EVERYTHING
	*	recipientID 	=> ID of message recipient (TO:)
	*	replyID			=> ID of message to reply to ('' if none)
	*	targetID			=> ID of resume/job of interest ('' if none)
	*/
	
	/* THIS is the current Window object, or the Opener Window object, when this function is called from a popup */
	myIframe = document.getElementById("msgIframe");
	myDiv = document.getElementById("msgDiv");
	mySpan = document.getElementById("msgSpan");

	currTop = (this.innerHeight) ? this.pageYOffset : ( (document.documentElement && document.documentElement.scrollTop) ? this.document.documentElement.scrollTop : ((document.body) ? this.document.body.scrollTop : "") );

	/*** Height of the current window's inner area: IE=document.documentElement.clientHeight, Moz=document.body.clientHeight; ***/
	/*** Height of the whole page content: IE=document.body.scrollHeight, Moz=document.documentElement.scrollHeight; ***/
	myWinHeight = (document.all) ? this.document.body.scrollHeight : this.document.documentElement.scrollHeight;
	myWinWidth = (document.all) ? this.document.body.scrollWidth : this.document.documentElement.scrollWidth-16;
	
	if (what2do == 2) {
		myIframe.style.display="none";
		myDiv.style.display="none";
		mySpan.style.display="none";
		mySpan.src="";
	}
	else // Show everything
	{
		mySpan.src='../tpl/mail_msgForm.php?recipient_id=' +recipientID+ '&reply_id=' +replyID+ '&target_id=' +targetID;
	
		// First of all, let's prepare the Iframe (for select-one fields and other Iframes to stay on the background)
		myIframe.style.filter = "alpha(opacity=0)";
		myIframe.style.MozOpacity = 0;
		myIframe.style.opacity = 0;
		myIframe.style.height = myWinHeight + "px";
		myIframe.style.width = myWinWidth + "px";

		// Then, prepare Div and Span (the inner Iframe)
		myDiv.style.filter = "alpha(opacity=60)";
		myDiv.style.MozOpacity = 0.6;
		myDiv.style.opacity = 0.6;
		myDiv.style.height = myIframe.style.height;

		if (mySpan.parentNode != document.body) {
			mySpan.parentNode.removeChild(mySpan); //Move the inner Iframe from wherever it is...
			document.body.appendChild(mySpan); //To the body
		}
		mySpan.style.left = (myWinWidth/2 - 350) + "px";
		mySpan.style.top = (currTop+30) + "px";

		// Finally, show everything
		myIframe.style.display="block";
		myDiv.style.display="block";
		mySpan.style.display="block";
	}
}
document.write('<iframe id="msgIframe"></iframe> <div id="msgDiv"></div> <iframe id="msgSpan" name="msgSpan" frameborder="0" border="0" scrolling="no" src=""></iframe>');
