

function check(val) {
 if (isNaN(val)) {
   alert("Not a number");
 } else {
   alert("It's a number");
 }
}



function currency(anynum) {
   //-- Returns passed number as string in $xxx,xxx.xx format.
   anynum=eval(anynum)
   workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum
   if (workStr.indexOf(".")==-1){workStr+=".00"}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))
   while (pStr.length<3){pStr+="0"}

   //--- Adds comma in thousands place.
   if (dNum>=1000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
   }

   //-- Adds comma in millions place.
   if (dNum>=1000000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
   }
   retval = dStr + pStr 
   //-- Put numbers in parentheses if negative.
   if (anynum<0) {retval="("+retval+")"}
   return "$"+retval
}



function isValidCardNumber (strNum) 
{
   var nCheck = 0;
   var nDigit = 0;
   var bEven  = false;
   
   for (n = strNum.length - 1; n >= 0; n--) 
   {
      var cDigit = strNum.charAt (n);
      if (isDigit (cDigit))
      {
         var nDigit = parseInt(cDigit, 10);
         if (bEven)
         {
            if ((nDigit *= 2) > 9)
               nDigit -= 9;
         }
         nCheck += nDigit;
         bEven = ! bEven;
      }
      else if (cDigit != ' ' && cDigit != '.' && cDigit != '-')
      {
         return false;
      }
   }
   return (nCheck % 10) == 0;
}
function isDigit (c)
{
   var strAllowed = "1234567890";
   return (strAllowed.indexOf (c) != -1);
}
function isCardTypeCorrect (strNum, type)
{
   var nLen = 0;
   for (n = 0; n < strNum.length; n++)
   {
      if (isDigit (strNum.substring (n,n+1)))
         ++nLen;
   }
   
   if (type == 'Visa')
      return ((strNum.substring(0,1) == '4') && (nLen == 13 || nLen == 16));
   else if (type == 'Amex')
      return ((strNum.substring(0,2) == '34' || strNum.substring(0,2) == '37') && (nLen == 15));
   else if (type == 'Master Card')
      return ((strNum.substring(0,2) == '51' || strNum.substring(0,2) == '52'
              || strNum.substring(0,2) == '53' || strNum.substring(0,2) == '54'
              || strNum.substring(0,2) == '55') && (nLen == 16));
   else
      return false;
   
}




	
	
	

function open1(x) 
{
window.open(x,'text','toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=yes,scrolling=yes,resizable=no,copyhistory=no,width=675,height=600, top=20,left=100');
}
	
	
	
		
	function validateemail(inemail)
	// SS changed so suffix could be up to 6 character (longest known is museum)
	{
		if (inemail.length >0)
		{
			i=inemail.indexOf("@")
			j=inemail.indexOf(".",i)
			k=inemail.indexOf(",")
			kk=inemail.indexOf(" ")
			jj=inemail.lastIndexOf(".")+1
			len=inemail.length   
			if ((i>0) && (j>(i+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=6)) 
			{
			return true;
			}
			else 
			{
			return false;			
			}
		}			
	}
	
	
	
	
	// SS added on 9-16-02 from http://www.evolt.org/article/rating/17/24700/
function isValidCardNumberXX (strNum) 
{
   var nCheck = 0;
   var nDigit = 0;
   var bEven  = false;
   
   for (n = strNum.length - 1; n >= 0; n--) 
   {
      var cDigit = strNum.charAt (n);
      if (isDigit (cDigit))
      {
         var nDigit = parseInt(cDigit, 10);
         if (bEven)
         {
            if ((nDigit *= 2) > 9)
               nDigit -= 9;
         }
         nCheck += nDigit;
         bEven = ! bEven;
      }
      else if (cDigit != ' ' && cDigit != '.' && cDigit != '-')
      {
         return false;
      }
   }
   return (nCheck % 10) == 0;
}


function isDigit (c)
{
   var strAllowed = "1234567890";
   return (strAllowed.indexOf (c) != -1);
}


function isCardTypeCorrect (strNum, type)
{
   var nLen = 0;
   for (n = 0; n < strNum.length; n++)
   {
      if (isDigit (strNum.substring (n,n+1)))
         ++nLen;
   }
   
   if (type == 'Visa')
      return ((strNum.substring(0,1) == '4') && (nLen == 13 || nLen == 16));
   else if (type == 'Amex')
      return ((strNum.substring(0,2) == '34' || strNum.substring(0,2) == '37') && (nLen == 15));
   else if (type == 'Master Card')
      return ((strNum.substring(0,2) == '51' || strNum.substring(0,2) == '52'
              || strNum.substring(0,2) == '53' || strNum.substring(0,2) == '54'
              || strNum.substring(0,2) == '55') && (nLen == 16));
   else
      return false;   
}


	
	
	
	
	function popupwindow(urlpop)
	{
		popup = window.open (urlpop,"Popup","toolbar=no,menubar=no,location=no,directories=no,status=no,width=500,height=500,scrollbars=yes,resizable=yes,copyhistory=no,top=20,left=100'")
	}

	function popupfullwindow(urlpop)
	{
		popup = window.open (urlpop,"Popup","toolbar=yes,menubar=yes,location=no,directories=no,status=no,width=600,height=500,scrollbars=yes,resizable=yes,copyhistory=no,top=20,left=100'")
	}
	
	function verifydate(strDate) 

	{ 
	  var tst = strDate.toUpperCase()
	  if (tst.indexOf("PM",0) >0) return true;
	  if (tst.indexOf("AM",0) >0) return true;
	  var s=strDate.indexOf("/",0);
	  var y=strDate.indexOf("/",s+1);
	  if (s<0) return false
	  if (y<0) return false
	  var mm = strDate.substring(0, s)
	  var dd = strDate.substring(s+1,y)
	  var yy = strDate.substring(y+1)
	  
 	  
	  if (mm<1 || mm>12) return false
	  
	  
	  else if (yy.length != 2 && yy.length != 4) return false
	  else if (dd<1 || dd>31) return false
	  else if (yy<0 || yy>2050) return false
	  else if (mm==4 || mm==6 || mm==9 || mm==11) 
	  {
	    if (dd==31) return false  
	  } 
	  else if (mm==2) 
	  {
	    if (dd<29) return true
	    if (dd>29) return false
	    var g=parseInt(yy/4)
	    if (isNaN(g)) return false
	    if (dd==29 && ((yy/4)!= g)) 
	    {
	        return false
	    }
	    else return true
	  }
	  return true
	}




// ToolBar Functionality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

			var currentitem
			var cursorpos
			var notext
			notext = true;
			var selectedtext
			var newtext

function popit(label, msg){  
	
	// Set up Page Colors & Table  
	var s1 = "<TITLE>Administration Help</TITLE>" +    
	"<BODY BGCOLOR='ffffff'><TABLE BORDER=0><TR>" +        
	"<TD WIDTH=100% VALIGN=TOP ALIGN=LEFT COLSPAN=2>"+        
	"<FONT SIZE=2>"    
	var s2 = "<B>"+label+"</B></FONT><P>"   
	var s3 =       "</TD></TR><TR><TD> </TD>"+    
	"<TD VALIGN=TOP ALIGN=RIGHT colspan=2>"+    
	"<a href='javascript:self.close();'><font size=2>Close</font></a>" +
	"</TD></TR></TABLE></BODY>"   
	popup = window.open("","GlobalHelp","height=200,width=300,resizable=yes, scrollbars=yes,dependent=yes,top=150,left=100")  
	popup.document.write(s1+s2+msg+s3)  
	popup.document.close()
}

function popit2(){  
	if (notext == true) 
	{
		alert("You must click in the text area you wish to view first.")
		return;
	}
	// Set up Page Colors & Table  
	var s1 = "<TITLE>View Your Text</TITLE><BODY BGCOLOR='ffffff'><FONT SIZE=2>"    
	var s2 = "<a href='javascript:self.close();'><font size=2>Close</font></a><BR><BR>" 
	popup = window.open("","GlobalHelp","height=400,width=500,resizable=yes, scrollbars=yes,dependent=yes,top=150,left=100")  
	popup.document.write(s1+s2+currentitem.value)  
	popup.document.close()
}


function setitem(item)
{
	currentitem = item
	notext = false;
	storeCaret(item)
	MM_showHideLayers('toolbar', '', 'show')
}

function htmltag(tag)
{
	getSel();
	starttag = "<" + tag + ">"
	endtag = "</" + tag + ">"
	document.selection.clear
		
	insertAtCaret(currentitem,starttag + selectedtext + endtag)
	currentitem.focus();
}

function atag(tag)
{
	getSel();
	starttag = "<A HREF='" + selectedtext + "'>"
	endtag = "</A>"
	
	insertAtCaret(currentitem,starttag + selectedtext + endtag)
	currentitem.focus();
	
}

function amailtag(tag)
{
	getSel();
	if (!validateemail(selectedtext))
	{
		alert("Invalid email address");
		currentitem.focus();
	}
	else
	{
	starttag = "<A HREF='mailto:" + selectedtext + "'>"
	endtag = "</A>"
	insertAtCaret(currentitem,starttag + selectedtext + endtag)
	currentitem.focus();
	}
}

function insertbreak()
{
	
	insertAtCaret(currentitem,"<BR>")
	currentitem.focus();
	
}

function storeCaret (intext) {
  if (intext.createTextRange) 
    cursorpos = document.selection.createRange().duplicate();
}

function insertAtCaret (textEl, text) {
  if (textEl.createTextRange && cursorpos) {
	  cursorpos.text =
      cursorpos.text.charAt(cursorpos.text.length - 1) == ' ' ?
        text + ' ' : text;
  }
  else
    textEl.value  = text;
}
     
function getSel()
{
	if (document.getSelection) selectedtext = document.getSelection();
	else if (document.selection) selectedtext = document.selection.createRange().text;	
	else return;
	
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0

  if (navigator.appName == "Netscape") return;
  
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function hidetoolbar()
{
	MM_showHideLayers('toolbar', '', 'hide')
}



// END ToolBar Functionality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




// Begin Background Color Increment Changes  SS 2-20-02

    hexa = new Array(16);
        for(var i = 0; i < 10; i++)
                hexa[i] = i;
        hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
        hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

        function hex(i) 
        {
                if (i < 0)
                        return "00";
                else if (i > 255)
                        return "ff";
                else
                        return "" + hexa[Math.floor(i/16)] + hexa[i%16];
        }

        function setbgColor(r, g, b) 
        {
                document.bgColor = "#"+hex(r)+hex(g)+hex(b);
        }
        
        // 1 -- white --> black
        // -1 -- black --> white
        var inc = 1;
        var cur_i = 20;
        var max_step = 20;
        var in_progress = false;
        
        function msover()
        {
                inc = -1;
                if( !in_progress )
                        step();
        }

        function msout()
        {
                inc = 1;
                if( !in_progress )
                        step();
        }
        
        function step()
        {		
        	//	alert(document.bgColor);
                setbgColor( Math.floor(255 * cur_i / max_step),
                                Math.floor(255 * cur_i / max_step),
                                Math.floor(255 * cur_i /max_step) );
           //    alert("2:" + document.bgColor);
                cur_i += inc;
                if( (inc > 0 && cur_i > max_step) || (inc < 0 && cur_i < 0) )
                {
                        cur_i -= inc;
                        inc = -inc;
                        in_progress = false;
                }
                else
                {
                        in_progress = true;
                        setTimeout("step()", 3);
                }
        }


// End Background Color Increment Changes  SS 2-20-02
