var dc = document.cookie;
var testEmail = "";
var testPassword = "";


if (document.cookie) {
 testEmail = getCookie("email");
 testPassword = getCookie("pswd");

}  

if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}
overdiv="0";

var parmArray = new Array();
//function getParms() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf('=');
   if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      parmArray[key] = val;
   }
}

function getCookie(name){
var cname = name + "=";               
var dc = document.cookie;
if (dc.length > 0) {              
    begin = dc.indexOf(cname);
	 if (begin != -1) {           
        begin += cname.length;
		end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));        }
}
return null;
}

function setActive() {
   if (FORM.active.value == "yes") {
      FORM.active.value = "";
   }
   else {
      FORM.active.value = "yes";
   }
  
}
 
function buildMenu(text) {
 
	var outText = "";
    if (menuLines == "yes") {
	    break1 = "<tr><td>";
		break2 = "</td></tr>";
    }
	else {
	    break1 = "";
		break2 = "<BR>";
	}			
    var segments = text.split("|");
	for (var loop=0; loop < segments.length; loop++) {
	    var stuff = segments[loop].split(",");
		if (loop == 0) {
		    outText += "<A HREF=http://" + stuff[0] + ">" + stuff[1];
		}
		else {	
		    outText += break1 + "<A HREF=http://" + stuff[0] + ">" + stuff[1];
		}	
		outText += "</A>" + break2 + "\n";
	}
	
	return outText;
}
	

function popVertMenu(text) {
   if (!verticalColor) {
       verticalColor = "#eeeeee";
   }
   if (!menuWidth) {
       menuWidth = 130;
   }   

   text = buildMenu(text);
  
  // alert ("Text=" + text);
   popLayer(text,verticalPosition,0,menuWidth,verticalColor)
}

function popHorizMenu(text,newBrowser) {
   if (!horizontalColor) {
       horizontalColor = "#eeeeee";
   }
   if (!menuWidth) {
       menuWidth = 130;
   }   
  text = buildMenu(text);
   popLayer(text,-1,horizontalPosition,menuWidth,horizontalColor)
}

function popDescription(text) {
var descriptionColor = "#666699";
   if (!descriptionColor) {
       descriptionColor = "#ffeeff";
   }   
  popLayer(text,0,0,140,descriptionColor);
 }    


function popLayer(text,xParm,yParm,bWidth,bgColor){
         
var insWidth = "";
var insBGColor = "";

if (bWidth > "") {
   insWidth = " width=" + bWidth + " ";
} 

desc = 	  "<table cellspacing=0 cellpadding=3 "+insWidth+" bordercolor=black border=1 bgcolor="+bgColor+"><tr><td >\n"
	+"<div align="+align+">\n"
	+text
	+"\n</div></td></tr></table>\n";
   
var leftPos;
var topPos;

if (xParm > 0) {
    leftPos =  xParm;
}
else if (xParm == -1) {
    leftPos = x - offsetX;
}
else {
    leftPos = x + 15;
}

if (yParm > 0) {
    topPos =  yParm;
}
else if (yParm == -1) {
    topPos = y - offsetY;
}
else {
    topPos = y - 5;
}


//if (yParm > "0") {
//    topPos =  yParm;
//}
//else {
//    topPos = y - 10;
  //  topPos = y - offsetY;
//}

 if(navigator.family =="nn4") {
	document.popupdiv.document.write(desc);
	document.popupdiv.document.close();
	document.popupdiv.left=x+15;
	document.popupdiv.top=y-5;
	}
else if(navigator.family =="ie4"){
	popupdiv.innerHTML=desc;
	popupdiv.style.pixelLeft=leftPos;
	popupdiv.style.pixelTop=topPos;
	}
else if(navigator.family =="gecko"){
	document.getElementById("popupdiv").innerHTML=desc;
	document.getElementById("popupdiv").style.left=x+15;
	document.getElementById("popupdiv").style.top=y-5;
	}
overdiv = 1;
}
function hideLayer() {
  //  alert("Hide");
    overdiv = 0;
    setTimeout('hideLayer2()',1000)
}
function hideLayer2(){
  //  alert("Hide2: overdiv=" + overdiv);

if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.popupdiv.top="-500");}
	else if(navigator.family =="ie4"){popupdiv.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("popupdiv").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
offsetX = (isNav) ? e.x : event.offsetX;
offsetY = (isNav) ? e.screenY : event.offsetY;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;

var dc = document.cookie;
var testEmail = "";
var testPassword = "";


if (document.cookie) {
 testEmail = getCookie("email");
 testPassword = getCookie("pswd");

}  

function getCookie(name){
var cname = name + "=";               
var dc = document.cookie;
if (dc.length > 0) {              
    begin = dc.indexOf(cname);
	 if (begin != -1) {           
        begin += cname.length;
		end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));        }
}
return null;
}


function SetSecurityCookie(theForm) {
  // alert ("Form=" + theForm + " Name=" + theForm.UserID.value);
	   var mEmail;
	//   alert ("C2");
	   var mpswd;
	//   alert ("C3");
	 //  alert("EX="+document.FORM.owner.value);
	//   document.FORM.owner.value
       mEmail = theForm.email.value;
	   mpswd = theForm.pswd.value;
	//  alert ("ID=" + mUserID);
        SetCookie("userID",mEmail);
		SetCookie("pswd",mpswd);
	//	alert ("Name=" + mUserID);
		
}		


   function SetCookie(sName, sValue)
   {
       date = new Date();
       document.cookie = sName + "=" + escape(sValue) + "; path=/";
    //   alert(ReadCookie("url"));
   }




// MouseOver Function
function swapOn(imgLocation) {

if(document.images) {
document.images[imgLocation].src = eval(imgLocation + "2.src");
}
}
// MouseOut Function
function swapOff(imgLocation) {

   if(document.images) {
      document.images[imgLocation].src = eval(imgLocation + "1.src");
    }
}

function Validator() {

  // alert ("Validator");

		  if (document.FORM.fields) {
		     var required = new Array();
			 var fieldDefs = document.FORM.fields.value;
			 var k = 0;
			 var missing = "";
			 while (fieldDefs.indexOf('|') != -1) {
			    k++;
				if (k > 100) {
				alert("Timeout");
					  return true;
				  }
			    var i = fieldDefs.indexOf('|');
				var field = fieldDefs.substr(0,i);
			//	alert ("Field=" + field);
				var temp = fieldDefs.substr(i+1);
				fieldDefs = temp;
				i = fieldDefs.indexOf('|');
				var temp2 = fieldDefs.substr(0,i);
				var reqFlag = temp2.substr(0,1);
				var desc = temp2.substr(2);
				temp = fieldDefs.substr(i+1);
				fieldDefs = temp;
				if (reqFlag == "R") {
         //   for (i=0;i<required.length;i++) {
			    eval ('req = document.FORM.' + field + '.value.length');
				if (!(req > 0)) {
				  missing += desc + "\n";
				}
				}
			}
				 if (missing > "") {
			     	alert("The following fields are required:\n" + missing);
				    return false;
				  }
          }  // End check for required				  
				  
       if (!(document.FORM.delet)) {
	       return true;
	   }
        if (document.FORM.delet.checked == 1)
        {
        	var deleteOK = confirm("Are you sure you want to delete this entry?");
           	return (deleteOK);
        }
	//	alert("No errors");
		return true;
} 
				 

function getActiveText(msgarea) {

        if (msgarea.createTextRange)
        msgarea.caretPos = document.selection.createRange().duplicate();
        textarea = (document.all) ? document.selection.createRange().text : document.getSelection();
}

function formatText(msgarea, InsValue, EPlace) {

  var x = InsValue.indexOf('|');
  var StartTag = InsValue.substr(0,x);
  if (StartTag.substr(0,8) == "<a href=") {
     var repURL = "";
     repURL = prompt("Enter URL for hyperlink",repURL);
	 if (repURL.substr(4,3) !=  "://") {
	     repURL = "http://" + repURL;
	}	 
	 StartTag = StartTag.replace(/replaceURL/g,repURL);
	 }
  if (StartTag.substr(0,4) == "<li>") {
	 StartTag = StartTag.replace(/replaceURL/g,repURL);
	 }	 
  var y = InsValue.length - x;
  var EndTag = InsValue.substr(x+1,y)

 // alert ("FT " + msgarea + " " + msgarea.createTextRange + " " + msgarea.caretPos)
        if (msgarea.createTextRange && msgarea.caretPos) {
        var caretPos = msgarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? StartTag + textarea + EndTag : StartTag + textarea + EndTag;
        // document.topicform.message.focus();
        msgarea.focus();
        getActiveText(msgarea);
            }
   EPlace[0].selected = 1
}
             
       function Popup(PopupURL,wWidth,wHeight) {
	   
	         if (!(wWidth > "")) {
			    wWidth = 600;
				}
			 if (!(wHeight > "")) {
			    wHeight = 375;
			 }
             w=window.open(PopupURL,'WavesRcalling','scrollbars,menubar=yes,status=yes,resizable,width='+wWidth+',height='+wHeight);
			 w.focus();
        }





