
//--------------------------------------------------------//
function Show_ST()
{
	x=screen.width/2-150;
	y=screen.height/2-75;
	features='scrollbars=yes,width='+300+',height='+160+',top='+y+',left='+x;
	window.open("Members.cfm?Show_ST=1",'',features);
}
function Show_ST0()
{
	x=screen.width/2-150;
	y=screen.height/2-75;
	features='scrollbars=yes,width='+300+',height='+160+',top='+y+',left='+x;
	window.open("../Members.cfm?Show_ST=1",'',features);
}
// Handle PopUp Window
function openWinReqPassword(url) 
{
	x=screen.width/2-210;
	y=screen.height/2-110;
	popupWin = window.open(url,'new_page','width=430,height=220,top='+y+',left='+x+',toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no')
}
//--------------------------------------------------------//

//--------------------------------------------------------//
// Multiple Functions to handle element OnFocus event on Login form
function UnameFocus() 
 {
   document.getElementById('username').style.backgroundColor = '#FFF9EC'; //Make the textbox color lightyellow
   document.getElementById('lbluname').style.color = '#555555'; //Make the label text color black
   document.getElementById('lbluname').innerHTML = 'Username'; //On error raised textbox focus, assign label default text 
}
function Uname1Focus() 
 {
   document.getElementById('username').style.backgroundColor = '#FFF9EC'; //Make the textbox color lightyellow
   document.getElementById('lbluname').style.color = '#555555'; //Make the label text color black
   document.getElementById('lbluname').innerHTML = 'Username[Institute]'; //On error raised textbox focus, assign label default text 
}
function PassWordFocus() 
 {
   document.getElementById('password').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblpass').style.color = '#555555';
   document.getElementById('lblpass').innerHTML = 'Password';
}
// Handle Login Form Validation
function LoginValidate(LogForm) 
 {
   var LoginPass = LogForm.elements['password'].value;
   var LoginName = LogForm.elements['username'].value;
if (LoginName == "" && LoginPass == "") 
  {
     // Change the background color of the textbox,border as well as label text
     document.getElementById('username').style.backgroundColor='#FFF4F4'; 
     document.getElementById('username').style.border = '1px solid #CC0000';
     document.getElementById('lbluname').style.color = '#CC0000';
     document.getElementById('lbluname').innerHTML = 'Empty Field:';
     document.getElementById('password').style.backgroundColor='#FFF4F4'; 
     document.getElementById('password').style.border = '1px solid #CC0000';
     document.getElementById('lblpass').style.color = '#CC0000';
     document.getElementById('lblpass').innerHTML = 'Empty Field:';
     alert("Please fill in the empty fields.\n- Username\n- Password");
     return false;
}
// Check Username login
 if (LoginName == "") // if is empty/blank alert
  {
     alert("Please enter your username");
     document.getElementById('username').style.backgroundColor='#FFF4F4'; //Change the background color of the textbox
     document.getElementById('username').style.border = '1px solid #CC0000';
     document.getElementById('lbluname').style.color = '#CC0000';
     document.getElementById('lbluname').innerHTML = 'Empty Field:';
     return false;
  }
// Login Password
 if (LoginPass == "")
  {
     alert("Please enter your password");   
     document.getElementById('password').style.backgroundColor='#FFF4F4'; 
     document.getElementById('password').style.border = '1px solid #CC0000';
     document.getElementById('lblpass').style.color = '#CC0000';
     document.getElementById('lblpass').innerHTML = 'Empty Field:';
     return false;
  }
return true;
}

// Handle Request Password Form Validation
function ReqPassVal(ReqPass) 
 {
 // Email
var UserReqEMail = ReqPass.elements['email'].value;
 if (UserReqEMail == "")
  {
     alert("You must enter an email address");
     ReqPass.elements['email'].style.backgroundColor='#FFF9EC';
     return false;
  }
else if (!(UserReqEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not valid.\n Please enter a valid email address.");
    ReqPass.elements['email'].style.backgroundColor='#FFF9EC';
    return false ;
}
return true;
}

//--------------------------------------------------------//
// Multiple Functions to handle element OnFocus event on Contact form
function UnameContactFocus() 
 {
   document.getElementById('fname').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblconuname').style.color = '#000000';
   document.getElementById('lblconuname').innerHTML = 'Your name:'; 
}
function UemailContactFocus() 
 {
   document.getElementById('email').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblconemail').style.color = '#000000';
   document.getElementById('lblconemail').innerHTML = 'Email:';
}
function UcommentContactFocus() 
 {
   document.getElementById('comments').style.backgroundColor = '#FFF9EC'; 
   document.getElementById('lblcomment').style.color = '#000000';
   document.getElementById('lblcomment').innerHTML = 'Comments:';
}
// Handle Contact Form Validation
function ContactVal(ConForm) 
 {
 var FirstName = ConForm.elements['fname'].value;
 var UserEMail = ConForm.elements['email'].value;
 var ConComments = ConForm.elements['comments'].value;
if (FirstName == "" && UserEMail == "" && ConComments =="") 
  {
     // Change the background color of the textbox,border as well as label text
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Empty Field:';
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Empty Field:';
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Empty Field:';
     alert("Please fill in the empty fields.\n- Your name\n- Email\n- Comments");
     return false;
}
// Contact First name
 if (FirstName == "")
  {
     alert("You must enter your name");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Empty Field:';
     return false;
  }
// Allow only letters 
else if (FirstName.search(/^[A-Z ]+$/i) == -1) 
  {
     alert ("Your name contained numbers. Only alphabetic characters are allowed..\n Please try again.");
     document.getElementById('fname').style.backgroundColor='#FFF4F4'; 
     document.getElementById('fname').style.border = '1px solid #CC0000';
     document.getElementById('lblconuname').style.color = '#CC0000';
     document.getElementById('lblconuname').innerHTML = 'Illegal Char:';
     return false;
} 
 // Contact Email
 if (UserEMail == "")
  {
     alert("You must enter an email address");
     document.getElementById('email').style.backgroundColor='#FFF4F4'; 
     document.getElementById('email').style.border = '1px solid #CC0000';
     document.getElementById('lblconemail').style.color = '#CC0000';
     document.getElementById('lblconemail').innerHTML = 'Empty Field:';
     return false;
  }
else if (!(UserEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not valid.\n Please enter a valid email address.");
    document.getElementById('email').style.backgroundColor='#FFF4F4'; 
    document.getElementById('email').style.border = '1px solid #CC0000';
    document.getElementById('lblconemail').style.color = '#CC0000';
    document.getElementById('lblconemail').innerHTML = 'Invalid Email:';
    return false ;
}
 // Contact Comments Field
 if (ConComments == "")
  {
     alert("You must a comments or questions");
     document.getElementById('comments').style.backgroundColor='#FFF4F4'; 
     document.getElementById('comments').style.border = '1px solid #CC0000';
     document.getElementById('lblcomment').style.color = '#CC0000';
     document.getElementById('lblcomment').innerHTML = 'Empty Field:';
     return false;
  }
return true;
}

//--------------------------------------------------------//
// Handle Article Submission Form Validation
function ArticleSubmissionVal(ArtForm) 
 {
// Article Title
 var ATitle = ArtForm.elements['arttitle'].value;
 if (ATitle == "")
  {
     alert("You must enter an article title");
     ArtForm.elements['arttitle'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Main Content
var AContent = ArtForm.elements['maincontent'].value;
 if (AContent == "")
  {
     alert("You must enter a main content");
     ArtForm.elements['maincontent'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Summary
var ASummary = ArtForm.elements['summary'].value;
 if (ASummary == "")
  {
     alert("You must enter a summary");
     ArtForm.elements['summary'].style.backgroundColor='#FFF9EC';
     return false;
}
 // Email
var ArtEMail = ArtForm.elements['email'].value;
 if (ArtEMail == "")
  {
     alert("You must enter an email address");
     ArtForm.elements['email'].style.backgroundColor='#FFF9EC';
     return false;
  }
else if (!(ArtEMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
 {
    alert("E-mail address is not valid.\n Please enter a valid email address.");
    ArtForm.elements['email'].style.backgroundColor='#FFF9EC';
    return false ;
}
 // Author
var Aauthor = ArtForm.elements['author'].value;
 if (Aauthor == "")
  {
     alert("You must enter an author/publisher name");
     ArtForm.elements['author'].style.backgroundColor='#FFF9EC';
     return false;
}
return true;
}

function moneyCommaSep(Value)
{
  var separator = ",";
  var init = Value.replace ( new RegExp ( separator, "g" ), "" );
  var regexp = new RegExp ( "\\B(\\d{3})(" + separator + "|$)" );
  do{
    init = init.replace ( regexp, separator + "$1" );
  }while ( init.search ( regexp ) >= 0 )
	  MValue = init;
	return MValue;
}

function removeComma(ctrl)
{
  var separator = ",";  
  ctrl.value = ctrl.value.replace ( new RegExp ( separator, "g" ), "" );
}
var offsetfromcursorX = 12;
var offsetfromcursorY = 10; 
var offsetdivfrompointerX = 10; 
var offsetdivfrompointerY = 14;

document.write('<div id="hinttooltip"></div>')
document.write('<img id="hintpointer" src="images/arrow_tooltip.gif">')

var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip=false;

if (ie||ns6)
  var tipobj=document.all? document.all["hinttooltip"] : document.getElementById? document.getElementById("hinttooltip") : "";
  var pointerobj=document.all? document.all["hintpointer"] : document.getElementById? document.getElementById("hintpointer") : "";

function ietruebody()
 {
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showtooltip(thetext, thewidth, thecolor)
 {
    if (ns6||ie)
    {
       if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
       if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
       tipobj.innerHTML=thetext;
       enabletip=true;
       return false;
    }
}

function positiontip(e)
 {
    if (enabletip)
      {
         var nondefaultpos=false;
         var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
         var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;

         var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
         var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

         var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
         var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

         var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

   if (rightedge<tipobj.offsetWidth)
       {
          tipobj.style.left=curX-tipobj.offsetWidth+"px";
          nondefaultpos=true;
      }
      else if (curX<leftedge)
          tipobj.style.left="5px";
     else
     {
          tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
          pointerobj.style.left=curX+offsetfromcursorX+"px";
}

if (bottomedge<tipobj.offsetHeight)
    {
       tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
       nondefaultpos=true;
   }
   else
   {
       tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
       pointerobj.style.top=curY+offsetfromcursorY+"px";
}
tipobj.style.visibility="visible";
if (!nondefaultpos)
    pointerobj.style.visibility="visible";
else
    pointerobj.style.visibility="hidden";
 }
}
function hidetooltip()
  {
     if (ns6||ie)
         {
            enabletip=false;
            tipobj.style.visibility="hidden";
            pointerobj.style.visibility="hidden";
            tipobj.style.left="-1000px";
            tipobj.style.backgroundColor='';
            tipobj.style.width='';
  }
}
document.onmousemove=positiontip
//--------------------------------------------------------//