/********************************************************************************
*      Script: iyfrsf_js.js
* Description: Several common routines 
*    Comments: 
*     Created: 01/23/2008 [CLC]
*    Modified:
*********************************************************************************/

/********************************************************************************/
// function reverse_string
// Reverse a string; abcd becomes dcba 
/********************************************************************************/                                    
function reverse_string() {
   if (this.length <= 1) return this;
	var reversestring = "";
   for (var x = 0; x < this.length; x++) {
      reversestring = this.charAt(x) + reversestring;
   }
   return reversestring;
} //reverse_string
String.prototype.reverse = reverse_string


/********************************************************************************/
// function FixMail
// This function derives the correct e-mail for an e-mail link when the user clicks on the link to send.
// The 'onclick' option of each of these links passes the real name and system address written in
// reverse which tells us which real address to send the message to.  the calling code for this is...
// <A href="mailto:<spamtrap@somesystem>" onclick="FixMail(this,'<reversename>','<reverseatvalue>','<subject>');">
/********************************************************************************/
function FixMail(email, faketoname, fakeatname, subject) {
	var oldemail;
	var realtoname;
	var realatname;
	oldemail = email.href;
// reverse the order to give us our real value here.
	realtoname = faketoname.reverse();
	realatname = fakeatname.reverse();
	var atsign = "@";
// Set the correct hyperlink e-mail address
	if (subject.length >= 0) {
	   email.href = "mailto:" + realtoname + atsign + realatname + '?Subject=' + subject; }
	else {
		email.href = "mailto:" + realtoname + atsign + realatname; }
// for debuging....
//	alert("Fake E-mail address was ... \n   " + oldemail + "\n\n\n" +
//			"Real E-mail address is  ... \n   " + email.href);
	return true;             // make it work...
} // FixMail


/********************************************************************************/
// openWindow
// Open a small window (no chrome)
/********************************************************************************/
function openWindow(url,w,h) {
	Version=navigator.appVersion;
	var showpic=null;
	w=w+20;
	h=h+30;
	showpic =
window.open(url,"Image",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,'+'width='+w+',height='+h);
	if ((Version.substring(0,1)>= 3) && (Version.indexOf("MSIE") == -1)) {
        showpic.focus();
	}
} // openWindow
